@@ -85,6 +85,8 @@ class DTIFitOutputSpec(TraitedSpec):
8585 'diffusion weighting' ))
8686 tensor = File (
8787 exists = True , desc = 'path/name of file with the 4D tensor volume' )
88+ sse = File (
89+ exists = True , desc = 'path/name of file with the summed squared error' )
8890
8991
9092class DTIFit (FSLCommand ):
@@ -111,13 +113,21 @@ class DTIFit(FSLCommand):
111113 output_spec = DTIFitOutputSpec
112114
113115 def _list_outputs (self ):
116+ keys_to_ignore = {'outputtype' , 'environ' , 'args' }
117+ # Optional output: Map output name to input flag
118+ opt_output = {'tensor' : self .inputs .save_tensor ,
119+ 'sse' : self .inputs .sse }
120+ # Ignore optional output, whose corresponding input-flag is not defined
121+ # or set to False
122+ for output , input_flag in opt_output .items ():
123+ if isdefined (input_flag ) and input_flag :
124+ # this is wanted output, do not ignore
125+ continue
126+ keys_to_ignore .add (output )
127+
114128 outputs = self .output_spec ().get ()
115- for k in list (outputs .keys ()):
116- if k not in ('outputtype' , 'environ' , 'args' ):
117- if k != 'tensor' or (isdefined (self .inputs .save_tensor )
118- and self .inputs .save_tensor ):
119- outputs [k ] = self ._gen_fname (
120- self .inputs .base_name , suffix = '_' + k )
129+ for k in set (outputs .keys ()) - keys_to_ignore :
130+ outputs [k ] = self ._gen_fname (self .inputs .base_name , suffix = '_' + k )
121131 return outputs
122132
123133
0 commit comments