Skip to content

Commit 3f04e3c

Browse files
committed
TST: add multiframe 5D data sorting test
Might need some review.
1 parent 367076c commit 3f04e3c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

nibabel/nicom/tests/test_dicomwrappers.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,37 @@ def test_data_fake(self):
578578
sorted_data = data[..., [3, 1, 2, 0]]
579579
fake_mf['pixel_array'] = np.rollaxis(sorted_data, 2)
580580
assert_array_equal(MFW(fake_mf).get_data(), data * 2.0 - 1)
581+
# 5D!
582+
dim_idxs = [
583+
[1, 4, 2, 1],
584+
[1, 2, 2, 1],
585+
[1, 3, 2, 1],
586+
[1, 1, 2, 1],
587+
[1, 4, 2, 2],
588+
[1, 2, 2, 2],
589+
[1, 3, 2, 2],
590+
[1, 1, 2, 2],
591+
[1, 4, 1, 1],
592+
[1, 2, 1, 1],
593+
[1, 3, 1, 1],
594+
[1, 1, 1, 1],
595+
[1, 4, 1, 2],
596+
[1, 2, 1, 2],
597+
[1, 3, 1, 2],
598+
[1, 1, 1, 2]]
599+
frames = fake_frames('FrameContentSequence',
600+
'DimensionIndexValues',
601+
dim_idxs)
602+
fake_mf['PerFrameFunctionalGroupsSequence'] = frames
603+
fake_mf['NumberOfFrames'] = len(frames)
604+
shape = (2, 3, 4, 2, 2)
605+
data = np.arange(np.prod(shape)).reshape(shape)
606+
sorted_data = data.reshape(shape[:2] + (-1,), order='F')
607+
order = [11, 9, 10, 8, 3, 1, 2, 0,
608+
15, 13, 14, 12, 7, 5, 6, 4]
609+
sorted_data = sorted_data[..., np.argsort(order)]
610+
fake_mf['pixel_array'] = np.rollaxis(sorted_data, 2)
611+
assert_array_equal(MFW(fake_mf).get_data(), data * 2.0 - 1)
581612

582613
def test__scale_data(self):
583614
# Test data scaling

0 commit comments

Comments
 (0)