18
18
Cifti2MatrixIndicesMap , Cifti2NamedMap , Cifti2Parcel ,
19
19
Cifti2Surface , Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ ,
20
20
Cifti2Vertices , Cifti2Volume , CIFTI_BRAIN_STRUCTURES ,
21
- CIFTI_MODEL_TYPES , _underscore , CIFTI2HeaderError )
21
+ CIFTI_MODEL_TYPES , _underscore , Cifti2HeaderError )
22
22
from .. import xmlutils as xml
23
23
from ..spatialimages import HeaderDataError
24
24
from ..externals .six import BytesIO
@@ -186,7 +186,7 @@ def StartElementHandler(self, name, attrs):
186
186
matrix = Cifti2Matrix ()
187
187
parent = self .struct_state [- 1 ]
188
188
if not isinstance (parent , Cifti2Header ):
189
- raise CIFTI2HeaderError (
189
+ raise Cifti2HeaderError (
190
190
'Matrix element can only be a child of the CIFTI2 Header element'
191
191
)
192
192
parent .matrix = matrix
@@ -197,7 +197,7 @@ def StartElementHandler(self, name, attrs):
197
197
meta = Cifti2MetaData ()
198
198
parent = self .struct_state [- 1 ]
199
199
if not isinstance (parent , (Cifti2Matrix , Cifti2NamedMap )):
200
- raise CIFTI2HeaderError (
200
+ raise Cifti2HeaderError (
201
201
'MetaData element can only be a child of the CIFTI2 Matrix or NamedMap elements'
202
202
)
203
203
@@ -229,7 +229,7 @@ def StartElementHandler(self, name, attrs):
229
229
setattr (mim , _underscore (key ), dtype (attrs [key ]))
230
230
matrix = self .struct_state [- 1 ]
231
231
if not isinstance (matrix , Cifti2Matrix ):
232
- raise CIFTI2HeaderError (
232
+ raise Cifti2HeaderError (
233
233
'MatrixIndicesMap element can only be a child of the CIFTI2 Matrix element'
234
234
)
235
235
matrix .append (mim )
@@ -240,7 +240,7 @@ def StartElementHandler(self, name, attrs):
240
240
named_map = Cifti2NamedMap ()
241
241
mim = self .struct_state [- 1 ]
242
242
if not isinstance (mim , Cifti2MatrixIndicesMap ):
243
- raise CIFTI2HeaderError (
243
+ raise Cifti2HeaderError (
244
244
'NamedMap element can only be a child of the CIFTI2 MatrixIndicesMap element'
245
245
)
246
246
self .struct_state .append (named_map )
@@ -250,13 +250,13 @@ def StartElementHandler(self, name, attrs):
250
250
named_map = self .struct_state [- 1 ]
251
251
mim = self .struct_state [- 2 ]
252
252
if mim .indices_map_to_data_type != "CIFTI_INDEX_TYPE_LABELS" :
253
- raise CIFTI2HeaderError (
253
+ raise Cifti2HeaderError (
254
254
'LabelTable element can only be a child of a MatrixIndicesMap '
255
255
'with CIFTI_INDEX_TYPE_LABELS type'
256
256
)
257
257
lata = Cifti2LabelTable ()
258
258
if not isinstance (named_map , Cifti2NamedMap ):
259
- raise CIFTI2HeaderError (
259
+ raise Cifti2HeaderError (
260
260
'LabelTable element can only be a child of the CIFTI2 NamedMap element'
261
261
)
262
262
self .fsm_state .append ('LabelTable' )
@@ -266,7 +266,7 @@ def StartElementHandler(self, name, attrs):
266
266
elif name == 'Label' :
267
267
lata = self .struct_state [- 1 ]
268
268
if not isinstance (lata , Cifti2LabelTable ):
269
- raise CIFTI2HeaderError (
269
+ raise Cifti2HeaderError (
270
270
'Label element can only be a child of the CIFTI2 LabelTable element'
271
271
)
272
272
label = Cifti2Label ()
@@ -282,7 +282,7 @@ def StartElementHandler(self, name, attrs):
282
282
elif name == "MapName" :
283
283
named_map = self .struct_state [- 1 ]
284
284
if not isinstance (named_map , Cifti2NamedMap ):
285
- raise CIFTI2HeaderError (
285
+ raise Cifti2HeaderError (
286
286
'MapName element can only be a child of the CIFTI2 NamedMap element'
287
287
)
288
288
@@ -293,11 +293,11 @@ def StartElementHandler(self, name, attrs):
293
293
surface = Cifti2Surface ()
294
294
mim = self .struct_state [- 1 ]
295
295
if not isinstance (mim , Cifti2MatrixIndicesMap ):
296
- raise CIFTI2HeaderError (
296
+ raise Cifti2HeaderError (
297
297
'Surface element can only be a child of the CIFTI2 MatrixIndicesMap element'
298
298
)
299
299
if mim .indices_map_to_data_type != "CIFTI_INDEX_TYPE_PARCELS" :
300
- raise CIFTI2HeaderError (
300
+ raise Cifti2HeaderError (
301
301
'Surface element can only be a child of a MatrixIndicesMap '
302
302
'with CIFTI_INDEX_TYPE_PARCELS type'
303
303
)
@@ -309,7 +309,7 @@ def StartElementHandler(self, name, attrs):
309
309
parcel = Cifti2Parcel ()
310
310
mim = self .struct_state [- 1 ]
311
311
if not isinstance (mim , Cifti2MatrixIndicesMap ):
312
- raise CIFTI2HeaderError (
312
+ raise Cifti2HeaderError (
313
313
'Parcel element can only be a child of the CIFTI2 MatrixIndicesMap element'
314
314
)
315
315
parcel .name = attrs ["Name" ]
@@ -321,12 +321,12 @@ def StartElementHandler(self, name, attrs):
321
321
vertices = Cifti2Vertices ()
322
322
parcel = self .struct_state [- 1 ]
323
323
if not isinstance (parcel , Cifti2Parcel ):
324
- raise CIFTI2HeaderError (
324
+ raise Cifti2HeaderError (
325
325
'Vertices element can only be a child of the CIFTI2 Parcel element'
326
326
)
327
327
vertices .brain_structure = attrs ["BrainStructure" ]
328
328
if vertices .brain_structure not in CIFTI_BRAIN_STRUCTURES :
329
- raise CIFTI2HeaderError (
329
+ raise Cifti2HeaderError (
330
330
'BrainStructure for this Vertices element is not valid'
331
331
)
332
332
parcel .append_cifti_vertices (vertices )
@@ -337,7 +337,7 @@ def StartElementHandler(self, name, attrs):
337
337
elif name == "VoxelIndicesIJK" :
338
338
parent = self .struct_state [- 1 ]
339
339
if not isinstance (parent , (Cifti2Parcel , Cifti2BrainModel )):
340
- raise CIFTI2HeaderError (
340
+ raise Cifti2HeaderError (
341
341
'VoxelIndicesIJK element can only be a child of the CIFTI2 '
342
342
'Parcel or BrainModel elements'
343
343
)
@@ -347,7 +347,7 @@ def StartElementHandler(self, name, attrs):
347
347
elif name == "Volume" :
348
348
mim = self .struct_state [- 1 ]
349
349
if not isinstance (mim , Cifti2MatrixIndicesMap ):
350
- raise CIFTI2HeaderError (
350
+ raise Cifti2HeaderError (
351
351
'Volume element can only be a child of the CIFTI2 MatrixIndicesMap element'
352
352
)
353
353
dimensions = tuple ([int (val ) for val in
@@ -360,7 +360,7 @@ def StartElementHandler(self, name, attrs):
360
360
elif name == "TransformationMatrixVoxelIndicesIJKtoXYZ" :
361
361
volume = self .struct_state [- 1 ]
362
362
if not isinstance (volume , Cifti2Volume ):
363
- raise CIFTI2HeaderError (
363
+ raise Cifti2HeaderError (
364
364
'TransformationMatrixVoxelIndicesIJKtoXYZ element can only be a child '
365
365
'of the CIFTI2 Volume element'
366
366
)
@@ -375,12 +375,12 @@ def StartElementHandler(self, name, attrs):
375
375
model = Cifti2BrainModel ()
376
376
mim = self .struct_state [- 1 ]
377
377
if not isinstance (mim , Cifti2MatrixIndicesMap ):
378
- raise CIFTI2HeaderError (
378
+ raise Cifti2HeaderError (
379
379
'BrainModel element can only be a child '
380
380
'of the CIFTI2 MatrixIndicesMap element'
381
381
)
382
382
if mim .indices_map_to_data_type != "CIFTI_INDEX_TYPE_BRAIN_MODELS" :
383
- raise CIFTI2HeaderError (
383
+ raise Cifti2HeaderError (
384
384
'BrainModel element can only be a child of a MatrixIndicesMap '
385
385
'with CIFTI_INDEX_TYPE_BRAIN_MODELS type'
386
386
)
@@ -392,11 +392,11 @@ def StartElementHandler(self, name, attrs):
392
392
if key in attrs :
393
393
setattr (model , _underscore (key ), dtype (attrs [key ]))
394
394
if model .brain_structure not in CIFTI_BRAIN_STRUCTURES :
395
- raise CIFTI2HeaderError (
395
+ raise Cifti2HeaderError (
396
396
'BrainStructure for this BrainModel element is not valid'
397
397
)
398
398
if model .model_type not in CIFTI_MODEL_TYPES :
399
- raise CIFTI2HeaderError (
399
+ raise Cifti2HeaderError (
400
400
'ModelType for this BrainModel element is not valid'
401
401
)
402
402
mim .append (model )
@@ -407,7 +407,7 @@ def StartElementHandler(self, name, attrs):
407
407
index = Cifti2VertexIndices ()
408
408
model = self .struct_state [- 1 ]
409
409
if not isinstance (model , Cifti2BrainModel ):
410
- raise CIFTI2HeaderError (
410
+ raise Cifti2HeaderError (
411
411
'VertexIndices element can only be a child '
412
412
'of the CIFTI2 BrainModel element'
413
413
)
0 commit comments