Skip to content

Commit ff4f855

Browse files
petsutereffigies
andauthored
Update nibabel/minc2.py
Co-authored-by: Chris Markiewicz <[email protected]>
1 parent 9704034 commit ff4f855

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nibabel/minc2.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ def __init__(self, mincfile):
5959
# We don't currently support irregular spacing
6060
# https://en.wikibooks.org/wiki/MINC/Reference/MINC2.0_File_Format_Reference#Dimension_variable_attributes
6161
for dim in self._dims:
62-
if hasattr(dim, 'spacing'):
63-
if dim.spacing == b'irregular':
64-
raise ValueError('Irregular spacing not supported')
65-
elif dim.spacing != b'regular__':
66-
warnings.warn(f'Invalid spacing declaration: {dim.spacing}; assuming regular')
62+
# "If this attribute is absent, a value of regular__ should be assumed."
63+
spacing = getattr(dim, 'spacing', b'regular__')
64+
if spacing == b'irregular':
65+
raise ValueError('Irregular spacing not supported')
66+
elif spacing != b'regular__':
67+
warnings.warn(f'Invalid spacing declaration: {spacing}; assuming regular')
6768

6869
self._spatial_dims = [name for name in self._dim_names if name.endswith('space')]
6970
self._image_max = image['image-max']

0 commit comments

Comments
 (0)