Skip to content

Commit 0417007

Browse files
committed
TST: add get_dimension_label tests to the 5D and 6D data sets used for testing strict_sort
1 parent 6fe8fdb commit 0417007

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

nibabel/tests/test_parrec.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ def test_sorting_dual_echo_T1():
301301
# second half (volume 2) should all correspond to echo 2
302302
assert_equal(np.all(sorted_echos[n_half:] == 2), True)
303303

304+
# check volume labels
305+
vol_labels = t1_hdr.get_dimension_labels()
306+
assert_equal(list(vol_labels.keys()), ['echo number'])
307+
assert_array_equal(vol_labels['echo number'], [1, 2])
308+
304309

305310
def test_sorting_multiple_echos_and_contrasts():
306311
# This .PAR file has 3 echos and 4 image types (real, imaginary, magnitude,
@@ -343,6 +348,14 @@ def test_sorting_multiple_echos_and_contrasts():
343348
assert_equal(np.all(sorted_types[ntotal//2:3*ntotal//4] == 2), True)
344349
assert_equal(np.all(sorted_types[3*ntotal//4:ntotal] == 3), True)
345350

351+
# check volume labels
352+
vol_labels = t1_hdr.get_dimension_labels()
353+
assert_equal(sorted(list(vol_labels.keys())),
354+
['echo number', 'image_type_mr'])
355+
assert_array_equal(vol_labels['echo number'], [1, 2, 3]*4)
356+
assert_array_equal(vol_labels['image_type_mr'],
357+
[0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3])
358+
346359

347360
def test_sorting_multiecho_ASL():
348361
# For this .PAR file has 3 keys corresponding to volumes:
@@ -384,6 +397,15 @@ def test_sorting_multiecho_ASL():
384397
# check that slices vary fastest
385398
assert_array_equal(sorted_slices[:nslices], np.arange(1, nslices+1))
386399

400+
# check volume labels
401+
vol_labels = asl_hdr.get_dimension_labels()
402+
assert_equal(sorted(list(vol_labels.keys())),
403+
['dynamic scan number', 'echo number', 'label type'])
404+
assert_array_equal(vol_labels['dynamic scan number'], [1]*6 + [2]*6)
405+
assert_array_equal(vol_labels['label type'], [1]*3 + [2]*3 + [1]*3 + [2]*3)
406+
assert_array_equal(vol_labels['echo number'], [1, 2, 3]*4)
407+
408+
387409
def test_vol_number():
388410
# Test algorithm for calculating volume number
389411
assert_array_equal(vol_numbers([1, 3, 0]), [0, 0, 0])

0 commit comments

Comments
 (0)