Skip to content

Commit e40bfad

Browse files
committed
Now using name_source etc., both new interfaces
1 parent e67ed98 commit e40bfad

File tree

3 files changed

+21
-55
lines changed

3 files changed

+21
-55
lines changed

nipype/interfaces/fsl/tests/test_auto_ConvertWarp.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ def test_ConvertWarp_inputs():
2424
xor=['out_relwarp'],
2525
),
2626
out_file=dict(argstr='--out=%s',
27-
genfile=True,
28-
hash_files=False,
27+
name_source=['reference'],
28+
name_template='%s_concatwarp',
29+
output_name='out_file',
30+
position=-1,
2931
),
3032
out_relwarp=dict(argstr='--relout',
3133
xor=['out_abswarp'],
@@ -37,6 +39,7 @@ def test_ConvertWarp_inputs():
3739
),
3840
reference=dict(argstr='--ref=%s',
3941
mandatory=True,
42+
position=1,
4043
),
4144
relwarp=dict(argstr='--rel',
4245
xor=['abswarp'],

nipype/interfaces/fsl/tests/test_auto_WarpUtils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ def test_WarpUtils_inputs():
1717
knot_space=dict(argstr='--knotspace=%d,%d,%d',
1818
),
1919
out_file=dict(argstr='--out=%s',
20-
genfile=True,
21-
hash_files=False,
20+
name_source=['in_file'],
21+
output_name='out_file',
22+
position=-1,
2223
),
2324
out_format=dict(argstr='--outformat=%s',
2425
),

nipype/interfaces/fsl/utils.py

Lines changed: 13 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,7 +1488,7 @@ class WarpUtilsInputSpec(FSLCommandInputSpec):
14881488
desc=('Alternative (to --warpres) specifikation of the resolution of '
14891489
'the output spline-field.'))
14901490

1491-
out_file = File(genfile=True, hash_files=False, argstr='--out=%s',
1491+
out_file = File(argstr='--out=%s', position=-1, name_source = ['in_file'], output_name='out_file',
14921492
desc=('Name of output file. The format of the output depends on what other '
14931493
'parameters are set. The default format is a (4D) field-file. If the '
14941494
'--outformat is set to spline the format will be a (4D) file of spline '
@@ -1531,7 +1531,7 @@ class WarpUtils(FSLCommand):
15311531
>>> warputils.inputs.out_format = 'spline'
15321532
>>> warputils.inputs.warp_resolution = (10,10,10)
15331533
>>> warputils.cmdline # doctest: +ELLIPSIS
1534-
'fnirtfileutils --in=warpfield.nii --out=.../warpfield_coeffs.nii.gz --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000'
1534+
'fnirtfileutils --in=warpfield.nii --outformat=spline --ref=T1.nii --warpres=10.0000,10.0000,10.0000 --out=.../warpfield_coeffs.nii.gz'
15351535
>>> res = invwarp.run() # doctest: +SKIP
15361536
"""
15371537

@@ -1544,49 +1544,29 @@ def _parse_inputs(self, skip=None):
15441544
if skip is None:
15451545
skip = []
15461546

1547-
if self.inputs.write_jacobian:
1548-
if not isdefined(self.inputs.out_jacobian):
1549-
self.inputs.out_jacobian = self._gen_fname(self.inputs.in_file,
1550-
suffix='_jac')
1551-
skip+=['write_jacobian']
1552-
return super(WarpUtils, self)._parse_inputs(skip=skip)
1553-
1554-
1555-
1556-
def _list_outputs(self):
1557-
outputs = self.output_spec().get()
1558-
outputs['out_file'] = self.inputs.out_file
1559-
15601547
suffix = 'field'
1561-
15621548
if isdefined(self.inputs.out_format) and self.inputs.out_format=='spline':
15631549
suffix = 'coeffs'
15641550

1551+
trait_spec = self.inputs.trait('out_file')
1552+
trait_spec.name_template = "%s_" + suffix
15651553

1566-
if not isdefined(outputs['out_file']):
1567-
outputs['out_file'] = self._gen_fname(self.inputs.in_file,
1568-
suffix='_'+suffix)
1569-
1570-
if isdefined(self.inputs.out_jacobian):
1571-
outputs['out_jacobian'] = os.path.abspath(self.inputs.out_jacobian)
1572-
1573-
outputs['out_file'] = os.path.abspath(outputs['out_file'])
1574-
return outputs
1575-
1576-
def _gen_filename(self, name):
1577-
if name == 'out_file':
1578-
return self._list_outputs()[name]
1579-
1580-
return None
1581-
1554+
if self.inputs.write_jacobian:
1555+
if not isdefined(self.inputs.out_jacobian):
1556+
trait_spec = self.inputs.trait('out_jacobian')
1557+
trait_spec.name_source = ['in_file']
1558+
trait_spec.name_template = '%s_jac'
15821559

1560+
skip+=['write_jacobian']
1561+
return super(WarpUtils, self)._parse_inputs(skip=skip)
15831562

15841563

15851564
class ConvertWarpInputSpec(FSLCommandInputSpec):
15861565
reference = File(exists=True, argstr='--ref=%s', mandatory=True, position=1,
15871566
desc=('Name of a file in target space of the full transform.'))
15881567

1589-
out_file = File(genfile=True, hash_files=False, argstr='--out=%s', position=-1,
1568+
out_file = File(argstr='--out=%s', position=-1, name_source=['reference'],
1569+
name_template='%s_concatwarp', output_name='out_file',
15901570
desc=('Name of output file, containing warps that are the combination of all '
15911571
'those given as arguments. The format of this will be a field-file (rather '
15921572
'than spline coefficients) with any affine components included.'))
@@ -1678,22 +1658,4 @@ class ConvertWarp(FSLCommand):
16781658

16791659
input_spec = ConvertWarpInputSpec
16801660
output_spec = ConvertWarpOutputSpec
1681-
16821661
_cmd = 'convertwarp'
1683-
1684-
def _list_outputs(self):
1685-
outputs = self.output_spec().get()
1686-
outputs['out_file'] = self.inputs.out_file
1687-
1688-
if not isdefined(outputs['out_file']):
1689-
outputs['out_file'] = self._gen_fname(self.inputs.reference,
1690-
suffix='_concatwarps')
1691-
1692-
outputs['out_file'] = os.path.abspath(outputs['out_file'])
1693-
return outputs
1694-
1695-
def _gen_filename(self, name):
1696-
if name == 'out_file':
1697-
return self._list_outputs()[name]
1698-
1699-
return None

0 commit comments

Comments
 (0)