Skip to content

Commit 3294e29

Browse files
committed
RF: make opt-in list of spatial-first image types
From suggestion by Chris M, make an opt-in list of image types known to be spatial axes first, so that new image types don't accidentally imply they are spatial axes first.
1 parent 214dd3b commit 3294e29

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

nibabel/imageclasses.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ def __getitem__(self, *args, **kwargs):
105105
('par', '.par'),
106106
))
107107

108+
# Image classes known to require spatial axes to be first in index ordering.
109+
# When adding an image class, consider whether the new class should be listed
110+
# here.
111+
KNOWN_SPATIAL_FIRST = (Nifti1Pair, Nifti1Image, Nifti2Pair, Nifti2Image,
112+
Spm2AnalyzeImage, Spm99AnalyzeImage, AnalyzeImage,
113+
MGHImage, PARRECImage)
114+
108115

109116
def spatial_axes_first(img):
110117
""" True if spatial image axes for `img` always preceed other axes
@@ -122,4 +129,4 @@ def spatial_axes_first(img):
122129
"""
123130
if len(img.shape) < 4:
124131
return True
125-
return not isinstance(img, Minc1Image)
132+
return type(img) in KNOWN_SPATIAL_FIRST

0 commit comments

Comments
 (0)