24
24
25
25
"""
26
26
27
- from ..base import TraitedSpec , CommandLineInputSpec , traits , File
27
+ from ..base import TraitedSpec , CommandLineInputSpec , traits , File , isdefined
28
28
from ...utils .filemanip import fname_presuffix
29
29
from .base import CommandLineDtitk
30
+ import os
30
31
31
32
__docformat__ = 'restructuredtext'
32
33
@@ -164,9 +165,9 @@ class ComposeXfmInputSpec(CommandLineInputSpec):
164
165
in_aff = File (desc = 'affine transform file' , exists = True ,
165
166
argstr = "-aff %s" , mandatory = True )
166
167
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
170
171
171
172
172
173
class ComposeXfmOutputSpec (TraitedSpec ):
@@ -186,13 +187,28 @@ class ComposeXfm(CommandLineDtitk):
186
187
>>> node.inputs.in_aff= 'im_affine.aff'
187
188
>>> node.cmdline
188
189
'dfRightComposeAffine -aff im_affine.aff -df im_warp.df.nii -out
189
- im_warp.df_affdf .nii'
190
+ im_warp_affdf.df .nii'
190
191
>>> node.run() # doctest: +SKIP
191
192
"""
192
193
input_spec = ComposeXfmInputSpec
193
194
output_spec = ComposeXfmOutputSpec
194
195
_cmd = 'dfRightComposeAffine'
195
196
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
+
196
212
197
213
class AffSymTensor3DVolInputSpec (CommandLineInputSpec ):
198
214
in_file = File (desc = 'moving tensor volume' , exists = True ,
0 commit comments