Skip to content

Commit 61bc69c

Browse files
committed
New eddy interface (#662)
* New interface for eddy. NO TESTING HAS BEEN DONE, though * Added interface.cmdline on documentation comments
1 parent cbe7b72 commit 61bc69c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class PrepareFieldmap(FSLCommand):
5757
>>> prepare = PrepareFieldmap()
5858
>>> prepare.inputs.in_phase = "phase.nii"
5959
>>> prepare.inputs.in_magnitude = "magnitude.nii"
60+
>>> prepare.cmdline
6061
>>> res = prepare.run() # doctest: +SKIP
6162
6263
@@ -147,6 +148,7 @@ class TOPUP( FSLCommand ):
147148
>>> topup = TOPUP()
148149
>>> topup.inputs.in_file = "b0_b0rev.nii"
149150
>>> topup.inputs.encoding_file = "topup_encoding.txt"
151+
>>> topup.cmdline
150152
>>> res = topup.run() # doctest: +SKIP
151153
152154
"""
@@ -251,6 +253,7 @@ class ApplyTOPUP( FSLCommand ):
251253
>>> applytopup.inputs.encoding_file = "topup_encoding.txt"
252254
>>> applytopup.inputs.in_index = [ 1,2 ]
253255
>>> applytopup.inputs.in_topup = "my_topup_results"
256+
>>> applytopup.cmdline
254257
>>> res = applytopup.run() # doctest: +SKIP
255258
256259
"""
@@ -288,7 +291,66 @@ def _list_outputs(self):
288291

289292

290293

294+
class EddyInputSpec( FSLCommandInputSpec ):
295+
in_file = File(exists=True, mandatory=True, desc='File containing all the images to estimate distortions for', argstr='--imain=%s' )
296+
in_mask = File(exists=True, mandatory=True, desc='Mask to indicate brain', argstr='--mask=%s' )
297+
in_index = File(exists=True, mandatory=True, desc='File containing indices for all volumes in --imain into --acqp and --topup', argstr='--index=%s' )
298+
in_acqp = File(exists=True, mandatory=True, desc='File containing acquisition parameters', argstr='--acqp=%s' )
299+
in_bvec = File(exists=True, mandatory=True, desc='File containing the b-vectors for all volumes in --imain', argstr='--bvecs=%s' )
300+
in_bval = File(exists=True, mandatory=True, desc='File containing the b-values for all volumes in --imain', argstr='--bvals=%s' )
301+
302+
out_base = File( desc='basename for output (warped) image', argstr='--out=%s' )
303+
304+
305+
session = File(exists=True, desc='File containing session indices for all volumes in --imain', argstr='--session=%s' )
306+
in_topup = File(exists=True, desc='Base name for output files from topup', argstr='--topup=%s' )
307+
flm = traits.Enum( ('linear','quadratic','cubic'), desc='First level EC model', argstr='--flm=%s' )
308+
fwhm = traits.Float( desc='FWHM for conditioning filter when estimating the parameters', argstr='--fwhm=%s' )
309+
niter = traits.Int( 5, desc='Number of iterations', argstr='--niter=%s' )
310+
method = traits.Enum( ('jac','lsr'), argstr='--resamp=%s', desc='Final resampling method (jacobian/least squeares)' )
311+
repol = traits.Bool( False, desc='Detect and replace outlier slices', argstr='--repol' )
312+
313+
class EddyOutputSpec( TraitedSpec ):
314+
out_corrected = File( exists=True, desc='4D image file containing all the corrected volumes' )
315+
out_parameter = File( exists=True, desc='text file with parameters definining the field and movement for each scan')
316+
317+
class Eddy( FSLCommand ):
318+
""" Interface for FSL eddy, a tool for estimating and correcting eddy currents induced distortions
319+
User guide: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/Eddy/UsersGuide
320+
Regarding acqp file: http://fsl.fmrib.ox.ac.uk/fsl/fslwiki/eddy/Faq#How_do_I_know_what_to_put_into_my_--acqp_file
291321
322+
Examples
323+
--------
324+
>>> eddy = Eddy()
325+
>>> eddy.inputs.in_files = 'epi.nii'
326+
>>> eddy.inputs.in_mask = 'epi_mask.nii'
327+
>>> eddy.inputs.in_index = 'epi_index.txt'
328+
>>> eddy.inputs.in_acqp = 'epi_acqp.txt'
329+
>>> eddy.inputs.in_bvec = 'bvecs'
330+
>>> eddy.inputs.in_bval = 'bvals'
331+
>>> eddy.cmdline
332+
>>> res = eddy.run() # doctest: +SKIP
333+
334+
335+
"""
336+
_cmd = 'eddy'
337+
input_spec = EddyInputSpec
338+
output_spec = EddyOutputSpec
339+
340+
def _parse_inputs( self, skip=None ):
341+
if skip is None:
342+
skip = []
343+
344+
if not isdefined(self.inputs.out_base ):
345+
self.inputs.out_base = os.path.abspath( './eddy_corrected' )
346+
return super(Eddy, self)._parse_inputs(skip=skip)
347+
348+
349+
def _list_outputs(self):
350+
outputs = self.output_spec().get()
351+
outputs['out_corrected'] = '%s.nii.gz' % self.inputs.out_base
352+
outputs['out_parameter'] = '%s..eddy_parameters' % self.inputs.out_base
353+
return outputs
292354

293355

294356
class EPIDeWarpInputSpec(FSLCommandInputSpec):
@@ -343,6 +405,7 @@ class EPIDeWarp(FSLCommand):
343405
>>> dewarp.inputs.epi_file = "functional.nii"
344406
>>> dewarp.inputs.mag_file = "magnitude.nii"
345407
>>> dewarp.inputs.dph_file = "phase.nii"
408+
>>> dewarp.cmdline
346409
>>> res = dewarp.run() # doctest: +SKIP
347410
348411
References
@@ -426,6 +489,7 @@ class SigLoss(FSLCommand):
426489
>>> sigloss = SigLoss()
427490
>>> sigloss.inputs.in_file = "phase.nii"
428491
>>> sigloss.inputs.echo_time = 0.03
492+
>>> sigloss.cmdline
429493
>>> res = sigloss.run() # doctest: +SKIP
430494
"""
431495
input_spec = SigLossInputSpec

0 commit comments

Comments
 (0)