We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a1394a6 commit d4341afCopy full SHA for d4341af
nibabel/spatialimages.py
@@ -339,7 +339,11 @@ def __getitem__(self, slicer):
339
slicer = self.check_slicing(slicer)
340
except ValueError as err:
341
raise IndexError(*err.args)
342
+
343
dataobj = self.img.dataobj[slicer]
344
+ if any(dim == 0 for dim in dataobj.shape):
345
+ raise IndexError("Empty slice requested")
346
347
affine = self.slice_affine(slicer)
348
return self.img.__class__(dataobj.copy(), affine, self.img.header)
349
0 commit comments