Skip to content

Commit ba97ef1

Browse files
committed
[ENH] Added new fsl.WarpPointsFromStd interface
1 parent 9ee2828 commit ba97ef1

File tree

4 files changed

+106
-2
lines changed

4 files changed

+106
-2
lines changed

nipype/interfaces/freesurfer/tests/test_auto_MRIsConvert.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ def test_MRIsConvert_inputs():
3030
),
3131
origname=dict(argstr='-o %s',
3232
),
33-
out_datatype=dict(xor=['out_file'],
33+
out_datatype=dict(mandatory=True,
34+
xor=['out_file'],
3435
),
3536
out_file=dict(argstr='%s',
3637
genfile=True,
38+
mandatory=True,
3739
position=-1,
3840
xor=['out_datatype'],
3941
),

nipype/interfaces/fsl/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
PlotTimeSeries, PlotMotionParams, ConvertXFM,
1818
SwapDimensions, PowerSpectrum, Reorient2Std,
1919
Complex, InvWarp, WarpUtils, ConvertWarp, WarpPoints,
20-
WarpPointsToStd, RobustFOV, CopyGeom, MotionOutliers)
20+
WarpPointsToStd, WarpPointsFromStd,
21+
RobustFOV, CopyGeom, MotionOutliers)
2122

2223
from .epi import (PrepareFieldmap, TOPUP, ApplyTOPUP, Eddy, EPIDeWarp,
2324
SigLoss, EddyCorrect, EpiReg)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from ....testing import assert_equal
3+
from ..utils import WarpPointsFromStd
4+
5+
6+
def test_WarpPointsFromStd_inputs():
7+
input_map = dict(args=dict(argstr='%s',
8+
),
9+
coord_mm=dict(argstr='-mm',
10+
xor=['coord_vox'],
11+
),
12+
coord_vox=dict(argstr='-vox',
13+
xor=['coord_mm'],
14+
),
15+
environ=dict(nohash=True,
16+
usedefault=True,
17+
),
18+
ignore_exception=dict(nohash=True,
19+
usedefault=True,
20+
),
21+
img_file=dict(argstr='-img %s',
22+
mandatory=True,
23+
),
24+
in_coords=dict(argstr='%s',
25+
mandatory=True,
26+
position=-1,
27+
),
28+
out_file=dict(name_source='in_coords',
29+
name_template='%s_warped',
30+
output_name='out_file',
31+
),
32+
std_file=dict(argstr='-std %s',
33+
mandatory=True,
34+
),
35+
terminal_output=dict(nohash=True,
36+
),
37+
transform=dict(argstr='-xfm %s',
38+
),
39+
warp_file=dict(argstr='-warp %s',
40+
xor=['xfm_file'],
41+
),
42+
xfm_file=dict(argstr='-xfm %s',
43+
xor=['warp_file'],
44+
),
45+
)
46+
inputs = WarpPointsFromStd.input_spec()
47+
48+
for key, metadata in list(input_map.items()):
49+
for metakey, value in list(metadata.items()):
50+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
51+
52+
53+
def test_WarpPointsFromStd_outputs():
54+
output_map = dict(out_file=dict(),
55+
)
56+
outputs = WarpPointsFromStd.output_spec()
57+
58+
for key, metadata in list(output_map.items()):
59+
for metakey, value in list(metadata.items()):
60+
yield assert_equal, getattr(outputs.traits()[key], metakey), value

nipype/interfaces/fsl/utils.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,47 @@ class WarpPointsToStd(WarpPoints):
20172017
_cmd = 'img2stdcoord'
20182018

20192019

2020+
class WarpPointsFromStdInputSpec(WarpPointsBaseInputSpec):
2021+
img_file = File(exists=True, argstr='-img %s', mandatory=True,
2022+
desc='filename of a destination image')
2023+
std_file = File(exists=True, argstr='-std %s', mandatory=True,
2024+
desc='filename of the image in standard space')
2025+
transform = File(exists=True, argstr='-xfm %s',
2026+
desc='filename of pre-warp affine transform '
2027+
'(e.g. example_func2highres.mat)')
2028+
2029+
2030+
class WarpPointsFromStd(WarpPoints):
2031+
"""
2032+
Use FSL `std2imgcoord <http://fsl.fmrib.ox.ac.uk/fsl/fsl-4.1.9/flirt/overview.html>`_
2033+
to transform point sets to standard space coordinates. Accepts plain text files and
2034+
vtk files.
2035+
2036+
.. Note:: transformation of TrackVis trk files is not yet implemented
2037+
2038+
2039+
Examples
2040+
--------
2041+
2042+
>>> from nipype.interfaces.fsl import WarpPointsFromStd
2043+
>>> warppoints = WarpPointsFromStd()
2044+
>>> warppoints.inputs.in_coords = 'surf.txt'
2045+
>>> warppoints.inputs.img_file = 'T1.nii'
2046+
>>> warppoints.inputs.std_file = 'mni.nii'
2047+
>>> warppoints.inputs.warp_file = 'warpfield.nii'
2048+
>>> warppoints.inputs.coord_mm = True
2049+
>>> warppoints.cmdline # doctest: +ELLIPSIS
2050+
'std2imgcoord -mm -img T1.nii -std mni.nii -warp warpfield.nii surf.txt'
2051+
>>> res = warppoints.run() # doctest: +SKIP
2052+
2053+
2054+
"""
2055+
2056+
input_spec = WarpPointsFromStdInputSpec
2057+
output_spec = WarpPointsOutputSpec
2058+
_cmd = 'std2imgcoord'
2059+
2060+
20202061
class MotionOutliersInputSpec(FSLCommandInputSpec):
20212062
in_file = File(
20222063
exists=True, mandatory=True, desc="unfiltered 4D image", argstr="-i %s")

0 commit comments

Comments
 (0)