@@ -813,13 +813,16 @@ class DenoiseImageInputSpec(ANTSCommandInputSpec):
813813 'the input image can be resampled. The shrink '
814814 'factor, specified as a single integer, describes '
815815 'this resampling. Shrink factor = 1 is the default.' ))
816- output_image = traits .Str (argstr = "-o %s" , genfile = True , hash_files = False ,
817- desc = 'The output consists of the noise corrected '
818- 'version of the input image.' )
816+ output_image = File (argstr = "-o %s" , name_source = ['input_image' ], hash_files = False ,
817+ keep_extension = True , name_template = '%s_noise_corrected' ,
818+ desc = 'The output consists of the noise corrected '
819+ 'version of the input image.' )
819820 save_noise = traits .Bool (False , mandatory = True , usedefault = True ,
820821 desc = ('True if the estimated noise should be saved '
821822 'to file.' ), xor = ['noise_image' ])
822- noise_image = File (desc = 'Filename for the estimated noise.' , hash_files = False )
823+ noise_image = File (name_source = ['input_image' ], hash_files = False ,
824+ keep_extension = True , name_template = '%s_noise' ,
825+ desc = 'Filename for the estimated noise.' )
823826 verbose = traits .Bool (False , argstr = "-v" , desc = ('Verbose output.' ))
824827
825828
@@ -857,45 +860,12 @@ class DenoiseImage(ANTSCommand):
857860 output_spec = DenoiseImageOutputSpec
858861 _cmd = 'DenoiseImage'
859862
860- def _gen_filename (self , name ):
861- if name == 'output_image' :
862- output = self .inputs .output_image
863- if not isdefined (output ):
864- _ , name , ext = split_filename (self .inputs .input_image )
865- output = name + '_noise_corrected' + ext
866- return output
867-
868- if name == 'noise_image' :
869- output = self .inputs .noise_image
870- if not isdefined (output ):
871- _ , name , ext = split_filename (self .inputs .input_image )
872- output = name + '_noise' + ext
873- return output
874- return None
875-
876863 def _format_arg (self , name , trait_spec , value ):
877864 if ((name == 'output_image' ) and
878865 (self .inputs .save_noise or isdefined (self .inputs .noise_image ))):
879- noise_image = self ._gen_filename ('noise_image' )
880- output = self ._gen_filename ('output_image' )
881- newval = '[ %s, %s ]' % (output , noise_image )
866+ newval = '[ %s, %s ]' % (self ._filename_from_source ('output_image' ),
867+ self ._filename_from_source ('noise_image' ))
882868 return trait_spec .argstr % newval
883869
884870 return super (DenoiseImage ,
885871 self )._format_arg (name , trait_spec , value )
886-
887- def _parse_inputs (self , skip = None ):
888- if skip is None :
889- skip = []
890- skip += ['save_noise' , 'noise_image' ]
891- return super (DenoiseImage , self )._parse_inputs (skip = skip )
892-
893- def _list_outputs (self ):
894- outputs = self ._outputs ().get ()
895- outputs ['output_image' ] = os .path .abspath (
896- self ._gen_filename ('output_image' ))
897-
898- if self .inputs .save_noise or isdefined (self .inputs .noise_image ):
899- outputs ['noise_image' ] = os .path .abspath (
900- self ._gen_filename ('noise_image' ))
901- return outputs
0 commit comments