Skip to content

Commit 244c8cf

Browse files
committed
ENH(TST): basic test for consistent choice of slice_code in case of multiple available
1 parent 7ba14b1 commit 244c8cf

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

nibabel/tests/test_nifti1.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,19 @@ def test_slice_times(self):
558558
assert_equal(hdr['slice_end'], 5)
559559
assert_array_almost_equal(hdr['slice_duration'], 0.1)
560560

561+
# Ambiguous case
562+
hdr2 = self.header_class()
563+
hdr2.set_dim_info(slice=2)
564+
hdr2.set_slice_duration(0.1)
565+
hdr2.set_data_shape((1, 1, 2))
566+
hdr2.set_slice_times([0.1, 0]) # will generate warning that multiple match
567+
# but always must be choosing sequential one first
568+
assert_equal(hdr2.get_value_label('slice_code'), 'sequential decreasing')
569+
# and the other direction
570+
hdr2.set_slice_times([0, 0.1])
571+
assert_equal(hdr2.get_value_label('slice_code'), 'sequential increasing')
572+
573+
561574
def test_intents(self):
562575
ehdr = self.header_class()
563576
ehdr.set_intent('t test', (10,), name='some score')

0 commit comments

Comments
 (0)