Skip to content

Commit 3d19b50

Browse files
committed
fix: voxelindicesijk initialization, header version check, typo in error message
1 parent 645edaa commit 3d19b50

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

nibabel/cifti/cifti.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,9 @@ class CiftiParcel(object):
310310

311311
def __init__(self, name=None, voxel_indices_ijk=None, vertices=None):
312312
self.name = name
313-
self.voxelIndicesIJK = voxel_indices_ijk
313+
self._voxelIndicesIJK = CiftiVoxelIndicesIJK()
314314
if voxel_indices_ijk is not None:
315-
self._voxelIndicesIJK = voxel_indices_ijk
315+
self.voxelIndicesIJK = voxel_indices_ijk
316316
if vertices is None:
317317
vertices = []
318318
self.vertices = vertices

nibabel/cifti/parse_cifti_fast.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ##
99
from __future__ import division, print_function, absolute_import
1010

11+
from distutils.version import LooseVersion
12+
1113
from ..externals.six import StringIO
1214
from xml.parsers.expat import ParserCreate, ExpatError
1315

@@ -44,8 +46,9 @@ def StartElementHandler(self, name, attrs):
4446
if name == 'CIFTI':
4547
# create gifti image
4648
self.header = CiftiHeader()
47-
if 'Version' in attrs:
48-
self.header.version = attrs['Version']
49+
self.header.version = attrs['Version']
50+
if LooseVersion(self.header.version) < LooseVersion('2.0'):
51+
raise ValueError('Only CIFTI-2 files are supported')
4952
self.fsm_state.append('CIFTI')
5053
self.struct_state.append(self.header)
5154
elif name == 'Matrix':
@@ -361,7 +364,7 @@ def parse_cifti_string(cifti_string):
361364
try:
362365
parser.Parse(cifti_string, True)
363366
except ExpatError:
364-
print('An expat error occured while parsing the Gifti file.')
367+
print('An expat error occured while parsing the Cifti file.')
365368
return out.header
366369

367370
def create_cifti_image(nifti2_image, cifti_header, intent_code):

0 commit comments

Comments
 (0)