Skip to content

Commit 1ac6bfc

Browse files
authored
Merge pull request #317 from effigies/fmriprep_wrapper
[RTM] fmriprep-docker wrapper script
2 parents 9313917 + 22fec3e commit 1ac6bfc

File tree

8 files changed

+449
-13
lines changed

8 files changed

+449
-13
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Next release
88
* [ENH] Sample functional series to subject and ``fsaverage`` surfaces (#391)
99
* [ENH] Output spaces for functional data may be selected with ``--output-space`` option (#447)
1010
* [DEP] ``--skip-native`` functionality replaced by ``--output-space`` (#447)
11+
* [ENH] ``fmriprep-docker`` wrapper script simplifies running in a Docker environment (#317)
1112

1213
0.3.2 (7th of April 2017)
1314
=========================

circle.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ dependencies:
2727
override:
2828
- if [[ -e $HOME/docker/image.tar ]]; then docker load -i $HOME/docker/image.tar; fi
2929
- sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" fmriprep/info.py
30+
- sed -i -E "s/(__version__ = )'[A-Za-z0-9.-]+'/\1'$CIRCLE_TAG'/" wrapper/fmriprep_docker.py
3031
- e=1 && for i in {1..5}; do docker build --rm=false -t poldracklab/fmriprep:latest --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" ] :
3132
timeout: 21600
3233
- mkdir -p $HOME/docker; docker save poldracklab/fmriprep:latest > $HOME/docker/image.tar
34+
- pip install future && pip install --upgrade wrapper/
3335
test:
3436
override:
3537
- docker run -ti --rm=false --entrypoint="python" poldracklab/fmriprep:latest -m unittest discover test
@@ -38,8 +40,8 @@ test:
3840
- cat $HOME/docs/builddocs.log && if grep -q "ERROR" $HOME/docs/builddocs.log; then false; else true; fi
3941
- docker run -ti --rm=false -v $HOME/nipype.cfg:/root/.nipype/nipype.cfg:ro -v $HOME/data:/data:ro -v $HOME/ds054/scratch:/scratch -v $HOME/ds054/out:/out poldracklab/fmriprep:latest /data/ds054 /out/ participant --no-freesurfer --debug -w /scratch:
4042
timeout: 4800
41-
- docker run -ti --rm=false -v $HOME/nipype.cfg:/root/.nipype/nipype.cfg:ro -v $HOME/data:/data:ro -v $HOME/ds005/scratch:/scratch -v $HOME/ds005/out:/out poldracklab/fmriprep:latest /data/ds005 /out/ participant --no-freesurfer --debug -w /scratch:
42-
timeout: 4800
43+
- fmriprep-docker -i poldracklab/fmriprep:latest --config $HOME/nipype.cfg -w $HOME/ds005/scratch $HOME/data/ds005 $HOME/ds005/out participant --no-freesurfer --debug:
44+
timeout: 4800
4345
- find ~/ds054/scratch -not -name "*.svg" -not -name "*.html" -not -name "*.svg" -not -name "*.rst" -type f -delete
4446
- find ~/ds005/scratch -not -name "*.svg" -not -name "*.html" -not -name "*.svg" -not -name "*.rst" -type f -delete
4547

@@ -61,3 +63,4 @@ deployment:
6163
timeout: 21600
6264
- printf "[distutils]\nindex-servers =\n pypi\n\n[pypi]\nusername:$PYPI_USER\npassword:$PYPI_PASS\n" > ~/.pypirc
6365
- python setup.py sdist upload -r pypi
66+
- cd wrapper && python setup.py sdist upload -r pypi

docs/contributors.rst

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,27 @@ Patching working repositories
2323
In order to test new code without rebuilding the Docker image, it is
2424
possible to mount working repositories as source directories within the
2525
container.
26-
In the docker container, the all Python packages are installed in
27-
``/usr/local/miniconda/lib/python3.6/site-packages``.
26+
The `fmriprep-docker`_ script simplifies this for the most common repositories::
2827

29-
To patch in working repositories of FMRIPREP or its dependencies, for instance
30-
contained in ``$HOME/projects/``, add the following arguments to your docker
31-
command: ::
28+
-f PATH, --patch-fmriprep PATH
29+
working fmriprep repository (default: None)
30+
-n PATH, --patch-niworkflows PATH
31+
working niworkflows repository (default: None)
32+
-p PATH, --patch-nipype PATH
33+
working nipype repository (default: None)
34+
35+
For instance, if your repositories are contained in ``$HOME/projects``::
36+
37+
$ fmriprep-docker -f $HOME/projects/fmriprep/fmriprep \
38+
-n $HOME/projects/niworkflows/niworkflows \
39+
-p $HOME/projects/nipype/nipype \
40+
-i poldracklab/fmriprep:latest \
41+
$HOME/fullds005 $HOME/dockerout participant
42+
43+
Note the ``-i`` flag allows you to specify an image.
44+
45+
When invoking ``docker`` directly, the mount options must be specified
46+
with the ``-v`` flag::
3247

3348
-v $HOME/projects/fmriprep/fmriprep:/usr/local/miniconda/lib/python3.6/site-packages/fmriprep:ro
3449
-v $HOME/projects/niworkflows/niworkflows:/usr/local/miniconda/lib/python3.6/site-packages/niworkflows:ro
@@ -41,8 +56,13 @@ For example, ::
4156
poldracklab/fmriprep:latest /data /out/out participant \
4257
-w /out/work/
4358

44-
In order to work directly in the container, use ``--entrypoint=bash``, and
45-
omit the fmriprep arguments: ::
59+
In order to work directly in the container, pass the ``--shell`` flag to
60+
``fmriprep-docker``::
61+
62+
$ fmriprep-docker --shell $HOME/fullds005 $HOME/dockerout participant
63+
64+
This is the equivalent of using ``--entrypoint=bash`` and omitting the fmriprep
65+
arguments in a ``docker`` command::
4666

4767
$ docker run --rm -v $HOME/fullds005:/data:ro -v $HOME/dockerout:/out \
4868
-v $HOME/projects/fmriprep/fmriprep:/usr/local/miniconda/lib/python3.6/site-packages/fmriprep:ro --entrypoint=bash \
@@ -97,3 +117,7 @@ repository, located in ``~/projects/fmriprep``: ::
97117

98118
To work in this image, replace ``poldracklab/fmriprep:latest`` with
99119
``fmriprep`` in any of the above commands.
120+
This image may be accessed by the `fmriprep-docker`_ wrapper via the
121+
``-i`` flag, e.g. ::
122+
123+
$ fmriprep-docker -i fmriprep --shell

docs/installation.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@ Make sure command-line `Docker is installed <https://docs.docker.com/engine/inst
1515

1616
See `External Dependencies`_ for more information (e.g., specific versions) on what is included in the fmriprep Docker image.
1717

18-
Now, assuming you have data, you can run fmriprep. You will need an active internet connection the first time. ::
18+
There are two ways to run fmriprep through Docker; the first, recommended way
19+
is to use the `fmriprep-docker`_ wrapper.
20+
This requires Python and an internet connection.
21+
22+
To install::
23+
24+
$ pip install --user --upgrade fmriprep-docker
25+
26+
To run::
27+
28+
$ fmriprep-docker /path/to/data/dir /path/to/output/dir participant
29+
30+
The second way to run fmriprep is to invoke ``docker`` directly. ::
1931

2032
$ docker run -ti --rm \
2133
-v filepath/to/data/dir:/data:ro \

docs/links.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
.. _`submillimeter reconstruction`: https://surfer.nmr.mgh.harvard.edu/fswiki/SubmillimeterRecon
99
.. _GIFTI: https://www.nitrc.org/projects/gifti/
1010
.. _`Connectome Workbench`: https://www.humanconnectome.org/software/connectome-workbench.html
11+
.. _`fmriprep-docker`: https://pypi.python.org/pypi/fmriprep-docker

fmriprep/info.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
__version__ = '99.99.99'
1010
__author__ = 'The CRN developers'
11-
__copyright__ = 'Copyright 2016, Center for Reproducible Neuroscience, Stanford University'
11+
__copyright__ = 'Copyright 2017, Center for Reproducible Neuroscience, Stanford University'
1212
__credits__ = ['Craig Moodie', 'Ross Blair', 'Oscar Esteban', 'Chris Gorgolewski', 'Shoshana Berleant',
13-
'Russell A. Poldrack']
13+
'Christopher J. Markiewicz', 'Russell A. Poldrack']
1414
__license__ = '3-clause BSD'
1515
__maintainer__ = 'Ross Blair'
1616
__email__ = '[email protected]'
@@ -24,6 +24,7 @@
2424
'https://pypi.python.org/packages/source/{name[0]}/{name}/{name}-{ver}.tar.gz'.format(
2525
name=__packagename__, ver=__version__))
2626

27+
2728
SETUP_REQUIRES = [
2829
'setuptools>=18.0',
2930
'numpy',
@@ -68,6 +69,6 @@
6869
'Intended Audience :: Science/Research',
6970
'Topic :: Scientific/Engineering :: Image Recognition',
7071
'License :: OSI Approved :: BSD License',
71-
'Programming Language :: Python :: 2.7',
7272
'Programming Language :: Python :: 3.5',
73+
'Programming Language :: Python :: 3.6',
7374
]

0 commit comments

Comments
 (0)