-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSingularity.pnlpipe
139 lines (131 loc) · 4.86 KB
/
Singularity.pnlpipe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Bootstrap: docker
From: centos:7.5.1804
%labels
MAINTAINER Tashrif Billah <tbillah@bwh.harvard.edu>
%help
For running container
- https://github.com/pnlbwh/pnlpipe-containers
For pipeline basics
- https://github.com/pnlbwh/pnlNipype
- https://github.com/pnlbwh/pnlpipe
Please report issues on GitHub.
%post
#
# set up user and working directory
mkdir /home/pnlbwh
cd /home/pnlbwh
export HOME=`pwd`
#
# install required libraries
yum -y groupinstall 'development tools'
yum -y install tree wget file bzip2 which vim git make libstdc++-static mesa-libGL bc tcsh libSM libXt-devel \
psmisc
yum clean all
rm -rf /var/cache/yum
#
# install freesurfer
echo "Downloading FreeSurfer"
wget https://surfer.nmr.mgh.harvard.edu/pub/dist/freesurfer/7.1.0/freesurfer-linux-centos7_x86_64-7.1.0.tar.gz > /dev/null 2>&1
echo "Unzipping FreeSurfer tar ball"
tar -xzf freesurfer-linux-centos7_x86_64-7.1.0.tar.gz
rm -f freesurfer-linux-centos7_x86_64-7.1.0.tar.gz
mv freesurfer freesurfer-7.1.0
#
# install MCR for -subfields
cd freesurfer-7.1.0
curl "https://surfer.nmr.mgh.harvard.edu/fswiki/MatlabRuntime?action=AttachFile&do=get&target=runtime2014bLinux.tar.gz" -o "runtime2014b.tar.gz"
tar -xzf runtime2014b.tar.gz && rm -f runtime2014b.tar.gz
cd ..
#
# install FSL
echo "Downloading FSL installer"
wget https://fsl.fmrib.ox.ac.uk/fsldownloads/fslinstaller.py -O fslinstaller.py > /dev/null 2>&1
echo "Installing FSL"
python fslinstaller.py -V 6.0.1 -d $HOME/fsl-6.0.1 -p > /dev/null 2>&1
# setup FSL environment
export FSLDIR=$HOME/fsl-6.0.1
source $FSLDIR/etc/fslconf/fsl.sh
$FSLDIR/fslpython/bin/conda clean -y --all
rm -f fslinstaller.py
#
# clone pnlpipe repositories
git clone --recurse-submodules https://github.com/pnlbwh/pnlpipe.git
git clone https://github.com/pnlbwh/pnlNipype.git
git clone https://github.com/pnlbwh/luigi-pnlpipe.git
#
# install CNN-Diffusion-MRIBrain-Segmentation
git clone https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation.git
cd CNN-Diffusion-MRIBrain-Segmentation
wget https://github.com/pnlbwh/CNN-Diffusion-MRIBrain-Segmentation/releases/download/v0.3/model_folder.tar.gz
tar -xzvf model_folder.tar.gz
cd ..
#
# install miniconda3
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O Miniconda3-latest-Linux-x86_64.sh
/bin/bash Miniconda3-latest-Linux-x86_64.sh -b -p miniconda3/
#
# initialize .bashrc
cp /root/.bashrc $HOME/
#
# create conda env
source miniconda3/bin/activate
conda env create -f pnlpipe/python_env/environment36.yml
conda activate pnlpipe3
export FREESURFER_HOME=$HOME/freesurfer-7.1.0
#
# build pnlpipe dependencies
cd pnlpipe && mkdir soft_dir && export PNLPIPE_SOFT=$HOME/pnlpipe/soft_dir
./pnlpipe std init
./pnlpipe std setup
#
# clean up sources
conda deactivate
conda clean -y --all
rm -rf $HOME/Miniconda3-latest-Linux-x86_64.sh .cache/pip/*
cd soft_dir
rm -rf BRAINSTools BRAINSTools-build ANTs ANTs-build ANTs-bin-*/CMakeFiles ukftractography UKFTractography-build dcm2niix
rm -rf /tmp/* /var/tmp/*
#
# remove problematic aliases
sed -i "s/alias mv='mv -i'//g" ~/.bashrc
sed -i "s/alias cp='cp -i'//g" ~/.bashrc
sed -i "s/alias rm='rm -i'//g" ~/.bashrc
#
# facilitate creation of ~/matlab/startup.m
export FREESURFER_HOME=$HOME/freesurfer-7.1.0
source ${FREESURFER_HOME}/SetUpFreeSurfer.sh
#
# provide write permissions
chmod a+w $HOME
chmod -R a+w $HOME/luigi-pnlpipe
chmod -R a+w $HOME/pnlpipe
%environment
#
# set up bashrc i.e shell
export HOME=/home/pnlbwh/
export USER=`whoami`
export LANG=en_US.UTF-8
#
# miniconda3 pnlpipe3
export CONDA_SHLVL=2
export CONDA_PROMPT_MODIFIER=(pnlpipe3)
export CONDA_EXE=/home/pnlbwh/miniconda3/bin/conda
export _CE_CONDA=
export CONDA_PREFIX_1=/home/pnlbwh/miniconda3
export CONDA_PREFIX=/home/pnlbwh/miniconda3/envs/pnlpipe3
export CONDA_PYTHON_EXE=/home/pnlbwh/miniconda3/bin/python
export CONDA_DEFAULT_ENV=pnlpipe3
export PATH=/home/pnlbwh/miniconda3/envs/pnlpipe3/bin:/home/pnlbwh/miniconda3/condabin:$PATH
#
# pnlpipe software
export PNLPIPE_SOFT=$HOME/pnlpipe/soft_dir
cd $PNLPIPE_SOFT
for d in `find . -name env.sh`; do source ${PNLPIPE_SOFT}/$d; done
cd $HOME
export FSLDIR=$HOME/fsl-6.0.1
source $FSLDIR/etc/fslconf/fsl.sh
export PATH=$FSLDIR/bin:$PATH
export FREESURFER_HOME=$HOME/freesurfer-7.1.0
source ${FREESURFER_HOME}/SetUpFreeSurfer.sh
export PATH=$HOME/pnlNipype/scripts:$HOME/pnlNipype/exec:$HOME/CNN-Diffusion-MRIBrain-Segmentation/pipeline:$PATH
export PYTHONPATH=$HOME/luigi-pnlpipe:$PYTHONPATH