fix naming issue of output_name
@@ -20,10 +20,16 @@ class FixHeaderApplyTransforms(ApplyTransforms):
runtime = super(FixHeaderApplyTransforms, self)._run_interface(
runtime, correct_return_codes)
+ _copyheader(self.input.reference_image,
+ os.path.abspath(self._gen_filename('output_image')),
+ message=self.__class__.__name__)
+ return runtime
+
+
+def _copyheader(ref_image, out_image, message=None):
# Read in reference and output
- out_file = os.path.abspath(self.inputs.output_image)
- orig = nb.load(self.inputs.reference_image)
- resampled = nb.load(out_file)
+ orig = nb.load(ref_image)
+ resampled = nb.load(out_image)
# Copy xform infos
qform, qform_code = orig.header.get_qform(coded=True)
@@ -31,8 +37,7 @@ class FixHeaderApplyTransforms(ApplyTransforms):
header = resampled.header.copy()
header.set_qform(qform, int(qform_code))
header.set_qform(sform, int(sform_code))
- header['descrip'] = 'header fixed after ants.ApplyTransforms'
+ header['descrip'] = 'header fixed (%s)' % (message or 'unknown')
newimg = resampled.__class__(resampled.get_data(), orig.affine, header)
- newimg.to_filename(out_file)
- return runtime
+ newimg.to_filename(out_image)
