Skip to content

Commit

Permalink
fix: copy header for ResampleImageBySpacing
Browse files Browse the repository at this point in the history
  • Loading branch information
oesteban committed Mar 2, 2020
1 parent dfe8501 commit dffcb78
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def test_ResampleImageBySpacing_inputs():
addvox=dict(argstr="%d", position=6, requires=["apply_smoothing"],),
apply_smoothing=dict(argstr="%d", position=5,),
args=dict(argstr="%s",),
copy_header=dict(mandatory=True, usedefault=True,),
dimension=dict(argstr="%d", position=1, usedefault=True,),
environ=dict(nohash=True, usedefault=True,),
input_image=dict(argstr="%s", extensions=None, mandatory=True, position=2,),
Expand Down
14 changes: 14 additions & 0 deletions nipype/interfaces/ants/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit dffcb78

Please sign in to comment.