Skip to content

Commit 1512329

Browse files
committed
ENH: Add SpatialImage._spatial_dims slicer
1 parent 2386f4f commit 1512329

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

nibabel/minc1.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ def from_file_map(klass, file_map):
319319
data = klass.ImageArrayProxy(minc_file)
320320
return klass(data, affine, header, extra=None, file_map=file_map)
321321

322+
@property
323+
def _spatial_dims(self):
324+
if len(self.shape) > 3:
325+
return slice(1, 4)
326+
return slice(0, 3)
327+
322328

323329
load = Minc1Image.load
324330

nibabel/spatialimages.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ class ImageDataError(Exception):
325325
class SpatialImage(DataobjImage):
326326
''' Template class for volumetric (3D/4D) images '''
327327
header_class = SpatialHeader
328+
# Make a strong assumption that the first three dimensions are spatial
329+
# Subclasses/images for which this is not true should change this attribute
330+
_spatial_dims = slice(0, 3)
328331

329332
class Slicer(object):
330333
def __init__(self, img):

0 commit comments

Comments
 (0)