@@ -422,7 +422,7 @@ def test_slicer(self):
422422 img = img_klass (in_data , base_affine .copy ())
423423
424424 # 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 :
426426 t_axis = 3 if img ._spatial_dims .start == 0 else 0
427427
428428 assert_true (hasattr (img .slicer , '__getitem__' ))
@@ -451,7 +451,7 @@ def test_slicer(self):
451451 img .slicer [None ]
452452 # 4D Minc to 3D
453453 assert_equal (img .slicer [0 ].shape , img .shape [1 :])
454- else :
454+ elif t_axis is not None :
455455 # 3D Minc to 4D
456456 assert_equal (img .slicer [None ].shape , (1 ,) + img .shape )
457457 # Axes 1 and 2 are always spatial
@@ -479,7 +479,7 @@ def test_slicer(self):
479479 # 4D to 3D using ellipsis or slices
480480 assert_equal (img .slicer [..., 0 ].shape , img .shape [:- 1 ])
481481 assert_equal (img .slicer [:, :, :, 0 ].shape , img .shape [:- 1 ])
482- else :
482+ elif t_axis is not None :
483483 # 3D Analyze/NIfTI/MGH to 4D
484484 assert_equal (img .slicer [:, :, :, None ].shape , img .shape + (1 ,))
485485 if len (img .shape ) == 3 :
@@ -499,7 +499,7 @@ def test_slicer(self):
499499 sliced_j = img .slicer [:, 1 :]
500500 sliced_k = img .slicer [:, :, 1 :]
501501 sliced_ijk = img .slicer [1 :, 1 :, 1 :]
502- else :
502+ elif t_axis is not None :
503503 # 4D Minc
504504 sliced_i = img .slicer [:, 1 :]
505505 sliced_j = img .slicer [:, :, 1 :]
0 commit comments