Skip to content

Commit 7b031eb

Browse files
committed
Merge pull request #1494 from oesteban/enh/AutomaticInIndexApplyTopup
[ENH] Fill in_index automatically in ApplyTOPUP if not defined
2 parents 3c9316a + e3478ca commit 7b031eb

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

nipype/interfaces/fsl/epi.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,9 @@ class ApplyTOPUPInputSpec(FSLCommandInputSpec):
314314
encoding_file = File(exists=True, mandatory=True,
315315
desc='name of text file with PE directions/times',
316316
argstr='--datain=%s')
317-
in_index = traits.List(traits.Int, argstr='--inindex=%s', sep=',',
318-
mandatory=True,
319-
desc=('comma separated list of indicies into '
320-
'--datain of the input image (to be '
321-
'corrected)'))
317+
in_index = traits.List(
318+
traits.Int, argstr='--inindex=%s', sep=',',
319+
desc='comma separated list of indices corresponding to --datain')
322320
in_topup_fieldcoef = File(exists=True, argstr="--topup=%s", copyfile=False,
323321
requires=['in_topup_movpar'],
324322
desc=('topup file containing the field '
@@ -360,7 +358,6 @@ class ApplyTOPUP(FSLCommand):
360358
>>> applytopup = ApplyTOPUP()
361359
>>> applytopup.inputs.in_files = ["epi.nii", "epi_rev.nii"]
362360
>>> applytopup.inputs.encoding_file = "topup_encoding.txt"
363-
>>> applytopup.inputs.in_index = [1,2]
364361
>>> applytopup.inputs.in_topup_fieldcoef = "topup_fieldcoef.nii.gz"
365362
>>> applytopup.inputs.in_topup_movpar = "topup_movpar.txt"
366363
>>> applytopup.inputs.output_type = "NIFTI_GZ"
@@ -374,6 +371,17 @@ class ApplyTOPUP(FSLCommand):
374371
input_spec = ApplyTOPUPInputSpec
375372
output_spec = ApplyTOPUPOutputSpec
376373

374+
def _parse_inputs(self, skip=None):
375+
if skip is None:
376+
skip = []
377+
378+
# If not defined, assume index are the first N entries in the
379+
# parameters file, for N input images.
380+
if not isdefined(self.inputs.in_index):
381+
self.inputs.in_index = list(range(1, len(self.inputs.in_files) + 1))
382+
383+
return super(ApplyTOPUP, self)._parse_inputs(skip=skip)
384+
377385
def _format_arg(self, name, spec, value):
378386
if name == 'in_topup_fieldcoef':
379387
return spec.argstr % value.split('_fieldcoef')[0]

nipype/interfaces/fsl/tests/test_auto_ApplyTOPUP.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def test_ApplyTOPUP_inputs():
2222
sep=',',
2323
),
2424
in_index=dict(argstr='--inindex=%s',
25-
mandatory=True,
2625
sep=',',
2726
),
2827
in_topup_fieldcoef=dict(argstr='--topup=%s',

0 commit comments

Comments
 (0)