Skip to content

Commit 3b5f99d

Browse files
committed
get argstrs in line for ants motion correction
1 parent 39d986a commit 3b5f99d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

nipype/interfaces/ants/preprocess.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ class AntsMotionCorrInputSpec(ANTSCommandInputSpec):
6161
"specified-dimensional image. If not specified, N4 tries to infer "
6262
"the dimensionality from the input image."
6363
)
64-
dimensionality = traits.Enum(3, 2, argstr='-d %d', usedefault=False,
64+
dimensionality = traits.Enum(3, 2, argstr='-d %d', usedefault=True,
6565
position=0, desc=dimension_desc, default=3)
6666

67-
average_image = File(argstr='-a %s', position=1,
67+
average_image = File(argstr='-a %s', position=1, exists=False,
6868
desc="Average the input time series image.")
6969

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)
7172
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)
7375

7476
metric_type = traits.Enum("CC", "MeanSquares", "Demons", "GC", "MI",
7577
"Mattes", argstr="%s")
@@ -120,7 +122,7 @@ class AntsMotionCorrInputSpec(ANTSCommandInputSpec):
120122
class AntsMotionCorrOutputSpec(TraitedSpec):
121123
'''Output spec for the antsMotionCorr command'''
122124
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')
124126
inverse_composite_transform = File(desc='Inverse composite transform file')
125127
warped_image = File(desc="Outputs warped image")
126128
inverse_warped_image = File(desc="Outputs the inverse of the warped image")
@@ -164,10 +166,17 @@ class AntsMotionCorr(ANTSCommand):
164166

165167

166168
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)
169174
new_fname = '{}{}{}'.format(fname, '_avg', ext)
170175
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)
171180
return None
172181

173182
def _format_arg(self, opt, spec, val):
@@ -176,6 +185,7 @@ def _format_arg(self, opt, spec, val):
176185
if opt == 'transformation_model':
177186
return self._format_transform()
178187
if opt == 'output_average_image':
188+
self.inputs.output_average_image = self._gen_filename("output_average_image")
179189
return self._format_output()
180190
return super(AntsMotionCorr, self)._format_arg(opt, spec, val)
181191

@@ -198,7 +208,7 @@ def _format_transform(self):
198208
and _extant(self.inputs.gradient_step_length)):
199209
return transform_str.format(self.inputs.transformation_model,
200210
self.inputs.gradient_step_length)
201-
return ""
211+
return " bad format "
202212

203213
def _format_output(self):
204214
if (_extant(self.inputs.output_transform_prefix)
@@ -226,6 +236,6 @@ def _list_outputs(self):
226236
)
227237
if _extant(self.inputs.output_transform_prefix):
228238
outputs['composite_transform'] = '{}MOCOparams.csv'.format(
229-
self.inputs.output_tranform_prefix
239+
self.inputs.output_transform_prefix
230240
)
231241
return outputs

0 commit comments

Comments
 (0)