forked from tommysprague/preproc_shFiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompute_mu.sh
More file actions
64 lines (38 loc) · 1.48 KB
/
compute_mu.sh
File metadata and controls
64 lines (38 loc) · 1.48 KB
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
#!/bin/bash
# compute_mu.sh
#
# Computes the mean across each run within this sub-session, saves in align_QC directory
#
# (note: this is a super-slimmed-down version of the spatail_afni_proc_SEalign.sh that ONLY does the mean volume computation - used to re-run QC alone with preproc_QC.sh if necessary)
#
# DATAROOT is global variable now
EXPTDIR=$1
SUBJ=$2
SESS=$3
SEtarg=$4
STARTRUN=$5
ENDRUN=$6
cd $DATAROOT/$EXPTDIR/$SUBJ/$SESS/
#oldthreads=$(echo $OMP_NUM_THREADS)
#cd $DATAROOT/$EXPTDIR/$SUBJ/$SESS/
mkdir $DATAROOT/$EXPTDIR/$SUBJ/align_QC
# where do we put results?
RESULTSDIR=${SUBJ}_${SESS}_r${STARTRUN}to${ENDRUN}_SEalign
# must make STARTRUN; ENDRUN base10...$((10#$STARTRUN))
# loop from end to beginning of run list, converting all r## (1-n) to startrun:endrun
# runidx=$(( $((10#$ENDRUN)) - $((10#$STARTRUN)) + 1 ))
# for (( i=$((10#$ENDRUN)); i>=$((10#$STARTRUN)); i-- ))
# do
# echo Renaming run $runidx to run $i
# # perl rename str # rename -n -v 's/\.r02.(.*.)\./.r03.$1./' *.suff
# repstr=s/`printf "\.r%02.f.(.*.)\." $runidx`/`printf ".r%02.f." $i`'$1'./
# rename -v $repstr `printf "$RESULTSDIR.results/*.r%02.f.*" $runidx`
# runidx=$(( $runidx - 1 ))
# done
# make QC files ($SUBJ/align_QC/$SUBJ_$SESS_mu_r$i.nii.gz)
# average over each run
for ii in $(seq -s " " $STARTRUN $ENDRUN)
do
rnum=$(printf "%02.f" $ii)
3dTstat -overwrite -mean -prefix ../align_QC/${SUBJ}_${SESS}_mu_r$rnum.nii.gz $RESULTSDIR.results/pb02.$RESULTSDIR.r$rnum.volreg+orig
done