-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_general.sh
More file actions
333 lines (310 loc) · 10.8 KB
/
plot_general.sh
File metadata and controls
333 lines (310 loc) · 10.8 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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
expName=$1
maxIter=$2
outputtype=$3
write_model_cuts=$4
use_max_radius=$5
yerrorbars=$6
gt_map_mode=$7
# if [ -n $8 ]
# then
# resultsdir=../../../results/
# else
# resultsdir=results
# fi
#
# Do the plots.
#
# Set title and output type
title=${expName}
font=/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf
fontsize=9
width=1200
height=800
if [ "${outputtype}" == "ps" ]
then
outputFile=${expName}_results.ps
gnustr="set term postscript enhanced color eps font 'Helvetiva,10'"
gnustr="${gnustr}; set output '${outputFile}'"
elif [ "${outputtype}" == "svg" ]
then
outputFile=${expName}_results.svg
gnustr="set term svg enhanced font '${font},${fontsize}' size ${width}, ${height}"
gnustr="${gnustr}; set output '${outputFile}'"
else
outputFile=${expName}_results.png
gnustr="set terminal png font '${font},${fontsize}' size ${width}, ${height}"
gnustr="${gnustr}; set output '${outputFile}'"
# gnustr="${gnustr}; set output '| display png:-'"
fi
gnustr="${gnustr}; set multiplot layout 2, 3 title '${title} results'"
# Incremental FSC curves
title="Incremental FSC plots"
xlabel="Resolution"
ylabel=""
str="set title '${title}'"
str="${str}; set xlabel '${xlabel}'"
str="${str}; set ylabel '${ylabel}'"
str="${str}; set yrange [0:1.05]"
str="${str}; set xrange [*:*]"
str="${str}; plot "
let itersn=maxIter-1
doIterations=$(seq 2 1 ${itersn})
for k in ${doIterations}
do
let n=k+1
str="${str} '${expName}_fsc_`printf %02d $k`_`printf %02d $n`.txt' with lines "
if [ "$k" == "$itersn" ]; then
str=${str}
else
str="${str} , ";
fi
done
gnustr="${gnustr}; ${str}"
# FSC curves
title="FSC curves"
xlabel="Resolution"
ylabel=""
str="set title '${title}'"
str="${str}; set xlabel '${xlabel}'"
str="${str}; set ylabel '${ylabel}'"
str="${str}; set yrange [0:1.05]"
str="${str}; set xrange [0:.15]"
str="${str}; plot "
doIterations=$(seq 2 1 ${maxIter})
lw=2
for k in ${doIterations}
do
int=$(( 255-255*${k}/${maxIter} ))
hexx=`printf %02X $int`
# lw=$(( 3*$k/15 ))
# if [ "$gt_map_mode" == "1" ]
# then
# rgb="#FF${hexx}${hexx}"
# str="${str} '${expName}_CSP_`printf %02d $k`_gt_fsc.txt' using 1:2 with lines lw $lw lc rgbcolor '$rgb' "
# if [ "$k" == "$maxIter" ]; then
# str="${str} ti \"CSP vs. GT\", ";
# else
# str="${str} ti \"\", ";
# fi
# fi
rgb="#FF${hexx}${hexx}"
str="${str} '${expName}_CSP_`printf %02d $k`_fsc.txt' with lines lw $lw "
if [ "$k" == "$maxIter" ]; then
str=${str}
#str="${str} ti \"CSP\" ";
else
#str="${str} ti \"\", ";
str="${str} , ";
fi
#let lw=lw+1
done
str="${str}; set yrange [*:*]"
str="${str}; set xrange [*:*]"
gnustr="${gnustr}; ${str}"
# FSC curves
if [ "$gt_map_mode" == "1" ]
then
title="FSC curves to GT"
xlabel="Resolution"
ylabel=""
str="set title '${title}'"
str="${str}; set xlabel '${xlabel}'"
str="${str}; set ylabel '${ylabel}'"
str="${str}; set yrange [0:1.05]"
str="${str}; set xrange [0:.15]"
str="${str}; plot "
doIterations=$(seq 2 1 ${maxIter})
# doIterations="2 ${maxIter}"
# for k in ${doIterations}
# do
# int=$(( 255-255*${k}/${maxIter} ))
# hexx=`printf %02X $int`
# lw=$(( 3*$k/15 ))
# rgb="#${hexx}FF${hexx}"
# str="${str} '${expName}_USP_`printf %02d $k`_gt_fsc.txt' using 1:2 with lines lw $lw lc rgbcolor '$rgb' "
# if [ "$k" == "$maxIter" ]; then
# str="${str} ti \"USP vs. GT\", ";
# else
# str="${str} ti \"\", ";
# fi
# done
for k in ${doIterations}
do
int=$(( 255-255*${k}/${maxIter} ))
hexx=`printf %02X $int`
#lw=$(( 3*$k/15 ))
rgb="#FF${hexx}${hexx}"
str="${str} '${expName}_CSP_`printf %02d $k`_gt_fsc.txt' with lines lw $lw "
if [ "$k" == "$maxIter" ]; then
str=${str}
#str="${str} ti \"CSP vs. GT\" ";
else
#str="${str} ti \"\", ";
str="${str} , ";
fi
done
# str="${str}; set yrange [*:*]"
gnustr="${gnustr}; ${str}"
fi
# Global PR
file=${expName}_DATA_PR
# sed -i 1d ${file} # remove first line
title="Mean Phase Residual per Iteration"
xlabel=Iterations
ylabel="Mean Phase Residual"
str="set title '${title}'"
str="${str}; set xlabel '${xlabel}'"
str="${str}; set ylabel '${ylabel}'"
str="${str}; set style data linespoints"
str="${str}; set xrange [*:*]; set yrange [*:*]";
if [ "$yerrorbars" == "0" ]; then
#str="${str}; plot '${file}' using 1:2 pt 5 ti \"CSP\", '${file}' using 1:5 pt 5 ti \"USP\""
str="${str}; plot '${file}' using 1:2 pt 5 ti \"CSP\""
else
str="${str}; plot '${file}' using 1:2:3:4 with yerrorbars pt 5 ti \"CSP\", '${file}' using 1:5:6:7 with yerrorbars pt 5 ti \"USP\""
fi
gnustr="${gnustr}; ${str}"
# Global DPR
file=${expName}_DATA_DPR
# sed -i 1d ${file} # remove first line
title="Mean Differential Phase Residual"
xlabel=Iterations
ylabel="Mean Differential Phase Residual per Iteration"
str="set title '${title}'"
str="${str}; set xlabel '${xlabel}'"
str="${str}; set ylabel '${ylabel}'"
str="${str}; set style data linespoints"
str="${str}; plot '${file}' using 1:2 pt 5 lc rgb \"green\" ti \"CSP\" "
#str="${str} '${file}' using 1:3 pt 5 ti \"USP\""
gnustr="${gnustr}; ${str}"
output=${expName}_DATA.txt
str="set xrange [*:*]; set yrange [*:*]; set xlabel 'Iterations'; set ylabel 'Resolution'; plot"
str="${str} '${output}' using 1:2 with linespoints ti \"Internal FSC\","
str="${str} '${output}' using 1:3 with linespoints ti \"FSC to GT\","
str="${str} '${output}' using 1:4 with linespoints ti \"RMEASURE\""
gnustr="${gnustr}; ${str}"
# # Frobenius of Transformation Matrices
# title="Frobenius of Difference in Transformation Matrices"
# xlabel="Particle Projection Index"
# ylabel=""
# str="set title '${title}'"
# # str="${str}; set logscale y"
# str="${str}; set xlabel '${xlabel}'"
# str="${str}; set ylabel '${ylabel}'"
# str="${str}; set style data points"
# # str="${str}; set key title 'CSP iter'"
# str="${str}; plot "
# doIterations="2 ${maxIter}"
# index=1
# for k in ${doIterations}
# do
# titer=`printf %02d $k`
# file1=${expName}_DATA_FROB_${titer}
# file2=${expName}_DATA_FROB_SORT_${titer}
# # str="${str} '${file1}' using 1:2 pt 4 ps .5 lt ${index} ti \"CSP ${k}\", "
# # str="${str} '${file2}' using 1:2 with lines lc ${index} lw 2 ti \"\", "
# str="${str} '${file2}' using 1:2 with lines lc ${index} lw 2 ti \"CSP ${k}\", "
# index=$(( index + 1 ))
# # str="${str} '${file1}' using 1:3 pt 2 ps .5 lt ${index} ti \"USP ${k}\", "
# # str="${str} '${file2}' using 1:3 with lines lc ${index} lw 2 ti \"\" "
# str="${str} '${file2}' using 1:3 with lines lc ${index} lw 2 ti \"USP ${k}\" "
# if [ "${k}" -lt "${maxIter}" ]; then str="${str}, "; fi
# index=$(( index + 1 ))
# done
# gnustr="${gnustr}; ${str}"
# # Plot angles differences
# if [ "$use_max_radius" == "1" ]; then
# max_radius=`cat .max_radius`
# else
# max_radius=1
# fi
# xtics=`echo "0.5 * $max_radius" | bc -l`
# yposition=`echo "0.9 * $max_radius" | bc -l`
# max_radius=`echo "1.1 * $max_radius" | bc -l`
# title="Angles difference"
# str="set title '${title}'"
# str="${str}; set key title ''"
# str="${str}; unset border"
# str="${str}; unset logscale y"
# str="${str}; set angles degrees"
# str="${str}; set grid polar 15"
# str="${str}; set polar"
# str="${str}; set size square"
# str="${str}; set style data points"
# str="${str}; set xtics ${xtics} norotate"
# str="${str}; unset ytics"
# str="${str}; set format x \"%2.0te%L\""
# str="${str}; set yrange [-${max_radius}:${max_radius}]"
# str="${str}; set xrange [-${max_radius}:${max_radius}]"
# str="${str}; set label 'radius=sin(theta) vs. angle=phi' at -${max_radius},-${yposition}"
# str="${str}; plot "
# # doIterations=$(seq 2 1 ${maxIter})
# doIterations="2 ${maxIter}"
# for k in ${doIterations}
# do
# titer=`printf %02d $k`
# file=${expName}_DATA_POLARANGDIF_${titer}
# str="${str} '${file}' using 4:3 pt 4 ps .7 ti \"CSP iter $k\", "
# str="${str} '${file}' using 7:6 pt 4 ps .7 ti \"USP iter $k\""
# if [ "${k}" -lt "$maxIter" ]; then str="${str}, "; fi
# done
# gnustr="${gnustr}; ${str}"
# Run gnuplot
command=`echo "${gnustr}" | gnuplot`
# echo ${gnustr}
echo $command
size=`header ${expName}_CSP_02.mrc | grep sections | awk '{print $9}'`
midsection=`echo $size/2 | bc`
halfsection=`echo $size/2-64 | bc`
# Obtain the axial, sagital and coronal cuts for all the final density
# map. Then concatenate them in one image.
if [ "$write_model_cuts" == "1" ]
then
tput civis
for XSP in CSP
do
doIterations=$(seq 2 1 ${maxIter})
for k in ${doIterations}
do
iter=`printf %02d $k`
model=${expName}_${XSP}_${iter}.mrc
modellpf=${expName}_${XSP}_${iter}_lpf.mrc
# proc3d $model $modellpf apix=1.4 lp=10
echo -ne "Generating model cuts for ${model}\r"
axial=${expName}_${XSP}_${iter}_axial
coronal=${expName}_${XSP}_${iter}_coronal
sagital=${expName}_${XSP}_${iter}_sagital
newstack ${model} ${axial}.mrc -secs $midsection -scale 0,255 -mode 0 > /dev/null
mrc2tif ${axial}.mrc ${axial}.tif > /dev/null
convert -normalize -crop 128x128+${halfsection}+${halfsection} ${axial}.tif ${axial}.png
rotatevol -input ${model} -output ${sagital}.mrc -angles 0,90,0 > /dev/null
newstack ${sagital}.mrc ${sagital}.mrc -secs ${midsection} -scale 0,255 -mode 0 > /dev/null
mrc2tif ${sagital}.mrc ${sagital}.tif > /dev/null
convert -normalize -rotate 90 -crop 128x128+${halfsection}+${halfsection} -negate ${sagital}.tif ${sagital}.png
convert -negate ${sagital}.png ${sagital}.png
rotatevol -input ${model} -output ${coronal}.mrc -angles 0,90,90 > /dev/null
newstack ${coronal}.mrc ${coronal}.mrc -secs ${midsection} -scale 0,255 -mode 0 > /dev/null
mrc2tif ${coronal}.mrc ${coronal}.tif > /dev/null
convert -normalize -rotate 90 -crop 128x128+${halfsection}+${halfsection} -negate ${coronal}.tif ${coronal}.png
convert -negate ${coronal}.png ${coronal}.png
rm -f *.mrc~ $modellpf
montage -tile 3x -geometry 256x256 ${expName}_${XSP}_${iter}_{axial,coronal,sagital}.png ${XSP}_${iter}.png
done
montage -tile 1x -geometry 768x256 ${XSP}_*.png ${XSP}.png
rm -f ${XSP}_*.png *_{axial,coronal,sagital}.*
done
montage -tile 2x1 -geometry 768x$(( 256 * ( maxIter - 1 ) )) CSP.png CSP.png ${expName}_model_cuts.png
rm -f CSP.png USP.png
echo ""
tput cnorm
fi
# Move the results to the results folder
#mv ${outputFile} ${resultsdir}
echo "Results plotted in ${outputFile}"
# # Show the results
# if [ "${outputtype}" == "ps" ]
# then
# evince ${outputFile} &
# else
# display ${outputFile} &
# fi