Skip to content

Commit 4b6968f

Browse files
committed
TEST: Test that MRIsExpand runs correctly
1 parent e9af42c commit 4b6968f

File tree

1 file changed

+52
-1
lines changed

1 file changed

+52
-1
lines changed

nipype/interfaces/freesurfer/tests/test_utils.py

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
from nipype.testing.fixtures import (create_files_in_directory_plus_dummy_file,
99
create_surf_file_in_directory)
1010

11+
from nipype.pipeline import engine as pe
12+
from nipype.interfaces import freesurfer as fs
1113
from nipype.interfaces.base import TraitError
12-
import nipype.interfaces.freesurfer as fs
14+
from nipype.interfaces.io import FreeSurferSource
1315

1416

1517
@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
@@ -159,3 +161,52 @@ def test_surfshots(create_files_in_directory_plus_dummy_file):
159161
os.environ["DISPLAY"] = hold_display
160162
except KeyError:
161163
pass
164+
165+
166+
@pytest.mark.skipif(fs.no_freesurfer(), reason="freesurfer is not installed")
167+
def test_mrisexpand(tmpdir):
168+
fssrc = FreeSurferSource(subjects_dir=fs.Info.subjectsdir(),
169+
subject_id='fsaverage', hemi='lh')
170+
171+
fsavginfo = fssrc.run().outputs.get()
172+
173+
# dt=60 to ensure very short runtime
174+
expand_if = fs.MRIsExpand(in_file=fsavginfo['smoothwm'],
175+
out_name='expandtmp',
176+
distance=1,
177+
dt=60)
178+
179+
expand_nd = pe.Node(
180+
fs.MRIsExpand(in_file=fsavginfo['smoothwm'],
181+
out_name='expandtmp',
182+
distance=1,
183+
dt=60),
184+
name='expand_node')
185+
186+
# Interfaces should have same command line at instantiation
187+
orig_cmdline = 'mris_expand -T 60 {} 1 expandtmp'.format(fsavginfo['smoothwm'])
188+
assert expand_if.cmdline == orig_cmdline
189+
assert expand_nd.interface.cmdline == orig_cmdline
190+
191+
# Run both interfaces
192+
if_res = expand_if.run()
193+
nd_res = expand_nd.run()
194+
195+
# Commandlines differ
196+
node_cmdline = 'mris_expand -T 60 -pial {cwd}/lh.pial {cwd}/lh.smoothwm ' \
197+
'1 expandtmp'.format(cwd=nd_res.runtime.cwd)
198+
assert if_res.runtime.cmdline == orig_cmdline
199+
assert nd_res.runtime.cmdline == node_cmdline
200+
201+
# Check output
202+
if_out_file = if_res.outputs.get()['out_file']
203+
nd_out_file = nd_res.outputs.get()['out_file']
204+
# Same filename
205+
assert op.basename(if_out_file) == op.basename(nd_out_file)
206+
# Interface places output in source directory
207+
assert op.dirname(if_out_file) == op.dirname(fsavginfo['smoothwm'])
208+
# Node places output in working directory
209+
assert op.dirname(nd_out_file) == nd_res.runtime.cwd
210+
211+
# Remove test surface
212+
os.unlink(if_out_file)

0 commit comments

Comments
 (0)