-
Notifications
You must be signed in to change notification settings - Fork 0
/
pipeline_collate_ext.sh
277 lines (233 loc) · 18.9 KB
/
pipeline_collate_ext.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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
#!/bin/bash
#
# Single-subject pipeline output collating to labeled csv
#
# pipeline_collate.sh -p {project} -z {bidsname of subject} -s {bidsname of session} {base directory} {version} {email address for error messages (sent plaintext)}
#
# Paul Camacho
while getopts :p:s:z:b:t:e: option; do
case ${option} in
p) export project=$OPTARG ;;
s) export session=$OPTARG ;;
z) export subject=$OPTARG ;;
b) export based=$OPTARG ;;
t) export version=$OPTARG ;;
e) export address=$OPTARG ;;
esac
done
projDir=${based}/${version}/testing/${project}
mriqcDir=${projDir}/bids/derivatives/mriqc/${subject}/${session}
fmriprepDir=${projDir}/bids/derivatives/fmriprep/${subject}/${session}
xcpDir=${projDir}/bids/derivatives/xcp/${session}
qsiprepDir=${projDir}/bids/derivatives/qsiprep/${subject}/${session}/dwi
qsireconDir=${projDir}/bids/derivatives/qsicsd/${subject}/${session}/dwi
qsianDir=${projDir}/bids/derivatives/qsiamiconoddi/${subject}/${session}/dwi
qsigqiDir=${projDir}/bids/derivatives/qsigqi/${subject}/${session}/dwi
#dtiDir=${projDir}/bids/derivatives/dtipipeline/${subject}/${session}/Analyze/Tracking
#strucconDir=${projDir}/bids/derivatives/structconpipeline/ResStructConn/${subject}/${session}/Conn84
scriptsDir=${based}/${version}/scripts
outputDir=${based}/${version}/output/${project}/${subject}/${session}
NOW=`date +%d-%b-%Y`
if [ -d "$outputDir" ];
then
echo $outputDir
else
mkdir ${based}/${version}/output/${project}
mkdir ${based}/${version}/output/${project}/${subject}
mkdir $outputDir
chmod 777 -R ${based}/${version}/output/${project}
fi
#get all output files with metrics
echo "Gathering Outputs"
cd $outputDir
SINGCACHE=${based}/${version}/scratch/scache/${project}_${subject}_${session}
mkdir $SINGCACHE
SINGTMP=${based}/${version}/scratch/stmp/${project}_${subject}_${session}
mkdir $SINGTMP
IMAGEDIR=${based}/singularity_images
#mriqc
cp ${mriqcDir}/anat/*T1w.json ${outputDir}/mriqc_T1w.json
cp ${mriqcDir}/anat/*run-1*T2w.json ${outputDir}/mriqc_T2w.json
cp ${mriqcDir}/func/*rest*json ${outputDir}/mriqc_rest_bold.json
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}:/scripts ${IMAGEDIR}/ubuntu-jq-0.1.sif /scripts/mriqciqms.sh
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/mriqc_iqms_func_rest.csv /data/${subject}_mriqc_iqms_func_rest.csv
mv ${outputDir}/${subject}_mriqc_iqms_func_rest.csv ${outputDir}/mriqc_iqms_func_rest.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/mriqc_iqms_t1w.csv /data/${subject}_mriqc_iqms_t1w.csv
mv ${outputDir}/${subject}_mriqc_iqms_t1w.csv ${outputDir}/mriqc_iqms_t1w.csv
if [[ -f "${mriqcDir}/anat/*run-1*T2w.json" ]];
then
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/mriqc_iqms_t2w.csv /data/${subject}_mriqc_iqms_t2w.csv
mv ${outputDir}/${subject}_mriqc_iqms_t2w.csv ${outputDir}/mriqc_iqms_t2w.csv
fi
#get quality reports
#cp ${xcpDir}/xcp_minimal_func/${subject}/*quality.csv ${outputDir}/xcp_func_quality_orig.csv
cp ${xcpDir}/xcp_minimal_func/${subject}/*_quality_fc36p.csv ${outputDir}/xcp_func_quality_orig.csv
cp ${xcpDir}/xcp_minimal_func/${subject}/*_quality_despike.csv ${outputDir}/xcp_despike_quality_orig.csv
cp ${xcpDir}/xcp_minimal_func/${subject}/*_quality_scrub.csv ${outputDir}/xcp_scrub_quality_orig.csv
cp ${xcpDir}/xcp_minimal_aroma/${subject}/*quality_aroma.csv ${outputDir}/xcp_aroma_quality_orig.csv
cp ${xcpDir}/xcp_36p_nback/${subject}/*quality.csv ${outputDir}/xcp_fc36p_nback_quality_orig.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/xcp_func_quality_orig.csv /data/xcp_func_quality.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/xcp_despike_quality_orig.csv /data/xcp_despike_quality.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/xcp_scrub_quality_orig.csv /data/xcp_scrub_quality.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/xcp_aroma_quality_orig.csv /data/xcp_aroma_quality.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/xcp_fc36p_nback_quality_orig.csv /data/xcp_fc36p_nback_quality.csv
#nbs files
mkdir ${outputDir}/fc36p
mkdir ${outputDir}/despike
mkdir ${outputDir}/scrub
mkdir ${outputDir}/aroma
cp ${xcpDir}/xcp_36p_nback/${subject}/roiquant/aal116/${subject}_aal116_mean_zstat1_2back1back.csv ${outputDir}/${subject}_aal116_mean_zstat1_2back1back.csv
cp ${xcpDir}/xcp_36p_nback/${subject}/roiquant/desikanKilliany/${subject}_desikanKilliany_mean_zstat1_2back1back.csv ${outputDir}/${subject}_desikanKilliany_mean_zstat1_2back1back.csv
cp ${xcpDir}/xcp_36p_nback/${subject}/roiquant/power264/${subject}_power264_mean_zstat1_2back1back.csv ${outputDir}/${subject}_power264_mean_zstat1_2back1back.csv
chmod 777 -R ${outputDir}
if [[ `cat ${xcpDir}/xcp_minimal_func/${subject}/${subject}_logs/${subject}_audit.csv | grep "1,1,1,1,1,1,1,1,1,1"` ]];
then
echo ""
else
echo "XCPengine failure detected in ${subject}_audit.csv" > ${outputDir}/pipeline_error_log.txt
echo "Pipeline processing error detected in XCPengine for ${subject}. Check attached audit files for module failure point" | mail -a ${xcpDir}/xcp_minimal_func/${subject}/${subject}_logs/${subject}_audit.csv -s "Pipeline error detected in XCPengine audit for ${subject}" ${address}
fi
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/fc36p/*txt ${outputDir}/fc36p/
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/fc36p/${subject}_desikanKillianynbs_table.txt ${outputDir}/${subject}_desikanKillianynbs_table_fc36p.csv
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/fc36p/${subject}_power264nbs_table.txt ${outputDir}/${subject}_power264nbs_table_fc36p.csv
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/fc36p/${subject}_aal116nbs_table.txt ${outputDir}/${subject}_aal116nbs_table_fc36p.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_desikanKillianynbs_table_fc36p.csv /data/${subject}_${session}_desikanKillianynbs_table_fc36p.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_power264nbs_table_fc36p.csv /data/${subject}_${session}_power264nbs_table_fc36p.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_aal116nbs_table_fc36p.csv /data/${subject}_${session}_aal116nbs_table_fc36p.csv
if [[ `cat ${xcpDir}/xcp_despike/${subject}/${subject}_logs/${subject}_audit.csv | grep "1,1,1,1,1,1,1,1,1,1"` ]];
then
echo ""
else
echo "XCPengine failure detected in ${subject}_audit.csv" > ${outputDir}/pipeline_error_log.txt
echo "Pipeline processing error detected in XCPengine for ${subject}. Check attached audit files for module failure point" | mail -a ${xcpDir}/xcp_despike/${subject}/${subject}_logs/${subject}_audit.csv -s "Pipeline error detected in XCPengine audit for ${subject}" ${address}
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/despike/${subject}_desikanKillianynbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/despike/${subject}_power264nbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/despike/${subject}_aal116nbs_table.txt
fi
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/despike/*txt ${outputDir}/despike/
mv ${outputDir}/despike/${subject}_desikanKillianynbs_table.txt ${outputDir}/${subject}_desikanKillianynbs_table_despike.csv
mv ${outputDir}/despike/${subject}_power264nbs_table.txt ${outputDir}/${subject}_power264nbs_table_despike.csv
mv ${outputDir}/despike/${subject}_aal116nbs_table.txt ${outputDir}/${subject}_aal116nbs_table_despike.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_desikanKillianynbs_table_despike.csv /data/${subject}_${session}_desikanKillianynbs_table_despike.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_power264nbs_table_despike.csv /data/${subject}_${session}_power264nbs_table_despike.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_aal116nbs_table_despike.csv /data/${subject}_${session}_aal116nbs_table_despike.csv
if [[ `cat ${xcpDir}/*scrub/${subject}/${subject}_logs/*process | grep "total number of fixed regressors"` ]];
then
echo "Too many fixed regressors identified in XCPengine Power Scrub method, functional connectivity for this design unusable for ${subject}. Pipeline outputs csv will contain NA for respective measures" > ${outputDir}/pipeline_error_log.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_desikanKillianynbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_power264nbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_aal116nbs_table.txt
fi
if [[ `cat ${xcpDir}/xcp_scrub/${subject}/${subject}_logs/${subject}_audit.csv | grep "1,1,1,1,1,1,1,1,1,1"` ]];
then
echo ""
else
echo "XCPengine failure detected in ${subject}_audit.csv" > ${outputDir}/pipeline_error_log.txt
echo "Pipeline processing error detected in XCPengine for ${subject}. Check attached audit files for module failure point" | mail -a ${xcpDir}/xcp_scrub/${subject}/${subject}_logs/${subject}_audit.csv -s "Pipeline error detected in XCPengine audit for ${subject}" ${address}
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_desikanKillianynbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_power264nbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/scrub/${subject}_aal116nbs_table.txt
fi
cp ${xcpDir}/xcp_minimal_func/${subject}/fcon/nbs/scrub/*txt ${outputDir}/scrub/
mv ${outputDir}/scrub/${subject}_desikanKillianynbs_table.txt ${outputDir}/${subject}_desikanKillianynbs_table_scrub.csv
mv ${outputDir}/scrub/${subject}_power264nbs_table.txt ${outputDir}/${subject}_power264nbs_table_scrub.csv
mv ${outputDir}/scrub/${subject}_aal116nbs_table.txt ${outputDir}/${subject}_aal116nbs_table_scrub.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_desikanKillianynbs_table_scrub.csv /data/${subject}_${session}_desikanKillianynbs_table_scrub.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_power264nbs_table_scrub.csv /data/${subject}_${session}_power264nbs_table_scrub.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_aal116nbs_table_scrub.csv /data/${subject}_${session}_aal116nbs_table_scrub.csv
if [[ `cat ${xcpDir}/xcp_minimal_aroma/${subject}/${subject}_logs/${subject}_audit.csv | grep "1,1,1,1,1,1,1,1,1,1"` ]];
then
echo ""
else
echo "XCPengine failure detected in ${subject}_audit.csv" > ${outputDir}/pipeline_error_log.txt
echo "Pipeline processing error detected in XCPengine for ${subject}. Check attached audit files for module failure point" | mail -a ${xcpDir}/xcp_minimal_aroma/${subject}/${subject}_logs/${subject}_audit.csv -s "Pipeline error detected in XCPengine audit for ${subject}" ${address}
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/aroma/${subject}_desikanKillianynbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/aroma/${subject}_power264nbs_table.txt
cp ${scriptsDir}/null_files/null_rsfc_nbs_table.txt ${outputDir}/aroma/${subject}_aal116nbs_table.txt
fi
cp ${xcpDir}/xcp_minimal_aroma/${subject}/fcon/nbs/*txt ${outputDir}/aroma/
mv ${outputDir}/aroma/${subject}_desikanKillianynbs_table.txt ${outputDir}/${subject}_desikanKillianynbs_table_aroma.csv
mv ${outputDir}/aroma/${subject}_power264nbs_table.txt ${outputDir}/${subject}_power264nbs_table_aroma.csv
mv ${outputDir}/aroma/${subject}_aal116nbs_table.txt ${outputDir}/${subject}_aal116nbs_table_aroma.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_desikanKillianynbs_table_aroma.csv /data/${subject}_${session}_desikanKillianynbs_table_aroma.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_power264nbs_table_aroma.csv /data/${subject}_${session}_power264nbs_table_aroma.csv
SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/${subject}_aal116nbs_table_aroma.csv /data/${subject}_${session}_aal116nbs_table_aroma.csv
#if [ -d "${strucconDir}" ];
#then
# cp ${dtiDir}/${subject}_mridti_results.txt ${outputDir}/${subject}_mridti_results.csv
# cp ${strucconDir}/scfsl_nbs_${subject}.txt ${outputDir}/scfsl_nbs_${subject}.csv
# cp ${strucconDir}/${subject}_scfsl_nbs_rois.txt ${outputDir}/${subject}_scfsl_nbs_rois.csv
#
# SINGULARITY_CACHEDIR=$SINGCACHE SINGULARITY_TMPDIR=$SINGTMP singularity run --cleanenv -B ${outputDir}:/data,${scriptsDir}/pyscripts:/work ${IMAGEDIR}/python3.sif /work/dsn_tag.py /data/scfsl_nbs_${subject}.csv /data/scfsl_nbs_${subject}_${session}.csv
#else
# echo "no scfsl detected"
#fi
#sub-MBB005_ses-A_run-1_desc-ImageQC_dwi.csv
cp ${qsiprepDir}/${subject}_${session}_run-1_desc-ImageQC_dwi.csv ${outputDir}/${subject}_${session}_run-1_desc-ImageQC_dwi.csv
cp ${qsireconDir}/qsi_nbs_${subject}_aal116.txt ${outputDir}/${subject}_${session}_nbs_qsi_aal116.csv
cp ${qsireconDir}/qsi_nbs_${subject}_brainnetome246.txt ${outputDir}/${subject}_${session}_nbs_qsi_brainnetome246.csv
cp ${qsireconDir}/qsi_nbs_${subject}_power264.txt ${outputDir}/${subject}_${session}_nbs_qsi_power264.csv
# create csv and rename existing version
if [ -f "$outputDir/${subject}_${session}_pipeline_results.csv" ];
then
mv $outputDir/${subject}_${session}_pipeline_results.csv $outputDir/${subject}_${session}_pipeline_results_old.csv
else
touch $outputDir/${subject}_${session}_pipeline_results.csv
echo "date_processed" >> $outputDir/${subject}_${session}_pipeline_results.csv
echo $NOW >> $outputDir/${subject}_${session}_pipeline_results.csv
fi
#collate csv
echo "Collating single-subject csv"
cd $outputDir
if [ -f "${outputDir}/mriqc_iqms_t2w.csv" ];
then
paste -d, mriqc_iqms_t2w.csv mriqc_iqms_t1w.csv > tmp_anat.csv
paste -d, mriqc_iqms_func_rest.csv tmp_anat.csv > tmp1.csv
else
paste -d, mriqc_iqms_func_rest.csv mriqc_iqms_t1w.csv > tmp1.csv
fi
paste -d, tmp1.csv xcp_func_quality.csv > tmpfc36p.csv
paste -d, tmpfc36p.csv xcp_despike_quality.csv > tmpds.csv
paste -d, tmpds.csv xcp_scrub_quality.csv > tmp2.csv
paste -d, tmp2.csv xcp_aroma_quality.csv > tmp22.csv
paste -d, tmp22.csv xcp_fc36p_nback_quality.csv > tmp23.csv
paste -d, tmp23.csv ${subject}_aal116_mean_zstat1_2back1back.csv > tmpn1.csv
paste -d, tmpn1.csv ${subject}_desikanKilliany_mean_zstat1_2back1back.csv > tmpn2.csv
paste -d, tmpn2.csv ${subject}_power264_mean_zstat1_2back1back.csv > tmp3.csv
paste -d, tmp3.csv ${subject}_${session}_desikanKillianynbs_table_fc36p.csv > tmpnbs1.csv
paste -d, tmpnbs1.csv ${subject}_${session}_power264nbs_table_fc36p.csv > tmpnbs2.csv
paste -d, tmpnbs2.csv ${subject}_${session}_aal116nbs_table_fc36p.csv > tmpnbs3.csv
paste -d, tmpnbs3.csv ${subject}_${session}_desikanKillianynbs_table_despike.csv > tmpnbs4.csv
paste -d, tmpnbs4.csv ${subject}_${session}_power264nbs_table_despike.csv > tmpnbs5.csv
paste -d, tmpnbs5.csv ${subject}_${session}_aal116nbs_table_despike.csv > tmpnbs6.csv
paste -d, tmpnbs6.csv ${subject}_${session}_desikanKillianynbs_table_scrub.csv > tmpnbs7.csv
paste -d, tmpnbs7.csv ${subject}_${session}_power264nbs_table_scrub.csv > tmpnbs8.csv
paste -d, tmpnbs8.csv ${subject}_${session}_aal116nbs_table_scrub.csv > tmpnbs9.csv
paste -d, tmpnbs9.csv ${subject}_${session}_desikanKillianynbs_table_aroma.csv > tmpnbs10.csv
paste -d, tmpnbs10.csv ${subject}_${session}_power264nbs_table_aroma.csv > tmpnbs11.csv
paste -d, tmpnbs11.csv ${subject}_${session}_aal116nbs_table_aroma.csv > tmpnbs12.csv
if [ -d "${strucconDir}" ];
then
paste -d, tmpnbs12.csv ${subject}_mridti_results.txt > tmp10.csv
paste -d, tmp10.csv scfsl_nbs_${subject}_${session}.csv > tmpfinal.csv
elif [ -d "${qsiprepDir}" ];
then
paste -d, tmpnbs12.csv ${subject}_${session}_run-1_desc-ImageQC_dwi.csv > tmpnbs13.csv
paste -d, tmpnbs13.csv ${subject}_${session}_nbs_qsi_aal116.csv > tmpnbs14.csv
paste -d, tmpnbs14.csv ${subject}_${session}_nbs_qsi_brainnetome246.csv > tmpnbs15.csv
paste -d, tmpnbs15.csv ${subject}_${session}_nbs_qsi_power264.csv > tmpfinal.csv
else
mv tmpnbs12.csv tmpfinal.csv
fi
ses=${session:4}
sub=${subject:4}
echo "datetime" > tmp_date.csv
echo `cat ${projDir}/${sub}/${ses}/*/*/99/DICOM/scan_99_catalog.xml | grep -m 1 -o 'Time=".*" d' | cut -c 7- | rev | cut -c 4- | rev | sed 's/:/./g' | sed 's/-/./g'` >> tmp_date.csv
paste -d, tmpfinal.csv tmp_date.csv > tmpfinaldate.csv
mv tmpfinaldate.csv ${subject}_${session}_pipeline_results.csv
rm tmp*.csv
rm -R $SINGCACHE
rm -R $SINGTMP
echo "Finished collating"
echo "See ${outputDir} for results csv"
echo "See ${based}/${version}/data_qc for visual quality control reports"