Skip to content

Commit 0498267

Browse files
authored
Merge pull request #2586 from satra/enh/labelgeom
enh: add interface for LabelGeometryMeasures
2 parents caf87f5 + 900d9f2 commit 0498267

File tree

3 files changed

+118
-1
lines changed

3 files changed

+118
-1
lines changed

nipype/interfaces/ants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
# Utility Programs
2424
from .utils import (AverageAffineTransform, AverageImages, MultiplyImages,
2525
CreateJacobianDeterminantImage, AffineInitializer,
26-
ComposeMultiTransform)
26+
ComposeMultiTransform, LabelGeometry)
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 __future__ import unicode_literals
3+
from ..utils import LabelGeometry
4+
5+
6+
def test_LabelGeometry_inputs():
7+
input_map = dict(
8+
args=dict(argstr='%s', ),
9+
dimension=dict(
10+
argstr='%d',
11+
position=0,
12+
usedefault=True,
13+
),
14+
environ=dict(
15+
nohash=True,
16+
usedefault=True,
17+
),
18+
ignore_exception=dict(
19+
deprecated='1.0.0',
20+
nohash=True,
21+
usedefault=True,
22+
),
23+
intensity_image=dict(
24+
argstr='%s',
25+
mandatory=True,
26+
position=2,
27+
usedefault=True,
28+
),
29+
label_image=dict(
30+
argstr='%s',
31+
mandatory=True,
32+
position=1,
33+
),
34+
num_threads=dict(
35+
nohash=True,
36+
usedefault=True,
37+
),
38+
output_file=dict(
39+
argstr='%s',
40+
name_source=['label_image'],
41+
name_template='%s.csv',
42+
position=3,
43+
),
44+
terminal_output=dict(
45+
deprecated='1.0.0',
46+
nohash=True,
47+
),
48+
)
49+
inputs = LabelGeometry.input_spec()
50+
51+
for key, metadata in list(input_map.items()):
52+
for metakey, value in list(metadata.items()):
53+
assert getattr(inputs.traits()[key], metakey) == value
54+
def test_LabelGeometry_outputs():
55+
output_map = dict(output_file=dict(), )
56+
outputs = LabelGeometry.output_spec()
57+
58+
for key, metadata in list(output_map.items()):
59+
for metakey, value in list(metadata.items()):
60+
assert getattr(outputs.traits()[key], metakey) == value

nipype/interfaces/ants/utils.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,60 @@ class ComposeMultiTransform(ANTSCommand):
357357
_cmd = 'ComposeMultiTransform'
358358
input_spec = ComposeMultiTransformInputSpec
359359
output_spec = ComposeMultiTransformOutputSpec
360+
361+
362+
class LabelGeometryInputSpec(ANTSCommandInputSpec):
363+
dimension = traits.Enum(
364+
3,
365+
2,
366+
argstr='%d',
367+
usedefault=True,
368+
position=0,
369+
desc='image dimension (2 or 3)')
370+
label_image = File(
371+
argstr='%s',
372+
position=1,
373+
mandatory=True,
374+
desc='label image to use for extracting geometry measures')
375+
intensity_image = File(
376+
value='[]',
377+
exists=True,
378+
argstr='%s',
379+
mandatory=True,
380+
usedefault=True,
381+
position=2,
382+
desc='Intensity image to extract values from. '
383+
'This is an optional input')
384+
output_file = traits.Str(
385+
name_source=['label_image'],
386+
name_template='%s.csv',
387+
argstr='%s',
388+
position=3,
389+
desc='name of output file')
390+
391+
392+
class LabelGeometryOutputSpec(TraitedSpec):
393+
output_file = File(exists=True, desc='CSV file of geometry measures')
394+
395+
396+
class LabelGeometry(ANTSCommand):
397+
"""
398+
Extracts geometry measures using a label file and an optional image file
399+
400+
Examples
401+
--------
402+
>>> from nipype.interfaces.ants import LabelGeometry
403+
>>> label_extract = LabelGeometry()
404+
>>> label_extract.inputs.dimension = 3
405+
>>> label_extract.inputs.label_image = 'atlas.nii.gz'
406+
>>> label_extract.cmdline
407+
'LabelGeometryMeasures 3 atlas.nii.gz [] atlas.csv'
408+
409+
>>> label_extract.inputs.intensity_image = 'ants_Warp.nii.gz'
410+
>>> label_extract.cmdline
411+
'LabelGeometryMeasures 3 atlas.nii.gz ants_Warp.nii.gz atlas.csv'
412+
413+
"""
414+
_cmd = 'LabelGeometryMeasures'
415+
input_spec = LabelGeometryInputSpec
416+
output_spec = LabelGeometryOutputSpec

0 commit comments

Comments
 (0)