/
04_deconGLM
executable file
·64 lines (54 loc) · 2.44 KB
/
04_deconGLM
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
#!/usr/bin/env bash
set -euo pipefail
env|grep ^DRYRUN=. && DRYRUN=echo || DRYRUN=""
cd $(dirname "$0")
final_preproc=nfaswdktm_func_6.nii.gz
for aus_file in ../preproc/aus/[0-9][0-9][0-9]/ses-*/*/nfaswdktm_func_6.nii.gz; do
! [[ $aus_file =~ /([0-9][0-9][0-9]/ses-[0-9])/ ]] && echo "no id/ses- in '$aus_file'" && continue
idses=${BASH_REMATCH[1]}
preprocs=($(find ../preproc/*/$idses/ -not -ipath '*TEST*' -name $final_preproc))
expected_runs=3
test $expected_runs -ne ${#preprocs[@]} && echo "ERROR: $idses has $_/$expected_runs runs: ${preprocs[*]}" && continue
id_ses=${idses//\//_}
saveas=../glm/${id_ses}/${id_ses}_glm_bucket-MemTest.nii.gz
[ -r $saveas ] && echo "# have $saveas" && continue
all_censor_files="$(perl -pe "s:$final_preproc:motion_info/fd_0.8_censor.1D:g" <<< "${preprocs[@]}")"
all_motion_files=$(perl -pe "s:$final_preproc:motion.par:g" <<< "${preprocs[@]}")
echo "proc: ${preprocs[*]}"
echo "censor: $all_censor_files"
echo "mot: $all_motion_files"
timebase=1d/sub-${id_ses}
glmdir=$(dirname $saveas)
test -d $glmdir || mkdir -p $_
# make motion and censor files
# ...._bold/motion_info/fd_0.8_censor.1D
# ...._bold/motion.par
censortr=$glmdir/fd_censor.1d
cat $all_censor_files >$censortr
motion=$glmdir/motion.1d
cat $all_motion_files > $motion
$DRYRUN 3dDeconvolve -input "${preprocs[@]}" \
-fout -rout -tout \
-overwrite \
-bucket $saveas \
-x1D $glmdir/X.1D \
-polort 3 \
-local_times \
-num_stimts 9 \
-censor $censortr \
\
-stim_times_AM1 1 ${timebase}/Mem.1d 'dmBLOCK' -stim_label 1 'mem' \
-stim_times_AM1 2 ${timebase}/Test_crct.1d 'dmBLOCK' -stim_label 2 'corr' \
-stim_times_AM1 3 ${timebase}/Test_err.1d 'dmBLOCK' -stim_label 3 'err' \
\
-stim_file 4 $motion'[0]' -stim_base 4 -stim_label 4 "tx"\
-stim_file 5 $motion'[1]' -stim_base 5 -stim_label 5 "ty"\
-stim_file 6 $motion'[2]' -stim_base 6 -stim_label 6 "tz"\
-stim_file 7 $motion'[3]' -stim_base 7 -stim_label 7 "rx"\
-stim_file 8 $motion'[4]' -stim_base 8 -stim_label 8 "ry"\
-stim_file 9 $motion'[5]' -stim_base 9 -stim_label 9 "rz"\
-num_glt 3 \
-gltsym "SYM:corr -mem" -glt_label 1 'corr-mem' \
-gltsym "SYM:err +corr" -glt_label 2 'all_test' \
-gltsym "SYM:.5*err +.5*corr -mem" -glt_label 3 'all_test-mem'
done