-
Notifications
You must be signed in to change notification settings - Fork 7
/
L1_task-sharedreward_model-01.sh
executable file
·82 lines (68 loc) · 2.91 KB
/
L1_task-sharedreward_model-01.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
#!/usr/bin/env bash
maindir=`pwd`
TASK=sharedreward
sub=$1
run=$2
ppi=$3 # 0 for activation, otherwise name of the roi
sm=$4
MAINOUTPUT=${maindir}/fsl/sub-${sub}
mkdir -p $MAINOUTPUT
# denoise data, if it doesn't exist
cd ${maindir}/fmriprep/fmriprep/sub-${sub}/func
if [ ! -e sub-${sub}_task-${TASK}_run-0${run}_bold_space-MNI152NLin2009cAsym_variant-unsmoothedAROMAnonaggr_preproc.nii.gz ]; then
fsl_regfilt -i sub-${sub}_task-${TASK}_run-0${run}_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz \
-f $(cat sub-${sub}_task-${TASK}_run-0${run}_AROMAnoiseICs.csv) \
-d sub-${sub}_task-${TASK}_run-0${run}_desc-MELODIC_mixing.tsv \
-o sub-${sub}_task-${TASK}_run-0${run}_bold_space-MNI152NLin2009cAsym_variant-unsmoothedAROMAnonaggr_preproc.nii.gz
fi
EVDIR=${maindir}/fsl/EVfiles/sub-${sub}/${TASK}/run-0${run}
if [ "$ppi" == "0" ]; then
DATA=${maindir}/fmriprep/fmriprep/sub-${sub}/func/sub-${sub}_task-${TASK}_run-0${run}_bold_space-MNI152NLin2009cAsym_variant-unsmoothedAROMAnonaggr_preproc.nii.gz
TYPE=act
OUTPUT=${MAINOUTPUT}/L1_task-${TASK}_model-01_type-${TYPE}_run-0${run}_sm-${sm}
else
DATA=${MAINOUTPUT}/L1_task-${TASK}_model-01_type-act_run-0${run}_sm-${sm}.feat/filtered_func_data.nii.gz
DATAPPI=${MAINOUTPUT}/L1_task-${TASK}_model-01_type-act_run-0${run}_sm-${sm}.feat/filtered_func_data.nii.gz
TYPE=ppi
OUTPUT=${MAINOUTPUT}/L1_task-${TASK}_model-01_type-${TYPE}_seed-${ppi}_run-0${run}_sm-${sm}
fi
if [ -e ${OUTPUT}.feat/cluster_mask_zstat1.nii.gz ]; then
exit
else
echo "missing: $OUTPUT " >> ${maindir}/re-runL1.log
rm -rf ${OUTPUT}.feat
fi
ITEMPLATE=${maindir}/templates/L1_task-${TASK}_model-01_type-${TYPE}.fsf
OTEMPLATE=${MAINOUTPUT}/L1_task-${TASK}_model-01_seed-${ppi}_run-0${run}.fsf
if [ "$ppi" == "0" ]; then
sed -e 's@OUTPUT@'$OUTPUT'@g' \
-e 's@DATA@'$DATA'@g' \
-e 's@EVDIR@'$EVDIR'@g' \
-e 's@SMOOTH@'$sm'@g' \
<$ITEMPLATE> $OTEMPLATE
else
PHYS=${MAINOUTPUT}/ts_task-${TASK}_mask-${ppi}_run-0${run}.txt
MASK=${maindir}/masks/r${ppi}_func.nii.gz
fslmeants -i $DATAPPI -o $PHYS -m $MASK
sed -e 's@OUTPUT@'$OUTPUT'@g' \
-e 's@DATA@'$DATA'@g' \
-e 's@EVDIR@'$EVDIR'@g' \
-e 's@PHYS@'$PHYS'@g' \
-e 's@SMOOTH@'$sm'@g' \
<$ITEMPLATE> $OTEMPLATE
fi
# runs feat on output template
feat $OTEMPLATE
# fix registration as per NeuroStars post:
# https://neurostars.org/t/performing-full-glm-analysis-with-fsl-on-the-bold-images-preprocessed-by-fmriprep-without-re-registering-the-data-to-the-mni-space/784/3
mkdir -p ${OUTPUT}.feat/reg
ln -s $FSLDIR/etc/flirtsch/ident.mat ${OUTPUT}.feat/reg/example_func2standard.mat
ln -s $FSLDIR/etc/flirtsch/ident.mat ${OUTPUT}.feat/reg/standard2example_func.mat
ln -s ${OUTPUT}.feat/mean_func.nii.gz ${OUTPUT}.feat/reg/standard.nii.gz
# delete unused files
rm -rf ${OUTPUT}.feat/stats/res4d.nii.gz
rm -rf ${OUTPUT}.feat/stats/corrections.nii.gz
rm -rf ${OUTPUT}.feat/stats/threshac1.nii.gz
if [ ! "$ppi" == "0" ]; then
rm -rf ${OUTPUT}.feat/filtered_func_data.nii.gz
fi