OSDN Git Service

Stirng.h -> eosString.h
[eos/base.git] / src / Tools / ctfInfo / ctfDeterminationByBayes / src / ctfDeterminationByBayes.c
index 49dc5ce..2328ce9 100755 (executable)
@@ -22,7 +22,7 @@
 #define DEBUG
 #include "genUtil.h"
 #include "ctfDeterminationByBayes.h"
-#include "String.h"
+#include "eosString.h"
 
 /*
 Example:
@@ -44,7 +44,6 @@ main(int argc, char* argv[])
 {
   
   int i;
-  int j;
 
   ctfDeterminationByBayesInfo info;
   ctfInfo ctfinfo;
@@ -67,6 +66,7 @@ main(int argc, char* argv[])
   init1(&info);
 
   DEBUGPRINT("Program Start\n");
+  DEBUGPRINT("local binary:MTF plus\n");
 
   ctfinfo.mode = 33;
 
@@ -83,6 +83,35 @@ main(int argc, char* argv[])
   spatialfrequencyRead(info.fptIn2,&ctf,info.rmax,info.rmin,0);
   ctfInfoRead(info.fptIn3,&ctfinfo,"",0);
   DEBUGPRINT6("kV:%f  Cs:%f  Ain:%f Cc:%f MTF:%f ctfMode:%ld\n",ctfinfo.kV,ctfinfo.Cs,ctfinfo.Ain,ctfinfo.Cc,ctfinfo.BofMTF,ctfinfo.mode);
+
+
+  /*ctfInfoflagcheck*/
+  DEBUGPRINT2("flagAliasing:%ld flagSampling:%ld\n",ctfinfo.flagAliasing,ctfinfo.flagSampling);
+  DEBUGPRINT1("NyquistFrequency:%f\n",ctfinfo.NyquistFrequency);
+
+  ctfinfo.flagMolecEnvTable = 0;
+  DEBUGPRINT1("flagMolecEnvTable:%ld\n",ctfinfo.flagMolecEnvTable);
+  ctfinfo.flagElastic = 0;
+  DEBUGPRINT1("flagElastic:%ld\n",ctfinfo.flagElastic);
+
+  ctfinfo.flagWithInElasticTable = 0;
+  DEBUGPRINT1("flagWithInElasticEnvTable:%ld\n",ctfinfo.flagWithInElasticTable);
+  ctfinfo.flagInElastic = 0;
+  DEBUGPRINT1("flagInElastic:%ld\n",ctfinfo.flagInElastic);
+  ctfinfo.flagWithInElastic = 0;
+  DEBUGPRINT1("flagWithInElastic:%ld\n",ctfinfo.flagWithInElastic);
+
+  ctfinfo.flagVibration = 0;
+  DEBUGPRINT1("flagVibration:%ld\n",ctfinfo.flagVibration);
+  ctfinfo.VibrationMode = 0;
+  DEBUGPRINT1("VibrationMode:%ld\n",ctfinfo.VibrationMode);
+  ctfinfo.Magnification = 0;
+  DEBUGPRINT1("Magnification:%f\n",ctfinfo.Magnification);
+  ctfinfo.flagMagnification = 0;
+  DEBUGPRINT1("flagMagnification:%ld\n",ctfinfo.flagMagnification);
+
+
   DEBUGPRINT1("flagIn4:%ld\n",info.flagIn4);
 
   Rmax = ctf.rmax;
@@ -122,8 +151,8 @@ main(int argc, char* argv[])
   eosBayesProbabilityReset(info.fptIn,&out,10,0);
 
   DEBUGPRINT("set rangechangeflag of B\n");
-  out.posterior[2].rangechangeflag = 1;
-  eosBayesProbabilityRangeChange(&out,100,0.95,0);
+  eosBayesRangeChangeflagSet(&out,2,0.95,100);
+  eosBayesProbabilityRangeChange(&out,0);
 
   DistributionChangeCheck(&out, 1, 0);
 
@@ -141,7 +170,7 @@ main(int argc, char* argv[])
 
 
   /*df,A B serch*/
-  DEBUGPRINT("df, A, k search start\n");
+  DEBUGPRINT("df, A, B search start\n");
   ctf.rmax = Rintermediate;
   ctf.rmin = Rmin;
   DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
@@ -156,9 +185,13 @@ main(int argc, char* argv[])
   DEBUGPRINT("set resetflag of df,k\n");
   out.prior[0].resetflag = 1;
   out.prior[1].resetflag = 1;
-  out.prior[2].resetflag = 1;
   eosBayesProbabilityReset(info.fptIn,&out,1,0);
 
+  DEBUGPRINT("set rangechangeflag of B\n");
+  eosBayesRangeChangeflagSet(&out,2,0.95,20);
+  eosBayesProbabilityRangeChange(&out,0);
+
+
   DistributionChangeCheck(&out, 4, 0);
   DEBUGPRINT("----maxflagcheck----\n");
   #ifdef DEBUG
@@ -168,13 +201,12 @@ main(int argc, char* argv[])
   #endif
 
   DefocusEstimationLoop(info,&out,&ctfinfo,&ctf,&intensity,&likelihood,4,1);
-  DEBUGPRINT("A,df,k search finish\n");
+  DEBUGPRINT("A,B,df search finish\n");
   ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
 
 
-  /*df,A serch*/
-
-  DEBUGPRINT("df, A, k search start\n");
+  /*df,A, B 2 serch*/
+  DEBUGPRINT("df, A, B search 2 start\n");
   ctf.rmax = Rintermediate;
   ctf.rmin = Rmin;
   DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
@@ -183,8 +215,8 @@ main(int argc, char* argv[])
   eosBayesMaxposteriorflagSet(&out,4);
 
   DEBUGPRINT("set canstantflag of Ain");
-  out.posterior[5].constantflag = 1;
   out.posterior[3].constantflag = 1;
+  out.posterior[5].constantflag = 1;
 
   DEBUGPRINT("set resetflag of df,k\n");
   out.prior[0].resetflag = 1;
@@ -192,15 +224,17 @@ main(int argc, char* argv[])
 
 
   DEBUGPRINT("set rangechangeflag of A\n");
-  out.posterior[1].rangechangeflag = 1;
-  out.posterior[2].rangechangeflag = 1;
-  eosBayesProbabilityRangeChange(&out,20,0.95,0);
+  eosBayesRangeChangeflagSet(&out,1,0.95,20);
+  eosBayesRangeChangeflagSet(&out,2,0.95,20);
+  eosBayesProbabilityRangeChange(&out,0);
 
   DistributionChangeCheck(&out, 5, 0);
   DEBUGPRINT("----maxflagcheck----\n");
   #ifdef DEBUG
   for(i=0;i<out.numDistribution;i++){
        printf("dist%d:%d\n",i,(out.posterior[i].maxposteriorflag));
+       printf("rangechange%d:%d\n",i,(out.posterior[i].rangechangeflag));
+
   }
   #endif
 
@@ -209,18 +243,19 @@ main(int argc, char* argv[])
   ctfforbayescheckIntensityOfMaxPosterior(ctf,out.posterior,out.numDistribution,&ctfinfo,intensity.MTFmode,intensity.Ainmode,1,1);
 
 
-/*Defocus ref*/
+  /*Defocus ref*/
   DEBUGPRINT("defocus refinement start\n");
-  ctf.rmax = Rintermediate;
-  ctf.rmin = Rmin;
+  ctf.rmax = Rmax;
+  ctf.rmin = Rfirstpeak;
   DEBUGPRINT2("set R range:%f~%f\n",ctf.rmin,ctf.rmax);
 
   DEBUGPRINT("set maxposteriorflag of defocus,A,B,MTF\n");
   out.posterior[0].maxposteriorflag = 0;
   out.posterior[1].maxposteriorflag = 0;
   out.posterior[3].maxposteriorflag = 0;
+  out.posterior[4].maxposteriorflag = 0;
   out.posterior[5].maxposteriorflag = 0;
-  eosBayesMaxposteriorflagSet(&out,4);
+  // eosBayesMaxposteriorflagSet(&out,4);
 
   DEBUGPRINT("set canstantflag of Ain");
   out.posterior[3].constantflag = 0;
@@ -232,11 +267,11 @@ main(int argc, char* argv[])
   eosBayesProbabilityReset(info.fptIn,&out,1,0);
 
   DEBUGPRINT("set rangechangeflag of A\n");
-  out.posterior[0].rangechangeflag = 1;
-  out.posterior[1].rangechangeflag = 1;
-  out.posterior[2].rangechangeflag = 1;
-  eosBayesProbabilityRangeChange(&out,20,0.95,0);
-
+  eosBayesRangeChangeflagSet(&out,0,0.70,10);
+  eosBayesRangeChangeflagSet(&out,1,0.95,20);
+  eosBayesRangeChangeflagSet(&out,2,0.95,20);
+  eosBayesRangeChangeflagSet(&out,4,0.40,5);
+  eosBayesProbabilityRangeChange(&out,0);
 
   DistributionChangeCheck(&out, 6, 0);
   defocusLikelihoodInit(&likelihood,&out,1);