From df89399f1c070ba7b86b3aeaeee23cf8d722a1a8 Mon Sep 17 00:00:00 2001 From: oesteban Date: Fri, 28 Feb 2020 14:54:12 -0800 Subject: [PATCH] fix: copy header for ResampleImageBySpacing Closes nipreps/niworkflows#459 --- nipype/interfaces/ants/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nipype/interfaces/ants/utils.py b/nipype/interfaces/ants/utils.py index 28f4cbfd97..4322fadb7c 100644 --- a/nipype/interfaces/ants/utils.py +++ b/nipype/interfaces/ants/utils.py @@ -141,6 +141,12 @@ class _ResampleImageBySpacingInputSpec(ANTSCommandInputSpec): nn_interp = traits.Bool( argstr="%d", desc="nn interpolation", position=-1, requires=["addvox"] ) + copy_header = traits.Bool( + True, + mandatory=True, + usedefault=True, + desc="copy headers of the original image into the output (corrected) file", + ) class _ResampleImageBySpacingOutputSpec(TraitedSpec): @@ -193,6 +199,14 @@ def _format_arg(self, name, trait_spec, value): return super(ResampleImageBySpacing, self)._format_arg(name, trait_spec, value) + def _list_outputs(self): + outputs = super(ResampleImageBySpacing, self)._list_outputs() + if self.inputs.copy_header: # Fix headers + _copy_header( + self.inputs.input_image, outputs["output_image"], keep_dtype=True + ) + return outputs + class _ThresholdImageInputSpec(ANTSCommandInputSpec): dimension = traits.Int(