@@ -3183,31 +3183,33 @@ class NlpFitInputSpec(CommandLineInputSpec):
31833183 desc = 'output xfm file' ,
31843184 genfile = True ,
31853185 argstr = '%s' ,
3186- position = - 1 ,)
3186+ position = - 1 ,
3187+ name_source = ['source' ],
3188+ hash_files = False ,
3189+ name_template = '%s_nlpfit.mnc' ,
3190+ keep_extension = False )
31873191
31883192 # This is a dummy input.
31893193 input_grid_files = InputMultiPath (
31903194 traits .File ,
31913195 desc = 'input grid file(s)' ,)
31923196
3193- # FIXME outout_mnc?
3194-
31953197 config_file = File (
31963198 desc = 'File containing the fitting configuration use.' ,
31973199 argstr = '-config_file %s' ,
3198- mandatory = True , # FIXME debugging
3200+ mandatory = True ,
31993201 exists = True )
32003202
32013203 init_xfm = File (
32023204 desc = 'Initial transformation (default identity).' ,
32033205 argstr = '-init_xfm %s' ,
3204- mandatory = True , # FIXME debugging
3206+ mandatory = True ,
32053207 exists = True )
32063208
32073209 source_mask = File (
32083210 desc = 'Source mask to use during fitting.' ,
32093211 argstr = '-source_mask %s' ,
3210- mandatory = True , # FIXME Just for debugging...
3212+ mandatory = True ,
32113213 exists = True )
32123214
32133215 verbose = traits .Bool (
@@ -3219,15 +3221,9 @@ class NlpFitInputSpec(CommandLineInputSpec):
32193221 usedefault = True ,
32203222 default_value = True )
32213223
3222- # FIXME Very bare implementation, many parameters not done yet.
3223-
32243224
32253225class NlpFitOutputSpec (TraitedSpec ):
3226- # FIXME nlpfit has two modes... deal with output.xfm vs output.mnc
3227- # depending on whether -config_file is passed.
3228-
32293226 output_xfm = File (desc = 'output xfm file' , exists = True )
3230- # FIXME Is this always the case, that exists=True?
32313227 output_grid = File (desc = 'output grid file' , exists = True )
32323228
32333229
@@ -3258,32 +3254,13 @@ class NlpFit(CommandLine):
32583254 output_spec = NlpFitOutputSpec
32593255 _cmd = 'nlpfit'
32603256
3261- def _gen_filename (self , name ):
3262- if name == 'output_xfm' :
3263- output_xfm = self .inputs .output_xfm
3264-
3265- if isdefined (output_xfm ):
3266- return os .path .abspath (output_xfm )
3267- else :
3268- return aggregate_filename (
3269- [self .inputs .source , self .inputs .target ], 'nlpfit_xfm_output' ) + '.xfm'
3270- else :
3271- raise NotImplemented
3272-
32733257 def _list_outputs (self ):
3274- outputs = self .output_spec ().get ()
3275- # FIXME see above.
3276- # outputs['output_mnc'] = os.path.abspath(self._gen_filename('output_mnc'))
3277- outputs ['output_xfm' ] = os .path .abspath (
3278- self ._gen_filename ('output_xfm' ))
3258+ outputs = super (NlpFit , self )._list_outputs ()
32793259
3280- # FIXME Is this the sensible? No other way to tell if the grid files
3281- # were produced.
3282- # FIXME This is safe to assume?
3283- assert os .path .exists (outputs ['output_xfm' ])
3284- if 'grid' in open (outputs ['output_xfm' ], 'r' ).read ():
3285- outputs ['output_grid' ] = re .sub (
3286- '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_xfm' ])
3260+ if os .path .exists (outputs ['output_xfm' ]):
3261+ if 'grid' in open (outputs ['output_xfm' ], 'r' ).read ():
3262+ outputs ['output_grid' ] = re .sub (
3263+ '.(nlxfm|xfm)$' , '_grid_0.mnc' , outputs ['output_xfm' ])
32873264
32883265 return outputs
32893266
0 commit comments