Skip to content

Commit 4e26bef

Browse files
committed
Split fsl dti and epi tests
This would fix one of the failed tests
1 parent 984456a commit 4e26bef

File tree

2 files changed

+91
-44
lines changed

2 files changed

+91
-44
lines changed

nipype/interfaces/fsl/tests/test_dti.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,6 @@ def test_dtifit1():
6868
for metakey, value in metadata.items():
6969
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
7070

71-
@skipif(no_fsl)
72-
def test_eddy_correct1():
73-
input_map = dict(args = dict(argstr='%s',),
74-
environ = dict(),
75-
in_file = dict(argstr='%s',mandatory=True,),
76-
out_file = dict(argstr='%s',),
77-
output_type = dict(),
78-
ref_num = dict(mandatory=True,argstr='%d',),
79-
)
80-
instance = fsl.EddyCorrect()
81-
for key, metadata in input_map.items():
82-
for metakey, value in metadata.items():
83-
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
84-
85-
86-
8771
@skipif(no_fsl)
8872
def test_findthebiggest():
8973
input_map = dict(args = dict(argstr='%s',),
@@ -232,34 +216,6 @@ def test_bedpostx2():
232216
yield assert_equal, actualCmdline, desiredCmdline
233217

234218

235-
236-
# test eddy_correct
237-
@skipif(no_fsl)
238-
def test_eddy_correct2():
239-
filelist, outdir, cwd = create_files_in_directory()
240-
eddy = fsl.EddyCorrect()
241-
242-
# make sure command gets called
243-
yield assert_equal, eddy.cmd, 'eddy_correct'
244-
245-
# test raising error with mandatory args absent
246-
yield assert_raises, ValueError, eddy.run
247-
248-
# .inputs based parameters setting
249-
eddy.inputs.in_file = filelist[0]
250-
eddy.inputs.out_file = 'foo_eddc.nii'
251-
eddy.inputs.ref_num = 100
252-
yield assert_equal, eddy.cmdline, 'eddy_correct %s foo_eddc.nii 100'%filelist[0]
253-
254-
# .run based parameter setting
255-
eddy2 = fsl.EddyCorrect(in_file=filelist[0], out_file='foo_ec.nii', ref_num=20)
256-
yield assert_equal, eddy2.cmdline, 'eddy_correct %s foo_ec.nii 20'%filelist[0]
257-
258-
# test arguments for opt_map
259-
# eddy_correct class doesn't have opt_map{}
260-
clean_directory(outdir, cwd)
261-
262-
263219
# test dtifit
264220
@skipif(no_fsl)
265221
def test_dtifit2():
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
import os
4+
import tempfile
5+
import shutil
6+
7+
from tempfile import mkdtemp
8+
from shutil import rmtree
9+
10+
import numpy as np
11+
12+
import nibabel as nb
13+
14+
from nose import with_setup
15+
16+
from nipype.testing import ( assert_equal, assert_not_equal,
17+
assert_raises, skipif, example_data)
18+
import nipype.interfaces.fsl.epi as fsl
19+
from nipype.interfaces.fsl import Info, no_fsl
20+
from nipype.interfaces.base import Undefined
21+
22+
# nosetests --with-doctest path_to/test_fsl.py
23+
24+
@skipif(no_fsl)
25+
def test_eddy_correct1():
26+
input_map = dict(args = dict(argstr='%s',),
27+
environ = dict(),
28+
in_file = dict(argstr='%s',mandatory=True,),
29+
out_file = dict(argstr='%s',),
30+
output_type = dict(),
31+
ref_num = dict(mandatory=True,argstr='%d',),
32+
)
33+
instance = fsl.EddyCorrect()
34+
for key, metadata in input_map.items():
35+
for metakey, value in metadata.items():
36+
yield assert_equal, getattr(instance.inputs.traits()[key], metakey), value
37+
38+
39+
def skip_epi_tests():
40+
"""XXX These tests are skipped until we clean up some of this code
41+
"""
42+
return True
43+
44+
def create_files_in_directory():
45+
outdir = os.path.realpath(mkdtemp())
46+
cwd = os.getcwd()
47+
os.chdir(outdir)
48+
filelist = ['a.nii','b.nii']
49+
for f in filelist:
50+
hdr = nb.Nifti1Header()
51+
shape = (3,3,3,4)
52+
hdr.set_data_shape(shape)
53+
img = np.random.random(shape)
54+
nb.save(nb.Nifti1Image(img,np.eye(4),hdr),
55+
os.path.join(outdir,f))
56+
return filelist, outdir, cwd
57+
58+
def clean_directory(outdir, old_wd):
59+
if os.path.exists(outdir):
60+
rmtree(outdir)
61+
os.chdir(old_wd)
62+
63+
64+
# test eddy_correct
65+
@skipif(no_fsl)
66+
def test_eddy_correct2():
67+
filelist, outdir, cwd = create_files_in_directory()
68+
eddy = fsl.EddyCorrect()
69+
70+
# make sure command gets called
71+
yield assert_equal, eddy.cmd, 'eddy_correct'
72+
73+
# test raising error with mandatory args absent
74+
yield assert_raises, ValueError, eddy.run
75+
76+
# .inputs based parameters setting
77+
eddy.inputs.in_file = filelist[0]
78+
eddy.inputs.out_file = 'foo_eddc.nii'
79+
eddy.inputs.ref_num = 100
80+
yield assert_equal, eddy.cmdline, 'eddy_correct %s foo_eddc.nii 100'%filelist[0]
81+
82+
# .run based parameter setting
83+
eddy2 = fsl.EddyCorrect(in_file=filelist[0], out_file='foo_ec.nii', ref_num=20)
84+
yield assert_equal, eddy2.cmdline, 'eddy_correct %s foo_ec.nii 20'%filelist[0]
85+
86+
# test arguments for opt_map
87+
# eddy_correct class doesn't have opt_map{}
88+
clean_directory(outdir, cwd)
89+
90+
91+

0 commit comments

Comments
 (0)