Skip to content

Commit ee5652a

Browse files
committed
fix: updated apply topup
1 parent d131f2e commit ee5652a

File tree

1 file changed

+13
-34
lines changed

1 file changed

+13
-34
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,13 @@ def _overload_extension(self, value, name=None):
263263

264264
class ApplyTOPUPInputSpec(FSLCommandInputSpec):
265265
in_files = InputMultiPath(File(exists=True), mandatory=True,
266-
desc='name of 4D file with images', argstr='%s')
266+
desc='name of 4D file with images',
267+
argstr='--imain=%s...', sep=',')
267268
encoding_file = File(exists=True, mandatory=True,
268269
desc='name of text file with PE directions/times',
269270
argstr='--datain=%s')
270-
in_index = traits.List(argstr='%s', mandatory=True,
271+
in_index = traits.List(traits.Int, argstr='--inindex=%d...', sep=',',
272+
mandatory=True,
271273
desc=('comma separated list of indicies into '
272274
'--datain of the input image (to be '
273275
'corrected)'))
@@ -290,7 +292,9 @@ class ApplyTOPUPInputSpec(FSLCommandInputSpec):
290292

291293

292294
class ApplyTOPUPOutputSpec( TraitedSpec ):
293-
out_corrected = File( exists=True, desc='name of 4D image file with unwarped images' )
295+
out_corrected = File( exists=True, desc=('name of 4D image file with '
296+
'unwarped images'))
297+
294298

295299
class ApplyTOPUP( FSLCommand ):
296300
""" Interface for FSL topup, a tool for estimating and correcting susceptibility induced distortions.
@@ -306,9 +310,10 @@ class ApplyTOPUP( FSLCommand ):
306310
>>> applytopup.inputs.in_files = [ "epi.nii", "epi_rev.nii" ]
307311
>>> applytopup.inputs.encoding_file = "topup_encoding.txt"
308312
>>> applytopup.inputs.in_index = [ 1,2 ]
309-
>>> applytopup.inputs.in_topup = "my_topup_results"
313+
>>> applytopup.inputs.in_topup_fieldcoef = "topup_fieldcoef.nii.gz"
314+
>>> applytopup.inputs.in_topup_movpar = "topup_movpar.txt"
310315
>>> applytopup.cmdline #doctest: +ELLIPSIS
311-
'applytopup --datain=topup_encoding.txt --imain=epi.nii,epi_rev.nii --inindex=1,2 --topup=my_topup_results --out=.../nipypeatu'
316+
'applytopup --datain=topup_encoding.txt --imain=epi.nii,--imain=epi_rev.nii --inindex=1,--inindex=2 --topup=topup --out=epi_corrected.nii.gz'
312317
>>> res = applytopup.run() # doctest: +SKIP
313318
314319
"""
@@ -317,35 +322,9 @@ class ApplyTOPUP( FSLCommand ):
317322
output_spec = ApplyTOPUPOutputSpec
318323

319324
def _format_arg(self, name, spec, value):
320-
# first do what should be done in general
321-
formated = super(ApplyTOPUP, self)._format_arg(name, spec, value)
322-
if name == 'in_files' or name == 'in_index':
323-
if name == 'in_files':
324-
formated = '--imain='
325-
else:
326-
formated = '--inindex='
327-
328-
formated = formated + "%s" % value[0]
329-
for fname in value[1:]:
330-
formated = formated + ",%s" % fname
331-
return formated
332-
333-
def _parse_inputs( self, skip=None ):
334-
if skip is None:
335-
skip = []
336-
337-
if not isdefined(self.inputs.out_base ):
338-
self.inputs.out_base = './nipypeatu'
339-
340-
self.inputs.out_base = os.path.abspath(self.inputs.out_base)
341-
return super(ApplyTOPUP, self)._parse_inputs(skip=skip)
342-
343-
344-
def _list_outputs(self):
345-
outputs = self.output_spec().get()
346-
outputs['out_corrected'] = '%s.nii.gz' % self.inputs.out_base
347-
return outputs
348-
325+
if name == 'in_topup_fieldcoef':
326+
return spec.argstr % value.split('_fieldcoef')[0]
327+
return super(ApplyTOPUP, self)._format_arg(name, spec, value)
349328

350329

351330
class EddyInputSpec( FSLCommandInputSpec ):

0 commit comments

Comments
 (0)