@@ -3254,11 +3254,7 @@ class XfmAvgInputSpec(CommandLineInputSpec):
32543254 desc = 'output file' ,
32553255 genfile = True ,
32563256 argstr = '%s' ,
3257- position = - 1 ,
3258- name_source = ['input_files' ],
3259- hash_files = False ,
3260- name_template = '%s_xfmavg.xfm' ,
3261- keep_extension = False )
3257+ position = - 1 ,)
32623258
32633259 verbose = traits .Bool (
32643260 desc = 'Print out log messages. Default: False.' ,
@@ -3316,13 +3312,29 @@ class XfmAvg(CommandLine):
33163312 output_spec = XfmAvgOutputSpec
33173313 _cmd = 'xfmavg'
33183314
3315+ def _gen_filename (self , name ):
3316+ if name == 'output_file' :
3317+ output_file = self .inputs .output_file
3318+
3319+ if isdefined (output_file ):
3320+ return os .path .abspath (output_file )
3321+ else :
3322+ return aggregate_filename (
3323+ self .inputs .input_files , 'xfmavg_output' ) + '.xfm'
3324+ else :
3325+ raise NotImplemented
3326+
3327+ def _gen_outfilename (self ):
3328+ return self ._gen_filename ('output_file' )
3329+
33193330 def _list_outputs (self ):
3320- outputs = super (XfmAvg , self )._list_outputs ()
3331+ outputs = self .output_spec ().get ()
3332+ outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
33213333
3322- if os .path .exists (outputs ['output_file' ]):
3323- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3324- outputs ['output_grid' ] = re .sub (
3325- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3334+ assert os .path .exists (outputs ['output_file' ])
3335+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3336+ outputs ['output_grid' ] = re .sub (
3337+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
33263338
33273339 return outputs
33283340
@@ -3339,10 +3351,7 @@ class XfmInvertInputSpec(CommandLineInputSpec):
33393351 desc = 'output file' ,
33403352 genfile = True ,
33413353 argstr = '%s' ,
3342- position = - 1 ,
3343- name_source = ['input_file' ],
3344- hash_files = False ,
3345- name_template = '%s_xfminvert.xfm' )
3354+ position = - 1 ,)
33463355
33473356 verbose = traits .Bool (
33483357 desc = 'Print out log messages. Default: False.' ,
@@ -3377,13 +3386,29 @@ class XfmInvert(CommandLine):
33773386 output_spec = XfmInvertOutputSpec
33783387 _cmd = 'xfminvert'
33793388
3389+ def _gen_filename (self , name ):
3390+ if name == 'output_file' :
3391+ output_file = self .inputs .output_file
3392+
3393+ if isdefined (output_file ):
3394+ return os .path .abspath (output_file )
3395+ else :
3396+ return aggregate_filename (
3397+ [self .inputs .input_file ], 'xfminvert_output' ) + '.xfm'
3398+ else :
3399+ raise NotImplemented
3400+
3401+ def _gen_outfilename (self ):
3402+ return self ._gen_filename ('output_file' )
3403+
33803404 def _list_outputs (self ):
3381- outputs = super (XfmInvert , self )._list_outputs ()
3405+ outputs = self .output_spec ().get ()
3406+ outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
33823407
3383- if os .path .exists (outputs ['output_file' ]):
3384- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3385- outputs ['output_grid' ] = re .sub (
3386- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3408+ assert os .path .exists (outputs ['output_file' ])
3409+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3410+ outputs ['output_grid' ] = re .sub (
3411+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
33873412
33883413 return outputs
33893414
0 commit comments