|
24 | 24 |
|
25 | 25 | from .scriptrunner import ScriptRunner
|
26 | 26 | from .nibabel_data import needs_nibabel_data
|
27 |
| -from .test_parrec import DTI_PAR_BVECS, DTI_PAR_BVALS |
| 27 | +from ..testing import assert_dt_equal |
| 28 | +from .test_parrec import (DTI_PAR_BVECS, DTI_PAR_BVALS, |
| 29 | + EXAMPLE_IMAGES as PARREC_EXAMPLES) |
28 | 30 | from .test_parrec_data import BALLS, AFF_OFF
|
| 31 | +from .test_helpers import assert_data_similar |
29 | 32 |
|
30 | 33 |
|
31 | 34 | def _proc_stdout(stdout):
|
@@ -89,19 +92,18 @@ def test_parrec2nii():
|
89 | 92 | cmd = ['parrec2nii', '--help']
|
90 | 93 | code, stdout, stderr = run_command(cmd)
|
91 | 94 | assert_true(stdout.startswith('Usage'))
|
92 |
| - in_fname = pjoin(DATA_PATH, 'phantom_EPI_asc_CLEAR_2_1.PAR') |
93 |
| - out_froot = 'phantom_EPI_asc_CLEAR_2_1.nii' |
94 | 95 | with InTemporaryDirectory():
|
95 |
| - run_command(['parrec2nii', in_fname]) |
96 |
| - img = load(out_froot) |
97 |
| - assert_equal(img.shape, (64, 64, 9, 3)) |
98 |
| - assert_equal(img.get_data_dtype(), np.dtype(np.uint16)) |
99 |
| - # Check against values from Philips converted nifti image |
100 |
| - data = img.get_data() |
101 |
| - assert_true(np.allclose( |
102 |
| - (data.min(), data.max(), data.mean()), |
103 |
| - (0.0, 2299.4110643863678, 194.95876256117265))) |
104 |
| - assert_almost_equal(vox_size(img.get_affine()), (3.75, 3.75, 8)) |
| 96 | + for eg_dict in PARREC_EXAMPLES: |
| 97 | + fname = eg_dict['fname'] |
| 98 | + run_command(['parrec2nii', fname]) |
| 99 | + out_froot = splitext(basename(fname))[0] + '.nii' |
| 100 | + img = load(out_froot) |
| 101 | + assert_equal(img.shape, eg_dict['shape']) |
| 102 | + assert_dt_equal(img.get_data_dtype(), eg_dict['dtype']) |
| 103 | + # Check against values from Philips converted nifti image |
| 104 | + data = img.get_data() |
| 105 | + assert_data_similar(data, eg_dict) |
| 106 | + assert_almost_equal(img.header.get_zooms(), eg_dict['zooms']) |
105 | 107 |
|
106 | 108 |
|
107 | 109 | @script_test
|
|
0 commit comments