@@ -61,15 +61,17 @@ class AntsMotionCorrInputSpec(ANTSCommandInputSpec):
61
61
"specified-dimensional image. If not specified, N4 tries to infer "
62
62
"the dimensionality from the input image."
63
63
)
64
- dimensionality = traits .Enum (3 , 2 , argstr = '-d %d' , usedefault = False ,
64
+ dimensionality = traits .Enum (3 , 2 , argstr = '-d %d' , usedefault = True ,
65
65
position = 0 , desc = dimension_desc , default = 3 )
66
66
67
- average_image = File (argstr = '-a %s' , position = 1 ,
67
+ average_image = File (argstr = '-a %s' , position = 1 , exists = False ,
68
68
desc = "Average the input time series image." )
69
69
70
- output_average_image = File (argstr = "%s" , hash_files = False , desc = "" , genfile = True )
70
+ output_average_image = File (hash_files = False , desc = "" , argstr = "%s" ,
71
+ genfile = True , exists = False , usedefault = True )
71
72
output_transform_prefix = traits .Str ()
72
- output_warped_image = File (hash_files = False , desc = "" )
73
+ output_warped_image = File (hash_files = False , desc = "" ,
74
+ exists = False )
73
75
74
76
metric_type = traits .Enum ("CC" , "MeanSquares" , "Demons" , "GC" , "MI" ,
75
77
"Mattes" , argstr = "%s" )
@@ -120,7 +122,7 @@ class AntsMotionCorrInputSpec(ANTSCommandInputSpec):
120
122
class AntsMotionCorrOutputSpec (TraitedSpec ):
121
123
'''Output spec for the antsMotionCorr command'''
122
124
average_image = File (exists = True , desc = 'Average of an image' )
123
- composite_transform = File (exists = True , desc = 'Composite transform file' )
125
+ composite_transform = File (desc = 'Composite transform file' )
124
126
inverse_composite_transform = File (desc = 'Inverse composite transform file' )
125
127
warped_image = File (desc = "Outputs warped image" )
126
128
inverse_warped_image = File (desc = "Outputs the inverse of the warped image" )
@@ -164,10 +166,17 @@ class AntsMotionCorr(ANTSCommand):
164
166
165
167
166
168
def _gen_filename (self , name ):
167
- if name == 'output_average_image' and _extant (self .inputs .average ):
168
- pth , fname , ext = split_filename (self .inputs .average )
169
+ if name == 'output_average_image' :
170
+ if _extant (self .inputs .average_image ):
171
+ pth , fname , ext = split_filename (self .inputs .average_image )
172
+ else :
173
+ pth , fname , ext = split_filename (self .inputs .fixed_image )
169
174
new_fname = '{}{}{}' .format (fname , '_avg' , ext )
170
175
return os .path .join (pth , new_fname )
176
+ if name == 'ouput_warped_image' and _extant (self .inputs .fixed_image ):
177
+ pth , fname , ext = split_filename (self .inputs .fixed_image )
178
+ new_fname = '{}{}{}' .format (fname , '_warped' , ext )
179
+ return os .path .join (pth , new_fname )
171
180
return None
172
181
173
182
def _format_arg (self , opt , spec , val ):
@@ -176,6 +185,7 @@ def _format_arg(self, opt, spec, val):
176
185
if opt == 'transformation_model' :
177
186
return self ._format_transform ()
178
187
if opt == 'output_average_image' :
188
+ self .inputs .output_average_image = self ._gen_filename ("output_average_image" )
179
189
return self ._format_output ()
180
190
return super (AntsMotionCorr , self )._format_arg (opt , spec , val )
181
191
@@ -198,7 +208,7 @@ def _format_transform(self):
198
208
and _extant (self .inputs .gradient_step_length )):
199
209
return transform_str .format (self .inputs .transformation_model ,
200
210
self .inputs .gradient_step_length )
201
- return ""
211
+ return " bad format "
202
212
203
213
def _format_output (self ):
204
214
if (_extant (self .inputs .output_transform_prefix )
@@ -226,6 +236,6 @@ def _list_outputs(self):
226
236
)
227
237
if _extant (self .inputs .output_transform_prefix ):
228
238
outputs ['composite_transform' ] = '{}MOCOparams.csv' .format (
229
- self .inputs .output_tranform_prefix
239
+ self .inputs .output_transform_prefix
230
240
)
231
241
return outputs
0 commit comments