From b1eb9b04a46633fcb2b9187d380e592a1860c951 Mon Sep 17 00:00:00 2001 From: Brendan Moloney Date: Wed, 20 Nov 2024 15:52:50 -0800 Subject: [PATCH] TST: Add tests for non-integer StackID --- nibabel/nicom/tests/test_dicomwrappers.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/nibabel/nicom/tests/test_dicomwrappers.py b/nibabel/nicom/tests/test_dicomwrappers.py index 7482115fa..9f707b25e 100755 --- a/nibabel/nicom/tests/test_dicomwrappers.py +++ b/nibabel/nicom/tests/test_dicomwrappers.py @@ -594,6 +594,17 @@ def test_shape(self): # Check for error when explicitly requested StackID is missing with pytest.raises(didw.WrapperError): MFW(fake_mf, frame_filters=(didw.FilterMultiStack(3),)) + # StackID can be a string + div_seq = ((1,), (2,), (3,), (4,)) + sid_seq = ('a', 'a', 'a', 'b') + fake_mf.update(fake_shape_dependents(div_seq, sid_seq=sid_seq)) + with pytest.warns( + UserWarning, + match='A multi-stack file was passed without an explicit filter,', + ): + assert MFW(fake_mf).image_shape == (32, 64, 3) + assert MFW(fake_mf, frame_filters=(didw.FilterMultiStack('a'),)).image_shape == (32, 64, 3) + assert MFW(fake_mf, frame_filters=(didw.FilterMultiStack('b'),)).image_shape == (32, 64) # Make some fake frame data for 4D when StackID index is 0 div_seq = ((1, 1, 1), (1, 2, 1), (1, 1, 2), (1, 2, 2), (1, 1, 3), (1, 2, 3)) fake_mf.update(fake_shape_dependents(div_seq, sid_dim=0))