@@ -100,8 +100,12 @@ def _underscore(string):
100100
101101
102102class Cifti2MetaData (xml .XmlSerializable ):
103- """ A list of key -value pairs stored in the list self.data """
103+ """ A list of name -value pairs
104104
105+ Attributes
106+ ----------
107+ data : list of (name, value) tuples
108+ """
105109 def __init__ (self , nvpair = None ):
106110 self .data = []
107111 self .add_metadata (nvpair )
@@ -171,6 +175,8 @@ def _to_xml_element(self):
171175
172176
173177class Cifti2LabelTable (xml .XmlSerializable ):
178+ """ Cifti2 label table: a sequence of ``Cifti2Label``s
179+ """
174180
175181 def __init__ (self ):
176182 self .labels = []
@@ -197,9 +203,28 @@ def print_summary(self):
197203
198204
199205class Cifti2Label (xml .XmlSerializable ):
206+ """ Cifti2 label: association of integer key with a name and RGBA values
207+
208+ Attribute descriptions are from the CIFTI-2 spec dated 2014-03-01.
209+ For all color components, value is floating point with range 0.0 to 1.0.
200210
201- def __init__ (self , key = 0 , label = '' , red = None ,
202- green = None , blue = None , alpha = None ):
211+ Attributes
212+ ----------
213+ key : int
214+ Integer, data value which is assigned this name and color.
215+ label : str
216+ Name of the label.
217+ red : None or float
218+ Red color component for label.
219+ green : None or float
220+ Green color component for label.
221+ blue : None or float
222+ Blue color component for label.
223+ alpha : None or float
224+ Alpha color component for label.
225+ """
226+ def __init__ (self , key = 0 , label = '' , red = None , green = None , blue = None ,
227+ alpha = None ):
203228 self .key = key
204229 self .label = label
205230 self .red = red
@@ -228,13 +253,24 @@ def _to_xml_element(self):
228253
229254
230255class Cifti2NamedMap (xml .XmlSerializable ):
231- """Class for Named Map"""
232- map_name = str
256+ """Cifti2 named map: association of name and optional data with a map index
257+
258+ Associates a name, optional metadata, and possibly a LabelTable with an
259+ index in a map.
233260
261+ Attributes
262+ ----------
263+ map_name : str
264+ Name of map
265+ metadata : None or Cifti2MetaData
266+ Metadata associated with named map
267+ label_table : None or Cifti2LabelTable
268+ Label table associated with named map
269+ """
234270 def __init__ (self , map_name = None , metadata = None , label_table = None ):
235271 self .map_name = map_name
236- self .metadata = metadata # _value_or_make_klass(metadata, Cifti2MetaData)
237- self .label_table = label_table # _value_or_make_klass(label_table, Cifti2LabelTable)
272+ self .metadata = metadata
273+ self .label_table = label_table
238274
239275 @property
240276 def metadata (self ):
@@ -284,10 +320,20 @@ def _to_xml_element(self):
284320
285321
286322class Cifti2Surface (xml .XmlSerializable ):
287- """Class for Surface """
288- # brainStructure = str
289- # surfaceNumberOfVertices = int
323+ """Cifti surface: association of brain structure and number of vertices
290324
325+ "Specifies the number of vertices for a surface, when IndicesMapToDataType
326+ is 'CIFTI_INDEX_TYPE_PARCELS.' This is separate from the Parcel element
327+ because there can be multiple parcels on one surface, and one parcel may
328+ involve multiple surfaces."
329+
330+ Attributes
331+ ----------
332+ brain_structure : str
333+ Name of brain structure
334+ surface_number_of_vertices : int
335+ Number of vertices on surface
336+ """
291337 def __init__ (self , brain_structure = None , surface_number_of_vertices = None ):
292338 self .brain_structure = brain_structure
293339 self .surface_number_of_vertices = surface_number_of_vertices
@@ -301,26 +347,45 @@ def _to_xml_element(self):
301347
302348
303349class Cifti2VoxelIndicesIJK (xml .XmlSerializable ):
304- # indices = np.array
350+ """Cifti2 VoxelIndicesIJK: Set of voxel indices contained in a structure
351+
352+ "Identifies the voxels that model a brain structure, or participate in a
353+ parcel. Note that when this is a child of BrainModel, the IndexCount
354+ attribute of the BrainModel indicates the number of voxels contained in
355+ this element."
305356
357+ Attributes
358+ ----------
359+ indices : ndarray shape (N, 3)
360+ Array of N triples (i, j, k)
361+ """
306362 def __init__ (self , indices = None ):
307363 self .indices = indices
308364
309365 def _to_xml_element (self ):
310366 assert self .indices is not None
311367 vox_ind = xml .Element ('VoxelIndicesIJK' )
312- if self .indices is not None :
313- vox_ind .text = ''
314- for row in self .indices :
315- vox_ind .text += ' ' .join (row .astype (str ).tolist ()) + '\n '
368+ vox_ind .text = '\n ' .join (' ' .join (row .astype (str ))
369+ for row in self .indices )
316370 return vox_ind
317371
318372
319373class Cifti2Vertices (xml .XmlSerializable ):
374+ """Cifti2 vertices - association of brain structure and a list of vertices
320375
321- # brain_structure = str
322- # vertices = np.array
376+ "Contains a BrainStructure type and a list of vertex indices within a
377+ Parcel."
323378
379+ Attribute descriptions are from the CIFTI-2 spec dated 2014-03-01.
380+
381+ Attributes
382+ ----------
383+ brain_structure : str
384+ A string from the BrainStructure list to identify what surface this
385+ vertex list is from (usually left cortex, right cortex, or cerebellum).
386+ vertices : ndarray shape (N,)
387+ Vertex indices (which are independent for each surface, and zero-based)
388+ """
324389 def __init__ (self , brain_structure = None , vertices = None ):
325390 self .vertices = vertices
326391 self .brain_structure = brain_structure
@@ -331,14 +396,22 @@ def _to_xml_element(self):
331396 vertices .attrib ['BrainStructure' ] = str (self .brain_structure )
332397
333398 if self .vertices is not None :
334- vertices .text = ' ' .join (self .vertices .astype (str ). tolist () )
399+ vertices .text = ' ' .join (self .vertices .astype (str ))
335400 return vertices
336401
337402
338403class Cifti2Parcel (object ):
339- """Class for Parcel"""
340- # name = str
404+ """Cifti2 parcel: association of a name with vertices and/or voxels
341405
406+ Attributes
407+ ----------
408+ name : str
409+ Name of parcel
410+ voxel_indices_ijk : None or Cifti2VoxelIndicesIJK
411+ Voxel indices associated with parcel
412+ vertices : list of Cifti2Vertices
413+ Vertices associated with parcel
414+ """
342415 def __init__ (self , name = None , voxel_indices_ijk = None , vertices = None ):
343416 self .name = name
344417 self .voxel_indices_ijk = voxel_indices_ijk
@@ -379,7 +452,18 @@ def _to_xml_element(self):
379452
380453
381454class Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ (object ):
455+ """Matrix that translates voxel indices to spatial coordinates
382456
457+ Attributes
458+ ----------
459+ meter_exponent : int
460+ "[S]pecifies that the coordinate result from the transformation matrix
461+ should be multiplied by 10 to this power to get the spatial coordinates
462+ in meters (e.g., if this is '-3', then the transformation matrix is in
463+ millimeters)."
464+ matrix : array-like shape (4, 4)
465+ Affine transformation matrix from voxel indices to RAS space
466+ """
383467 # meterExponent = int
384468 # matrix = np.array
385469
@@ -391,18 +475,25 @@ def _to_xml_element(self):
391475 assert self .matrix is not None
392476 trans = xml .Element ('TransformationMatrixVoxelIndicesIJKtoXYZ' )
393477 trans .attrib ['MeterExponent' ] = str (self .meter_exponent )
394- if self .matrix is not None :
395- trans .text = ''
396- for row in self .matrix :
397- trans .text += ' ' .join (['%.10f' % val for val in row ]) + "\n "
478+ trans .text = '\n ' .join (' ' .join (map ('%.10f' .format , row ))
479+ for row in self .matrix )
398480 return trans
399481
400482
401483class Cifti2Volume (object ):
484+ """Cifti2 volume: information about a volume for mappings that use voxels
402485
403- # volumeDimensions = np.array
404- # transformationMatrixVoxelIndicesIJKtoXYZ = np.array
405-
486+ Attributes
487+ ----------
488+ volume_dimensions : array-like shape (3,)
489+ "[T]he lengthss of the three volume file dimensions that are related to
490+ spatial coordinates, in number of voxels. Voxel indices (which are
491+ zero-based) that are used in the mapping that this element applies to
492+ must be within these dimensions."
493+ transformation_matrix_voxel_indices_ijk_to_xyz \
494+ : Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ
495+ Matrix that translates voxel indices to spatial coordinates
496+ """
406497 def __init__ (self , volume_dimensions = None , transform_matrix = None ):
407498 self .volume_dimensions = volume_dimensions
408499 self .transformation_matrix_voxel_indices_ijk_to_xyz = transform_matrix
@@ -417,8 +508,15 @@ def _to_xml_element(self):
417508
418509
419510class Cifti2VertexIndices (object ):
420- # indices = np.array
511+ """Cifti2 vertex indices: vertex indices for an associated brain model
421512
513+ Attributes
514+ ----------
515+ indices : ndarray shape (n,)
516+ The vertex indices (which are independent for each surface, and
517+ zero-based) that are used in this brain model[.] The parent
518+ BrainModel's ``index_count`` indicates the number of indices.
519+ """
422520 def __init__ (self , indices = None ):
423521 self .indices = indices
424522
0 commit comments