@@ -100,8 +100,12 @@ def _underscore(string):
100
100
101
101
102
102
class Cifti2MetaData (xml .XmlSerializable ):
103
- """ A list of key -value pairs stored in the list self.data """
103
+ """ A list of name -value pairs
104
104
105
+ Attributes
106
+ ----------
107
+ data : list of (name, value) tuples
108
+ """
105
109
def __init__ (self , nvpair = None ):
106
110
self .data = []
107
111
self .add_metadata (nvpair )
@@ -171,6 +175,8 @@ def _to_xml_element(self):
171
175
172
176
173
177
class Cifti2LabelTable (xml .XmlSerializable ):
178
+ """ Cifti2 label table: a sequence of ``Cifti2Label``s
179
+ """
174
180
175
181
def __init__ (self ):
176
182
self .labels = []
@@ -197,9 +203,28 @@ def print_summary(self):
197
203
198
204
199
205
class 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.
200
210
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 ):
203
228
self .key = key
204
229
self .label = label
205
230
self .red = red
@@ -228,13 +253,24 @@ def _to_xml_element(self):
228
253
229
254
230
255
class 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.
233
260
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
+ """
234
270
def __init__ (self , map_name = None , metadata = None , label_table = None ):
235
271
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
238
274
239
275
@property
240
276
def metadata (self ):
@@ -284,10 +320,20 @@ def _to_xml_element(self):
284
320
285
321
286
322
class Cifti2Surface (xml .XmlSerializable ):
287
- """Class for Surface """
288
- # brainStructure = str
289
- # surfaceNumberOfVertices = int
323
+ """Cifti surface: association of brain structure and number of vertices
290
324
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
+ """
291
337
def __init__ (self , brain_structure = None , surface_number_of_vertices = None ):
292
338
self .brain_structure = brain_structure
293
339
self .surface_number_of_vertices = surface_number_of_vertices
@@ -301,26 +347,45 @@ def _to_xml_element(self):
301
347
302
348
303
349
class 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."
305
356
357
+ Attributes
358
+ ----------
359
+ indices : ndarray shape (N, 3)
360
+ Array of N triples (i, j, k)
361
+ """
306
362
def __init__ (self , indices = None ):
307
363
self .indices = indices
308
364
309
365
def _to_xml_element (self ):
310
366
assert self .indices is not None
311
367
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 )
316
370
return vox_ind
317
371
318
372
319
373
class Cifti2Vertices (xml .XmlSerializable ):
374
+ """Cifti2 vertices - association of brain structure and a list of vertices
320
375
321
- # brain_structure = str
322
- # vertices = np.array
376
+ "Contains a BrainStructure type and a list of vertex indices within a
377
+ Parcel."
323
378
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
+ """
324
389
def __init__ (self , brain_structure = None , vertices = None ):
325
390
self .vertices = vertices
326
391
self .brain_structure = brain_structure
@@ -331,14 +396,22 @@ def _to_xml_element(self):
331
396
vertices .attrib ['BrainStructure' ] = str (self .brain_structure )
332
397
333
398
if self .vertices is not None :
334
- vertices .text = ' ' .join (self .vertices .astype (str ). tolist () )
399
+ vertices .text = ' ' .join (self .vertices .astype (str ))
335
400
return vertices
336
401
337
402
338
403
class Cifti2Parcel (object ):
339
- """Class for Parcel"""
340
- # name = str
404
+ """Cifti2 parcel: association of a name with vertices and/or voxels
341
405
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
+ """
342
415
def __init__ (self , name = None , voxel_indices_ijk = None , vertices = None ):
343
416
self .name = name
344
417
self .voxel_indices_ijk = voxel_indices_ijk
@@ -379,7 +452,18 @@ def _to_xml_element(self):
379
452
380
453
381
454
class Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ (object ):
455
+ """Matrix that translates voxel indices to spatial coordinates
382
456
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
+ """
383
467
# meterExponent = int
384
468
# matrix = np.array
385
469
@@ -391,18 +475,25 @@ def _to_xml_element(self):
391
475
assert self .matrix is not None
392
476
trans = xml .Element ('TransformationMatrixVoxelIndicesIJKtoXYZ' )
393
477
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 )
398
480
return trans
399
481
400
482
401
483
class Cifti2Volume (object ):
484
+ """Cifti2 volume: information about a volume for mappings that use voxels
402
485
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
+ """
406
497
def __init__ (self , volume_dimensions = None , transform_matrix = None ):
407
498
self .volume_dimensions = volume_dimensions
408
499
self .transformation_matrix_voxel_indices_ijk_to_xyz = transform_matrix
@@ -417,8 +508,15 @@ def _to_xml_element(self):
417
508
418
509
419
510
class Cifti2VertexIndices (object ):
420
- # indices = np.array
511
+ """Cifti2 vertex indices: vertex indices for an associated brain model
421
512
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
+ """
422
520
def __init__ (self , indices = None ):
423
521
self .indices = indices
424
522
0 commit comments