Skip to content

Commit f46fb75

Browse files
committed
Bugfix in FUGUE and doctest added
FUGUE interface was adding wrong parameter in forward warping mode. Added the missing doctest of the interface.
1 parent e815741 commit f46fb75

File tree

3 files changed

+28
-15
lines changed

3 files changed

+28
-15
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Next Release
22
============
33

4+
* FIX: FUGUE interface was adding wrong parameter in forward warping mode.
45
* API: Interfaces to external packages are no longer available in the top-level ``nipype`` namespace, and must be imported directly (e.g. ``from nipype.interfaces import fsl``).
56
* ENH: New ANTs interface: ApplyTransformsToPoints
67
* ENH: New FreeSurfer workflow: create_skullstripped_recon_flow()

nipype/interfaces/fsl/preprocess.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -678,17 +678,17 @@ def _list_outputs(self):
678678
'_variance.ext', cwd=cwd)
679679
outputs['std_img'] = self._gen_fname(outputs['out_file'] +
680680
'_sigma.ext', cwd=cwd)
681-
681+
682682
# The mean image created if -stats option is specified ('meanvol')
683-
# is missing the top and bottom slices. Therefore we only expose the
684-
# mean image created by -meanvol option ('mean_reg') which isn't
683+
# is missing the top and bottom slices. Therefore we only expose the
684+
# mean image created by -meanvol option ('mean_reg') which isn't
685685
# corrupted.
686686
# Note that the same problem holds for the std and variance image.
687-
687+
688688
if isdefined(self.inputs.mean_vol) and self.inputs.mean_vol:
689689
outputs['mean_img'] = self._gen_fname(outputs['out_file'] +
690690
'_mean_reg.ext', cwd=cwd)
691-
691+
692692
if isdefined(self.inputs.save_mats) and self.inputs.save_mats:
693693
_, filename = os.path.split(outputs['out_file'])
694694
matpathname = os.path.join(cwd, filename + '.mat')
@@ -1159,9 +1159,8 @@ def _gen_filename(self, name):
11591159
class FUGUEInputSpec(FSLCommandInputSpec):
11601160
in_file = File(exists=True, argstr='--in=%s',
11611161
desc='filename of input volume')
1162-
unwarped_file = File(
1163-
argstr='--unwarp=%s', genfile=True,
1164-
desc='apply unwarping and save as filename', hash_files=False)
1162+
unwarped_file = File(argstr='--unwarp=%s', desc='apply unwarping and save as filename',
1163+
hash_files=False)
11651164
forward_warping = traits.Bool(
11661165
False, usedefault=True,
11671166
desc='apply forward warping instead of unwarping')
@@ -1242,7 +1241,16 @@ class FUGUE(FSLCommand):
12421241
Examples
12431242
--------
12441243
1245-
Please insert examples for use of this command
1244+
>>> from nipype.interfaces.fsl.preprocess import FUGUE
1245+
>>> fugue = FUGUE()
1246+
>>> fugue.inputs.forward_warping = True
1247+
>>> fugue.inputs.in_file = 'epi.nii'
1248+
>>> fugue.inputs.mask_file = 'epi_mask.nii'
1249+
>>> fugue.inputs.shift_in_file = 'image.nii' # Previously computed with fugue as well
1250+
>>> fugue.inputs.unwarp_direction = 'y'
1251+
>>> fugue.cmdline #doctest: +ELLIPSIS
1252+
'fugue --in=epi.nii --mask=epi_mask.nii --loadshift=image.nii --unwarpdir=y --warp=.../epi_warped.nii.gz'
1253+
>>> fugue.run() #doctest: +SKIP
12461254
12471255
"""
12481256

@@ -1257,10 +1265,14 @@ def __init__(self, **kwargs):
12571265

12581266
def _list_outputs(self):
12591267
outputs = self._outputs().get()
1260-
if self.inputs.forward_warping:
1268+
1269+
if isdefined(self.inputs.forward_warping) and self.inputs.forward_warping:
12611270
out_field = 'warped_file'
1271+
self.inputs.unwarped_file = Undefined
1272+
outputs.pop('unwarped_file')
12621273
else:
12631274
out_field = 'unwarped_file'
1275+
outputs.pop('warped_file')
12641276

12651277
out_file = getattr(self.inputs, out_field)
12661278
if not isdefined(out_file):
@@ -1279,10 +1291,11 @@ def _list_outputs(self):
12791291
return outputs
12801292

12811293
def _gen_filename(self, name):
1282-
if name == 'unwarped_file' and not self.inputs.forward_warping:
1283-
return self._list_outputs()['unwarped_file']
1284-
if name == 'warped_file' and self.inputs.forward_warping:
1285-
return self._list_outputs()['warped_file']
1294+
is_fwd = isdefined(self.inputs.forward_warping) and self.inputs.forward_warping
1295+
1296+
if (is_fwd and name=='warped_file') or (not is_fwd and name=='unwarped_file'):
1297+
return self._list_outputs()[name]
1298+
12861299
return None
12871300

12881301
def _parse_inputs(self, skip=None):

nipype/interfaces/fsl/tests/test_auto_FUGUE.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ def test_FUGUE_inputs():
7979
unwarp_direction=dict(argstr='--unwarpdir=%s',
8080
),
8181
unwarped_file=dict(argstr='--unwarp=%s',
82-
genfile=True,
8382
hash_files=False,
8483
),
8584
warped_file=dict(argstr='--warp=%s',

0 commit comments

Comments
 (0)