Skip to content

Commit 4d14512

Browse files
committed
Merge pull request #785 from JensNRAD/eddy_fix
Fix for Eddy-Wrapper does not work properly #769
2 parents b2d3a81 + 0836459 commit 4d14512

File tree

4 files changed

+101
-57
lines changed

4 files changed

+101
-57
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -305,32 +305,60 @@ def _list_outputs(self):
305305

306306

307307
class EddyInputSpec( FSLCommandInputSpec ):
308-
in_file = File(exists=True, mandatory=True, desc='File containing all the images to estimate distortions for', argstr='--imain=%s' )
309-
in_mask = File(exists=True, mandatory=True, desc='Mask to indicate brain', argstr='--mask=%s' )
310-
in_index = File(exists=True, mandatory=True, desc='File containing indices for all volumes in --imain into --acqp and --topup', argstr='--index=%s' )
311-
in_acqp = File(exists=True, mandatory=True, desc='File containing acquisition parameters', argstr='--acqp=%s' )
312-
in_bvec = File(exists=True, mandatory=True, desc='File containing the b-vectors for all volumes in --imain', argstr='--bvecs=%s' )
313-
in_bval = File(exists=True, mandatory=True, desc='File containing the b-values for all volumes in --imain', argstr='--bvals=%s' )
308+
in_file = File(exists=True, mandatory=True,
309+
desc=('File containing all the images to estimate '
310+
'distortions for'), argstr='--imain=%s')
311+
in_mask = File(exists=True, mandatory=True,
312+
desc='Mask to indicate brain', argstr='--mask=%s')
313+
in_index = File(exists=True, mandatory=True,
314+
desc=('File containing indices for all volumes in --imain '
315+
'into --acqp and --topup'), argstr='--index=%s')
316+
in_acqp = File(exists=True, mandatory=True,
317+
desc='File containing acquisition parameters',
318+
argstr='--acqp=%s' )
319+
in_bvec = File(exists=True, mandatory=True,
320+
desc=('File containing the b-vectors for all volumes in '
321+
'--imain'), argstr='--bvecs=%s')
322+
in_bval = File(exists=True, mandatory=True,
323+
desc=('File containing the b-values for all volumes in '
324+
'--imain'), argstr='--bvals=%s')
325+
out_base = File( desc='basename for output (warped) image',
326+
argstr='--out=%s' )
327+
session = File(exists=True,
328+
desc=('File containing session indices for all volumes in '
329+
'--imain'), argstr='--session=%s')
330+
in_topup_fieldcoef = File(exists=True, argstr="--topup=%s", copyfile=False,
331+
requires=['in_topup_movpar'],
332+
desc=('topup file containing the field '
333+
'coefficients'))
334+
in_topup_movpar = File(exists=True, requires=['in_topup_fieldcoef'],
335+
copyfile=False, desc='topup movpar.txt file')
336+
flm = traits.Enum(('linear','quadratic','cubic'),
337+
desc='First level EC model', argstr='--flm=%s' )
338+
fwhm = traits.Float(desc=('FWHM for conditioning filter when estimating '
339+
'the parameters'), argstr='--fwhm=%s')
340+
niter = traits.Int( 5, desc='Number of iterations', argstr='--niter=%s')
341+
method = traits.Enum(('jac','lsr'), argstr='--resamp=%s',
342+
desc=('Final resampling method (jacobian/least '
343+
'squeares)'))
344+
repol = traits.Bool( False, desc='Detect and replace outlier slices',
345+
argstr='--repol' )
314346

315-
out_base = File( desc='basename for output (warped) image', argstr='--out=%s' )
316-
317-
318-
session = File(exists=True, desc='File containing session indices for all volumes in --imain', argstr='--session=%s' )
319-
in_topup = File(exists=True, desc='Base name for output files from topup', argstr='--topup=%s' )
320-
flm = traits.Enum( ('linear','quadratic','cubic'), desc='First level EC model', argstr='--flm=%s' )
321-
fwhm = traits.Float( desc='FWHM for conditioning filter when estimating the parameters', argstr='--fwhm=%s' )
322-
niter = traits.Int( 5, desc='Number of iterations', argstr='--niter=%s' )
323-
method = traits.Enum( ('jac','lsr'), argstr='--resamp=%s', desc='Final resampling method (jacobian/least squeares)' )
324-
repol = traits.Bool( False, desc='Detect and replace outlier slices', argstr='--repol' )
325347

326348
class EddyOutputSpec( TraitedSpec ):
327-
out_corrected = File( exists=True, desc='4D image file containing all the corrected volumes' )
328-
out_parameter = File( exists=True, desc='text file with parameters definining the field and movement for each scan')
349+
out_corrected = File(exists=True,
350+
desc=('4D image file containing all the corrected '
351+
'volumes'))
352+
out_parameter = File(exists=True,
353+
desc=('text file with parameters definining the field '
354+
'and movement for each scan'))
329355

330356
class Eddy( FSLCommand ):
331-
""" Interface for FSL eddy, a tool for estimating and correcting eddy currents induced distortions.
332-
`User guide <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Eddy/UsersGuide>`_ and
333-
`more info regarding acqp file <http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/Faq#How_do_I_know_what_to_put_into_my_--acqp_file>`_.
357+
""" Interface for FSL eddy, a tool for estimating and correcting eddy
358+
currents induced distortions. `User guide
359+
<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Eddy/UsersGuide>`_ and
360+
`more info regarding acqp file
361+
<http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/Faq#How_do_I_know_what_to_put_into_my_--acqp_file>`_.
334362
335363
Examples
336364
--------
@@ -353,10 +381,15 @@ class Eddy( FSLCommand ):
353381
input_spec = EddyInputSpec
354382
output_spec = EddyOutputSpec
355383

384+
def _format_arg(self, name, spec, value):
385+
if name == 'in_topup_fieldcoef':
386+
return spec.argstr % value.split('_fieldcoef')[0]
387+
return super(Eddy, self)._format_arg(name, spec, value)
388+
356389
def _parse_inputs( self, skip=None ):
357390
if skip is None:
358391
skip = []
359-
392+
360393
if not isdefined(self.inputs.out_base ):
361394
self.inputs.out_base = os.path.abspath( './eddy_corrected' )
362395
return super(Eddy, self)._parse_inputs(skip=skip)
@@ -365,7 +398,7 @@ def _parse_inputs( self, skip=None ):
365398
def _list_outputs(self):
366399
outputs = self.output_spec().get()
367400
outputs['out_corrected'] = '%s.nii.gz' % self.inputs.out_base
368-
outputs['out_parameter'] = '%s..eddy_parameters' % self.inputs.out_base
401+
outputs['out_parameter'] = '%s.eddy_parameters' % self.inputs.out_base
369402
return outputs
370403

371404

nipype/interfaces/fsl/tests/test_auto_Eddy.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ def test_Eddy_inputs():
3333
in_mask=dict(argstr='--mask=%s',
3434
mandatory=True,
3535
),
36-
in_topup=dict(argstr='--topup=%s',
36+
in_topup_fieldcoef=dict(argstr='--topup=%s',
37+
copyfile=False,
38+
requires=['in_topup_movpar'],
39+
),
40+
in_topup_movpar=dict(copyfile=False,
41+
requires=['in_topup_fieldcoef'],
3742
),
3843
method=dict(argstr='--resamp=%s',
3944
),
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
22
from nipype.testing import assert_equal
33
from nipype.interfaces.vista.vista import Vnifti2Image
4+
45
def test_Vnifti2Image_inputs():
5-
input_map = dict(ignore_exception=dict(nohash=True,
6-
usedefault=True,
7-
),
8-
out_file=dict(hash_files=False,
9-
name_template='%s.v',
10-
name_source=['in_file'],
11-
keep_extension=False,
12-
position=-1,
13-
argstr='-out %s',
14-
),
15-
args=dict(argstr='%s',
6+
input_map = dict(args=dict(argstr='%s',
167
),
17-
terminal_output=dict(nohash=True,
18-
mandatory=True,
8+
attributes=dict(argstr='-attr %s',
9+
mandatory=False,
10+
position=2,
1911
),
2012
environ=dict(nohash=True,
2113
usedefault=True,
2214
),
23-
in_file=dict(position=1,
15+
ignore_exception=dict(nohash=True,
16+
usedefault=True,
17+
),
18+
in_file=dict(argstr='-in %s',
2419
mandatory=True,
25-
argstr='-in %s',
20+
position=1,
2621
),
27-
attributes=dict(position=2,
28-
mandatory=False,
29-
argstr='-attr %s',
22+
out_file=dict(argstr='-out %s',
23+
hash_files=False,
24+
keep_extension=False,
25+
name_source=['in_file'],
26+
name_template='%s.v',
27+
position=-1,
28+
),
29+
terminal_output=dict(mandatory=True,
30+
nohash=True,
3031
),
3132
)
3233
inputs = Vnifti2Image.input_spec()
3334

3435
for key, metadata in input_map.items():
3536
for metakey, value in metadata.items():
3637
yield assert_equal, getattr(inputs.traits()[key], metakey), value
38+
3739
def test_Vnifti2Image_outputs():
3840
output_map = dict(out_file=dict(),
3941
)
@@ -42,3 +44,4 @@ def test_Vnifti2Image_outputs():
4244
for key, metadata in output_map.items():
4345
for metakey, value in metadata.items():
4446
yield assert_equal, getattr(outputs.traits()[key], metakey), value
47+
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
22
from nipype.testing import assert_equal
33
from nipype.interfaces.vista.vista import VtoMat
4+
45
def test_VtoMat_inputs():
5-
input_map = dict(ignore_exception=dict(nohash=True,
6-
usedefault=True,
6+
input_map = dict(args=dict(argstr='%s',
77
),
8-
out_file=dict(hash_files=False,
9-
name_template='%s.mat',
10-
name_source=['in_file'],
11-
keep_extension=False,
12-
position=-1,
13-
argstr='-out %s',
8+
environ=dict(nohash=True,
9+
usedefault=True,
1410
),
15-
args=dict(argstr='%s',
11+
ignore_exception=dict(nohash=True,
12+
usedefault=True,
1613
),
17-
terminal_output=dict(nohash=True,
14+
in_file=dict(argstr='-in %s',
1815
mandatory=True,
16+
position=1,
1917
),
20-
environ=dict(nohash=True,
21-
usedefault=True,
18+
out_file=dict(argstr='-out %s',
19+
hash_files=False,
20+
keep_extension=False,
21+
name_source=['in_file'],
22+
name_template='%s.mat',
23+
position=-1,
2224
),
23-
in_file=dict(position=1,
24-
mandatory=True,
25-
argstr='-in %s',
25+
terminal_output=dict(mandatory=True,
26+
nohash=True,
2627
),
2728
)
2829
inputs = VtoMat.input_spec()
2930

3031
for key, metadata in input_map.items():
3132
for metakey, value in metadata.items():
3233
yield assert_equal, getattr(inputs.traits()[key], metakey), value
34+
3335
def test_VtoMat_outputs():
3436
output_map = dict(out_file=dict(),
3537
)
@@ -38,3 +40,4 @@ def test_VtoMat_outputs():
3840
for key, metadata in output_map.items():
3941
for metakey, value in metadata.items():
4042
yield assert_equal, getattr(outputs.traits()[key], metakey), value
43+

0 commit comments

Comments
 (0)