Skip to content

Commit 81ed963

Browse files
committed
Tests and doc changes
1 parent 56f4fe1 commit 81ed963

File tree

3 files changed

+70
-17
lines changed

3 files changed

+70
-17
lines changed

nipype/interfaces/ants/resampling.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,40 +338,44 @@ class ApplyTransformsToPointsInputSpec(ANTSCommandInputSpec):
338338
'specified, antsWarp tries to infer the '
339339
'dimensionality from the input image.'))
340340
input_file = File(argstr='--input %s', mandatory=True,
341-
desc=('image to apply transformation to (generally a '
342-
'coregistered functional)'),
343-
exists=True)
341+
desc=("Currently, the only input supported is a csv file with "
342+
"columns including x,y (2D), x,y,z (3D) or x,y,z,t,label (4D) column headers."
343+
"The points should be defined in physical space."
344+
"If in doubt how to convert coordinates from your files to the space"
345+
"required by antsApplyTransformsToPoints try creating/drawing a simple"
346+
"label volume with only one voxel set to 1 and all others set to 0."
347+
"Write down the voxel coordinates. Then use ImageMaths LabelStats to find"
348+
"out what coordinates for this voxel antsApplyTransformsToPoints is"
349+
"expecting."),
350+
exists=True)
344351
output_file = traits.Str(argstr='--output %s',
345-
desc=('output file name'), name_source=['input_file'],
346-
hash_files=False, name_template='%s_transformed.csv')
347-
transforms = traits.List(
348-
File(exists=True), argstr='%s', mandatory=True, desc=(''))
349-
invert_transform_flags = traits.List(traits.Bool())
352+
desc=('Name of the output CSV file'), name_source=['input_file'],
353+
hash_files=False, name_template='%s_transformed.csv')
354+
transforms = traits.List(File(exists=True), argstr='%s', mandatory=True,
355+
desc=('transforms that will be applied to the points'))
356+
invert_transform_flags = traits.List(traits.Bool(),
357+
desc=('list indicating if a transform should be reversed'))
350358

351359

352360
class ApplyTransformsToPointsOutputSpec(TraitedSpec):
353361
output_file = File(exists=True, desc='csv file with transformed coordinates')
354362

355363

356364
class ApplyTransformsToPoints(ANTSCommand):
357-
"""ApplyTransforms, applied to an input image, transforms it according to a
358-
reference image and a transform (or a set of transforms).
365+
"""ApplyTransformsToPoints, applied to an CSV file, transforms coordinates
366+
using provided transform (or a set of transforms).
359367
360368
Examples
361369
--------
362370
363371
>>> from nipype.interfaces.ants import ApplyTransforms
364-
>>> at = ApplyTransforms()
372+
>>> at = ApplyTransformsToPoints()
365373
>>> at.inputs.dimension = 3
366-
>>> at.inputs.input_image = 'moving1.nii'
367-
>>> at.inputs.reference_image = 'fixed1.nii'
368-
>>> at.inputs.output_image = 'deformed_moving1.nii'
369-
>>> at.inputs.interpolation = 'Linear'
370-
>>> at.inputs.default_value = 0
374+
>>> at.inputs.input_file = 'moving.csv'
371375
>>> at.inputs.transforms = ['trans.mat', 'ants_Warp.nii.gz']
372376
>>> at.inputs.invert_transform_flags = [False, False]
373377
>>> at.cmdline
374-
'antsApplyTransforms --default-value 0 --dimensionality 3 --input moving1.nii --interpolation Linear --output deformed_moving1.nii --reference-image fixed1.nii --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
378+
'antsApplyTransformsToPoints --dimensionality 3 --input moving.csv --output moving_transformed.csv --transform [trans.mat,0] --transform [ants_Warp.nii.gz,0]'
375379
376380
377381
"""
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
2+
from nipype.testing import assert_equal
3+
from nipype.interfaces.ants.resampling import ApplyTransformsToPoints
4+
5+
def test_ApplyTransformsToPoints_inputs():
6+
input_map = dict(args=dict(argstr='%s',
7+
),
8+
dimension=dict(argstr='--dimensionality %d',
9+
),
10+
environ=dict(nohash=True,
11+
usedefault=True,
12+
),
13+
ignore_exception=dict(nohash=True,
14+
usedefault=True,
15+
),
16+
input_file=dict(argstr='--input %s',
17+
mandatory=True,
18+
),
19+
invert_transform_flags=dict(),
20+
num_threads=dict(nohash=True,
21+
usedefault=True,
22+
),
23+
output_file=dict(argstr='--output %s',
24+
hash_files=False,
25+
name_source=['input_file'],
26+
name_template='%s_transformed.csv',
27+
),
28+
terminal_output=dict(mandatory=True,
29+
nohash=True,
30+
),
31+
transforms=dict(argstr='%s',
32+
mandatory=True,
33+
),
34+
)
35+
inputs = ApplyTransformsToPoints.input_spec()
36+
37+
for key, metadata in input_map.items():
38+
for metakey, value in metadata.items():
39+
yield assert_equal, getattr(inputs.traits()[key], metakey), value
40+
41+
def test_ApplyTransformsToPoints_outputs():
42+
output_map = dict(output_file=dict(),
43+
)
44+
outputs = ApplyTransformsToPoints.output_spec()
45+
46+
for key, metadata in output_map.items():
47+
for metakey, value in metadata.items():
48+
yield assert_equal, getattr(outputs.traits()[key], metakey), value
49+

nipype/testing/data/moving.csv

Whitespace-only changes.

0 commit comments

Comments
 (0)