-
Notifications
You must be signed in to change notification settings - Fork 1
/
PP_tbm_13.sh
executable file
·144 lines (99 loc) · 2.52 KB
/
PP_tbm_13.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
#!/bin/bash
# written by Nathan Muncy on 8/11/17
### Variables
workDir=/Volumes/Yorick/PreProc_Methods
scriptDir=${workDir}/Scripts
tempDir=${workDir}/Template
jlfDir=${tempDir}/priors_JLF
tbmDir=${workDir}/TBM
stats1Dir=${tbmDir}/stats_Hip
stats2Dir=${tbmDir}/stats_MTG
matDir=${tbmDir}/matrices
for a in $tbmDir $stats1Dir $stats2Dir $matDir; do
if [ ! -d $a ]; then
mkdir -p $a
fi
done
### Arrays
roiL=(0012 0017 1015)
roiR=(0051 0053 2015)
label=(Put Hip MTG)
# all subjects
c=0; for i in $(ls ${workDir}/Run1/); do
path=${workDir}/Run1/
subject=${i/$path}
if [[ $subject != xs* ]]; then
subj[$c]=$subject
let c=$[$c+1]
fi
done
# some subjects
c=0; while [ $c -lt 20 ]; do
subjList[$c]=${subj[$c]}
let c=$[$c+1]
done
c=0; for i in orig acpc n4bc n4ss; do
stepList[$c]=$i
let c=$[$c+1]
done
roiLen=${#label[@]}
subjLen=${#subjList[@]}
stepLen=${#stepList[@]}
### Stitch, binarize template priors
cd $tbmDir
c=0; while [ $c -lt $roiLen ]; do
if [ ! -f Template_"${label[$c]}"_bin.nii.gz ]; then
ImageMath 3 \
Template_"${label[$c]}".nii.gz \
+ \
${jlfDir}/label_"${roiL[$c]}".nii.gz \
${jlfDir}/label_"${roiR[$c]}".nii.gz
ThresholdImage 3 \
Template_"${label[$c]}".nii.gz \
Template_"${label[$c]}"_bin.nii.gz \
0.5 1
fi
let c=$[$c+1]
done
### Make subject roi normalized to template files, for 20 subjects
runDir=${workDir}/Run1
cd $runDir
for a in ${subjList[@]}; do
subjDir=${runDir}/$a
cd $subjDir
for i in ${stepList[@]}; do
stepDir=${subjDir}/${i}/scan1
cd $stepDir
for j in ${label[@]}; do
if [ ! -f ${tbmDir}/${a}_${i}_${j}_NTT.nii.gz ]; then
ImageMath 3 \
${tbmDir}/${a}_${i}_${j}_NTT.nii.gz \
m \
struct_LogJacNTT_act.nii.gz \
${tbmDir}/Template_${j}_bin.nii.gz
fi
done
cd $subjDir
done
cd $runDir
done
### Get data for matrices
echo "${subjList[@]}" > ${matDir}/subj_list.txt
> ${matDir}/grp.txt
for (( i=1; i<=$subjLen; i++)); do
for (( j=1; j<=$stepLen; j++)); do
echo $i >> ${matDir}/grp.txt
done
done
c1=0; while [ $c1 -lt $roiLen ]; do
print=${matDir}/list_${label[$c1]}.txt
> $print
for i in ${subjList[@]}; do
c2=0; while [ $c2 -lt $stepLen ]; do
num=$[$c2+1]
echo ${i}_${stepList[$c2]}_${label[$c1]}_${num} >> $print
let c2=$[$c2+1]
done
done
let c1=$[$c1+1]
done