-
Notifications
You must be signed in to change notification settings - Fork 0
/
MCA_Pain_Motion_Outliers.sh
61 lines (43 loc) · 2.8 KB
/
MCA_Pain_Motion_Outliers.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
#!/bin/bash
## Run from MCA study "Data" folder, after MRIcroGL dicom to .nii.gz conversion, Fieldmap correction and Brain Extraction; req's file = datain.txt (contains param's)
# NOTE: Move any and all prior data to a backup folder before running this script, as it will overwrite any existing files with the same name to avoid reddundancy
# NOTE: fdrms.txt and mp-confoundsMtx.txt files are saved to mp_beforescrubbing folder before running scrubbed.nii.gz data
#fsl_motion_outliers : runs motion calculations; Does Motion Correction (or not, usually with --nomoco for using MCFLIRT before/after via GUI; if using framewise displacement as the metric, have motion correction ON), finds Outliers, and creates Confound Matrix for GLM in First Level Preprocessing
#Reference: https://fsl.fmrib.ox.ac.uk/fsl/fslwiki/FSLMotionOutliers
#############################################################################
date
echo Starting Motion Calcs...
DATADIR=$PWD
# for individual runs, use the following:
# Subj=76
# Ses=2
# Task=2
#############################################################################
for Subj in {7..116}
do
for Ses in {1..2}
do
#####################PAIN DATA ####################
DATALABEL=MCA${Subj}_Ses${Ses}_Pain
if [ -f "${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_corrected.nii.gz" ] || [ -f "${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_corrected_scrubbed.nii.gz" ]; then
echo ${DATALABEL} - scan found
if [ -f ${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_fdrms.txt ]; then
echo Pain Data ${DATALABEL} Motion Outliers Detection Completed
else
echo "Pain Data ${DATALABEL} being processed..."
# check for any data with scrubbed volumes
if [ -f "${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_corrected_scrubbed.nii.gz" ]; then
INPUT=${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_corrected_scrubbed.nii.gz
else
INPUT=${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_corrected.nii.gz
fi
echo "Subj ${DATALABEL} Pain Done"
fsl_motion_outliers -i ${INPUT} -o ${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_mp-confoundsMtx.txt -s ${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_fdrms.txt -p ${DATADIR}/MCA${Subj}_Ses${Ses}/Pain_func/${DATALABEL}_fdrms_plot.png --fdrms --thresh=1.5 --dummy=0 -v
wait
fi
else echo ${DATALABEL} - scan not found
fi
done
done
echo All Done!
date