Skip to content

Commit f504736

Browse files
committed
Merge pull request #1405 from alexsavio/master
fix:test & fix bug using aux functions in connect
2 parents c96b3b1 + f3117e0 commit f504736

File tree

3 files changed

+126
-76
lines changed

3 files changed

+126
-76
lines changed

nipype/interfaces/petpvc.py

Lines changed: 71 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,8 @@
66
>>> filepath = os.path.dirname( os.path.realpath( __file__ ) )
77
>>> datadir = os.path.realpath(os.path.join(filepath, '../testing/data'))
88
>>> os.chdir(datadir)
9-
10-
Nipype interface for PETPVC.
11-
12-
PETPVC is a software from the Nuclear Medicine Department
13-
of the UCL University Hospital, London, UK.
14-
15-
Its source code is here: https://github.com/UCL/PETPVC
16-
17-
The methods that it implement are explained here:
18-
K. Erlandsson, I. Buvat, P. H. Pretorius, B. A. Thomas, and B. F. Hutton,
19-
"A review of partial volume correction techniques for emission tomography
20-
and their applications in neurology, cardiology and oncology," Phys. Med.
21-
Biol., vol. 57, no. 21, p. R119, 2012.
22-
23-
There is a publication waiting to be accepted for this software tool.
24-
25-
26-
Its command line help shows this:
27-
28-
-i --input < filename >
29-
= PET image file
30-
-o --output < filename >
31-
= Output file
32-
[ -m --mask < filename > ]
33-
= Mask image file
34-
-p --pvc < keyword >
35-
= Desired PVC method
36-
-x < X >
37-
= The full-width at half maximum in mm along x-axis
38-
-y < Y >
39-
= The full-width at half maximum in mm along y-axis
40-
-z < Z >
41-
= The full-width at half maximum in mm along z-axis
42-
[ -d --debug ]
43-
= Prints debug information
44-
[ -n --iter [ Val ] ]
45-
= Number of iterations
46-
With: Val (Default = 10)
47-
[ -k [ Val ] ]
48-
= Number of deconvolution iterations
49-
With: Val (Default = 10)
50-
[ -a --alpha [ aval ] ]
51-
= Alpha value
52-
With: aval (Default = 1.5)
53-
[ -s --stop [ stopval ] ]
54-
= Stopping criterion
55-
With: stopval (Default = 0.01)
56-
57-
----------------------------------------------
58-
Technique - keyword
59-
60-
Geometric transfer matrix - "GTM"
61-
Labbe approach - "LABBE"
62-
Richardson-Lucy - "RL"
63-
Van-Cittert - "VC"
64-
Region-based voxel-wise correction - "RBV"
65-
RBV with Labbe - "LABBE+RBV"
66-
RBV with Van-Cittert - "RBV+VC"
67-
RBV with Richardson-Lucy - "RBV+RL"
68-
RBV with Labbe and Van-Cittert - "LABBE+RBV+VC"
69-
RBV with Labbe and Richardson-Lucy- "LABBE+RBV+RL"
70-
Multi-target correction - "MTC"
71-
MTC with Labbe - "LABBE+MTC"
72-
MTC with Van-Cittert - "MTC+VC"
73-
MTC with Richardson-Lucy - "MTC+RL"
74-
MTC with Labbe and Van-Cittert - "LABBE+MTC+VC"
75-
MTC with Labbe and Richardson-Lucy- "LABBE+MTC+RL"
76-
Iterative Yang - "IY"
77-
Iterative Yang with Van-Cittert - "IY+VC"
78-
Iterative Yang with Richardson-Lucy - "IY+RL"
79-
Muller Gartner - "MG"
80-
Muller Gartner with Van-Cittert - "MG+VC"
81-
Muller Gartner with Richardson-Lucy - "MG+RL"
82-
839
"""
10+
8411
from __future__ import print_function
8512
from __future__ import division
8613

@@ -144,6 +71,76 @@ class PETPVCOutputSpec(TraitedSpec):
14471
class PETPVC(CommandLine):
14572
""" Use PETPVC for partial volume correction of PET images.
14673
74+
PETPVC is a software from the Nuclear Medicine Department
75+
of the UCL University Hospital, London, UK.
76+
77+
Its source code is here: https://github.com/UCL/PETPVC
78+
79+
The methods that it implement are explained here:
80+
K. Erlandsson, I. Buvat, P. H. Pretorius, B. A. Thomas, and B. F. Hutton,
81+
"A review of partial volume correction techniques for emission tomography
82+
and their applications in neurology, cardiology and oncology," Phys. Med.
83+
Biol., vol. 57, no. 21, p. R119, 2012.
84+
85+
There is a publication waiting to be accepted for this software tool.
86+
87+
Its command line help shows this:
88+
89+
-i --input < filename >
90+
= PET image file
91+
-o --output < filename >
92+
= Output file
93+
[ -m --mask < filename > ]
94+
= Mask image file
95+
-p --pvc < keyword >
96+
= Desired PVC method
97+
-x < X >
98+
= The full-width at half maximum in mm along x-axis
99+
-y < Y >
100+
= The full-width at half maximum in mm along y-axis
101+
-z < Z >
102+
= The full-width at half maximum in mm along z-axis
103+
[ -d --debug ]
104+
= Prints debug information
105+
[ -n --iter [ Val ] ]
106+
= Number of iterations
107+
With: Val (Default = 10)
108+
[ -k [ Val ] ]
109+
= Number of deconvolution iterations
110+
With: Val (Default = 10)
111+
[ -a --alpha [ aval ] ]
112+
= Alpha value
113+
With: aval (Default = 1.5)
114+
[ -s --stop [ stopval ] ]
115+
= Stopping criterion
116+
With: stopval (Default = 0.01)
117+
118+
----------------------------------------------
119+
Technique - keyword
120+
121+
Geometric transfer matrix - "GTM"
122+
Labbe approach - "LABBE"
123+
Richardson-Lucy - "RL"
124+
Van-Cittert - "VC"
125+
Region-based voxel-wise correction - "RBV"
126+
RBV with Labbe - "LABBE+RBV"
127+
RBV with Van-Cittert - "RBV+VC"
128+
RBV with Richardson-Lucy - "RBV+RL"
129+
RBV with Labbe and Van-Cittert - "LABBE+RBV+VC"
130+
RBV with Labbe and Richardson-Lucy- "LABBE+RBV+RL"
131+
Multi-target correction - "MTC"
132+
MTC with Labbe - "LABBE+MTC"
133+
MTC with Van-Cittert - "MTC+VC"
134+
MTC with Richardson-Lucy - "MTC+RL"
135+
MTC with Labbe and Van-Cittert - "LABBE+MTC+VC"
136+
MTC with Labbe and Richardson-Lucy- "LABBE+MTC+RL"
137+
Iterative Yang - "IY"
138+
Iterative Yang with Van-Cittert - "IY+VC"
139+
Iterative Yang with Richardson-Lucy - "IY+RL"
140+
Muller Gartner - "MG"
141+
Muller Gartner with Van-Cittert - "MG+VC"
142+
Muller Gartner with Richardson-Lucy - "MG+RL"
143+
147144
Examples
148145
--------
149146
>>> from ..testing import example_data

nipype/interfaces/tests/test_utility.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ def increment_array(in_array):
6363
f2 = pe.MapNode(utility.Function(input_names=['in_array'], output_names=['out_array'], function=increment_array), name='increment_array', iterfield=['in_array'])
6464

6565
wf.connect(f1, 'random_array', f2, 'in_array')
66-
6766
wf.run()
6867

6968
# Clean up
@@ -167,3 +166,57 @@ def test_csvReader():
167166
yield assert_equal, out.outputs.column_1, ['hello', 'world', 'goodbye']
168167
yield assert_equal, out.outputs.column_2, ['300.1', '5', '0.3']
169168
os.unlink(name)
169+
170+
171+
def test_aux_connect_function():
172+
""" This tests excution nodes with multiple inputs and auxiliary
173+
function inside the Workflow connect function.
174+
"""
175+
tempdir = os.path.realpath(mkdtemp())
176+
origdir = os.getcwd()
177+
os.chdir(tempdir)
178+
179+
wf = pe.Workflow(name="test_workflow")
180+
181+
def _gen_tuple(size):
182+
return [1, ] * size
183+
184+
def _sum_and_sub_mul(a, b, c):
185+
return (a+b)*c, (a-b)*c
186+
187+
def _inc(x):
188+
return x + 1
189+
190+
params = pe.Node(utility.IdentityInterface(fields=['size', 'num']), name='params')
191+
params.inputs.num = 42
192+
params.inputs.size = 1
193+
194+
gen_tuple = pe.Node(utility.Function(input_names=['size'],
195+
output_names=['tuple'],
196+
function=_gen_tuple),
197+
name='gen_tuple')
198+
199+
ssm = pe.Node(utility.Function(input_names=['a', 'b', 'c'],
200+
output_names=['sum', 'sub'],
201+
function=_sum_and_sub_mul),
202+
name='sum_and_sub_mul')
203+
204+
split = pe.Node(utility.Split(splits=[1, 1],
205+
squeeze=True),
206+
name='split')
207+
208+
209+
wf.connect([
210+
(params, gen_tuple, [(("size", _inc), "size")]),
211+
(params, ssm, [(("num", _inc), "c")]),
212+
(gen_tuple, split, [("tuple", "inlist")]),
213+
(split, ssm, [(("out1", _inc), "a"),
214+
("out2", "b"),
215+
]),
216+
])
217+
218+
wf.run()
219+
220+
# Clean up
221+
os.chdir(origdir)
222+
shutil.rmtree(tempdir)

nipype/pipeline/engine/workflows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ def _configure_exec_nodes(self, graph):
690690
node.input_source = {}
691691
for edge in graph.in_edges_iter(node):
692692
data = graph.get_edge_data(*edge)
693-
for sourceinfo, field in sorted(data['connect']):
693+
for sourceinfo, field in data['connect']:
694694
node.input_source[field] = \
695695
(op.join(edge[0].output_dir(),
696696
'result_%s.pklz' % edge[0].name),

0 commit comments

Comments
 (0)