• R/O
  • HTTP
  • SSH
  • HTTPS

base: Commit

This repository is a base of Eos.


Commit MetaInfo

Revisión87ea6b9a251e5b1b5988123cf24dd4fb7e9caee9 (tree)
Tiempo2017-01-11 14:30:14
Autor久永浩司 <hisanagakouji@hisa...>
Commiter久永浩司

Log Message

modified eosBayesCondision.c

Cambiar Resumen

Diferencia incremental

--- a/include/eosBayes.h
+++ b/include/eosBayes.h
@@ -69,7 +69,7 @@ extern void eosBayesDistributionInit(eosBayesDistribution* d,eosBayesDistributio
6969
7070 // Initialize probe of Each distribution of eosBayesDistriubutions
7171 extern void eosBayesDistributionInitialProbabilitySet(eosBayesDistribution* d, eosBayesDistributionInfo* info, int mode);
72-extern void eosBayesProbabilityReset(eosBayes* d, int mode);
72+extern void eosBayesProbabilityReset(FILE* fptIn,eosBayes* d, int n, int mode);
7373 extern void eosBayesProbabilitysetLinear(eosBayesDistribution* d, float a, float b);
7474
7575 /* eosBayesEstimation.c */
--- a/src/Objects/General/eosBayes/inc/eosBayes.h
+++ b/src/Objects/General/eosBayes/inc/eosBayes.h
@@ -69,7 +69,7 @@ extern void eosBayesDistributionInit(eosBayesDistribution* d,eosBayesDistributio
6969
7070 // Initialize probe of Each distribution of eosBayesDistriubutions
7171 extern void eosBayesDistributionInitialProbabilitySet(eosBayesDistribution* d, eosBayesDistributionInfo* info, int mode);
72-extern void eosBayesProbabilityReset(eosBayes* d, int mode);
72+extern void eosBayesProbabilityReset(FILE* fptIn,eosBayes* d, int n, int mode);
7373 extern void eosBayesProbabilitysetLinear(eosBayesDistribution* d, float a, float b);
7474
7575 /* eosBayesEstimation.c */
--- a/src/Objects/General/eosBayes/src/eosBayesCondition.c
+++ b/src/Objects/General/eosBayes/src/eosBayesCondition.c
@@ -71,8 +71,6 @@ void eosBayesRefinementCondition(FILE* fptIn, eosBayes* d, eosBayesDistributionI
7171
7272 DEBUGPRINT("eosBayesRefinementConditon start\n");
7373 fseek(fptIn,0,SEEK_SET);
74-
75- eosBayesParameterOfMaxPosteriorGet(d->posterior,d->numDistribution,0);
7674
7775 for(i=0;i<d->numDistribution;i++){
7876 DEBUGPRINT2("%d/%d loop\n",i+1,d->numDistribution);
@@ -90,6 +88,7 @@ void eosBayesRefinementCondition(FILE* fptIn, eosBayes* d, eosBayesDistributionI
9088 llinfo->sigma = d->posterior[i].delta;
9189 llinfo->mean = value[1];
9290 llinfo->delta = d->posterior[i].delta/n;
91+ llinfo->mode = 0;
9392 DEBUGPRINT1("%s\n",s);
9493 DEBUGPRINT6("min:%f max:%f delta:%f mode:%u mean:%f sigma:%f\n",llinfo->min,llinfo->max,llinfo->delta,llinfo->mode,llinfo->mean,llinfo->sigma);
9594 eosBayesDistributionInit(&(d->prior[i]),llinfo,1);
@@ -106,6 +105,7 @@ void eosBayesRefinementCondition(FILE* fptIn, eosBayes* d, eosBayesDistributionI
106105 llinfo->sigma = d->posterior[i].delta;
107106 llinfo->mean = value[1];
108107 llinfo->delta = d->posterior[i].delta/n;
108+ llinfo->mode = 0;
109109 DEBUGPRINT1("%s\n",s);
110110 DEBUGPRINT6("min:%f max:%f delta:%f mode:%u mean:%f sigma:%f\n",llinfo->min,llinfo->max,llinfo->delta,llinfo->mode,llinfo->mean,llinfo->sigma);
111111 eosBayesDistributionInit(&(d->prior[i]),llinfo,1);
@@ -151,15 +151,24 @@ void eosBayesRefinementCondition(FILE* fptIn, eosBayes* d, eosBayesDistributionI
151151
152152 void eosBayesGettopthreepoint(eosBayesDistribution* d, float* value, float* prob){
153153
154- value[0] = d->value[d->iofmaxposterior-1];
155- prob[0] = d->prob[d->iofmaxposterior-1];
154+ if(d->valueofmaxposterior==d->min){
155+ value[0] = d->valueofmaxposterior;
156+ prob[0] = d->probofmaxposterior;
157+ }else{
158+ value[0] = d->value[d->iofmaxposterior-1];
159+ prob[0] = d->prob[d->iofmaxposterior-1];
160+ }
156161
157162 value[1] = d->valueofmaxposterior;
158163 prob[1] = d->probofmaxposterior;
159164
160- value[2] = d->value[d->iofmaxposterior+1];
161- prob[2] = d->prob[d->iofmaxposterior+1];
162-
165+ if(d->valueofmaxposterior==d->max){
166+ value[2] = d->valueofmaxposterior;
167+ prob[2] = d->probofmaxposterior;
168+ }else{
169+ value[2] = d->value[d->iofmaxposterior+1];
170+ prob[2] = d->prob[d->iofmaxposterior+1];
171+ }
163172 }
164173
165174
@@ -171,12 +180,21 @@ void eosBayesLiniearinterpolationofTopthreepoint(eosBayesDistribution* d, float*
171180
172181 int i;
173182 float sum;
174-
175- a1 = (prob[0]-prob[1])/(value[0]-value[1]);
176- b1 = -a1*value[1]+prob[1];
177183
178- a2 = (prob[1]-prob[2])/(value[1]-value[2]);
179- b2 = -a2*value[1]+prob[1];
184+ a1 = 0;
185+ a2 = 0;
186+ b1 = 0;
187+ b2 = 0;
188+
189+ if(value[0] != value[1]){
190+ a1 = (prob[0]-prob[1])/(value[0]-value[1]);
191+ b1 = -a1*value[1]+prob[1];
192+ }
193+
194+ if(value[2] != value[1]){
195+ a2 = (prob[1]-prob[2])/(value[1]-value[2]);
196+ b2 = -a2*value[1]+prob[1];
197+ }
180198
181199 sum = 0;
182200 for(i=0;i<d->n;i++){
--- a/src/Objects/General/eosBayes/src/eosBayesDistributionInitialProbabilitySet.c
+++ b/src/Objects/General/eosBayes/src/eosBayesDistributionInitialProbabilitySet.c
@@ -58,33 +58,34 @@ void eosBayesDistributionInitialProbabilitySet(eosBayesDistribution* d, eosBayes
5858
5959 }
6060
61-void eosBayesProbabilityReset(eosBayes* d, int mode){
62-
63- FILE* fpt;
61+void eosBayesProbabilityReset(FILE* fptIn, eosBayes* d, int n, int mode){
6462 int i;
65- int j;
6663 char s[1024];
64+ eosBayesDistributionInfo info;
6765
6866 DEBUGPRINT("eosBayesProbabilityReset\n");
67+ fseek(fptIn,0,SEEK_SET);
6968
7069 for(i=0;i<d->numDistribution;i++){
70+ DEBUGPRINT2("%d/%d loop\n",i+1,d->numDistribution);
71+ stringGetFromFile(s, "in main", fptIn, stdout, 3);
7172 if(d->prior[i].resetflag==1){
73+ DEBUGPRINT("Set new peior\n");
74+ info.min = stringGetNthRealData(s, 2," \t");
75+ info.max = stringGetNthRealData(s, 3," \t");
76+ info.delta = stringGetNthRealData(s, 4," \t");
77+ info.mode = 0;
78+ info.mean = stringGetNthRealData(s, 6," \t");
79+ info.sigma = stringGetNthRealData(s, 7," \t");
80+ info.delta = info.delta/n;
81+ DEBUGPRINT1("%s\n",s);
82+ DEBUGPRINT6("min:%f max:%f delta:%f mode:%u mean:%f sigma:%f\n",info.min,info.max,info.delta,info.mode,info.mean,info.sigma);
83+ eosBayesDistributionInit(&(d->prior[i]),&info,1);
84+ eosBayesDistributionInit(&(d->posterior[i]),&info,1);
85+ eosBayesDistributionInit(&(d->likelihood[i]),&info,1);
86+ eosBayesDistributionInitialProbabilitySet(&(d->prior[i]), &info, 1);
87+ eosBayesDistributionInitialProbabilitySet(&(d->posterior[i]), &info, 1);
7288 DEBUGPRINT1("dist%d was reset\n",i);
73- free(d->prior[i].value);
74- free(d->prior[i].prob);
75- free(d->posterior[i].value);
76- free(d->posterior[i].prob);
77- free(d->likelihood[i].value);
78- free(d->likelihood[i].prob);
79- sprintf(s,"%s%d.out","./prior",i);
80- if((fpt=fopen(s,"r"))==NULL){
81- fprintf(stderr,"fopen error: %s\n",s);
82- }
83- DEBUGPRINT("eosBayesDistributionRead start\n");
84- eosBayesDistributionRead(fpt,&(d->prior[i]),1);
85- eosBayesDistributionRead(fpt,&(d->posterior[i]),1);
86- eosBayesDistributionRead(fpt,&(d->likelihood[i]),1);
87- fclose(fpt);
8889 leosBayesParameterOfMaxPosteriorGet(&(d->posterior[i]),0);
8990 d->posterior[i].maxposteriorflag = 0;
9091 d->prior[i].resetflag = 0;
--- a/src/Objects/General/eosBayes/src/eosBayesParameterOfMaxPosterior.c
+++ b/src/Objects/General/eosBayes/src/eosBayesParameterOfMaxPosterior.c
@@ -44,6 +44,7 @@ void leosBayesParameterOfMaxPosteriorGet(eosBayesDistribution* d, int mode){
4444
4545 d->valueofmaxposterior = d->value[0];
4646 d->probofmaxposterior = d->prob[0];
47+ d->iofmaxposterior = 0;
4748 for(i=0;i<d->n;i++){
4849 if(d->probofmaxposterior < d->prob[i]){
4950 d->valueofmaxposterior = d->value[i];
--- a/src/Tools/ctfInfo/ctfDeterminationByBayes/src/ctfDeterminationByBayes.c
+++ b/src/Tools/ctfInfo/ctfDeterminationByBayes/src/ctfDeterminationByBayes.c
@@ -44,6 +44,7 @@ main(int argc, char* argv[])
4444 {
4545
4646 int i;
47+ int j;
4748 ctfDeterminationByBayesInfo info;
4849 ctfInfo ctfinfo;
4950 eosBayesDistributionInfo llinfo;
@@ -94,9 +95,10 @@ main(int argc, char* argv[])
9495
9596
9697 /*MTF,B serch start\n*/
98+ for(j=0;j<2;j++){
9799 DEBUGPRINT("MTF,B search start\n");
100+ ctf.rmax = Rintermediate;
98101 DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
99-
100102 DEBUGPRINT("set maxposteriorflag of MTF,B\n");
101103 eosBayesMaxposteriorflagSet(&out,0);
102104 eosBayesMaxposteriorflagSet(&out,1);
@@ -115,7 +117,7 @@ main(int argc, char* argv[])
115117 DEBUGPRINT("set resetflag of df,A,k\n");
116118 out.prior[2].resetflag = 1;
117119 out.prior[4].resetflag = 1;
118- eosBayesProbabilityReset(&out,0);
120+ eosBayesProbabilityReset(info.fptIn,&out,5,0);
119121
120122 DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
121123 DEBUGPRINT("MTF,B search finish\n");
@@ -133,8 +135,8 @@ main(int argc, char* argv[])
133135
134136 /*df,A serch*/
135137 DEBUGPRINT("df, A, k search start\n");
136-
137138 ctf.rmax = Rintermediate;
139+ ctf.rmin = Rmin;
138140 DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
139141
140142 DEBUGPRINT("set maxposteriorflag of MTF,B\n");
@@ -148,7 +150,7 @@ main(int argc, char* argv[])
148150 out.prior[0].resetflag = 1;
149151 out.prior[1].resetflag = 1;
150152 out.prior[3].resetflag = 1;
151- eosBayesProbabilityReset(&out,0);
153+ eosBayesProbabilityReset(info.fptIn,&out,1,0);
152154
153155 DEBUGPRINT("----maxflagcheck----\n");
154156 #ifdef DEBUG
@@ -178,7 +180,7 @@ main(int argc, char* argv[])
178180
179181 DEBUGPRINT("set resetflag of df\n");
180182 out.prior[0].resetflag = 1;
181- eosBayesProbabilityReset(&out,0);
183+ eosBayesProbabilityReset(info.fptIn,&out,5,0);
182184
183185 DEBUGPRINT("----maxflagcheck----\n");
184186 #ifdef DEBUG
@@ -190,46 +192,138 @@ main(int argc, char* argv[])
190192 DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
191193 DEBUGPRINT("df search finish\n");
192194 ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
195+
196+ }
197+
198+ /*MTF refinement*/
199+ DEBUGPRINT("MTF,refinement\n");
200+ ctf.rmax = Rmax;
201+ DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
193202
194-
195- /*defocus refinement*/
203+ DEBUGPRINT("set maxposteriorflag of defocus,A,k\n");
204+ eosBayesMaxposteriorflagSet(&out,0);
205+ eosBayesMaxposteriorflagSet(&out,1);
206+ eosBayesMaxposteriorflagSet(&out,2);
207+ eosBayesMaxposteriorflagSet(&out,3);
208+
209+ DEBUGPRINT("set canstantflag of Ain");
210+ out.posterior[5].constantflag = 1;
211+
212+ DEBUGPRINT("set resetflag of B,MTF\n");
213+ out.prior[4].resetflag = 1;
214+ eosBayesProbabilityReset(info.fptIn,&out,5,0);
215+
216+ DEBUGPRINT("----maxflagcheck----\n");
217+ #ifdef DEBUG
218+ for(i=0;i<out.numDistribution;i++){
219+ printf("dist%d:%d\n",i,(out.posterior[i].maxposteriorflag));
220+ }
221+ #endif
222+
223+ DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
224+ DEBUGPRINT("MTF, B refinement finish\n");
225+ ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
226+
227+
228+ /*df search*/
229+ /*
230+ DEBUGPRINT("df serch start\n");
231+ ctf.rmax = Rintermediate;
232+ DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
233+
234+ DEBUGPRINT("set maxposteriorflag of defocus,A,B\n");
235+ eosBayesMaxposteriorflagSet(&out,1);
236+ eosBayesMaxposteriorflagSet(&out,2);
237+ eosBayesMaxposteriorflagSet(&out,3);
238+ eosBayesMaxposteriorflagSet(&out,4);
239+
240+ DEBUGPRINT("set canstantflag of Ain");
241+ out.posterior[5].constantflag = 1;
242+
243+ DEBUGPRINT("set resetflag of df\n");
244+ out.prior[0].resetflag = 1;
245+ eosBayesProbabilityReset(info.fptIn,&out,5,0);
246+
247+ DEBUGPRINT("----maxflagcheck----\n");
248+ #ifdef DEBUG
249+ for(i=0;i<out.numDistribution;i++){
250+ printf("dist%d:%d\n",i,(out.posterior[i].maxposteriorflag));
251+ }
252+ #endif
253+
254+ DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
255+ DEBUGPRINT("df search finish\n");
256+ ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
257+*/
258+
259+ /*A, Ain refinement*/
196260 /*
261+ DEBUGPRINT("A, k, Ain refinement start\n");
262+
263+ ctf.rmax = Rintermediate;
264+ ctf.rmin = Rmin;
265+ DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
266+
267+ DEBUGPRINT("set maxposteriorflag of MTF,B\n");
268+ eosBayesMaxposteriorflagSet(&out,0);
269+ eosBayesMaxposteriorflagSet(&out,2);
270+ eosBayesMaxposteriorflagSet(&out,4);
271+
272+ DEBUGPRINT("set canstantflag of Ain");
273+ out.posterior[5].constantflag = 0;
274+
275+ DEBUGPRINT("set resetflag of df,A,k\n");
276+ out.prior[0].resetflag = 1;
277+ out.prior[1].resetflag = 1;
278+ out.prior[3].resetflag = 1;
279+ out.prior[5].resetflag = 1;
280+ eosBayesProbabilityReset(info.fptIn,&out,5,0);
281+
282+ DEBUGPRINT("----maxflagcheck----\n");
283+ #ifdef DEBUG
284+ for(i=0;i<out.numDistribution;i++){
285+ printf("dist%d:%d\n",i,(out.posterior[i].maxposteriorflag));
286+ }
287+ #endif
288+
289+ DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
290+ DEBUGPRINT("df, A, k, Ain refinementfinish\n");
291+ ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
292+*/
293+ /*defocus refinement*/
294+
197295 DEBUGPRINT("defocus refinement start\n");
198- ctf.rmax = Rmax;
296+ ctf.rmax = Rintermediate;
199297 ctf.rmin = Rmin;
200298 DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
201299
202300 DEBUGPRINT("set maxposteriorflag of defocus,A,B,MTF\n");
203301 out.posterior[0].maxposteriorflag = 0;
204302 out.posterior[1].maxposteriorflag = 0;
205-
206- out.posterior[2].maxposteriorflag = 1;
207- out.posterior[2].n = 1;
208- out.prior[2].n = 1;
209- out.posterior[4].maxposteriorflag = 1;
210- out.posterior[4].n = 1;
211- out.prior[4].n = 1;
303+ out.posterior[3].maxposteriorflag = 0;
304+ out.posterior[5].maxposteriorflag = 0;
305+ eosBayesMaxposteriorflagSet(&out,2);
306+ eosBayesMaxposteriorflagSet(&out,4);
212307
213308 DEBUGPRINT("set canstantflag of k and Ain");
214- out.posterior[3].constantflag = 0;
215309 out.posterior[5].constantflag = 0;
216310
217311 DEBUGPRINT("set refmode\n");
218312 out.posterior[0].refmode = 1;
219313 out.posterior[1].refmode = 1;
220- out.posterior[2].refmode = 1;
221- out.posterior[3].refmode = 0;
222- out.posterior[4].refmode = 1;
223- out.posterior[5].refmode = 0;
314+ out.posterior[2].refmode = 0;
315+ out.posterior[3].refmode = 1;
316+ out.posterior[4].refmode = 0;
317+ out.posterior[5].refmode = 2;
224318
225319 eosBayesRefinementCondition(info.fptIn,&out,&llinfo,5,0);
226320 DistributionChangeCheck(&out, 0);
227- defocusLikelihoodInit(&likelihood,out,1);
321+ defocusLikelihoodInit(&likelihood,&out,1);
228322
229- DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood);
323+ DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,1);
230324 DEBUGPRINT("defocus refinement finish\n");
231325 ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
232-*/
326+
233327 eosBayesPosteriorWrite(&out,0);
234328
235329 ctfforbayesFree(&ctf,&intensity,&likelihood,out.numLikelihood);
Show on old repository browser