-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPP_roi_volumes_8.sh
executable file
·136 lines (91 loc) · 2.89 KB
/
PP_roi_volumes_8.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
#!/bin/bash
# written by Nathan Muncy on 8/11/17
workDir=/Volumes/Yorick/PreProc_Methods
outDir=${workDir}/analysis/vol
### Arrays
c=0; for i in Run{1..5}; do
runList[$c]=$i
let c=$[$c+1]
done
c=0; for i in scan{1..3}; do
scanList[$c]=$i
let c=$[$c+1]
done
c=0; for i in orig acpc n4bc n4ss; do
stepList[$c]=$i
let c=$[$c+1]
done
c=0; for i in 0012 0051 0017 0053 1015 2015; do
roiList[$c]=$i
let c=$[$c+1]
done
c=0; for i in 12 51 17 53 1015 2015; do
labelList[$c]=$i
let c=$[$c+1]
done
labelLen=${#labelList[@]}
### Output
if [ ! -d $outDir ]; then
mkdir -p $outDir
fi
for a in ${runList[@]}; do
for b in ${stepList[@]}; do
if [ $a == Run1 ]; then
> ${outDir}/${a}_${b}.txt
> ${outDir}/${a}_rescan_${b}.txt
else
> ${outDir}/${a}_${b}.txt
fi
done
done
### Work
cd $workDir
for i in ${runList[@]}; do
runDir=${workDir}/$i
cd $i
for j in s*; do
subjDir=${runDir}/$j
cd $j
for k in ${stepList[@]}; do
stepDir=${subjDir}/$k
cd $k
if [ $i != Run1 ]; then
c=0; while [ $c -lt $labelLen ]; do
if [ ! -f bin_${roiList[$c]}.nii.gz ]; then
c3d label_${roiList[$c]}.nii.gz -thresh 0.5 1 ${labelList[$c]} 0 -o bin_${roiList[$c]}.nii.gz
fi
vol=`c3d bin_${roiList[$c]}.nii.gz -dup -lstat`
echo "$j $vol" >> ${outDir}/${i}_${k}.txt
let c=$[$c+1]
done
else
for m in ${scanList[@]}; do
scanDir=${stepDir}/$m
cd $m
if [ $m == scan1 ]; then
c1=0; while [ $c1 -lt $labelLen ]; do
if [ ! -f bin_${roiList[$c1]}.nii.gz ]; then
c3d label_${roiList[$c1]}.nii.gz -thresh 0.5 1 ${labelList[$c1]} 0 -o bin_${roiList[$c1]}.nii.gz
fi
vol=`c3d bin_${roiList[$c1]}.nii.gz -dup -lstat`
echo "$j $vol" >> ${outDir}/${i}_${k}.txt
let c1=$[$c1+1]
done
fi
c2=0; while [ $c2 -lt $labelLen ]; do
if [ ! -f bin_${roiList[$c2]}.nii.gz ]; then
c3d label_${roiList[$c2]}.nii.gz -thresh 0.5 1 ${labelList[$c2]} 0 -o bin_${roiList[$c2]}.nii.gz
fi
vol=`c3d bin_${roiList[$c2]}.nii.gz -dup -lstat`
echo "$j $m $vol" >> ${outDir}/${i}_rescan_${k}.txt
let c2=$[$c2+1]
done
cd $stepDir
done
fi
cd $subjDir
done
cd $runDir
done
cd $workDir
done