Skip to content

Commit 55d052b

Browse files
authored
Merge pull request #1654 from dalejn/ants-jacobian
wrapped ANTs function CreateJacobianDeterminantImage
2 parents de6f4cf + 69bc007 commit 55d052b

File tree

4 files changed

+49
-75
lines changed

4 files changed

+49
-75
lines changed

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Upcoming release 0.13
2727
* ENH: Implement missing inputs/outputs in FSL AvScale (https://github.com/nipy/nipype/pull/1563)
2828
* FIX: Fix symlink test in copyfile (https://github.com/nipy/nipype/pull/1570, https://github.com/nipy/nipype/pull/1586)
2929
* ENH: Added support for custom job submission check in SLURM (https://github.com/nipy/nipype/pull/1582)
30-
30+
* ENH: Added ANTs interface CreateJacobianDeterminantImage; replaces deprecated JacobianDeterminant
31+
(https://github.com/nipy/nipype/pull/1654)
3132

3233
Release 0.12.1 (August 3, 2016)
3334
===============================

nipype/interfaces/ants/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
from .visualization import ConvertScalarImageToRGB, CreateTiledMosaic
2020

2121
# Utility Programs
22-
from .utils import AverageAffineTransform, AverageImages, MultiplyImages, JacobianDeterminant
22+
from .utils import AverageAffineTransform, AverageImages, MultiplyImages, CreateJacobianDeterminantImage

nipype/interfaces/ants/tests/test_auto_JacobianDeterminant.py renamed to nipype/interfaces/ants/tests/test_auto_CreateJacobianDeterminantImage.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,55 @@
11
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT
22
from ....testing import assert_equal
3-
from ..utils import JacobianDeterminant
3+
from ..utils import CreateJacobianDeterminantImage
44

55

6-
def test_JacobianDeterminant_inputs():
6+
def test_CreateJacobianDeterminantImage_inputs():
77
input_map = dict(args=dict(argstr='%s',
88
),
9-
dimension=dict(argstr='%d',
9+
deformationField=dict(argstr='%s',
1010
mandatory=True,
11-
position=0,
12-
usedefault=False,
11+
position=1,
12+
),
13+
doLogJacobian=dict(argstr='%d',
14+
mandatory=False,
15+
position=3,
1316
),
1417
environ=dict(nohash=True,
1518
usedefault=True,
1619
),
1720
ignore_exception=dict(nohash=True,
1821
usedefault=True,
1922
),
20-
norm_by_total=dict(argstr='%d',
21-
position=5,
23+
imageDimension=dict(argstr='%d',
24+
mandatory=True,
25+
position=0,
26+
usedefault=False,
2227
),
2328
num_threads=dict(nohash=True,
2429
usedefault=True,
2530
),
26-
output_prefix=dict(argstr='%s',
27-
genfile=True,
28-
hash_files=False,
31+
outputImage=dict(argstr='%s',
32+
mandatory=True,
2933
position=2,
3034
),
31-
projection_vector=dict(argstr='%s',
32-
position=6,
33-
sep='x',
34-
),
35-
template_mask=dict(argstr='%s',
36-
position=4,
37-
),
3835
terminal_output=dict(nohash=True,
3936
),
40-
use_log=dict(argstr='%d',
41-
position=3,
42-
),
43-
warp_file=dict(argstr='%s',
44-
mandatory=True,
45-
position=1,
37+
useGeometric=dict(argstr='%d',
38+
mandatory=False,
39+
position=4,
4640
),
4741
)
48-
inputs = JacobianDeterminant.input_spec()
42+
inputs = CreateJacobianDeterminantImage.input_spec()
4943

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

5448

55-
def test_JacobianDeterminant_outputs():
49+
def test_CreateJacobianDeterminantImage_outputs():
5650
output_map = dict(jacobian_image=dict(),
5751
)
58-
outputs = JacobianDeterminant.output_spec()
52+
outputs = CreateJacobianDeterminantImage.output_spec()
5953

6054
for key, metadata in list(output_map.items()):
6155
for metakey, value in list(metadata.items()):

nipype/interfaces/ants/utils.py

Lines changed: 26 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -137,65 +137,44 @@ def _list_outputs(self):
137137
self.inputs.output_product_image)
138138
return outputs
139139

140-
141-
class JacobianDeterminantInputSpec(ANTSCommandInputSpec):
142-
dimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True,
140+
class CreateJacobianDeterminantImageInputSpec(ANTSCommandInputSpec):
141+
imageDimension = traits.Enum(3, 2, argstr='%d', usedefault=False, mandatory=True,
143142
position=0, desc='image dimension (2 or 3)')
144-
warp_file = File(argstr='%s', exists=True, mandatory=True,
145-
position=1, desc='input warp file')
146-
output_prefix = File(argstr='%s', genfile=True, hash_files=False,
143+
deformationField = File(argstr='%s', exists=True, mandatory=True,
144+
position=1, desc='deformation transformation file')
145+
outputImage = File(argstr='%s', mandatory=True,
147146
position=2,
148-
desc=('prefix of the output image filename: '
149-
'PREFIX(log)jacobian.nii.gz'))
150-
use_log = traits.Enum(0, 1, argstr='%d', position=3,
151-
desc='log transform the jacobian determinant')
152-
template_mask = File(argstr='%s', exists=True, position=4,
153-
desc='template mask to adjust for head size')
154-
norm_by_total = traits.Enum(0, 1, argstr='%d', position=5,
155-
desc=('normalize jacobian by total in mask to '
156-
'adjust for head size'))
157-
projection_vector = traits.List(traits.Float(), argstr='%s', sep='x',
158-
position=6,
159-
desc='vector to project warp against')
160-
147+
desc='output filename')
148+
doLogJacobian = traits.Enum(0, 1, argstr='%d', mandatory=False, position=3,
149+
desc='return the log jacobian')
150+
useGeometric = traits.Enum(0, 1, argstr='%d', mandatory=False, position=4,
151+
desc='return the geometric jacobian')
161152

162-
class JacobianDeterminantOutputSpec(TraitedSpec):
163-
jacobian_image = File(exists=True, desc='(log transformed) jacobian image')
153+
class CreateJacobianDeterminantImageOutputSpec(TraitedSpec):
154+
jacobian_image = File(exists=True, desc='jacobian image')
164155

165-
166-
class JacobianDeterminant(ANTSCommand):
156+
class CreateJacobianDeterminantImage(ANTSCommand):
167157
"""
168158
Examples
169159
--------
170-
>>> from nipype.interfaces.ants import JacobianDeterminant
171-
>>> jacobian = JacobianDeterminant()
172-
>>> jacobian.inputs.dimension = 3
173-
>>> jacobian.inputs.warp_file = 'ants_Warp.nii.gz'
174-
>>> jacobian.inputs.output_prefix = 'Sub001_'
175-
>>> jacobian.inputs.use_log = 1
160+
>>> from nipype.interfaces.ants import CreateJacobianDeterminantImage
161+
>>> jacobian = CreateJacobianDeterminantImage()
162+
>>> jacobian.inputs.imageDimension = 3
163+
>>> jacobian.inputs.deformationField = 'ants_Warp.nii.gz'
164+
>>> jacobian.inputs.outputImage = 'out_name.nii.gz'
176165
>>> jacobian.cmdline # doctest: +IGNORE_UNICODE
177-
'ANTSJacobian 3 ants_Warp.nii.gz Sub001_ 1'
166+
'CreateJacobianDeterminantImage 3 ants_Warp.nii.gz out_name.nii.gz'
178167
"""
179168

180-
_cmd = 'ANTSJacobian'
181-
input_spec = JacobianDeterminantInputSpec
182-
output_spec = JacobianDeterminantOutputSpec
169+
_cmd = 'CreateJacobianDeterminantImage'
170+
input_spec = CreateJacobianDeterminantImageInputSpec
171+
output_spec = CreateJacobianDeterminantImageOutputSpec
183172

184-
def _gen_filename(self, name):
185-
if name == 'output_prefix':
186-
output = self.inputs.output_prefix
187-
if not isdefined(output):
188-
_, name, ext = split_filename(self.inputs.warp_file)
189-
output = name + '_'
190-
return output
191-
return None
173+
def _format_arg(self, opt, spec, val):
174+
return super(CreateJacobianDeterminantImage, self)._format_arg(opt, spec, val)
192175

193176
def _list_outputs(self):
194177
outputs = self._outputs().get()
195-
if self.inputs.use_log == 1:
196-
outputs['jacobian_image'] = os.path.abspath(
197-
self._gen_filename('output_prefix') + 'logjacobian.nii.gz')
198-
else:
199-
outputs['jacobian_image'] = os.path.abspath(
200-
self._gen_filename('output_prefix') + 'jacobian.nii.gz')
178+
outputs['jacobian_image'] = os.path.abspath(
179+
self.inputs.outputImage)
201180
return outputs

0 commit comments

Comments
 (0)