@@ -422,7 +422,7 @@ def test_slicer(self):
422
422
img = img_klass (in_data , base_affine .copy ())
423
423
424
424
# Detect time axis on first loop (4D image)
425
- if t_axis is None :
425
+ if t_axis is None and img . _spatial_dims is not None :
426
426
t_axis = 3 if img ._spatial_dims .start == 0 else 0
427
427
428
428
assert_true (hasattr (img .slicer , '__getitem__' ))
@@ -451,7 +451,7 @@ def test_slicer(self):
451
451
img .slicer [None ]
452
452
# 4D Minc to 3D
453
453
assert_equal (img .slicer [0 ].shape , img .shape [1 :])
454
- else :
454
+ elif t_axis is not None :
455
455
# 3D Minc to 4D
456
456
assert_equal (img .slicer [None ].shape , (1 ,) + img .shape )
457
457
# Axes 1 and 2 are always spatial
@@ -479,7 +479,7 @@ def test_slicer(self):
479
479
# 4D to 3D using ellipsis or slices
480
480
assert_equal (img .slicer [..., 0 ].shape , img .shape [:- 1 ])
481
481
assert_equal (img .slicer [:, :, :, 0 ].shape , img .shape [:- 1 ])
482
- else :
482
+ elif t_axis is not None :
483
483
# 3D Analyze/NIfTI/MGH to 4D
484
484
assert_equal (img .slicer [:, :, :, None ].shape , img .shape + (1 ,))
485
485
if len (img .shape ) == 3 :
@@ -499,7 +499,7 @@ def test_slicer(self):
499
499
sliced_j = img .slicer [:, 1 :]
500
500
sliced_k = img .slicer [:, :, 1 :]
501
501
sliced_ijk = img .slicer [1 :, 1 :, 1 :]
502
- else :
502
+ elif t_axis is not None :
503
503
# 4D Minc
504
504
sliced_i = img .slicer [:, 1 :]
505
505
sliced_j = img .slicer [:, :, 1 :]
0 commit comments