• R/O
  • HTTP
  • SSH
  • HTTPS

tutorial: Commit

This repository is for tutorials of Eos.


Commit MetaInfo

Revision197d09f9083e41edd378c9e112193cc1a1af2799 (tree)
Time2015-02-27 14:31:52
Authorkinoshita-eos <kinoshita@yasu...>
Commiterkinoshita-eos

Log Message

Add: PIONE tutorial for Clustering.
new file: SampleCode/PIONE/Advanced5/Main.pione
new file: SampleCode/PIONE/Advanced5/Main_ROIr.pione

Change Summary

Incremental Difference

--- /dev/null
+++ b/SampleCode/PIONE/Advanced5/Main.pione
@@ -0,0 +1,223 @@
1+param $task := 2
2+param $divide := 2
3+param $refine := 5
4+
5+Rule Main
6+ input '*.roi'.all
7+ input 'Makefile'
8+ input 'Makefile.config'
9+ output '*.avg'.all
10+ output '*.tiff'.all
11+ output 'all.logps'
12+ output 'all.treeinfo'
13+ output 'all.avgsortlst'
14+Flow
15+ rule Preprocess {filelist:$I[1].all, num:1.upto($task), length:$I[1].length()}
16+ rule Process
17+ rule Refinement {num:1.upto($divide)}
18+ rule RefinementRoot
19+ rule MontageAverage
20+End
21+
22+Rule Preprocess
23+ input $filelist.nth(((($num-1)*((($length-1)/$task)+1))+1).upto((($num*((($length-1)/$task)+1))|$length).min()))
24+ input 'Makefile'
25+ input 'Makefile.config'
26+ output '*.pad'.all
27+Action
28+ for data in {$I[1]}
29+ do
30+ make $(basename ${data} ".roi").pad
31+ done
32+End
33+
34+Rule Process
35+ input '*.pad'.all
36+ input 'Makefile'
37+ input 'Makefile.config'
38+ output 'all.padsortlst'
39+ output 'all.treeinfo'
40+ output 'all.avgsortlst'
41+ output ((1.upto($divide).str())+".lst").d().all()
42+ output ((1.upto($divide).str())+".tree").d().all()
43+ output ("*.pad"+(1.upto($divide).str())).d().all()
44+ output ("*.avg"+(0.upto($divide).str())).d().all()
45+ output '*.avglst'.all
46+ output 'all.padsortmon.tiff'
47+ output 'all.avgsortmon.tiff'
48+ output 'all.logps'
49+Action
50+ ls -1 *.pad > all.padlst
51+ make Log
52+ make LogPS
53+ mrc2tiff -i all.padsortmon -o all.padsortmon.tiff
54+ mrc2tiff -i all.avgsortmon -o all.avgsortmon.tiff
55+
56+ cp {$O[1]} 1.lst
57+ cp {$O[2]} 1.tree
58+ for (( i=2; i<={$divide}; i++ ))
59+ do
60+ max=0
61+ for data in $(ls *.lst)
62+ do
63+ num=$(wc -l ${data} | awk '{printf $1}')
64+ if [ ${num} -gt ${max} ] ; then
65+ max=${num}
66+ maxlist="${data}"
67+ fi
68+ done
69+ maxtree="$(basename ${maxlist} '.lst').tree"
70+ root=$(head -1 ${maxtree} | awk '{printf("%d", $1)}')
71+ rootname=$(basename $(awk -v val=${root} '$2==val {printf("%s", $1)}' ${maxlist}) ".pad")
72+ cp ${maxlist} ${rootname}.avglst
73+ cp ${rootname}.pad.avg ${rootname}.pad.avg0
74+ maxpos=$(awk -v val=${root} '$2==val {printf("%f", $3)}' ${maxlist})
75+ line=$(awk -v val=${root} '$2==val {print NR}' ${maxlist})
76+ head -$((${line} - 1)) ${maxlist} > ${i}.lst
77+ tail -$(($(wc -l ${maxlist} | awk '{print $1}') - ${line} + 1)) ${maxlist} > tmp
78+ cp tmp ${maxlist}
79+
80+ max_t=$(wc -l ${maxtree} | awk '{printf $1}')
81+ max_l=$(wc -l ${maxlist} | awk '{printf $1}')
82+ line_t=$(awk -v val=${root} '$1==val {print NR}' ${maxtree})
83+ head -$((${max_l} + ${line_t} - 1)) ${maxtree} | tail -$((${max_l} - 1)) > tmp
84+ tail -$((${max_t} - ${max_l})) ${maxtree} > ${i}.tree
85+ cp tmp ${maxtree}
86+ done
87+
88+ for (( i=1; i<={$divide}; i++ ))
89+ do
90+ for data in $(awk '{print $1}' ${i}.lst)
91+ do
92+ cp ${data} ${data}${i}
93+ cp ${data}.avg ${data}.avg${i}
94+ done
95+ done
96+End
97+
98+Rule Refinement
99+ input '*.pad{$num}'.all
100+ input '*.avg{$num}'.all
101+ input '{$num}.lst'
102+ input '{$num}.tree'
103+ input 'Makefile.config'
104+ output ($I[1][1].str()+".pad.avg").d().all()
105+ output ($I[1][1].str()+".pad.avg.tiff").d().all()
106+ output ($I[1][1].str()+".pad.avg"+$num.str()+".tiff").d().all()
107+Action
108+ max=$(wc -l {$num}.tree | awk '{printf $1}')
109+ data=$(head -1 {$num}.tree)
110+ i=$(echo ${data} | awk '{print $1}')
111+ name=$(basename $(awk -v i=${i} '$2==i {print $1}' {$num}.lst) ".pad")
112+ cp {$num}.lst ${name}.avglst
113+ cp {$num}.tree ${name}.tree
114+
115+ for (( k=1; k<=max ; k++ ))
116+ do
117+ i=$(head -${k} {$num}.tree | tail -1 | awk '{print $1}')
118+ name=$(basename $(awk -v i=${i} '$2==i {print $1}' {$num}.lst) ".pad")
119+
120+ if [ $(wc -l ${name}.avglst | awk '{print $1}') -gt 2 ] ; then
121+ tpos=$(awk -v i=${i} '$2==i {print NR}' ${name}.avglst)
122+ tline=$(wc -l ${name}.avglst | awk '{print $1}')
123+
124+ head -$((${tline} - ${tpos} + 1)) ${name}.tree | tail -$((${tline} - ${tpos})) > tmp
125+ i_sub1=$(head -1 tmp | tail -1 | awk '{print $1}')
126+ name_sub1=$(basename $(awk -v i=${i_sub1} '$2==i {print $1}' ${name}.avglst) ".pad")
127+ if [ $(wc -l tmp | awk '{print $1}') -ne 0 ] ; then
128+ cp tmp ${name_sub1}.tree
129+ tail -$((${tline} - ${tpos} + 1)) ${name}.avglst > ${name_sub1}.avglst
130+ fi
131+
132+ tail -$((${tpos} - 2)) ${name}.tree > tmp
133+ i_sub2=$(head -1 tmp | awk '{print $1}')
134+ name_sub2=$(basename $(awk -v i=${i_sub2} '$2==i {print $1}' ${name}.avglst) ".pad")
135+ if [ $(wc -l tmp | awk '{print $1}') -ne 0 ] ; then
136+ cp tmp ${name_sub2}.tree
137+ head -$((${tpos} - 1)) ${name}.avglst > ${name_sub2}.avglst
138+ fi
139+ fi
140+ done
141+
142+ cat Makefile.config | sed -e s/'='/' '/ > Makefile.config.tmp
143+ ClusterCorrelationMode=$(awk '$1=="ClusterCorrelationMode" {print $2}' Makefile.config.tmp)
144+ ClusterRotationRangeMin=$(awk '$1=="ClusterRotationRangeMin" {print $2}' Makefile.config.tmp)
145+ ClusterRotationRangeMax=$(awk '$1=="ClusterRotationRangeMax" {print $2}' Makefile.config.tmp)
146+ ClusterRotationRangePartitionNumber=$(awk '$1=="ClusterRotationRangePartitionNumber" {print $2}' Makefile.config.tmp)
147+ ClusterRotationIterationNumber=$(awk '$1=="ClusterRotationIterationNumber" {print $2}' Makefile.config.tmp)
148+ ClusterRotationCorrelationMode=$(awk '$1=="ClusterRotationCorrelationMode" {print $2}' Makefile.config.tmp)
149+
150+ for data in $(ls *.avglst)
151+ do
152+ name=$(basename ${data} ".avglst")
153+ awk '{print $1}' ${data} | sed -e s/.pad/.pad.fit/ > ${name}.fitlst
154+ cp ${name}.pad.avg{$num} ${name}.pad.avg
155+ for (( i=0; i < {$refine}; i++ ))
156+ do
157+ for element in $(awk '{print $1}' ${data})
158+ do
159+ mrcImageAutoRotationCorrelation -i ${element}{$num} -r ${name}.pad.avg -fit ${element}.fit -cor ${element}.cor -O ${element}.corinfo \
160+ -Method ${ClusterRotationCorrelationMode} -m ${ClusterCorrelationMode} -Iter ${ClusterRotationIterationNumber} \
161+ -range ${ClusterRotationRangeMin} ${ClusterRotationRangeMax} -n ${ClusterRotationRangePartitionNumber}
162+ done
163+
164+ mrcImageAverage -i ${name}.fitlst -o ${name}.pad.avg
165+ done
166+ mrc2tiff -i ${name}.pad.avg -o ${name}.pad.avg.tiff
167+ mrc2tiff -i ${name}.pad.avg{$num} -o ${name}.pad.avg{$num}.tiff
168+ done
169+End
170+
171+Rule RefinementRoot
172+ input '*.pad'.all
173+ input '*.pad.avg0'.all
174+ input ($I[2][1].str()+".avglst").d().all()
175+ input 'Makefile.config'
176+ output ($I[1][1].str()+".pad.avg").d().all()
177+ output ($I[1][1].str()+".pad.avg.tiff").d().all()
178+ output ($I[1][1].str()+".pad.avg0.tiff").d().all()
179+Action
180+ cat Makefile.config | sed -e s/'='/' '/ > Makefile.config.tmp
181+ ClusterCorrelationMode=$(awk '$1=="ClusterCorrelationMode" {print $2}' Makefile.config.tmp)
182+ ClusterRotationRangeMin=$(awk '$1=="ClusterRotationRangeMin" {print $2}' Makefile.config.tmp)
183+ ClusterRotationRangeMax=$(awk '$1=="ClusterRotationRangeMax" {print $2}' Makefile.config.tmp)
184+ ClusterRotationRangePartitionNumber=$(awk '$1=="ClusterRotationRangePartitionNumber" {print $2}' Makefile.config.tmp)
185+ ClusterRotationIterationNumber=$(awk '$1=="ClusterRotationIterationNumber" {print $2}' Makefile.config.tmp)
186+ ClusterRotationCorrelationMode=$(awk '$1=="ClusterRotationCorrelationMode" {print $2}' Makefile.config.tmp)
187+
188+ for data in $(ls *.avglst)
189+ do
190+ name=$(basename ${data} ".avglst")
191+ awk '{print $1}' ${data} | sed -e s/.pad/.pad.fit/ > ${name}.fitlst
192+ cp ${name}.pad.avg0 ${name}.pad.avg
193+ for (( i=0; i < {$refine}; i++ ))
194+ do
195+ for element in $(awk '{print $1}' ${data})
196+ do
197+ mrcImageAutoRotationCorrelation -i ${element} -r ${name}.pad.avg -fit ${element}.fit -cor ${element}.cor -O ${element}.corinfo \
198+ -Method ${ClusterRotationCorrelationMode} -m ${ClusterCorrelationMode} -Iter ${ClusterRotationIterationNumber} \
199+ -range ${ClusterRotationRangeMin} ${ClusterRotationRangeMax} -n ${ClusterRotationRangePartitionNumber}
200+ done
201+
202+ mrcImageAverage -i ${name}.fitlst -o ${name}.pad.avg
203+ done
204+ mrc2tiff -i ${name}.pad.avg -o ${name}.pad.avg.tiff
205+ mrc2tiff -i ${name}.pad.avg0 -o ${name}.pad.avg0.tiff
206+ done
207+End
208+
209+Rule MontageAverage
210+ input 'all.avgsortlst'
211+ input 'all.treeinfo'
212+ input '*.pad.avg'.all
213+ output 'all.avgrefinemon'
214+ output 'all.avgrefinemon.tiff'
215+Action
216+ root=$(head -1 {$I[2]} | awk '{print $1}')
217+ root_file=$(awk -v val=${root} '$2==val {print $1}' {$I[1]})
218+ cp ${root_file} $(head -1 {$I[1]} | awk '{print $1}')
219+ mrcImageMontageCreate -i {$I[1]} -o {$O[1]}
220+ mrc2tiff -i {$O[1]} -o {$O[2]}
221+End
222+
223+param $roi := false
--- /dev/null
+++ b/SampleCode/PIONE/Advanced5/Main_ROIr.pione
@@ -0,0 +1,71 @@
1+Rule Main
2+ input '*.ref3d'
3+ output '*.roi'.all
4+ output '*.tiff'.all
5+ param $X_SIZE := 32
6+ param $Y_SIZE := 32
7+ param $ROI_ROT_MODE := "XEYS"
8+ param $ROI_ROT1_NUM := 3
9+ param $ROI_ROT2_NUM := 3
10+ param $ROI_ROT3_NUM := 3
11+ param $ROI_SHIFT_NUM := 2
12+ param $ROI_SN := 1
13+ param $ROI_NOISE_NUM := 1
14+Action
15+ data=$(mrcInfo -i {$I[1]} | head -1)
16+ x_size=$(echo "${data}" | awk '{printf ("%i", $4)}')
17+ y_size=$(echo "${data}" | awk '{printf ("%i", $5)}')
18+ z_size=$(echo "${data}" | awk '{printf ("%i", $6)}')
19+
20+ data=$(mrcInfo -i {$I[1]} | head -5 | tail -1)
21+ x_length=$(echo "${data}" | awk '{printf ("%f", $4)}')
22+ y_length=$(echo "${data}" | awk '{printf ("%f", $5)}')
23+ z_length=$(echo "${data}" | awk '{printf ("%f", $6)}')
24+
25+ ref_size=${x_size}
26+ length=${x_length}
27+
28+ if [ ${ref_size} -lt ${y_size} ] ; then \
29+ ref_size=${y_size}
30+ length=${y_length}
31+ fi
32+
33+ if [ ${ref_size} -lt ${z_size} ] ; then \
34+ ref_size=${z_size}
35+ length=${z_length}
36+ fi
37+
38+ image_size={$X_SIZE}
39+
40+ if [ ${image_size} -lt {$Y_SIZE} ] ; then \
41+ image_size={$Y_SIZE}
42+ fi
43+
44+ sampling_length=$(echo "scale=7; ${length} * ${ref_size} / ${image_size}" | bc)
45+
46+ mrcImageSamplingUnitChange -i {$I[1]} -o {$I[1][1]}.sample3d -m 2 -S ${sampling_length} ${sampling_length} ${sampling_length}
47+
48+ for rot1 in $(randomUniformGet -n {$ROI_ROT1_NUM} -min 0 -max 359)
49+ do
50+ for rot2 in $(randomUniformGet -n {$ROI_ROT2_NUM} -min 0 -max 359)
51+ do
52+ for rot3 in $(randomUniformGet -n {$ROI_ROT3_NUM} -min 0 -max 359)
53+ do
54+ mrc3Dto2D -i {$I[1][1]}.sample3d -o {$I[1][1]}-${rot1}-${rot2}-${rot3}.data2d -InterpolationMode 2 -EulerMode {$ROI_ROT_MODE} \
55+ -Rot1 ${rot1} ${rot1} 1 \
56+ -Rot2 ${rot2} ${rot2} 1 \
57+ -Rot3 ${rot3} ${rot3} 1
58+ random_list=($(randomUniformGet -n {$ROI_SHIFT_NUM*2} -min -4 -max 4))
59+ for (( j=0; j<{$ROI_SHIFT_NUM*2}; j+=2 ))
60+ do
61+ mrcImageShift -i {$I[1][1]}-${rot1}-${rot2}-${rot3}.data2d -o {$I[1][1]}-${rot1}-${rot2}-${rot3}-${j}.shift2d -x ${random_list[${j}]} -y ${random_list[((${j}+1))]}
62+ for (( i=0; i<{$ROI_NOISE_NUM}; i++ ))
63+ do
64+ mrcImageNoiseAdd -i {$I[1][1]}-${rot1}-${rot2}-${rot3}-${j}.shift2d -o {$I[1][1]}-${rot1}-${rot2}-${rot3}-${j}-${i}.roi -SN {$ROI_SN}
65+ mrc2tiff -i {$I[1][1]}-${rot1}-${rot2}-${rot3}-${j}-${i}.roi -o {$I[1][1]}-${rot1}-${rot2}-${rot3}-${j}-${i}.tiff
66+ done
67+ done
68+ done
69+ done
70+ done
71+End
Show on old repository browser