Skip to content

Commit f1fac40

Browse files
committed
temporary fix for composeXfm naming
1 parent 08babbc commit f1fac40

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

nipype/interfaces/dtitk/registration.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
2525
"""
2626

27-
from ..base import TraitedSpec, CommandLineInputSpec, traits, File
27+
from ..base import TraitedSpec, CommandLineInputSpec, traits, File, isdefined
2828
from ...utils.filemanip import fname_presuffix
2929
from .base import CommandLineDtitk
30+
import os
3031

3132
__docformat__ = 'restructuredtext'
3233

@@ -164,9 +165,9 @@ class ComposeXfmInputSpec(CommandLineInputSpec):
164165
in_aff = File(desc='affine transform file', exists=True,
165166
argstr="-aff %s", mandatory=True)
166167
out_file = File(desc='output path',
167-
argstr="-out %s", name_source="in_df",
168-
name_template="%s_affdf.nii")
169-
# keep_extension is keeping the .df but not .nii; need to figure out
168+
argstr="-out %s", genfile=True)
169+
# keep_extension is keeping the .df but not .nii
170+
# need to fix when PR 2506 is done
170171

171172

172173
class ComposeXfmOutputSpec(TraitedSpec):
@@ -186,13 +187,28 @@ class ComposeXfm(CommandLineDtitk):
186187
>>> node.inputs.in_aff= 'im_affine.aff'
187188
>>> node.cmdline
188189
'dfRightComposeAffine -aff im_affine.aff -df im_warp.df.nii -out
189-
im_warp.df_affdf.nii'
190+
im_warp_affdf.df.nii'
190191
>>> node.run() # doctest: +SKIP
191192
"""
192193
input_spec = ComposeXfmInputSpec
193194
output_spec = ComposeXfmOutputSpec
194195
_cmd = 'dfRightComposeAffine'
195196

197+
def _list_outputs(self):
198+
outputs = self._outputs().get()
199+
out_file = self.inputs.out_file
200+
if not isdefined(out_file):
201+
out_file = self._gen_filename('out_file')
202+
outputs['out_file'] = os.path.abspath(out_file)
203+
return outputs
204+
205+
def _gen_filename(self, name):
206+
if name != 'out_file':
207+
return
208+
return fname_presuffix(os.path.basename(
209+
self.inputs.in_df).split('.')[0],
210+
suffix='_affdf.df.nii')
211+
196212

197213
class AffSymTensor3DVolInputSpec(CommandLineInputSpec):
198214
in_file = File(desc='moving tensor volume', exists=True,

nipype/interfaces/dtitk/tests/test_auto_ComposeXfm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def test_ComposeXfm_inputs():
2626
),
2727
out_file=dict(
2828
argstr='-out %s',
29-
name_source='in_df',
30-
name_template='%s_affdf.nii',
29+
genfile=True,
3130
),
3231
terminal_output=dict(
3332
deprecated='1.0.0',

nipype/interfaces/dtitk/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def _list_outputs(self):
246246
out_file = self.inputs.out_file
247247
if not isdefined(out_file):
248248
out_file = self._gen_filename('out_file')
249-
outputs['out_file'] = os.abspath(out_file)
249+
outputs['out_file'] = os.path.abspath(out_file)
250250
return outputs
251251

252252
def _gen_filename(self, name):

0 commit comments

Comments
 (0)