-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspinoza_setup
213 lines (182 loc) · 7.5 KB
/
spinoza_setup
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
203
204
205
206
207
208
209
210
211
212
213
#!/usr/bin/env bash
export SETUP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
export SETUP_FILE="${SETUP_DIR}/spinoza_setup" # copy to some location
export REPO_DIR=$(dirname ${SETUP_DIR}) # point to linescanning repo (arbitrary)
export PATH_HOME=$(dirname ${REPO_DIR}) # point to folder for temp/logs files
# source helper functions
source ${REPO_DIR}/bin/call_bashhelper
if [[ $1 == "setup" ]]; then
echo "==================================================================================================="
echo " SETUP SCRIPT FOR LINE SCANNING REPOSITORY "
echo "==================================================================================================="
echo "Setting up ~/.bash_profile"
# ignore permission changes in git
git config core.fileMode false 2>/dev/null
# make scripts executable
chmod -R 2775 ${REPO_DIR}/bin 2>/dev/null
chmod -R 2775 ${REPO_DIR}/shell 2>/dev/null
# source call_bashhelper
source ${REPO_DIR}/bin/call_bashhelper
if [ -f ~/.bash_profile ]; then
search_for="source ${SETUP_FILE}"
case `grep -Fx "${search_for}" ~/.bash_profile >/dev/null; echo $?` in
0)
# code if found
# echo "Line already present"
;;
1)
# code if not found
(
echo
echo "# Inserted via the linescanning-repository"
echo "source ${SETUP_FILE}"
) >> ~/.bash_profile
;;
*)
# code if an error occurred
echo "ERROR: Could not complete setup.."
;;
esac
else
(
echo "# .bash_profile"
echo "# Inserted via the linescanning-repository"
echo "source ${SETUP_FILE}"
) >> ~/.bash_profile
fi
# check itksnap installation
check_itksnap=`check_function itksnap`
if [[ ${check_itksnap} -eq 1 ]]; then
echo "Please install ITK-Snap here: \"https://sourceforge.net/projects/itk-snap/files/itk-snap/3.8.0\""
else
echo "Found ITK-Snap installation: `which itksnap`"
fi
# activate conda environment
ACTIVATE_CONDA=0
# mamba is faster; check if we can use it
check_mamba=`check_function mamba`
cmd="conda"
if [[ ${check_mamba} -eq 0 ]]; then
cmd="mamba"
fi
if [[ ${ACTIVATE_CONDA} -eq 1 ]]; then
echo
echo "---------------------------------------------------------------------------------------------------"
echo "Dealing with conda environment"
env_name="ls"
if [[ -z `conda info --envs | grep ${env_name}` ]]; then
${cmd} env create --file ${REPO_DIR}/environment.yml --prefix=~/.conda/envs/${env_name}
if [[ $? -ne 0 ]]; then
echo "ERROR: conda install from environment.yml file did not complete"
exit 1
fi
else
echo "WARNING: conda environment \"${env_name}\" already exists. Edit \"env_name\" in setup file and rerun"
exit 1
fi
conda activate ${env_name}
fi
# setup python packages
declare -a INSTALL_PACKAGES=("pRFpy" "Nideconv" "Pymp2rage" "Pybest" "Hedfpy" "Pycortex" "linescanning")
echo
echo "---------------------------------------------------------------------------------------------------"
echo "Checking installation of [${INSTALL_PACKAGES[@]}]"
cd ${PATH_HOME}
for package in ${INSTALL_PACKAGES[@]}; do
check=`pip list | grep -F ${package,,}`
if [[ -z ${check} ]]; then
echo "INSTALLING: ${package}.."
if [ ! -d ${PATH_HOME}/${package,,} ]; then
PACKAGE_LINK=`cat ${REPO_DIR}/doc/source/links.rst | grep ${package,,} | cut -d' ' -f3`
git clone ${PACKAGE_LINK}
fi
cd ${PATH_HOME}/${package,,}
python setup.py develop
cd ..
else
echo "Found ${package} installation"
fi
done
# scipy get installed by pip again, so uninstall and let mamba/conda sort it out
pip uninstall scipy -y
${cmd} install -c conda-forge scipy -y
# done
echo "Done. Now enter: \"source ~/.bash_profile\""
fi
#===================================================================================================
# VARIABLES
#===================================================================================================
# If you have access to SGE, leave to SGE; otherwise change to e.g., LOCAL
export PLACE="SGE"
export SGE_QUEUE_LONG="long.q@jupiter"
export SGE_QUEUE_SHORT="short.q@jupiter"
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export OPENBLAS_NUM_THREADS=1
# MATLAB
export MRRECON=/packages/matlab/toolbox/MRecon/3.0.541
export MATLAB_CMD="matlab -nosplash -nodisplay -batch" # find with 'which matlab'
export SPM_PATH=${PATH_HOME}/spm12
export SKIP_LINES=34
# fMRIPREP
export MRIQC_SIMG=/packages/singularity_containers/containers_bids-mriqc--23.0.1.simg
export FPREP_SIMG=/packages/singularity_containers/containers_bids-fmriprep--20.2.5.simg
export FPREP_OUT_SPACES="fsnative func"
export FPREP_BINDING="/data1/projects" # binding directory for singularity image
export CIFTI="" # leave empty if you don't want cifti output
export DO_SYN=0 # set to zero if you do not want additional syn-distortion correction
export BOLD_T1W_INIT="register" # default = register; for partial FOV, set to 'header'
export FS_LICENSE=${REPO_DIR}/misc/license.txt # this thing needs to be along the FPREP_BINDING path!
# PYBEST
export PYBEST_SPACE="fsnative"
export PYBEST_N_COMPS=10
# PROJECT
export DIR_PROJECTS="/data1/projects/MicroFunc/Jurjen/projects"
export PROJECT="motor"
export TASK_SES1=("clench")
export TASK_SES2="LR"
export SUBJECT_PREFIX="sub-"
export COMBINE_SEGMENTATIONS="weighted"
# DATA TYPE(S)
export ACQ=("MP2RAGE") # or ("MP2RAGE" "MP2RAGEME")
export DATA=${ACQ[0]} # or MP2RAGEME/AVERAGE
# phase encoding direction for BOLD; assume inverse for FMAP
export PE_DIR_BOLD="AP"
# For DATA == AVERAGE we'll need multiple acquisitions
if [[ ${DATA} == "AVERAGE" ]]; then
if [[ `echo ${#ACQ[@]}` -ne 2 ]]; then
echo "Average of what..? \"ACQ\" variable in spinoza_setup has ${#ACQ[@]} item(s) [\"${ACQ[@]}\"]"
exit 1
fi
fi
#===================================================================================================
# PATHS
#===================================================================================================
export DIR_SCRIPTS=${REPO_DIR}
export DIR_DATA_HOME=${DIR_PROJECTS}/${PROJECT}
export DIR_LOGS=${DIR_DATA_HOME}/code/logs
export DIR_DATA_SOURCE=${DIR_DATA_HOME}/sourcedata
export DIR_DATA_DERIV=${DIR_DATA_HOME}/derivatives
export DIR_DATA_ATLAS=${PATH_HOME}/atlas/MICCAI2012-Multi-Atlas-Challenge-Data
export SOURCEDATA=${DIR_DATA_HOME}
export DERIVATIVES=${DIR_DATA_DERIV}
export MASKS=${DIR_DATA_DERIV}/manual_masks
export ANTS=${DIR_DATA_DERIV}/ants
export FS=${DIR_DATA_DERIV}/freesurfer
export SUBJECTS_DIR=${FS}
export ANTS=${DIR_DATA_DERIV}/ants
export AVG=${DIR_DATA_DERIV}/average
export MASKED_AVG=${DIR_DATA_DERIV}/masked_average
export PYMP2RAGE=${DIR_DATA_DERIV}/pymp2rage
export NIGHRES=${DIR_DATA_DERIV}/nighres
export FSL=${DIR_DATA_DERIV}/fsl
export SKULLSTRIP=${DIR_DATA_DERIV}/skullstripped
export CTX=${DIR_DATA_DERIV}/pycortex
export PRF=${DIR_DATA_DERIV}/prf
# Make executables available in environment
export PATH=${PATH}:${DIR_SCRIPTS}/bin
export PATH=${PATH}:${DIR_SCRIPTS}/shell
# set SSH_KEY for start_ssh
export SSH_KEY="${HOME}/.ssh/hp_windows"
# source bash helper functions
source call_bashhelper