Skip to content

Commit 9704034

Browse files
authored
ENH: only warn about invalid Minc2 spacing declaration
Accept other values (like `xspacing`), assuming regular spacing. #1236
1 parent 064e80d commit 9704034

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nibabel/minc2.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
2626
mincstats my_funny.mnc
2727
"""
28+
import warnings
2829
import numpy as np
2930

3031
from .minc1 import Minc1File, Minc1Image, MincError, MincHeader
@@ -58,8 +59,12 @@ def __init__(self, mincfile):
5859
# We don't currently support irregular spacing
5960
# https://en.wikibooks.org/wiki/MINC/Reference/MINC2.0_File_Format_Reference#Dimension_variable_attributes
6061
for dim in self._dims:
61-
if dim.spacing != b'regular__':
62-
raise ValueError('Irregular spacing not supported')
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')
67+
6368
self._spatial_dims = [name for name in self._dim_names if name.endswith('space')]
6469
self._image_max = image['image-max']
6570
self._image_min = image['image-min']

0 commit comments

Comments
 (0)