Skip to content

Commit dffcb78

Browse files
committed
fix: copy header for ResampleImageBySpacing
Closes nipreps/niworkflows#459
1 parent dfe8501 commit dffcb78

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

nipype/interfaces/ants/tests/test_auto_ResampleImageBySpacing.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ def test_ResampleImageBySpacing_inputs():
77
addvox=dict(argstr="%d", position=6, requires=["apply_smoothing"],),
88
apply_smoothing=dict(argstr="%d", position=5,),
99
args=dict(argstr="%s",),
10+
copy_header=dict(mandatory=True, usedefault=True,),
1011
dimension=dict(argstr="%d", position=1, usedefault=True,),
1112
environ=dict(nohash=True, usedefault=True,),
1213
input_image=dict(argstr="%s", extensions=None, mandatory=True, position=2,),

nipype/interfaces/ants/utils.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ class _ResampleImageBySpacingInputSpec(ANTSCommandInputSpec):
141141
nn_interp = traits.Bool(
142142
argstr="%d", desc="nn interpolation", position=-1, requires=["addvox"]
143143
)
144+
copy_header = traits.Bool(
145+
True,
146+
mandatory=True,
147+
usedefault=True,
148+
desc="copy headers of the original image into the output (corrected) file",
149+
)
144150

145151

146152
class _ResampleImageBySpacingOutputSpec(TraitedSpec):
@@ -193,6 +199,14 @@ def _format_arg(self, name, trait_spec, value):
193199

194200
return super(ResampleImageBySpacing, self)._format_arg(name, trait_spec, value)
195201

202+
def _list_outputs(self):
203+
outputs = super(ResampleImageBySpacing, self)._list_outputs()
204+
if self.inputs.copy_header: # Fix headers
205+
_copy_header(
206+
self.inputs.input_image, outputs["output_image"], keep_dtype=True
207+
)
208+
return outputs
209+
196210

197211
class _ThresholdImageInputSpec(ANTSCommandInputSpec):
198212
dimension = traits.Int(

0 commit comments

Comments
 (0)