Skip to content

Commit 4b850c8

Browse files
author
David Ellis
committed
Merge remote-tracking branch 'nipype_proper/master' into FreeSurferBreakout
2 parents f0946e1 + c46b932 commit 4b850c8

File tree

14 files changed

+874
-152
lines changed

14 files changed

+874
-152
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ before_install:
3434
echo 'include_dirs = /usr/include:/usr/include/X11' >> $HOME/.numpy-site.cfg;
3535
fi
3636
install:
37+
- sudo apt-get install fusefat
3738
- conda update --yes conda
3839
- conda create -n testenv --yes pip python=$TRAVIS_PYTHON_VERSION
3940
- source activate testenv
@@ -56,7 +57,7 @@ install:
5657
- pip install -r requirements.txt # finish remaining requirements
5758
- python setup.py install
5859
script:
59-
- python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest --with-cov --cover-package nipype --cov-config .coveragerc --logging-level=INFO
60+
- python -W once:FSL:UserWarning:nipype `which nosetests` --with-doctest --with-cov --cover-package nipype --cov-config .coveragerc --logging-level=DEBUG --verbosity=3
6061
after_success:
6162
- coveralls --config_file .coveragerc
6263
deploy:

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Next release
2424
* ENH: New interfaces for interacting with AWS S3: S3DataSink and S3DataGrabber (https://github.com/nipy/nipype/pull/1201)
2525
* ENH: Interfaces for MINC tools (https://github.com/nipy/nipype/pull/1304)
2626
* FIX: Use realpath to determine hard link source (https://github.com/nipy/nipype/pull/1388)
27+
* FIX: Correct linking/copying fallback behavior (https://github.com/nipy/nipype/pull/1391)
2728
* ENH: Nipype workflow and interfaces for FreeSurfer's recon-all (https://github.com/nipy/nipype/pull/1326)
2829

2930
Release 0.11.0 (September 15, 2015)

CHANGES.orig

Lines changed: 538 additions & 0 deletions
Large diffs are not rendered by default.

README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ NIPYPE: Neuroimaging in Python: Pipelines and Interfaces
3434
:target: https://pypi.python.org/pypi/nipype/
3535
:alt: License
3636

37+
.. image:: https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg?style=flat
38+
:target: http://gitter.im/nipy/nipype
39+
:alt: Chat
40+
3741
Current neuroimaging software offer users an incredible opportunity to
3842
analyze data using a variety of different algorithms. However, this has
3943
resulted in a heterogeneous collection of specialized applications

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies:
1212
- bash <(wget -q -O- http://neuro.debian.net/_files/neurodebian-travis.sh)
1313
override:
1414
# Install apt packages
15-
- sudo apt-get install -y fsl-core fsl-atlases fsl-mni152-templates fsl-feeds afni swig python-vtk xvfb
15+
- sudo apt-get install -y fsl-core fsl-atlases fsl-mni152-templates fsl-feeds afni swig python-vtk xvfb fusefat
1616
- echo 'source /etc/fsl/fsl.sh' >> $HOME/.profile
1717
- echo 'source /etc/afni/afni.sh' >> $HOME/.profile
1818
- mkdir -p ~/examples/ && ln -sf /usr/share/fsl-feeds/ ~/examples/feeds

examples/README

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
A dataset for use with these scripts can be downloaded from the nipype
22
website. At the time of writing, it's at:
33

4-
http://nipy.sourceforge.net/nipype/users/pipeline_tutorial.html
4+
http://nipy.org/nipype/users/pipeline_tutorial.html

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),

nipype/testing/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from numpy.testing import *
3030

3131
from . import decorators as dec
32-
from .utils import skip_if_no_package, package_check
32+
from .utils import skip_if_no_package, package_check, TempFATFS
3333

3434
skipif = dec.skipif
3535

nipype/testing/tests/test_utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
2+
# vi: set ft=python sts=4 ts=4 sw=4 et:
3+
"""Test testing utilities
4+
"""
5+
6+
import os
7+
import warnings
8+
from nipype.testing.utils import TempFATFS
9+
from nose.tools import assert_true
10+
11+
12+
def test_tempfatfs():
13+
try:
14+
fatfs = TempFATFS()
15+
except IOError:
16+
warnings.warn("Cannot mount FAT filesystems with FUSE")
17+
else:
18+
with fatfs as tmpdir:
19+
yield assert_true, os.path.exists(tmpdir)

nipype/testing/utils.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
"""
55
__docformat__ = 'restructuredtext'
66

7+
import os
8+
import time
9+
import shutil
10+
import signal
11+
import subprocess
12+
from tempfile import mkdtemp
713
from ..utils.misc import package_check
814
from nose import SkipTest
915

@@ -19,3 +25,66 @@ def skip_if_no_package(*args, **kwargs):
1925
package_check(exc_failed_import=SkipTest,
2026
exc_failed_check=SkipTest,
2127
*args, **kwargs)
28+
29+
30+
class TempFATFS(object):
31+
def __init__(self, size_in_mbytes=8, delay=0.5):
32+
"""Temporary filesystem for testing non-POSIX filesystems on a POSIX
33+
system.
34+
35+
with TempFATFS() as fatdir:
36+
target = os.path.join(fatdir, 'target')
37+
copyfile(file1, target, copy=False)
38+
assert_false(os.path.islink(target))
39+
40+
Arguments
41+
---------
42+
size_in_mbytes : int
43+
Size (in MiB) of filesystem to create
44+
delay : float
45+
Time (in seconds) to wait for fusefat to start, stop
46+
"""
47+
self.delay = delay
48+
self.tmpdir = mkdtemp()
49+
self.dev_null = open(os.devnull, 'wb')
50+
51+
vfatfile = os.path.join(self.tmpdir, 'vfatblock')
52+
self.vfatmount = os.path.join(self.tmpdir, 'vfatmount')
53+
self.canary = os.path.join(self.vfatmount, '.canary')
54+
55+
with open(vfatfile, 'wb') as fobj:
56+
fobj.write(b'\x00' * (int(size_in_mbytes) << 20))
57+
os.mkdir(self.vfatmount)
58+
59+
mkfs_args = ['mkfs.vfat', vfatfile]
60+
mount_args = ['fusefat', '-o', 'rw+', '-f', vfatfile, self.vfatmount]
61+
62+
subprocess.check_call(args=mkfs_args, stdout=self.dev_null,
63+
stderr=self.dev_null)
64+
self.fusefat = subprocess.Popen(args=mount_args, stdout=self.dev_null,
65+
stderr=self.dev_null)
66+
time.sleep(self.delay)
67+
68+
if self.fusefat.poll() is not None:
69+
raise IOError("fatfuse terminated too soon")
70+
71+
open(self.canary, 'wb').close()
72+
73+
def __enter__(self):
74+
return self.vfatmount
75+
76+
def __exit__(self, exc_type, exc_val, exc_tb):
77+
if self.fusefat is not None:
78+
self.fusefat.send_signal(signal.SIGINT)
79+
80+
# Allow 1s to return without sending terminate
81+
for count in range(10):
82+
time.sleep(0.1)
83+
if self.fusefat.poll() is not None:
84+
break
85+
else:
86+
self.fusefat.terminate()
87+
time.sleep(self.delay)
88+
assert not os.path.exists(self.canary)
89+
self.dev_null.close()
90+
shutil.rmtree(self.tmpdir)

0 commit comments

Comments
 (0)