Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a Dockerfile #3

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Build Docker image for execution of dhcp pipelines within a Docker
## container with all modules and applications available in the image
##
## How to build the image:
## - Change to top-level directory of structural-pipeline source tree
## - Run "docker build --build-arg VCS_REF=`git rev-parse --short HEAD` -t <user>/structural-pipeline:latest ."
##
## Upload image to Docker Hub:
## - Log in with "docker login" if necessary
## - Push image using "docker push <user>/structural-pipeline:latest"
##

FROM ubuntu:xenial
MAINTAINER John Cupitt <[email protected]>
LABEL Description="dHCP structural-pipeline" Vendor="BioMedIA"

# Git repository and commit SHA from which this Docker image was built
# (see https://microbadger.com/#/labels)
ARG VCS_REF
LABEL org.label-schema.vcs-ref=$VCS_REF \
org.label-schema.vcs-url="https://github.com/DevelopingHCP/structural-pipeline"

# No. of threads to use for build (--build-arg THREADS=8)
# By default, all available CPUs are used. When a Docker Machine is used,
# set the number of CPUs in the VirtualBox VM Settings.
ARG THREADS

# install prerequsites
# - FSL
# - build tools

RUN apt-get update
RUN apt-get install -y apt-utils wget
RUN wget -O- http://neuro.debian.net/lists/artful.de-m.full | tee /etc/apt/sources.list.d/neurodebian.sources.list
RUN apt-key adv --recv-keys --keyserver hkp://pool.sks-keyservers.net:80 0xA5D32F012649A5A9
RUN apt-get update
RUN apt-get install -y \
fsl-complete \
g++-5 git cmake unzip bc python python-contextlib2 \
libtbb-dev libboost-dev zlib1g-dev libxt-dev libexpat1-dev \
libgstreamer1.0-dev libqt4-dev

COPY . /usr/src/structural-pipeline
RUN ls /usr/src/structural-pipeline \
&& NUM_CPUS=${THREADS:-`cat /proc/cpuinfo | grep processor | wc -l`} \
&& echo "Maximum number of build threads = $NUM_CPUS" \
&& cd /usr/src/structural-pipeline \
&& ./setup.sh -j $NUM_CPUS

50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,56 @@ A. Makropoulos and E. C. Robinson et al. "The Developing Human Connectome Projec
## License
The dHCP structural pipeline is distributed under the terms outlined in LICENSE.txt

## Install and run with docker
You can build the pipeline in a docker container. This will work on any
version of any platform, is automated, and fairly simple. First, install
docker:

https://docs.docker.com/engine/installation/

Then in the top directory of `structural-pipeline`, use git to switch to the
branch you want to build, and enter:

```
# docker build -t <user>/structural-pipeline:latest .
```

Substituting `<user>` for your username. This command must be run as root.

This will create a single docker image called
`<user>/structural-pipeline:latest` containing all the required files
and all required dependencies.

You can then execute the pipeline like this (for example):

```
# docker run --rm -t -v $PWD/data:/data \
-u $(id -u <user>):$(id -g <user>) \
<user>/structural-pipeline:latest \
bash -c ". /etc/fsl/fsl.sh; \
cd /usr/src/structural-pipeline; \
./dhcp-pipeline.sh subject1 session1 44 \
-d /data -T2 /data/sub-CC00183XX11_ses-60300_T2w.nii.gz -t 8"
```

Again, this must be run as root. This will mount the subdirectory `data` of
your current directory as `/data` in the container, then execute the pipeline
on the file `sub-CC00183XX11_ses-60300_T2w.nii.gz`. The output files will be
written to the `data` subdirectory.

## Run interactively
Handy for debugging:

```
# sudo docker run \
-v /home/john/pics/dhcp/data:/data \
-it john/structural-pipeline:latest /bin/bash
```

## Install locally
If you want to work on the code of the pipeline, it can be more convenient to
install locally to your machine. Only read on if you need to do a local
install.

## Dependencies
#### 1. FSL
Expand Down
6 changes: 5 additions & 1 deletion dhcp-pipeline.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# fsl prefix ... this was blank for fsl4, but fsl5+ have a versioned command
# prefix
fslprefix=fsl5.0-

usage()
{
base=$(basename "$0")
Expand Down Expand Up @@ -130,7 +134,7 @@ for modality in T1 T2;do
if [ $noreorient -eq 1 ];then
cp $mf $newf
else
fslreorient2std $mf $newf
${fslprefix}fslreorient2std $mf $newf
fi
eval "$modality=$newf"
done
Expand Down