Skip to content

Commit f4c2272

Browse files
committed
TST: test some options to parrec2nii
Test overwrite, bvs, dwell-time options to parrec2nii script.
1 parent 25b9e03 commit f4c2272

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

nibabel/tests/test_scripts.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
from ..tmpdirs import InTemporaryDirectory
1818
from ..loadsave import load
1919

20-
from nose.tools import assert_true, assert_not_equal, assert_equal
20+
from nose.tools import (assert_true, assert_false, assert_not_equal,
21+
assert_equal)
2122

2223
from numpy.testing import assert_almost_equal
2324

@@ -133,3 +134,31 @@ def test_parrec2nii_with_data():
133134
if par_root != 'fieldmap':
134135
assert_true(np.allclose(conved_img.dataobj,
135136
nimg.dataobj))
137+
with InTemporaryDirectory():
138+
# Test some options
139+
dti_par = pjoin(BALLS, 'PARREC', 'DTI.PAR')
140+
run_command(['parrec2nii', dti_par])
141+
assert_true(exists('DTI.nii'))
142+
assert_false(exists('DTI.bvals'))
143+
assert_false(exists('DTI.bvecs'))
144+
# Does not overwrite unless option given
145+
code, stdout, stderr = run_command(['parrec2nii', dti_par],
146+
check_code=False)
147+
assert_equal(code, 1)
148+
# Writes bvals, bvecs files if asked
149+
run_command(['parrec2nii', '--overwrite', '--bvs', dti_par])
150+
assert_true(exists('DTI.bvals'))
151+
assert_true(exists('DTI.bvecs'))
152+
assert_false(exists('DTI.dwell_time'))
153+
# Need field strength if requesting dwell time
154+
code, _, _, = run_command(
155+
['parrec2nii', '--overwrite', '--dwell-time', dti_par],
156+
check_code=False)
157+
assert_equal(code, 1)
158+
run_command(
159+
['parrec2nii', '--overwrite', '--dwell-time',
160+
'--field-strength', '3', dti_par])
161+
exp_dwell = (26 * 9.087) / (42.576 * 3.4 * 3 * 28)
162+
with open('DTI.dwell_time', 'rt') as fobj:
163+
contents = fobj.read().strip()
164+
assert_almost_equal(float(contents), exp_dwell)

0 commit comments

Comments
 (0)