-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslurm_proc_7T_CUPS_step2.sh
192 lines (141 loc) · 10.6 KB
/
slurm_proc_7T_CUPS_step2.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
#!/bin/bash
#slurm_process_pipeline.sh
while getopts :p:s:z:m:f:l:b:t: option; do
case ${option} in
p) export CLEANPROJECT=$OPTARG ;;
s) export CLEANSESSION=$OPTARG ;;
z) export CLEANSUBJECT=$OPTARG ;;
m) export MINQC=$OPTARG ;;
f) export fieldmaps=$OPTARG ;;
l) export longitudinal=$OPTARG ;;
b) export based=$OPTARG ;;
t) export version=$OPTARG ;;
esac
done
## takes project, subject, and session as inputs
pilotdir=${based}/original_location_of_images_from_XNAT
IMAGEDIR=${based}/singularity_images
tmpdir=${based}/${version}/testing
scripts=${based}/${version}/scripts
bids_out=${based}/${version}/bids_only
conn_out=${based}/${version}/conn_out
dataqc=${based}/${version}/data_qc
stmpdir=${based}/${version}/scratch/stmp
scachedir=${based}/${version}/scratch/scache
cd $pilotdir
DIR=${CLEANPROJECT}/${CLEANSUBJECT}/${CLEANSESSION}
## setup our variables and change to the session directory
echo ${CLEANPROJECT}
echo ${CLEANSUBJECT}
echo ${CLEANSESSION}
pwd
#translating naming conventions
echo "${CLEANSESSION: -1}"
session="${CLEANSESSION: -1}"
echo ${session}
project=${CLEANPROJECT}
mkdir -p ${tmpdir}/${project}/${CLEANSUBJECT}/${session}
cp -R ${pilotdir}/${DIR} ${tmpdir}/${project}/${CLEANSUBJECT}/${session}
subject="sub-"${CLEANSUBJECT}
sesname="ses-"${session}
projDir=${tmpdir}/${project}
scripts=${based}/${version}/scripts
cd $projDir
IMAGEDIR=${based}/singularity_images
CACHESING=${scachedir}/${project}_${subject}_${sesname}_dcm2rsfc
TMPSING=${stmpdir}/${project}_${subject}_${sesname}_dcm2rsfc
mkdir $CACHESING
mkdir $TMPSING
chmod 777 -R $CACHESING
chmod 777 -R $TMPSING
ses=${sesname:4}
sub=${subject:4}
TEMPLATEFLOW_HOST_HOME=$IMAGEDIR/templateflow
export SINGULARITYENV_TEMPLATEFLOW_HOME="/templateflow"
NOW=$(date +"%m-%d-%Y-%T")
echo "fMRIPrep started $NOW" >> ${scripts}/fulltimer.txt
#fmriprep
echo "Running fmriprep on $subject $sesname"
${scripts}/project_doc.sh ${project} ${subject} ${sesname} "fmriprep" "no"
if [ "${longitudinal}" == "yes" ];
then
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity exec --cleanenv --bind ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME},$IMAGEDIR/license.txt:/opt/freesurfer/license.txt,$TMPSING:/paulscratch,${projDir}:/datain $IMAGEDIR/fmriprep-v22.0.1.sif fmriprep /datain/bids /datain/bids/derivatives/fmriprep participant --participant-label ${subject} --longitudinal --use-aroma --output-spaces {MNI152NLin2009cAsym:res-1,MNI152NLin2009cAsym:res-native,T1w:res-1,fsnative:res-1} -w /paulscratch --fs-license-file /opt/freesurfer/license.txt
elif [ "${longitudinal}" == "no" ];
then
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity exec --cleanenv --bind ${TEMPLATEFLOW_HOST_HOME}:${SINGULARITYENV_TEMPLATEFLOW_HOME},$IMAGEDIR/license.txt:/opt/freesurfer/license.txt,$TMPSING:/paulscratch,${projDir}:/datain $IMAGEDIR/fmriprep-v22.0.1.sif fmriprep /datain/bids /datain/bids/derivatives/fmriprep participant --participant-label ${subject} --output-spaces {MNI152NLin2009cAsym:res-1,T1w:res-1,fsnative} -w /paulscratch --ignore t2w --use-aroma --fs-license-file /opt/freesurfer/license.txt --skip_bids_validation
fi
NOW=$(date +"%m-%d-%Y-%T")
echo "fMRIPrep finished $NOW" >> ${scripts}/fulltimer.txt
chmod 2777 -R ${projDir}/bids/derivatives/fmriprep
mkdir -p ${projDir}/bids/derivatives/qatools/${subject}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv --bind ${projDir}/bids/derivatives:/datain,${IMAGEDIR}/license.txt:/opt/freesurfer/license.txt $IMAGEDIR/qatools-v1.2.sif --subjects_dir /datain/freesurfer --output_dir /datain/qatools/${subject} --subjects ${subject} --screenshots --screenshots-html --shape
#print html?
#copy freesurfer to fmriprep so xcpEngine can find it
mkdir ./fmriprep/freesurfer
cp -R ./sourcedata/freesurfer/fsaverage ./fmriprep/freesurfer/fsaverage
cp -R ./sourcedata/freesurfer/${subject} ./fmriprep/freesurfer/${subject}
chmod 2777 -R ${projDir}/bids/derivatives/fmriprep
cd ${projDir}
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p started $NOW" >> ${scripts}/fulltimer.txt
#generate xcpEngine cohorts for a new subject
${scripts}/func_cohort_maker.sh ${subject} ${sesname} yes
#xcpEngine 36p
$scripts/project_doc.sh ${project} ${subject} ${sesname} "xcpengine" "no"
cp ${scripts}/xcpEngineDesigns/*_gh.dsn ${projDir}/
cd ${projDir}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv -B ${projDir}:/data,$TMPSING:/tmpdir $IMAGEDIR/xcpengine-v1.2.4.sif -d /data/fc-36p_gh.dsn -c /data/cohort_func_${subject}_${sesname}.csv -o /data/bids/derivatives/xcp/${sesname}/xcp_minimal_func -r /data/bids -i /tmpdir
chmod 2777 -R ${projDir}/bids/derivatives/xcp*
mv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/*quality.csv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/${subject}_${sesname}_quality_fc36p.csv
${scripts}/procd.sh ${project} xcp no ${subject} ${based}
${scripts}/pdf_printer.sh ${project} ${subject} ${sesname} xcp36p ${based}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --bind ${scripts}/spm12:/spmtoolbox,${scripts}/matlab:/work,${scripts}/2019_03_03_BCT:/bctoolbox,${projDir}/bids/derivatives/xcp/${sesname}:/datain ${IMAGEDIR}/matlab-R2019a.sif /work/rsfcnbs.sh "xcp_minimal_func" "${subject}"
mkdir ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs
mkdir ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/fc36p
chmod 777 -R ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/fc36p
cp ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/*txt ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/fc36p/
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p finished $NOW" >> ${scripts}/fulltimer.txt
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p despike started $NOW" >> ${scripts}/fulltimer.txt
#xcpEngine 36p despike
$scripts/project_doc.sh ${project} ${subject} ${sesname} "xcpengine" "no"
cd ${projDir}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv -B ${projDir}:/data,$TMPSING:/tmpdir $IMAGEDIR/xcpengine-v1.2.4.sif -d /data/fc-36p_despike_gh.dsn -c /data/cohort_func_${subject}_${sesname}.csv -o /data/bids/derivatives/xcp/${sesname}/xcp_despike -r /data/bids -i /tmpdir
chmod 2777 -R ${projDir}/bids/derivatives/xcp*
mv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_despike/${subject}/*quality.csv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/${subject}_${sesname}_quality_despike.csv
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --bind ${scripts}/spm12:/spmtoolbox,${scripts}/matlab:/work,${scripts}/2019_03_03_BCT:/bctoolbox,${projDir}/bids/derivatives/xcp/${sesname}:/datain ${IMAGEDIR}/matlab-R2019a.sif /work/rsfcnbs.sh "xcp_despike" "${subject}"
mkdir ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/despike
chmod 777 -R ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/despike
cp ${projDir}/bids/derivatives/xcp/${sesname}/xcp_despike/${subject}/fcon/*txt ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/despike/
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p despike finished $NOW" >> ${scripts}/fulltimer.txt
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p_scrub started $NOW" >> ${scripts}/fulltimer.txt
#xcpEngine 36p_scrub
cd ${projDir}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv -B ${projDir}:/data,$TMPSING:/tmpdir $IMAGEDIR/xcpengine-v1.2.4.sif -d /data/fc-36p_scrub_gh.dsn -c /data/cohort_func_${subject}_${sesname}.csv -o /data/bids/derivatives/xcp/${sesname}/xcp_scrub -r /data/bids -i /tmpdir
mv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_scrub/${subject}/*quality.csv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/${subject}_${sesname}_quality_scrub.csv
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv --bind ${scripts}/spm12:/spmtoolbox,${scripts}/matlab:/work,${scripts}/2019_03_03_BCT:/bctoolbox,${projDir}/bids/derivatives/xcp/${sesname}:/datain ${IMAGEDIR}/matlab-R2019a.sif /work/rsfcnbs.sh "xcp_scrub" "${subject}"
mkdir ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/scrub
chmod 777 -R ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/scrub
cp ${projDir}/bids/derivatives/xcp/${sesname}/xcp_scrub/${subject}/fcon/*txt ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/nbs/scrub/
# rm ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_func/${subject}/fcon/*txt
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-36p_scrub finished $NOW" >> ${scripts}/fulltimer.txt
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-aroma started $NOW" >> ${scripts}/fulltimer.txt
#xcpEngine aroma
$scripts/project_doc.sh ${project} ${subject} ${sesname} "xcpengine" "no"
cd ${projDir}
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv -B ${projDir}:/data,$TMPSING:/tmpdir $IMAGEDIR/xcpengine-v1.2.4.sif -d /data/fc-aroma_gh.dsn -c /data/cohort_func_${subject}_${sesname}.csv -o /data/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma -r /data/bids -i /tmpdir
chmod 2777 -R ${projDir}/bids/derivatives/xcp*
mv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/*quality.csv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/${subject}_${sesname}_quality_aroma.csv
${scripts}/procd.sh $project xcp no ${subject} ${based}
cp ${scripts}/projdoc.css ${based}/batchproc/${project}/${project}_sample.css
NOW=$(date +"%m-%d-%Y-%T")
echo "xcpEngine fc-aroma finished $NOW" >> ${scripts}/fulltimer.txt
SINGULARITY_CACHEDIR=$CACHESING SINGULARITY_TMPDIR=$TMPSING singularity run --cleanenv --bind ${scripts}/spm12:/spmtoolbox,${scripts}/matlab:/work,${scripts}/2019_03_03_BCT:/bctoolbox,${projDir}/bids/derivatives/xcp/${sesname}:/datain ${IMAGEDIR}/matlab-R2019a.sif /work/rsfcnbs.sh "xcp_minimal_aroma" "${subject}"
mkdir ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/fcon/nbs
chmod 777 -R ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/fcon/nbs
mv ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/fcon/*txt ${projDir}/bids/derivatives/xcp/${sesname}/xcp_minimal_aroma/${subject}/fcon/nbs/