Skip to content

Commit cd5385e

Browse files
author
Shoshana Berleant
committed
Merge http://github.com/nipy/nipype into debugging
2 parents c217a23 + 55d052b commit cd5385e

File tree

8 files changed

+59
-83
lines changed

8 files changed

+59
-83
lines changed

CHANGES

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Upcoming release 0.13
22
=====================
33

4+
* FIX: Semaphore capture using MultiProc plugin (https://github.com/nipy/nipype/pull/1689)
45
* REF: Refactor AFNI interfaces (https://github.com/nipy/nipype/pull/1678, https://github.com/nipy/nipype/pull/1680)
56
* ENH: Move nipype commands to group command using click (https://github.com/nipy/nipype/pull/1608)
67
* FIX: AFNI Retroicor interface fixes (https://github.com/nipy/nipype/pull/1669)
@@ -26,7 +27,8 @@ Upcoming release 0.13
2627
* ENH: Implement missing inputs/outputs in FSL AvScale (https://github.com/nipy/nipype/pull/1563)
2728
* FIX: Fix symlink test in copyfile (https://github.com/nipy/nipype/pull/1570, https://github.com/nipy/nipype/pull/1586)
2829
* ENH: Added support for custom job submission check in SLURM (https://github.com/nipy/nipype/pull/1582)
29-
30+
* ENH: Added ANTs interface CreateJacobianDeterminantImage; replaces deprecated JacobianDeterminant
31+
(https://github.com/nipy/nipype/pull/1654)
3032

3133
Release 0.12.1 (August 3, 2016)
3234
===============================

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

nipype/pipeline/engine/utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -648,11 +648,13 @@ def _propagate_internal_output(graph, node, field, connections, portinputs):
648648
if field in portinputs:
649649
srcnode, srcport = portinputs[field]
650650
if isinstance(srcport, tuple) and isinstance(src, tuple):
651-
raise ValueError(("Does not support two inline functions "
652-
"in series (\'%s\' and \'%s\'). "
653-
"Please use a Function node") %
654-
(srcport[1].split("\\n")[0][6:-1],
655-
src[1].split("\\n")[0][6:-1]))
651+
src_func = srcport[1].split("\\n")[0]
652+
dst_func = src[1].split("\\n")[0]
653+
raise ValueError("Does not support two inline functions "
654+
"in series ('{}' and '{}'), found when "
655+
"connecting {} to {}. Please use a Function "
656+
"node.".format(src_func, dst_func, srcnode, destnode))
657+
656658
connect = graph.get_edge_data(srcnode, destnode,
657659
default={'connect': []})
658660
if isinstance(src, tuple):

nipype/pipeline/plugins/multiproc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ def __init__(self, plugin_args=None):
160160
def _wait(self):
161161
if len(self.pending_tasks) > 0:
162162
semaphore_singleton.semaphore.acquire()
163-
semaphore_singleton.semaphore.release()
164163

165164
def _get_result(self, taskid):
166165
if taskid not in self._taskresult:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import print_function, division, unicode_literals, absolute_import
33
import threading
4-
semaphore = threading.Semaphore(1)
4+
semaphore = threading.Semaphore(0)

tools/build_interface_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
'\.testing',
4141
'\.scripts',
4242
]
43-
docwriter.class_skip_patterns += ['AFNI',
43+
docwriter.class_skip_patterns += ['AFNICommand',
4444
'ANTS',
4545
'FSL',
4646
'FS',

0 commit comments

Comments
 (0)