Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Next release
============

* ENH: New interface for FSL fslcpgeom utility (https://github.com/nipy/nipype/pull/1152)
* FIX: Enable absolute path definitions in DCMStack (https://github.com/nipy/nipype/pull/1089,
replaced by https://github.com/nipy/nipype/pull/1093)
* ENH: New mesh.MeshWarpMaths to operate on surface-defined warpings
Expand Down
2 changes: 1 addition & 1 deletion nipype/interfaces/fsl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
PlotTimeSeries, PlotMotionParams, ConvertXFM,
SwapDimensions, PowerSpectrum, Reorient2Std,
Complex, InvWarp, WarpUtils, ConvertWarp, WarpPoints,
WarpPointsToStd, RobustFOV)
WarpPointsToStd, RobustFOV, CopyGeom)

from .epi import (PrepareFieldmap, TOPUP, ApplyTOPUP, Eddy, EPIDeWarp,
SigLoss, EddyCorrect, EpiReg)
Expand Down
44 changes: 44 additions & 0 deletions nipype/interfaces/fsl/tests/test_auto_CopyGeom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
from nipype.testing import assert_equal
from nipype.interfaces.fsl.utils import CopyGeom

def test_CopyGeom_inputs():
input_map = dict(args=dict(argstr='%s',
),
dest_file=dict(argstr='%s',
copyfile=True,
mandatory=True,
position=1,
),
environ=dict(nohash=True,
usedefault=True,
),
ignore_dims=dict(argstr='-d',
position='-1',
),
ignore_exception=dict(nohash=True,
usedefault=True,
),
in_file=dict(argstr='%s',
mandatory=True,
position=0,
),
output_type=dict(),
terminal_output=dict(nohash=True,
),
)
inputs = CopyGeom.input_spec()

for key, metadata in input_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(inputs.traits()[key], metakey), value

def test_CopyGeom_outputs():
output_map = dict(out_file=dict(),
)
outputs = CopyGeom.output_spec()

for key, metadata in output_map.items():
for metakey, value in metadata.items():
yield assert_equal, getattr(outputs.traits()[key], metakey), value

27 changes: 26 additions & 1 deletion nipype/interfaces/fsl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,36 @@
from ..base import (traits, TraitedSpec, OutputMultiPath, File,
CommandLine, CommandLineInputSpec, isdefined)
from ...utils.filemanip import (load_json, save_json, split_filename,
fname_presuffix)
fname_presuffix, copyfile)

warn = warnings.warn
warnings.filterwarnings('always', category=UserWarning)

class CopyGeomInputSpec(FSLCommandInputSpec):
in_file = File(exists=True, mandatory=True, argstr="%s", position=0,
desc="source image")
dest_file = File(exists=True, mandatory=True, argstr="%s", position=1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add another two pieces of metadata to this:
output_name='out_file', name_template='%s_newhd'

and then remove all three functions (run_interface, gen_filename, list_outputs) from interface

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops. this may not work for this scenario where dest_file is an existing file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. So the current implementation is ok?

desc="destination image", copyfile=True, output_name='out_file',
name_source='dest_file', name_template='%s')
ignore_dims = traits.Bool(desc=('Do not copy image dimensions'),
argstr='-d', position="-1")

class CopyGeomOutputSpec(TraitedSpec):
out_file = File(exists=True, desc="image with new geometry header")

class CopyGeom(FSLCommand):
"""Use fslcpgeom to copy the header geometry information to another image.
Copy certain parts of the header information (image dimensions, voxel dimensions,
voxel dimensions units string, image orientation/origin or qform/sform info)
from one image to another. Note that only copies from Analyze to Analyze
or Nifti to Nifti will work properly. Copying from different files will result
in loss of information or potentially incorrect settings.
"""
_cmd = "fslcpgeom"
input_spec = CopyGeomInputSpec
output_spec = CopyGeomOutputSpec


class RobustFOVInputSpec(FSLCommandInputSpec):
in_file = File(exists=True,
desc='input filename',
Expand Down