Skip to content

Commit 111866f

Browse files
committed
Merge remote-tracking branch 'upstream/master' into fix/configparser
* upstream/master: Closes #2026 fix: use new link with fsaverage files for mris_expand Fix 3dUnifize outputs. updated freesurfer URL and added ANTS as well [Docker] Install minimized version of FS6 [ENH] Revise CircleCI settings FIX: ?h.white is actually created in the -pial step FIX: config can't be passed directly to Node TEST: Test attribute copying during MapNode expansion FIX: Pass parameters to all MapNode-generated Nodes update specs [ENH] Enable num_threads for antsAffineInitializer
2 parents 3def5cb + 90cfdd8 commit 111866f

File tree

9 files changed

+80
-49
lines changed

9 files changed

+80
-49
lines changed

circle.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,35 @@ dependencies:
2727
- mkdir -p $WORKDIR && sudo setfacl -d -m group:ubuntu:rwx $WORKDIR && sudo setfacl -m group:ubuntu:rwx $WORKDIR
2828
- mkdir -p $HOME/docker $HOME/examples $WORKDIR/tests $WORKDIR/logs $WORKDIR/crashfiles ${CIRCLE_TEST_REPORTS}/tests/
2929
- if [[ ! -e "$HOME/bin/codecov" ]]; then mkdir -p $HOME/bin; curl -so $HOME/bin/codecov https://codecov.io/bash && chmod 755 $HOME/bin/codecov; fi
30-
override:
31-
- if [[ -e "$HOME/docker/cache.tar" ]]; then docker load --input $HOME/docker/cache.tar; fi :
30+
- docker load --input $HOME/docker/cache.tar || true :
3231
timeout: 6000
33-
- docker images
34-
- docker pull nipype/base:latest
32+
override:
33+
# Get data
3534
- if [[ ! -d ~/examples/nipype-tutorial ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-tutorial.tar.bz2 "${DATA_NIPYPE_TUTORIAL_URL}" && tar xjf nipype-tutorial.tar.bz2 -C ~/examples/; fi
3635
- if [[ ! -d ~/examples/nipype-fsl_course_data ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O nipype-fsl_course_data.tar.gz "${DATA_NIPYPE_FSL_COURSE}" && tar xzf nipype-fsl_course_data.tar.gz -C ~/examples/; fi
3736
- if [[ ! -d ~/examples/feeds ]]; then wget --retry-connrefused --waitretry=5 --read-timeout=20 --timeout=15 -t 0 -q -O fsl-5.0.9-feeds.tar.gz "${DATA_NIPYPE_FSL_FEEDS}" && tar xzf fsl-5.0.9-feeds.tar.gz -C ~/examples/; fi
3837
- if [ "$CIRCLE_TAG" != "" ]; then sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" nipype/info.py; fi
39-
# - e=1 && for i in {1..5}; do docker build -f docker/base.Dockerfile --rm=false -t nipype/base:latest . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
40-
# timeout: 21600
41-
- e=1 && for i in {1..5}; do docker build --rm=false -t nipype/nipype:latest -t nipype/nipype:py36 --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
38+
# Docker
39+
- docker images
40+
- ? |
41+
e=1 && for i in {1..5}; do
42+
docker build --rm=false -f docker/base.Dockerfile -t nipype/base:latest . && e=0 && break || sleep 15;
43+
done && [ "$e" -eq "0" ]
44+
:
45+
timeout: 21600
46+
- ? |
47+
e=1 && for i in {1..5}; do
48+
docker build --rm=false -t nipype/nipype:latest -t nipype/nipype:py36 --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG . && e=0 && break || sleep 15;
49+
done && [ "$e" -eq "0" ]
50+
:
4251
timeout: 6000
43-
- e=1 && for i in {1..5}; do docker build --rm=false -t nipype/nipype:py27 --build-arg PYTHON_VERSION_MAJOR=2 --build-arg PYTHON_VERSION_MINOR=7 --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG-py27 . && e=0 && break || sleep 15; done && [ "$e" -eq "0" ] :
52+
- ? |
53+
e=1 && for i in {1..5}; do
54+
docker build --rm=false -t nipype/nipype:py27 --build-arg PYTHON_VERSION_MAJOR=2 --build-arg PYTHON_VERSION_MINOR=7 --build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` --build-arg VCS_REF=`git rev-parse --short HEAD` --build-arg VERSION=$CIRCLE_TAG-py27 . && e=0 && break || sleep 15;
55+
done && [ "$e" -eq "0" ]
56+
:
4457
timeout: 6000
45-
- docker save -o $HOME/docker/cache.tar nipype/base:latest nipype/nipype:py36 nipype/nipype:py27 :
58+
- docker save -o $HOME/docker/cache.tar ubuntu:xenial-20161213 nipype/base:latest nipype/nipype:py36 nipype/nipype:py27 :
4659
timeout: 6000
4760

4861
test:

docker/base.Dockerfile

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,25 @@ RUN apt-get update && \
4444

4545
WORKDIR /opt
4646
# Installing freesurfer -- do it first so that it is cached early
47-
RUN curl -sSL https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/6.0.0/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tar.gz | tar zxv -C /opt \
48-
--exclude='freesurfer/trctrain' \
49-
--exclude='freesurfer/subjects/fsaverage_sym' \
50-
--exclude='freesurfer/subjects/fsaverage3' \
51-
--exclude='freesurfer/subjects/fsaverage4' \
52-
--exclude='freesurfer/subjects/fsaverage5' \
53-
--exclude='freesurfer/subjects/fsaverage6' \
54-
--exclude='freesurfer/subjects/cvs_avg35' \
55-
--exclude='freesurfer/subjects/cvs_avg35_inMNI152' \
56-
--exclude='freesurfer/subjects/bert' \
57-
--exclude='freesurfer/subjects/V1_average' \
58-
--exclude='freesurfer/average/mult-comp-cor' \
59-
--exclude='freesurfer/lib/cuda' \
60-
--exclude='freesurfer/lib/qt'
61-
62-
ENV FSL_DIR=/usr/share/fsl/5.0 \
47+
#-----------------------------------------------------------------------------
48+
# 3. Install FreeSurfer v6.0 (minimized with reprozip):
49+
# https://github.com/freesurfer/freesurfer/issues/70
50+
#-----------------------------------------------------------------------------
51+
RUN curl -sSL https://dl.dropbox.com/s/pbaisn6m5qpi9uu/recon-all-freesurfer6-2.min.tgz?dl=0 | tar zx -C /opt
52+
ENV FS_OVERRIDE=0 \
6353
OS=Linux \
64-
FS_OVERRIDE=0 \
65-
FIX_VERTEX_AREA= \
6654
FSF_OUTPUT_FORMAT=nii.gz \
55+
FIX_VERTEX_AREA=\
6756
FREESURFER_HOME=/opt/freesurfer
68-
ENV SUBJECTS_DIR=$FREESURFER_HOME/subjects \
69-
FUNCTIONALS_DIR=$FREESURFER_HOME/sessions \
70-
MNI_DIR=$FREESURFER_HOME/mni \
71-
LOCAL_DIR=$FREESURFER_HOME/local \
72-
FSFAST_HOME=$FREESURFER_HOME/fsfast \
73-
MINC_BIN_DIR=$FREESURFER_HOME/mni/bin \
74-
MINC_LIB_DIR=$FREESURFER_HOME/mni/lib \
75-
MNI_DATAPATH=$FREESURFER_HOME/mni/data \
76-
FMRI_ANALYSIS_DIR=$FREESURFER_HOME/fsfast
77-
ENV PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \
78-
MNI_PERL5LIB=$MINC_LIB_DIR/perl5/5.8.5 \
79-
PATH=$FREESURFER_HOME/bin:$FSFAST_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH
57+
ENV MNI_DIR=$FREESURFER_HOME/mni \
58+
SUBJECTS_DIR=$FREESURFER_HOME/subjects
59+
ENV PERL5LIB=$MNI_DIR/share/perl5 \
60+
MNI_PERL5LIB=$MNI_DIR/share/perl5 \
61+
MINC_BIN_DIR=$MNI_DIR/bin \
62+
MINC_LIB_DIR=$MNI_DIR/lib \
63+
MNI_DATAPATH=$MNI_DIR/data
64+
ENV PATH=$FREESURFER_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH
65+
ENV FSL_DIR=/usr/share/fsl/5.0
8066
RUN echo "cHJpbnRmICJrcnp5c3p0b2YuZ29yZ29sZXdza2lAZ21haWwuY29tXG41MTcyXG4gKkN2dW12RVYzelRmZ1xuRlM1Si8yYzFhZ2c0RVxuIiA+IC9vcHQvZnJlZXN1cmZlci9saWNlbnNlLnR4dAo=" | base64 -d | sh
8167

8268
# Enable neurodebian
@@ -122,8 +108,8 @@ ENV FSLDIR=/usr/share/fsl/5.0 \
122108

123109
# Installing and setting up ANTs
124110
RUN mkdir -p /opt/ants && \
125-
curl -sSL "https://github.com/stnava/ANTs/releases/download/v2.1.0/Linux_Ubuntu14.04.tar.bz2" \
126-
| tar -xjC /opt/ants --strip-components 1
111+
curl -sSL "https://dl.dropbox.com/s/2f4sui1z6lcgyek/ANTs-Linux-centos5_x86_64-v2.2.0-0740f91.tar.gz?dl=0" \
112+
| tar -zx -C /opt
127113

128114
ENV ANTSPATH=/opt/ants \
129115
PATH=$ANTSPATH:$PATH

nipype/interfaces/afni/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,8 @@ class UnifizeInputSpec(AFNICommandInputSpec):
12471247
copyfile=False)
12481248
out_file = File(
12491249
desc='output image file name',
1250-
argstr='-prefix %s')
1250+
argstr='-prefix %s',
1251+
name_source='in_file')
12511252
t2 = traits.Bool(
12521253
desc='Treat the input as if it were T2-weighted, rather than '
12531254
'T1-weighted. This processing is done simply by inverting '

nipype/interfaces/ants/tests/test_auto_AffineInitializer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def test_AffineInitializer_inputs():
2828
mandatory=True,
2929
position=2,
3030
),
31+
num_threads=dict(nohash=True,
32+
usedefault=True,
33+
),
3134
out_file=dict(argstr='%s',
3235
position=3,
3336
usedefault=True,

nipype/interfaces/ants/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def _list_outputs(self):
181181
return outputs
182182

183183

184-
class AffineInitializerInputSpec(CommandLineInputSpec):
184+
class AffineInitializerInputSpec(ANTSCommandInputSpec):
185185
dimension = traits.Enum(3, 2, usedefault=True, position=0, argstr='%s',
186186
desc='dimension')
187187
fixed_image = File(exists=True, mandatory=True, position=1, argstr='%s',
@@ -207,7 +207,7 @@ class AffineInitializerOutputSpec(TraitedSpec):
207207
out_file = File(desc='output transform file')
208208

209209

210-
class AffineInitializer(CommandLine):
210+
class AffineInitializer(ANTSCommand):
211211
"""
212212
Initialize an affine transform (as in antsBrainExtraction.sh)
213213

nipype/interfaces/freesurfer/preprocess.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,8 @@ class ReconAll(CommandLine):
886886
('avgcurv', ['surf/lh.avg_curv'], []),
887887
('cortparc', ['label/lh.aparc.annot'], []),
888888
('pial', ['surf/lh.pial', 'surf/lh.curv.pial',
889-
'surf/lh.area.pial', 'surf/lh.thickness'], []),
889+
'surf/lh.area.pial', 'surf/lh.thickness',
890+
'surf/lh.white'], []),
890891
('parcstats', ['stats/lh.aparc.stats'], []),
891892
('cortparc2', ['label/lh.aparc.a2009s.annot'], []),
892893
('parcstats2', ['stats/lh.aparc.a2009s.stats'], []),

nipype/interfaces/fsl/ICA_AROMA.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class ICA_AROMA(CommandLine):
107107
output_spec = ICA_AROMAOutputSpec
108108

109109
def _list_outputs(self):
110+
outputs = self.output_spec().get()
110111
out_dir = os.path.abspath(self.inputs.out_dir)
111112
outputs['out_dir'] = out_dir
112113

nipype/pipeline/engine/nodes.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,9 +1112,14 @@ def _make_nodes(self, cwd=None):
11121112
nitems = len(filename_to_list(getattr(self.inputs, self.iterfield[0])))
11131113
for i in range(nitems):
11141114
nodename = '_' + self.name + str(i)
1115-
node = Node(deepcopy(self._interface), name=nodename)
1116-
node.overwrite = self.overwrite
1117-
node.run_without_submitting = self.run_without_submitting
1115+
node = Node(deepcopy(self._interface),
1116+
n_procs=self._interface.num_threads,
1117+
mem_gb=self._interface.estimated_memory_gb,
1118+
overwrite=self.overwrite,
1119+
needed_outputs=self.needed_outputs,
1120+
run_without_submitting=self.run_without_submitting,
1121+
base_dir=op.join(cwd, 'mapflow'),
1122+
name=nodename)
11181123
node.plugin_args = self.plugin_args
11191124
node._interface.inputs.set(
11201125
**deepcopy(self._interface.inputs.get()))
@@ -1126,7 +1131,6 @@ def _make_nodes(self, cwd=None):
11261131
logger.debug('setting input %d %s %s', i, field, fieldvals[i])
11271132
setattr(node.inputs, field, fieldvals[i])
11281133
node.config = self.config
1129-
node.base_dir = op.join(cwd, 'mapflow')
11301134
yield i, node
11311135

11321136
def _node_runner(self, nodes, updatehash=False):

nipype/pipeline/engine/tests/test_engine.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,28 @@ def func1(in1):
486486
assert "can only concatenate list" in str(excinfo.value)
487487

488488

489+
def test_mapnode_expansion(tmpdir):
490+
os.chdir(str(tmpdir))
491+
from nipype import MapNode, Function
492+
493+
def func1(in1):
494+
return in1 + 1
495+
496+
mapnode = MapNode(Function(function=func1),
497+
iterfield='in1',
498+
name='mapnode')
499+
mapnode.inputs.in1 = [1, 2]
500+
mapnode.interface.num_threads = 2
501+
mapnode.interface.estimated_memory_gb = 2
502+
503+
for idx, node in mapnode._make_nodes():
504+
for attr in ('overwrite', 'run_without_submitting', 'plugin_args'):
505+
assert getattr(node, attr) == getattr(mapnode, attr)
506+
for attr in ('num_threads', 'estimated_memory_gb'):
507+
assert (getattr(node._interface, attr) ==
508+
getattr(mapnode._interface, attr))
509+
510+
489511
def test_node_hash(tmpdir):
490512
wd = str(tmpdir)
491513
os.chdir(wd)

0 commit comments

Comments
 (0)