@@ -3284,7 +3284,11 @@ class XfmAvgInputSpec(CommandLineInputSpec):
3284
3284
desc = 'output file' ,
3285
3285
genfile = True ,
3286
3286
argstr = '%s' ,
3287
- position = - 1 ,)
3287
+ position = - 1 ,
3288
+ name_source = ['input_files' ],
3289
+ hash_files = False ,
3290
+ name_template = '%s_xfmavg.xfm' ,
3291
+ keep_extension = False )
3288
3292
3289
3293
verbose = traits .Bool (
3290
3294
desc = 'Print out log messages. Default: False.' ,
@@ -3314,7 +3318,6 @@ class XfmAvgInputSpec(CommandLineInputSpec):
3314
3318
3315
3319
class XfmAvgOutputSpec (TraitedSpec ):
3316
3320
output_file = File (desc = 'output file' , exists = True )
3317
- # FIXME is exists=True always correct?
3318
3321
output_grid = File (desc = 'output grid file' , exists = True )
3319
3322
3320
3323
@@ -3343,32 +3346,13 @@ class XfmAvg(CommandLine):
3343
3346
output_spec = XfmAvgOutputSpec
3344
3347
_cmd = 'xfmavg'
3345
3348
3346
- def _gen_filename (self , name ):
3347
- if name == 'output_file' :
3348
- output_file = self .inputs .output_file
3349
-
3350
- if isdefined (output_file ):
3351
- return os .path .abspath (output_file )
3352
- else :
3353
- return aggregate_filename (
3354
- self .inputs .input_files , 'xfmavg_output' ) + '.xfm'
3355
- else :
3356
- raise NotImplemented
3357
-
3358
- def _gen_outfilename (self ):
3359
- return self ._gen_filename ('output_file' )
3360
-
3361
3349
def _list_outputs (self ):
3362
- outputs = self .output_spec ().get ()
3363
- outputs ['output_file' ] = os .path .abspath (self ._gen_outfilename ())
3350
+ outputs = super (XfmAvg , self )._list_outputs ()
3364
3351
3365
- # FIXME Is this the sensible? No other way to tell if the grid files
3366
- # were produced.
3367
- # FIXME This is safe to assume?
3368
- assert os .path .exists (outputs ['output_file' ])
3369
- if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3370
- outputs ['output_grid' ] = re .sub (
3371
- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3352
+ if os .path .exists (outputs ['output_file' ]):
3353
+ if 'grid' in open (outputs ['output_file' ], 'r' ).read ():
3354
+ outputs ['output_grid' ] = re .sub (
3355
+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_file' ])
3372
3356
3373
3357
return outputs
3374
3358
0 commit comments