-
Notifications
You must be signed in to change notification settings - Fork 6
/
setup_gadgetron_local.sh
203 lines (164 loc) · 7.78 KB
/
setup_gadgetron_local.sh
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/sh
# Usage info
show_help() {
cat << EOF
Usage: ${0##*/} [-hm] [-c CXX_FLAGS] [-b Branch name]...
Set up gadgetron with debug flags.
-h display this help and exit
-m Compile with memory leakage checking
-c Compile with cxx flags
-b The branch to work with
-g Generator ("Unix Makefiles" or "Eclipse CDT4 - Unix Makefiles")
-t Build type (Release, Debug, RelWithDebugInfo)
-r Remove all folders before setting up
-s Suffix for build folder, e.g. "_eclipse"
-w Gadgetron working directory, default it is "~"
-m -b master -g "Unix Makefiles" -t Debug -r
EOF
}
# A POSIX variable
OPTIND=1 # Reset in case getopts has been used previously in the shell.
# Initialize our own variables:
BRANCHNAME=master
CXX_FLAGS=
# Generator
GENERATOR="Unix Makefiles"
BUILD_TYPE=Release
remove_flag=0
suffix=
export GT_WORKING_DIR=/home/${USER}
export GADGETRON_HOME=~/local
export ISMRMRD_HOME=~/local
export PATH=$PATH:$GADGETRON_HOME/bin:$ISMRMRD_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ISMRMRD_HOME/lib:$GADGETRON_HOME/lib
while getopts "h?c:mb:g:t:rs:w:" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
c) CXX_FLAGS=$OPTARG
;;
m) CXX_FLAGS="-fsanitize=leak -fPIC"
;;
b) BRANCHNAME=$OPTARG
;;
g) GENERATOR=$OPTARG
;;
t) BUILD_TYPE=$OPTARG
;;
r) remove_flag=1
;;
s) suffix=$OPTARG
;;
w) GT_WORKING_DIR=$OPTARG
;;
esac
done
shift $((OPTIND-1))
[ "${1:-}" = "--" ] && shift
echo "GT_WORKING_DIR=$GT_WORKING_DIR, BRANCHNAME=$BRANCHNAME, CXX_FLAGS='$CXX_FLAGS', GENERATOR='$GENERATOR', BUILD_TYPE='$BUILD_TYPE', remove_flag='$remove_flag', suffix='$suffix' "
export GT_INSTALL_DIR=${GT_WORKING_DIR}/local
gcc_v=$(gcc -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$/&00/')
echo "gcc version is ${gcc_v}"
if [ $gcc_v -gt 6 ]
then
NVCC_FLAG="'-ccbin gcc-6'"
else
NVCC_FLAG=""
fi
echo "NVCC_FLAG is ${NVCC_FLAG}"
# --------------------------------------------------------------------------------------------
# github
ISMRMRD_REPO=https://github.com/ismrmrd/ismrmrd.git
ISMRMRD_BRANCH=${BRANCHNAME}
GT_REPO=https://github.com/gadgetron/gadgetron.git
GT_BRANCH=${BRANCHNAME}
GT_CONVERTER_REPO=https://github.com/ismrmrd/siemens_to_ismrmrd.git
GT_CONVERTER_BRANCH=${BRANCHNAME}
ISMRMRD_PYTHON_API_REPO=https://github.com/ismrmrd/ismrmrd-python.git
ISMRMRD_PYTHON_API_BRANCH=${BRANCHNAME}
ISMRMRD_PYTHON_TOOLS_REPO=https://github.com/ismrmrd/ismrmrd-python-tools.git
ISMRMRD_PYTHON_TOOLS_BRANCH=${BRANCHNAME}
# ----------------------------------------------------------------------------------------------------------
# clean the installation
# ----------------------------------------------------------------------------------------------------------
if [ "$remove_flag" -eq "1" ]; then
rm -R -f ${GT_WORKING_DIR}/local
mkdir ${GT_WORKING_DIR}/local
fi
# ----------------------------------------------------------------------------------------------------------
# ismrmrd
# ----------------------------------------------------------------------------------------------------------
if [ "$remove_flag" -eq "1" ]; then
rm -R -f ${GT_WORKING_DIR}/mrprogs/ismrmrd
cd ${GT_WORKING_DIR}/mrprogs
git clone ${ISMRMRD_REPO} ${GT_WORKING_DIR}/mrprogs/ismrmrd
cd ${GT_WORKING_DIR}/mrprogs/ismrmrd
git checkout -b ${ISMRMRD_BRANCH} origin/${ISMRMRD_BRANCH}
rm -R -f ${GT_WORKING_DIR}/mrprogs/build_ismrmrd_${BUILD_TYPE}${suffix}
cd ${GT_WORKING_DIR}/mrprogs
mkdir build_ismrmrd_${BUILD_TYPE}${suffix}
fi
cd ${GT_WORKING_DIR}/mrprogs/build_ismrmrd_${BUILD_TYPE}${suffix}
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX=${GT_INSTALL_DIR} -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DJava_JAVAC_EXECUTABLE= -DJava_JAVA_EXECUTABLE= -DJAVA_INCLUDE_PATH= ../ismrmrd
make -j $(nproc)
make install
# ----------------------------------------------------------------------------------------------------------
# gadgetron
# ----------------------------------------------------------------------------------------------------------
if [ "$remove_flag" -eq "1" ]; then
rm -R -f ${GT_WORKING_DIR}/mrprogs/gadgetron
cd ${GT_WORKING_DIR}/mrprogs
git clone ${GT_REPO} ${GT_WORKING_DIR}/mrprogs/gadgetron
cd ${GT_WORKING_DIR}/mrprogs/gadgetron
git checkout -b ${GT_BRANCH}
rm -R -f ${GT_WORKING_DIR}/mrprogs/build_gadgetron_${BUILD_TYPE}${suffix}
cd ${GT_WORKING_DIR}/mrprogs
mkdir build_gadgetron_${BUILD_TYPE}${suffix}
fi
cd ${GT_WORKING_DIR}/mrprogs/build_gadgetron_${BUILD_TYPE}${suffix}
if [ $gcc_v -gt 6 ]
then
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX=${GT_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DISMRMRD_INCLUDE_DIR=${GT_INSTALL_DIR}/include -DISMRMRD_LIBRARY=${GT_INSTALL_DIR}/lib/libismrmrd.so -DISMRMRD_LIB_DIR=${GT_INSTALL_DIR}/lib -DISMRMRD_SCHEMA_DIR=${GT_INSTALL_DIR}/share/ismrmrd/schema -DCUDA_NVCC_FLAGS="-ccbin gcc-6" -DCMAKE_CXX_FLAGS=${CXX_FLAGS} -DBUILD_WITH_PYTHON3=ON -DUSE_MKL=ON ../gadgetron
else
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX=${GT_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DISMRMRD_INCLUDE_DIR=${GT_INSTALL_DIR}/include -DISMRMRD_LIBRARY=${GT_INSTALL_DIR}/lib/libismrmrd.so -DISMRMRD_LIB_DIR=${GT_INSTALL_DIR}/lib -DISMRMRD_SCHEMA_DIR=${GT_INSTALL_DIR}/share/ismrmrd/schema -DBUILD_WITH_PYTHON3=ON -DUSE_MKL=ON -DCMAKE_CXX_FLAGS=${CXX_FLAGS} ../gadgetron
fi
make -j $(nproc)
make install
# ----------------------------------------------------------------------------------------------------------
#ISMRMRD PYTHON API
# ----------------------------------------------------------------------------------------------------------
cd ${GT_WORKING_DIR}/mrprogs
git clone ${ISMRMRD_PYTHON_API_REPO}
cd ismrmrd-python
sudo python3 setup.py install
# ----------------------------------------------------------------------------------------------------------
#ISMRMRD PYTHON TOOLS
# ----------------------------------------------------------------------------------------------------------
cd ${GT_WORKING_DIR}/mrprogs
git clone ${ISMRMRD_PYTHON_TOOLS_REPO}
cd ismrmrd-python-tools
sudo python3 setup.py install
# ----------------------------------------------------------------------------------------------------------
# siemens_to_ismrmrd
# ----------------------------------------------------------------------------------------------------------
if [ "$remove_flag" -eq "1" ]; then
rm -R -f ${GT_WORKING_DIR}/mrprogs/siemens_to_ismrmrd
cd ${GT_WORKING_DIR}/mrprogs
git clone ${GT_CONVERTER_REPO} ${GT_WORKING_DIR}/mrprogs/siemens_to_ismrmrd
cd ${GT_WORKING_DIR}/mrprogs/siemens_to_ismrmrd
git checkout -b ${GT_CONVERTER_BRANCH} origin/${GT_CONVERTER_BRANCH}
rm -R -f ${GT_WORKING_DIR}/mrprogs/build_siemens_to_ismrmrd_${BUILD_TYPE}${suffix}
cd ${GT_WORKING_DIR}/mrprogs
mkdir build_siemens_to_ismrmrd_${BUILD_TYPE}${suffix}
fi
cd ${GT_WORKING_DIR}/mrprogs/build_siemens_to_ismrmrd_${BUILD_TYPE}${suffix}
cmake -G "${GENERATOR}" -DCMAKE_INSTALL_PREFIX=${GT_INSTALL_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DISMRMRD_INCLUDE_DIR=${GT_INSTALL_DIR}/include -DISMRMRD_LIBRARY=${GT_INSTALL_DIR}/lib/libismrmrd.so -DISMRMRD_LIB_DIR=${GT_INSTALL_DIR}/lib -DISMRMRD_SCHEMA_DIR=${GT_INSTALL_DIR}/share/ismrmrd/schema ../siemens_to_ismrmrd
make -j $(nproc)
make install
# ----------------------------------------------------------------------------------------------------------
# make gt ready
# ----------------------------------------------------------------------------------------------------------
cp -f ${GT_INSTALL_DIR}/share/gadgetron/config/gadgetron.xml.example ${GT_INSTALL_DIR}/share/gadgetron/config/gadgetron.xml
mkdir ${GT_INSTALL_DIR}/DebugOutput