@@ -301,6 +301,11 @@ def test_sorting_dual_echo_T1():
301
301
# second half (volume 2) should all correspond to echo 2
302
302
assert_equal (np .all (sorted_echos [n_half :] == 2 ), True )
303
303
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
+
304
309
305
310
def test_sorting_multiple_echos_and_contrasts ():
306
311
# This .PAR file has 3 echos and 4 image types (real, imaginary, magnitude,
@@ -343,6 +348,14 @@ def test_sorting_multiple_echos_and_contrasts():
343
348
assert_equal (np .all (sorted_types [ntotal // 2 :3 * ntotal // 4 ] == 2 ), True )
344
349
assert_equal (np .all (sorted_types [3 * ntotal // 4 :ntotal ] == 3 ), True )
345
350
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
+
346
359
347
360
def test_sorting_multiecho_ASL ():
348
361
# For this .PAR file has 3 keys corresponding to volumes:
@@ -384,6 +397,15 @@ def test_sorting_multiecho_ASL():
384
397
# check that slices vary fastest
385
398
assert_array_equal (sorted_slices [:nslices ], np .arange (1 , nslices + 1 ))
386
399
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
+
387
409
def test_vol_number ():
388
410
# Test algorithm for calculating volume number
389
411
assert_array_equal (vol_numbers ([1 , 3 , 0 ]), [0 , 0 , 0 ])
0 commit comments