Skip to content

Commit f720c84

Browse files
committed
TST: test_header_dimension_labels() added
1 parent 53dc4b2 commit f720c84

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

nibabel/tests/test_parrec.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,24 @@ def test_header_scaling():
189189
assert_false(np.all(fp_scaling == dv_scaling))
190190

191191

192+
def test_header_dimension_labels():
193+
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
194+
# check volume labels
195+
vol_labels = hdr.get_dimension_labels()
196+
assert_equal(list(vol_labels.keys()), ['dynamic scan number'])
197+
assert_array_equal(vol_labels['dynamic scan number'], [1, 2, 3])
198+
# check that output is ndarray rather than list
199+
assert_true(isinstance(vol_labels['dynamic scan number'], np.ndarray))
200+
# check case with individual slice labels
201+
slice_vol_labels = hdr.get_dimension_labels(collapse_slices=False)
202+
# verify that both expected keys are present
203+
assert_true('slice number' in slice_vol_labels)
204+
assert_true('dynamic scan number' in slice_vol_labels)
205+
# verify shape of labels matches final dimensions of data
206+
assert_equal(slice_vol_labels['slice number'].shape,
207+
hdr.get_data_shape()[2:])
208+
209+
192210
def test_orientation():
193211
hdr = PARRECHeader(HDR_INFO, HDR_DEFS)
194212
assert_array_equal(HDR_DEFS['slice orientation'], 1)

0 commit comments

Comments
 (0)