diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d08162a --- /dev/null +++ b/Dockerfile @@ -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 /structural-pipeline:latest ." +## +## Upload image to Docker Hub: +## - Log in with "docker login" if necessary +## - Push image using "docker push /structural-pipeline:latest" +## + +FROM ubuntu:xenial +MAINTAINER John Cupitt +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 + diff --git a/README.md b/README.md index 9c79beb..e020e2f 100755 --- a/README.md +++ b/README.md @@ -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 /structural-pipeline:latest . +``` + +Substituting `` for your username. This command must be run as root. + +This will create a single docker image called +`/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 ):$(id -g ) \ + /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 diff --git a/dhcp-pipeline.sh b/dhcp-pipeline.sh index 196ab0e..50255dc 100755 --- a/dhcp-pipeline.sh +++ b/dhcp-pipeline.sh @@ -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") @@ -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