|
17 | 17 | from ..tmpdirs import InTemporaryDirectory
|
18 | 18 | from ..loadsave import load
|
19 | 19 |
|
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) |
21 | 22 |
|
22 | 23 | from numpy.testing import assert_almost_equal
|
23 | 24 |
|
@@ -133,3 +134,31 @@ def test_parrec2nii_with_data():
|
133 | 134 | if par_root != 'fieldmap':
|
134 | 135 | assert_true(np.allclose(conved_img.dataobj,
|
135 | 136 | 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