Skip to content

Commit 44fd02b

Browse files
TEST: Added parrec2nii test with most interfaces mocked.
1 parent e37cb5d commit 44fd02b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

nibabel/tests/test_parrec2nii.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
""" Tests for the parrec2nii exe code
2+
"""
3+
import imp, numpy
4+
from mock import Mock, MagicMock
5+
from numpy import array as npa
6+
7+
AN_OLD_AFFINE = numpy.array(
8+
[[-3.64994708, 0., 1.83564171, 123.66276611],
9+
[0., -3.75, 0., 115.617],
10+
[0.86045705, 0., 7.78655376, -27.91161211],
11+
[0., 0., 0., 1.]])
12+
13+
def test_parrec2nii():
14+
parrec2nii = imp.load_source('parrec2nii', 'bin/parrec2nii')
15+
parrec2nii.verbose.switch = False
16+
17+
parrec2nii.io_orientation = Mock()
18+
parrec2nii.io_orientation.return_value = [[0, 1],[1, 1],[2, 1]] # LAS+
19+
20+
parrec2nii.nifti1 = Mock()
21+
nimg = Mock()
22+
nhdr = MagicMock()
23+
nimg.header = nhdr
24+
parrec2nii.nifti1.Nifti1Image.return_value = nimg
25+
26+
parrec2nii.pr = Mock()
27+
pr_img = Mock()
28+
pr_hdr = Mock()
29+
pr_hdr.get_data_scaling.return_value = (npa([]), npa([]))
30+
pr_hdr.get_bvals_bvecs.return_value = (None, None)
31+
pr_hdr.get_affine.return_value = AN_OLD_AFFINE
32+
pr_img.header = pr_hdr
33+
parrec2nii.pr.load.return_value = pr_img
34+
35+
opts = Mock()
36+
opts.outdir = None
37+
opts.scaling = 'off'
38+
opts.minmax = [1, 1]
39+
opts.store_header = False
40+
opts.bvs = False
41+
opts.vol_info = False
42+
opts.dwell_time = False
43+
44+
infile = 'nonexistent.PAR'
45+
parrec2nii.proc_file(infile, opts)

0 commit comments

Comments
 (0)