Skip to content

Commit 068d9ac

Browse files
demianweffigies
authored andcommitted
Renamed CIFTI2HeaderError to Cifti2HeaderError
1 parent aeb7f80 commit 068d9ac

File tree

4 files changed

+51
-51
lines changed

4 files changed

+51
-51
lines changed

nibabel/cifti2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@
2424
Cifti2Surface,
2525
Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ,
2626
Cifti2Vertices, Cifti2Volume, CIFTI_BRAIN_STRUCTURES,
27-
CIFTI2HeaderError, CIFTI_MODEL_TYPES, load, save)
27+
Cifti2HeaderError, CIFTI_MODEL_TYPES, load, save)

nibabel/cifti2/cifti2.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def _float_01(val):
3737
return out
3838

3939

40-
class CIFTI2HeaderError(Exception):
40+
class Cifti2HeaderError(Exception):
4141
""" Error in CIFTI2 header
4242
"""
4343

@@ -224,7 +224,7 @@ def __iter__(self):
224224

225225
def _to_xml_element(self):
226226
if len(self) == 0:
227-
raise CIFTI2HeaderError('LabelTable element requires at least 1 label')
227+
raise Cifti2HeaderError('LabelTable element requires at least 1 label')
228228
labeltable = xml.Element('LabelTable')
229229
for ele in self._labels.values():
230230
labeltable.append(ele._to_xml_element())
@@ -284,16 +284,16 @@ def rgba(self):
284284

285285
def _to_xml_element(self):
286286
if self.label is '':
287-
raise CIFTI2HeaderError('Label needs a name')
287+
raise Cifti2HeaderError('Label needs a name')
288288
try:
289289
v = int(self.key)
290290
except ValueError:
291-
raise CIFTI2HeaderError('The key must be an integer')
291+
raise Cifti2HeaderError('The key must be an integer')
292292
for c_ in ('red', 'blue', 'green', 'alpha'):
293293
try:
294294
v = _float_01(getattr(self, c_))
295295
except ValueError:
296-
raise CIFTI2HeaderError(
296+
raise Cifti2HeaderError(
297297
'Label invalid %s needs to be a float between 0 and 1. '
298298
'and it is %s' % (c_, v)
299299
)
@@ -420,7 +420,7 @@ def __init__(self, brain_structure=None, surface_number_of_vertices=None):
420420

421421
def _to_xml_element(self):
422422
if self.brain_structure is None:
423-
raise CIFTI2HeaderError('Surface element requires at least 1 BrainStructure')
423+
raise Cifti2HeaderError('Surface element requires at least 1 BrainStructure')
424424
surf = xml.Element('Surface')
425425
surf.attrib['BrainStructure'] = str(self.brain_structure)
426426
surf.attrib['SurfaceNumberOfVertices'] = str(self.surface_number_of_vertices)
@@ -501,7 +501,7 @@ def insert(self, index, value):
501501

502502
def _to_xml_element(self):
503503
if len(self) == 0:
504-
raise CIFTI2HeaderError('VoxelIndicesIJK element require an index table')
504+
raise Cifti2HeaderError('VoxelIndicesIJK element require an index table')
505505

506506
vox_ind = xml.Element('VoxelIndicesIJK')
507507
vox_ind.text = '\n'.join(' '.join([str(v) for v in row])
@@ -566,7 +566,7 @@ def insert(self, index, value):
566566

567567
def _to_xml_element(self):
568568
if self.brain_structure is None:
569-
raise CIFTI2HeaderError('Vertices element require a BrainStructure')
569+
raise Cifti2HeaderError('Vertices element require a BrainStructure')
570570

571571
vertices = xml.Element('Vertices')
572572
vertices.attrib['BrainStructure'] = str(self.brain_structure)
@@ -631,7 +631,7 @@ def pop_cifti2_vertices(self, ith):
631631

632632
def _to_xml_element(self):
633633
if self.name is None:
634-
raise CIFTI2HeaderError('Parcel element requires a name')
634+
raise Cifti2HeaderError('Parcel element requires a name')
635635

636636
parcel = xml.Element('Parcel')
637637
parcel.attrib['Name'] = str(self.name)
@@ -676,7 +676,7 @@ def __init__(self, meter_exponent=None, matrix=None):
676676

677677
def _to_xml_element(self):
678678
if self.matrix is None:
679-
raise CIFTI2HeaderError(
679+
raise Cifti2HeaderError(
680680
'TransformationMatrixVoxelIndicesIJKtoXYZ element requires a matrix'
681681
)
682682
trans = xml.Element('TransformationMatrixVoxelIndicesIJKtoXYZ')
@@ -720,7 +720,7 @@ def __init__(self, volume_dimensions=None, transform_matrix=None):
720720

721721
def _to_xml_element(self):
722722
if self.volume_dimensions is None:
723-
raise CIFTI2HeaderError('Volume element requires dimensions')
723+
raise Cifti2HeaderError('Volume element requires dimensions')
724724

725725
volume = xml.Element('Volume')
726726
volume.attrib['VolumeDimensions'] = ','.join(
@@ -777,7 +777,7 @@ def insert(self, index, value):
777777

778778
def _to_xml_element(self):
779779
if len(self) == 0:
780-
raise CIFTI2HeaderError('VertexIndices element requires indices')
780+
raise Cifti2HeaderError('VertexIndices element requires indices')
781781

782782
vert_indices = xml.Element('VertexIndices')
783783
vert_indices.text = ' '.join([str(i) for i in self])
@@ -987,15 +987,15 @@ def __setitem__(self, index, value):
987987
not isinstance(self._maps[index], Cifti2Volume)
988988
)
989989
):
990-
raise CIFTI2HeaderError("Only one Volume can be in a MatrixIndicesMap")
990+
raise Cifti2HeaderError("Only one Volume can be in a MatrixIndicesMap")
991991
self._maps[index] = value
992992

993993
def insert(self, index, value):
994994
if (
995995
isinstance(value, Cifti2Volume) and
996996
self.volume is not None
997997
):
998-
raise CIFTI2HeaderError("Only one Volume can be in a MatrixIndicesMap")
998+
raise Cifti2HeaderError("Only one Volume can be in a MatrixIndicesMap")
999999

10001000
self._maps.insert(index, value)
10011001

@@ -1053,7 +1053,7 @@ def brain_models(self):
10531053

10541054
def _to_xml_element(self):
10551055
if self.applies_to_matrix_dimension is None:
1056-
raise CIFTI2HeaderError(
1056+
raise Cifti2HeaderError(
10571057
'MatrixIndicesMap element requires to be applied to at least 1 dimension'
10581058
)
10591059

nibabel/cifti2/parse_cifti2.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Cifti2MatrixIndicesMap, Cifti2NamedMap, Cifti2Parcel,
1919
Cifti2Surface, Cifti2TransformationMatrixVoxelIndicesIJKtoXYZ,
2020
Cifti2Vertices, Cifti2Volume, CIFTI_BRAIN_STRUCTURES,
21-
CIFTI_MODEL_TYPES, _underscore, CIFTI2HeaderError)
21+
CIFTI_MODEL_TYPES, _underscore, Cifti2HeaderError)
2222
from .. import xmlutils as xml
2323
from ..spatialimages import HeaderDataError
2424
from ..externals.six import BytesIO
@@ -186,7 +186,7 @@ def StartElementHandler(self, name, attrs):
186186
matrix = Cifti2Matrix()
187187
parent = self.struct_state[-1]
188188
if not isinstance(parent, Cifti2Header):
189-
raise CIFTI2HeaderError(
189+
raise Cifti2HeaderError(
190190
'Matrix element can only be a child of the CIFTI2 Header element'
191191
)
192192
parent.matrix = matrix
@@ -197,7 +197,7 @@ def StartElementHandler(self, name, attrs):
197197
meta = Cifti2MetaData()
198198
parent = self.struct_state[-1]
199199
if not isinstance(parent, (Cifti2Matrix, Cifti2NamedMap)):
200-
raise CIFTI2HeaderError(
200+
raise Cifti2HeaderError(
201201
'MetaData element can only be a child of the CIFTI2 Matrix or NamedMap elements'
202202
)
203203

@@ -229,7 +229,7 @@ def StartElementHandler(self, name, attrs):
229229
setattr(mim, _underscore(key), dtype(attrs[key]))
230230
matrix = self.struct_state[-1]
231231
if not isinstance(matrix, Cifti2Matrix):
232-
raise CIFTI2HeaderError(
232+
raise Cifti2HeaderError(
233233
'MatrixIndicesMap element can only be a child of the CIFTI2 Matrix element'
234234
)
235235
matrix.append(mim)
@@ -240,7 +240,7 @@ def StartElementHandler(self, name, attrs):
240240
named_map = Cifti2NamedMap()
241241
mim = self.struct_state[-1]
242242
if not isinstance(mim, Cifti2MatrixIndicesMap):
243-
raise CIFTI2HeaderError(
243+
raise Cifti2HeaderError(
244244
'NamedMap element can only be a child of the CIFTI2 MatrixIndicesMap element'
245245
)
246246
self.struct_state.append(named_map)
@@ -250,13 +250,13 @@ def StartElementHandler(self, name, attrs):
250250
named_map = self.struct_state[-1]
251251
mim = self.struct_state[-2]
252252
if mim.indices_map_to_data_type != "CIFTI_INDEX_TYPE_LABELS":
253-
raise CIFTI2HeaderError(
253+
raise Cifti2HeaderError(
254254
'LabelTable element can only be a child of a MatrixIndicesMap '
255255
'with CIFTI_INDEX_TYPE_LABELS type'
256256
)
257257
lata = Cifti2LabelTable()
258258
if not isinstance(named_map, Cifti2NamedMap):
259-
raise CIFTI2HeaderError(
259+
raise Cifti2HeaderError(
260260
'LabelTable element can only be a child of the CIFTI2 NamedMap element'
261261
)
262262
self.fsm_state.append('LabelTable')
@@ -266,7 +266,7 @@ def StartElementHandler(self, name, attrs):
266266
elif name == 'Label':
267267
lata = self.struct_state[-1]
268268
if not isinstance(lata, Cifti2LabelTable):
269-
raise CIFTI2HeaderError(
269+
raise Cifti2HeaderError(
270270
'Label element can only be a child of the CIFTI2 LabelTable element'
271271
)
272272
label = Cifti2Label()
@@ -282,7 +282,7 @@ def StartElementHandler(self, name, attrs):
282282
elif name == "MapName":
283283
named_map = self.struct_state[-1]
284284
if not isinstance(named_map, Cifti2NamedMap):
285-
raise CIFTI2HeaderError(
285+
raise Cifti2HeaderError(
286286
'MapName element can only be a child of the CIFTI2 NamedMap element'
287287
)
288288

@@ -293,11 +293,11 @@ def StartElementHandler(self, name, attrs):
293293
surface = Cifti2Surface()
294294
mim = self.struct_state[-1]
295295
if not isinstance(mim, Cifti2MatrixIndicesMap):
296-
raise CIFTI2HeaderError(
296+
raise Cifti2HeaderError(
297297
'Surface element can only be a child of the CIFTI2 MatrixIndicesMap element'
298298
)
299299
if mim.indices_map_to_data_type != "CIFTI_INDEX_TYPE_PARCELS":
300-
raise CIFTI2HeaderError(
300+
raise Cifti2HeaderError(
301301
'Surface element can only be a child of a MatrixIndicesMap '
302302
'with CIFTI_INDEX_TYPE_PARCELS type'
303303
)
@@ -309,7 +309,7 @@ def StartElementHandler(self, name, attrs):
309309
parcel = Cifti2Parcel()
310310
mim = self.struct_state[-1]
311311
if not isinstance(mim, Cifti2MatrixIndicesMap):
312-
raise CIFTI2HeaderError(
312+
raise Cifti2HeaderError(
313313
'Parcel element can only be a child of the CIFTI2 MatrixIndicesMap element'
314314
)
315315
parcel.name = attrs["Name"]
@@ -321,12 +321,12 @@ def StartElementHandler(self, name, attrs):
321321
vertices = Cifti2Vertices()
322322
parcel = self.struct_state[-1]
323323
if not isinstance(parcel, Cifti2Parcel):
324-
raise CIFTI2HeaderError(
324+
raise Cifti2HeaderError(
325325
'Vertices element can only be a child of the CIFTI2 Parcel element'
326326
)
327327
vertices.brain_structure = attrs["BrainStructure"]
328328
if vertices.brain_structure not in CIFTI_BRAIN_STRUCTURES:
329-
raise CIFTI2HeaderError(
329+
raise Cifti2HeaderError(
330330
'BrainStructure for this Vertices element is not valid'
331331
)
332332
parcel.append_cifti_vertices(vertices)
@@ -337,7 +337,7 @@ def StartElementHandler(self, name, attrs):
337337
elif name == "VoxelIndicesIJK":
338338
parent = self.struct_state[-1]
339339
if not isinstance(parent, (Cifti2Parcel, Cifti2BrainModel)):
340-
raise CIFTI2HeaderError(
340+
raise Cifti2HeaderError(
341341
'VoxelIndicesIJK element can only be a child of the CIFTI2 '
342342
'Parcel or BrainModel elements'
343343
)
@@ -347,7 +347,7 @@ def StartElementHandler(self, name, attrs):
347347
elif name == "Volume":
348348
mim = self.struct_state[-1]
349349
if not isinstance(mim, Cifti2MatrixIndicesMap):
350-
raise CIFTI2HeaderError(
350+
raise Cifti2HeaderError(
351351
'Volume element can only be a child of the CIFTI2 MatrixIndicesMap element'
352352
)
353353
dimensions = tuple([int(val) for val in
@@ -360,7 +360,7 @@ def StartElementHandler(self, name, attrs):
360360
elif name == "TransformationMatrixVoxelIndicesIJKtoXYZ":
361361
volume = self.struct_state[-1]
362362
if not isinstance(volume, Cifti2Volume):
363-
raise CIFTI2HeaderError(
363+
raise Cifti2HeaderError(
364364
'TransformationMatrixVoxelIndicesIJKtoXYZ element can only be a child '
365365
'of the CIFTI2 Volume element'
366366
)
@@ -375,12 +375,12 @@ def StartElementHandler(self, name, attrs):
375375
model = Cifti2BrainModel()
376376
mim = self.struct_state[-1]
377377
if not isinstance(mim, Cifti2MatrixIndicesMap):
378-
raise CIFTI2HeaderError(
378+
raise Cifti2HeaderError(
379379
'BrainModel element can only be a child '
380380
'of the CIFTI2 MatrixIndicesMap element'
381381
)
382382
if mim.indices_map_to_data_type != "CIFTI_INDEX_TYPE_BRAIN_MODELS":
383-
raise CIFTI2HeaderError(
383+
raise Cifti2HeaderError(
384384
'BrainModel element can only be a child of a MatrixIndicesMap '
385385
'with CIFTI_INDEX_TYPE_BRAIN_MODELS type'
386386
)
@@ -392,11 +392,11 @@ def StartElementHandler(self, name, attrs):
392392
if key in attrs:
393393
setattr(model, _underscore(key), dtype(attrs[key]))
394394
if model.brain_structure not in CIFTI_BRAIN_STRUCTURES:
395-
raise CIFTI2HeaderError(
395+
raise Cifti2HeaderError(
396396
'BrainStructure for this BrainModel element is not valid'
397397
)
398398
if model.model_type not in CIFTI_MODEL_TYPES:
399-
raise CIFTI2HeaderError(
399+
raise Cifti2HeaderError(
400400
'ModelType for this BrainModel element is not valid'
401401
)
402402
mim.append(model)
@@ -407,7 +407,7 @@ def StartElementHandler(self, name, attrs):
407407
index = Cifti2VertexIndices()
408408
model = self.struct_state[-1]
409409
if not isinstance(model, Cifti2BrainModel):
410-
raise CIFTI2HeaderError(
410+
raise Cifti2HeaderError(
411411
'VertexIndices element can only be a child '
412412
'of the CIFTI2 BrainModel element'
413413
)

0 commit comments

Comments
 (0)