This repository is a base of Eos.
Revision | cade8e66ce4fafc8e2833d9d2071ae0dda23bb4a (tree) |
---|---|
Time | 2016-11-04 21:27:55 |
Author | 久永浩司 <hisanagakouji@hisa...> |
Commiter | 久永浩司 |
modified ctfforbayes.c
@@ -27,7 +27,7 @@ typedef struct ctfforbayes{ | ||
27 | 27 | float rmax; |
28 | 28 | float rmin; |
29 | 29 | float* I; |
30 | - float** Ii; | |
30 | + float* Ii; | |
31 | 31 | } ctfforbayes; |
32 | 32 | |
33 | 33 | typedef enum intensityforbayesMode{ |
@@ -37,10 +37,10 @@ typedef enum intensityforbayesMode{ | ||
37 | 37 | |
38 | 38 | |
39 | 39 | typedef struct intensityforbayes{ |
40 | - float** normI; | |
41 | - float** logI; | |
42 | - float** normII; | |
43 | - float** logII; | |
40 | + float* normI; | |
41 | + float* logI; | |
42 | + float* normII; | |
43 | + float* logII; | |
44 | 44 | |
45 | 45 | intensityforbayesMode mode; |
46 | 46 |
@@ -86,19 +86,22 @@ extern "C" { | ||
86 | 86 | /* prototype begin */ |
87 | 87 | /*ctfforbayes.c*/ |
88 | 88 | extern void ctfforbayesInit(FILE* fpt, ctfforbayes* ctf, int mode); |
89 | -extern void intensityforbayesInit(intensityforbayes* intensity, int filenum, int Inum, int mode); | |
90 | -extern void intensitySet(ctfforbayes* ctf, intensityforbayes intensity, int count, int mode); | |
89 | +extern void intensityforbayesInit(intensityforbayes* intensity,int Inum, int mode); | |
90 | +extern void intensitySet(ctfforbayes* ctf, intensityforbayes* intensity, int mode); | |
91 | 91 | extern void spatialfrequencyRead(FILE* fpt, ctfforbayes* ctf, float rmax, float rmin, int mode); |
92 | 92 | extern void intensityRead(char* filename, intensityforbayes* intensity, int count, int mode); |
93 | 93 | |
94 | -extern void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayesDistribution* d, ctfInfo* info, int numLikelihood, int count, int mode); | |
94 | +extern void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayes* d, ctfInfo* info, defocuslikelihoodforbayes* l, int count, int mode); | |
95 | 95 | extern float MTFFunctionforbayes(float R, float m, int mode); |
96 | 96 | extern float ctfforbayesIntensityCalculation(float* parameter, float R, ctfInfo* info, int mode); |
97 | +extern void ctfforbayesFree(ctfforbayes* ctf, intensityforbayes* intensity, defocuslikelihoodforbayes* likedihood); | |
98 | + | |
97 | 99 | |
98 | 100 | /*defocuslikelihood.c*/ |
99 | 101 | extern void defocusLikelihoodInit(defocuslikelihoodforbayes* l, eosBayes d, int mode); |
100 | -extern void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayes* d, int count, int mode); | |
101 | -extern void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayesDistribution* d, int numLikelihood, int count, int mode); | |
102 | +extern void ctfforbayesXofLikelihoodCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int* L, int count, int mode); | |
103 | +extern void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int count, int mode); | |
104 | +extern void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayesDistribution* d, int numLikelihood, int* L, int count, int mode); | |
102 | 105 | extern void ctfforBayesMeanCalculation(defocuslikelihoodforbayes* l, eosBayesDistribution* d, int numLikelihood, int count, int mode); |
103 | 106 | extern void defocusLikelihoodCalculationLorentz(defocuslikelihoodforbayes* l, eosBayesDistribution* d, int numLikelihood, int count, int mode); |
104 | 107 |
@@ -88,6 +88,7 @@ extern void eosBayesRead(FILE* fpt, eosBayes* d, int mode); | ||
88 | 88 | /* eosBayesParameterOfMaxPosterior.c*/ |
89 | 89 | extern void eosBayesParameterOfMaxPosteriorGet(eosBayesDistribution* d, int nunDistribution, int mode); |
90 | 90 | |
91 | +extern void eosBayesFree(eosBayes* d); | |
91 | 92 | |
92 | 93 | |
93 | 94 | #endif /* EOS_BAYES_H */ |
@@ -45,24 +45,18 @@ void ctfforbayesInit(FILE* fpt, ctfforbayes* ctf, int mode){ | ||
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | -void intensityforbayesInit(intensityforbayes* intensity, int filenum, int Inum, int mode){ | |
48 | +void intensityforbayesInit(intensityforbayes* intensity, int Inum, int mode){ | |
49 | 49 | |
50 | - int i; | |
51 | 50 | |
52 | - intensity->normI = (float**)malloc(sizeof(float*)*filenum); | |
53 | - intensity->logI = (float**)malloc(sizeof(float*)*filenum); | |
51 | + intensity->normI = (float*)malloc(sizeof(float)*Inum); | |
52 | + intensity->logI = (float*)malloc(sizeof(float)*Inum); | |
54 | 53 | |
55 | - for(i=0;i<filenum;i++){ | |
56 | - intensity->normI[i] = (float*)malloc(sizeof(float)*Inum); | |
57 | - intensity->logI[i] = (float*)malloc(sizeof(float)*Inum); | |
58 | - } | |
59 | - | |
60 | - intensity->normII = (float**)malloc(sizeof(float*)*Inum); | |
61 | - intensity->logII = (float**)malloc(sizeof(float*)*Inum); | |
54 | + intensity->normII = (float*)malloc(sizeof(float)*Inum); | |
55 | + intensity->logII = (float*)malloc(sizeof(float)*Inum); | |
62 | 56 | |
63 | 57 | intensity->mode = 0; |
64 | 58 | |
65 | - DEBUGPRINT2("Intensityinit finitsh! filenum:%d Inum:%d\n",filenum,Inum); | |
59 | + DEBUGPRINT1("Intensityinit finitsh! Inum:%d\n",Inum); | |
66 | 60 | |
67 | 61 | } |
68 | 62 |
@@ -99,8 +93,8 @@ void intensityRead(char* filename, intensityforbayes* intensity, int count, int | ||
99 | 93 | |
100 | 94 | i=0; |
101 | 95 | while(NULL != __getStringData(s,"In IntensityRead",fin,stdout,3)){ |
102 | - intensity->normI[count][i] = atof(s); | |
103 | - intensity->logI[count][i] = log(intensity->normI[count][i]); | |
96 | + intensity->normI[i] = atof(s); | |
97 | + intensity->logI[i] = log(intensity->normI[i]); | |
104 | 98 | i++; |
105 | 99 | } |
106 | 100 |
@@ -111,22 +105,22 @@ void intensityRead(char* filename, intensityforbayes* intensity, int count, int | ||
111 | 105 | } |
112 | 106 | |
113 | 107 | |
114 | -void intensitySet(ctfforbayes* ctf, intensityforbayes intensity, int count, int mode){ | |
108 | +void intensitySet(ctfforbayes* ctf, intensityforbayes* intensity, int mode){ | |
115 | 109 | |
116 | - switch(intensity.mode){ | |
110 | + switch(intensity->mode){ | |
117 | 111 | |
118 | 112 | case normal: |
119 | 113 | /*Normal*/ |
120 | - DEBUGPRINT("----Intensity mode Normal----\n"); | |
121 | - ctf->I = intensity.normI[count]; | |
122 | - ctf->Ii = intensity.normII; | |
114 | + //DEBUGPRINT("----Intensity mode Normal----\n"); | |
115 | + ctf->I = intensity->normI; | |
116 | + ctf->Ii = intensity->normII; | |
123 | 117 | break; |
124 | 118 | |
125 | 119 | case logarithm: |
126 | 120 | /*Log*/ |
127 | - DEBUGPRINT("----Intensity mode Log----\n"); | |
128 | - ctf->I = intensity.logI[count]; | |
129 | - ctf->Ii = intensity.logII; | |
121 | + //DEBUGPRINT("----Intensity mode Log----\n"); | |
122 | + ctf->I = intensity->logI; | |
123 | + ctf->Ii = intensity->logII; | |
130 | 124 | break; |
131 | 125 | |
132 | 126 | default: |
@@ -140,7 +134,7 @@ void intensitySet(ctfforbayes* ctf, intensityforbayes intensity, int count, int | ||
140 | 134 | |
141 | 135 | |
142 | 136 | |
143 | -void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayesDistribution* d, ctfInfo* info, int numLikelihood, int count, int mode){ | |
137 | +void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayes* d, ctfInfo* info, defocuslikelihoodforbayes* l, int count, int mode){ | |
144 | 138 | |
145 | 139 | float* parameter; |
146 | 140 | int* L; |
@@ -154,46 +148,50 @@ void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBaye | ||
154 | 148 | |
155 | 149 | DEBUGPRINT("In ctf\n"); |
156 | 150 | |
157 | - parameter = (float*)malloc(sizeof(float)*numLikelihood); | |
151 | + parameter = (float*)malloc(sizeof(float)*d->numLikelihood); | |
158 | 152 | |
159 | 153 | length = 1; |
160 | - for(i=0;i<numLikelihood;i++){ | |
161 | - length *= d[i].n; | |
154 | + for(i=0;i<d->numLikelihood;i++){ | |
155 | + length *= d->likelihood[i].n; | |
162 | 156 | } |
163 | 157 | |
164 | 158 | //DEBUGPRINT("L malloc\n"); |
165 | 159 | |
166 | - L = (int *)malloc(sizeof(int)*numLikelihood); | |
160 | + L = (int *)malloc(sizeof(int)*d->numLikelihood); | |
167 | 161 | |
168 | 162 | //DEBUGPRINT("L malloc\n"); |
169 | - | |
170 | - for(i=0;i<ctf->n;i++){ | |
171 | - intensity->normII[i] = (float *)malloc(sizeof(float)*length); | |
172 | - intensity->logII[i] = (float *)malloc(sizeof(float)*length); | |
173 | - //DEBUGPRINT("Ii malloc\n"); | |
174 | 163 | |
175 | - for(j=0;j<length;j++){ | |
176 | 164 | |
177 | - eosBayesloop(d,L,numLikelihood,j); | |
178 | - | |
179 | - //DEBUGPRINT3("%d:%d:%d\n",L[0],L[1],L[2]); | |
180 | - /* | |
181 | - info->defocus = d[0].min+(d[0].delta*L[0]); | |
182 | - S = d[1].min+(d[1].delta*L[1]); | |
183 | - N = d[2].min+(d[2].delta*L[2]); | |
184 | - */ | |
185 | - | |
186 | - for(k=0;k<numLikelihood;k++){ | |
187 | - parameter[k] = d[k].value[L[k]]; | |
188 | - } | |
165 | + for(i=0;i<d->numLikelihood;i++){ | |
166 | + l->width[i] = 0; | |
167 | + for(j=0;j<d->likelihood[i].n;j++){ | |
168 | + l->x[i][j] = 0; | |
169 | + } | |
170 | + } | |
189 | 171 | |
190 | - intensity->normII[i][j] = ctfforbayesIntensityCalculation(parameter,ctf->R[i],info,mode); | |
191 | - intensity->logII[i][j] = log(intensity->normII[i][j]); | |
192 | 172 | |
173 | + DEBUGPRINT("likelihood culcuration start\n"); | |
174 | + for(i=0;i<length;i++){ | |
175 | + eosBayesloop(d->likelihood,L,d->numLikelihood,i); | |
176 | + for(k=0;k<d->numLikelihood;k++){ | |
177 | + parameter[k] = d->likelihood[k].value[L[k]]; | |
178 | + } | |
179 | + //DEBUGPRINT3("%d:%d:%d\n",L[0],L[1],L[2]); | |
180 | + for(j=0;j<ctf->n;j++){ | |
181 | + intensity->normII[j] = ctfforbayesIntensityCalculation(parameter,ctf->R[j],info,mode); | |
182 | + intensity->logII[j] = log(intensity->normII[j]); | |
193 | 183 | } |
194 | 184 | |
185 | + intensitySet(ctf,intensity,0); | |
186 | + ctfforbayesXofLikelihoodCalculation(l,ctf,d,L,0,0); | |
187 | + | |
195 | 188 | } |
196 | 189 | |
190 | + defocusLikelihood(l,ctf,d,i,0); | |
191 | + | |
192 | + DEBUGPRINT("likelihood culcuration end\n"); | |
193 | + LikelihoodChangeCheck(d,i,0); | |
194 | + | |
197 | 195 | free(parameter); |
198 | 196 | free(L); |
199 | 197 |
@@ -231,11 +229,31 @@ float ctfforbayesIntensityCalculation(float* parameter, float R, ctfInfo* info, | ||
231 | 229 | float A; |
232 | 230 | float B; |
233 | 231 | float m; |
232 | + int mode2; | |
233 | + | |
234 | + mode2 = 1; | |
234 | 235 | |
235 | 236 | info->defocus = parameter[0]; |
236 | 237 | S = parameter[1]; |
237 | 238 | N = parameter[2]; |
238 | - m = parameter[4]; | |
239 | + | |
240 | + switch(mode2){ | |
241 | + | |
242 | + case 0: | |
243 | + | |
244 | + m = 7.8; | |
245 | + //m = 0; | |
246 | + break; | |
247 | + | |
248 | + case 1: | |
249 | + m = parameter[4]; | |
250 | + break; | |
251 | + | |
252 | + default: | |
253 | + fprintf(stderr,"\n"); | |
254 | + break; | |
255 | + | |
256 | + } | |
239 | 257 | |
240 | 258 | CTF = ctfFunction(info, R, 0); |
241 | 259 | MTF = MTFFunctionforbayes(R, m, 0); |
@@ -269,3 +287,20 @@ float ctfforbayesIntensityCalculation(float* parameter, float R, ctfInfo* info, | ||
269 | 287 | return (CTF*CTF*A+B)*MTF; |
270 | 288 | |
271 | 289 | } |
290 | + | |
291 | + | |
292 | +void ctfforbayesFree(ctfforbayes* ctf, intensityforbayes* intensity, defocuslikelihoodforbayes* likedihood){ | |
293 | + | |
294 | + DEBUGPRINT("In ctfforbayesfree\n"); | |
295 | + | |
296 | + free(ctf->R); | |
297 | + | |
298 | + free(intensity->normI); | |
299 | + free(intensity->logI); | |
300 | + | |
301 | + free(intensity->normII); | |
302 | + free(intensity->logII); | |
303 | + | |
304 | + DEBUGPRINT("compreated ctfforbayesfree\n"); | |
305 | + | |
306 | +} |
@@ -103,7 +103,7 @@ void ctfforbayescheckintensity(ctfforbayes ctf, eosBayesDistribution* d, int num | ||
103 | 103 | } |
104 | 104 | fprintf(fpt,"# d:%f A:%f B:%f\n",d[0].value[L[0]],d[1].value[L[1]],d[2].value[L[2]]); |
105 | 105 | for(j=0;j<ctf.n;j++){ |
106 | - fprintf(fpt,"%f %f %f %f\n",ctf.R[j],ctf.I[j],ctf.Ii[j][i],ctf.I[j]-ctf.Ii[j][i]); | |
106 | + fprintf(fpt,"%f %f %f %f\n",ctf.R[j],ctf.I[j],ctf.Ii[j],ctf.I[j]-ctf.Ii[j]); | |
107 | 107 | } |
108 | 108 | fprintf(fpt,"\n"); |
109 | 109 | fclose(fpt); |
@@ -123,7 +123,7 @@ void ctfforbayescheckintensity(ctfforbayes ctf, eosBayesDistribution* d, int num | ||
123 | 123 | } |
124 | 124 | fprintf(fpt,"# d:%f A:%f B:%f k:%f\n",d[0].value[L[0]],d[1].value[L[1]],d[2].value[L[2]],d[3].value[L[3]]); |
125 | 125 | for(j=0;j<ctf.n;j++){ |
126 | - fprintf(fpt,"%f %f %f %f\n",ctf.R[j],ctf.I[j],ctf.Ii[j][i],ctf.I[j]-ctf.Ii[j][i]); | |
126 | + fprintf(fpt,"%f %f %f %f\n",ctf.R[j],ctf.I[j],ctf.Ii[j],ctf.I[j]-ctf.Ii[j]); | |
127 | 127 | } |
128 | 128 | fprintf(fpt,"\n"); |
129 | 129 | fclose(fpt); |
@@ -27,7 +27,7 @@ typedef struct ctfforbayes{ | ||
27 | 27 | float rmax; |
28 | 28 | float rmin; |
29 | 29 | float* I; |
30 | - float** Ii; | |
30 | + float* Ii; | |
31 | 31 | } ctfforbayes; |
32 | 32 | |
33 | 33 | typedef enum intensityforbayesMode{ |
@@ -37,10 +37,10 @@ typedef enum intensityforbayesMode{ | ||
37 | 37 | |
38 | 38 | |
39 | 39 | typedef struct intensityforbayes{ |
40 | - float** normI; | |
41 | - float** logI; | |
42 | - float** normII; | |
43 | - float** logII; | |
40 | + float* normI; | |
41 | + float* logI; | |
42 | + float* normII; | |
43 | + float* logII; | |
44 | 44 | |
45 | 45 | intensityforbayesMode mode; |
46 | 46 |
@@ -86,19 +86,22 @@ extern "C" { | ||
86 | 86 | /* prototype begin */ |
87 | 87 | /*ctfforbayes.c*/ |
88 | 88 | extern void ctfforbayesInit(FILE* fpt, ctfforbayes* ctf, int mode); |
89 | -extern void intensityforbayesInit(intensityforbayes* intensity, int filenum, int Inum, int mode); | |
90 | -extern void intensitySet(ctfforbayes* ctf, intensityforbayes intensity, int count, int mode); | |
89 | +extern void intensityforbayesInit(intensityforbayes* intensity,int Inum, int mode); | |
90 | +extern void intensitySet(ctfforbayes* ctf, intensityforbayes* intensity, int mode); | |
91 | 91 | extern void spatialfrequencyRead(FILE* fpt, ctfforbayes* ctf, float rmax, float rmin, int mode); |
92 | 92 | extern void intensityRead(char* filename, intensityforbayes* intensity, int count, int mode); |
93 | 93 | |
94 | -extern void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayesDistribution* d, ctfInfo* info, int numLikelihood, int count, int mode); | |
94 | +extern void ctfFunctionforbayes(ctfforbayes* ctf, intensityforbayes* intensity, eosBayes* d, ctfInfo* info, defocuslikelihoodforbayes* l, int count, int mode); | |
95 | 95 | extern float MTFFunctionforbayes(float R, float m, int mode); |
96 | 96 | extern float ctfforbayesIntensityCalculation(float* parameter, float R, ctfInfo* info, int mode); |
97 | +extern void ctfforbayesFree(ctfforbayes* ctf, intensityforbayes* intensity, defocuslikelihoodforbayes* likedihood); | |
98 | + | |
97 | 99 | |
98 | 100 | /*defocuslikelihood.c*/ |
99 | 101 | extern void defocusLikelihoodInit(defocuslikelihoodforbayes* l, eosBayes d, int mode); |
100 | -extern void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayes* d, int count, int mode); | |
101 | -extern void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayesDistribution* d, int numLikelihood, int count, int mode); | |
102 | +extern void ctfforbayesXofLikelihoodCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int* L, int count, int mode); | |
103 | +extern void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int count, int mode); | |
104 | +extern void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayesDistribution* d, int numLikelihood, int* L, int count, int mode); | |
102 | 105 | extern void ctfforBayesMeanCalculation(defocuslikelihoodforbayes* l, eosBayesDistribution* d, int numLikelihood, int count, int mode); |
103 | 106 | extern void defocusLikelihoodCalculationLorentz(defocuslikelihoodforbayes* l, eosBayesDistribution* d, int numLikelihood, int count, int mode); |
104 | 107 |
@@ -21,7 +21,7 @@ static char __sccs_id[] = "%Z%defocuslikelihood ver%I%; Date:%D% %Z%"; | ||
21 | 21 | #include "./ctffuncforbayes.h" |
22 | 22 | |
23 | 23 | |
24 | -#define DEBUG | |
24 | +#undef DEBUG | |
25 | 25 | #undef DEBUG2 |
26 | 26 | #include "genUtil.h" |
27 | 27 | #include "String.h" |
@@ -48,27 +48,16 @@ void defocusLikelihoodInit(defocuslikelihoodforbayes* l, eosBayes d, int mode){ | ||
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | +void ctfforbayesXofLikelihoodCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int* L, int count, int mode){ | |
51 | 52 | |
52 | -void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayes* d, int count, int mode){ | |
53 | 53 | |
54 | - int i; | |
55 | - int j; | |
56 | - | |
57 | - | |
58 | - DEBUGPRINT("In defocuslikelihood\n"); | |
59 | - | |
60 | - for(i=0;i<d->numLikelihood;i++){ | |
61 | - l->width[i] = 0; | |
62 | - for(j=0;j<d->likelihood[i].n;j++){ | |
63 | - l->x[i][j] = 0; | |
64 | - } | |
65 | - } | |
54 | + DEBUGPRINT("In ctfforbayesXofLikelihoodCaluculation\n"); | |
66 | 55 | |
67 | 56 | switch(l->mode0){ |
68 | 57 | |
69 | 58 | case difference: |
70 | 59 | DEBUGPRINT("xmode is difference\n"); |
71 | - ctfforBayesDifferenceCalculation(l,ctf,d->likelihood,d->numLikelihood,count,mode); | |
60 | + ctfforBayesDifferenceCalculation(l,ctf,d->likelihood,d->numLikelihood,L,count,mode); | |
72 | 61 | break; |
73 | 62 | |
74 | 63 | case correlation: |
@@ -83,7 +72,13 @@ void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayes* | ||
83 | 72 | break; |
84 | 73 | |
85 | 74 | } |
75 | +} | |
76 | + | |
77 | + | |
86 | 78 | |
79 | +void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayes* d, int count, int mode){ | |
80 | + | |
81 | + DEBUGPRINT("In defocuslikelihood\n"); | |
87 | 82 | |
88 | 83 | switch(l->mode1){ |
89 | 84 |
@@ -123,36 +118,22 @@ void defocusLikelihood(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayes* | ||
123 | 118 | |
124 | 119 | |
125 | 120 | |
126 | -void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes ctf, eosBayesDistribution* d, int numLikelihood, int count, int mode){ | |
121 | +void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes* ctf, eosBayesDistribution* d, int numLikelihood, int* L, int count, int mode){ | |
127 | 122 | |
128 | 123 | float difference; |
129 | 124 | int length; |
130 | - int* L; | |
131 | 125 | |
132 | 126 | int i; |
133 | - int j; | |
134 | - | |
135 | 127 | |
136 | 128 | DEBUGPRINT("In ctfforBayesDifferenceCaluculation\n"); |
137 | 129 | |
138 | 130 | |
139 | - length = 1; | |
140 | - for(i=0;i<numLikelihood;i++){ | |
141 | - length *= d[i].n; | |
142 | - } | |
143 | - L = (int*)malloc(sizeof(int)*numLikelihood); | |
144 | - DEBUGPRINT("L malloc\n"); | |
145 | - | |
146 | - | |
147 | - DEBUGPRINT("difference caluculattion start\n") | |
148 | - for(i=0;i<length;i++){ | |
149 | - eosBayesloop(d,L,numLikelihood,i); | |
150 | - | |
131 | + DEBUGPRINT("difference caluculattion start\n"); | |
151 | 132 | |
152 | 133 | difference = 0; |
153 | - for(j=0;j<ctf.n;j++){ | |
154 | - if((ctf.rmin<=ctf.R[j]) && (ctf.R[j]<=ctf.rmax)){ | |
155 | - difference += (ctf.I[j]-ctf.Ii[j][i])*(ctf.I[j]-ctf.Ii[j][i]); | |
134 | + for(i=0;i<ctf->n;i++){ | |
135 | + if((ctf->rmin<=ctf->R[i]) && (ctf->R[i]<=ctf->rmax)){ | |
136 | + difference += (ctf->I[i]-ctf->Ii[i])*(ctf->I[i]-ctf->Ii[i]); | |
156 | 137 | } |
157 | 138 | } |
158 | 139 |
@@ -160,20 +141,12 @@ void ctfforBayesDifferenceCalculation(defocuslikelihoodforbayes* l, ctfforbayes | ||
160 | 141 | DEBUGPRINT3("L[0]:%d L[1]:%d L[2]:%d\n",L[0],L[1],L[2]); |
161 | 142 | #endif |
162 | 143 | |
163 | - for(j=0;j<numLikelihood;j++){ | |
164 | - l->x[j][L[j]] += difference; | |
144 | + for(i=0;i<numLikelihood;i++){ | |
145 | + l->x[i][L[i]] += difference; | |
165 | 146 | } |
166 | 147 | |
167 | 148 | |
168 | - } | |
169 | - DEBUGPRINT("difference caluculattion stop\n") | |
170 | - | |
171 | -#ifdef DEBUG2 | |
172 | - ctfforbayescheckdifference("difference",l,d,numLikelihood,count,0); | |
173 | -#endif | |
174 | - | |
175 | - | |
176 | - free(L); | |
149 | + DEBUGPRINT("difference caluculattion stop\n"); | |
177 | 150 | |
178 | 151 | |
179 | 152 | } |
@@ -211,7 +184,7 @@ void defocusLikelihoodCalculationLorentz(defocuslikelihoodforbayes* l, eosBayesD | ||
211 | 184 | DEBUGPRINT("In defocuslikelihoodcaluculationLorentz \n"); |
212 | 185 | |
213 | 186 | sum = (float*)malloc(sizeof(float)*numLikelihood); |
214 | - | |
187 | + | |
215 | 188 | DEBUGPRINT("sum malloc\n"); |
216 | 189 | for(i=0;i<numLikelihood;i++){ |
217 | 190 | sum[i] = 0; |
@@ -243,7 +216,7 @@ void defocusLikelihoodCalculationLorentz(defocuslikelihoodforbayes* l, eosBayesD | ||
243 | 216 | } |
244 | 217 | } |
245 | 218 | |
246 | - DEBUGPRINT("free\n"); | |
219 | + DEBUGPRINT("sum free\n"); | |
247 | 220 | free(sum); |
248 | 221 | |
249 | 222 | } |
@@ -99,6 +99,7 @@ extern void eosBayesRead(FILE* fpt, eosBayes* d, int mode); | ||
99 | 99 | /* eosBayesParameterOfMaxPosterior.c*/ |
100 | 100 | extern void eosBayesParameterOfMaxPosteriorGet(eosBayesDistribution* d, int nunDistribution, int mode); |
101 | 101 | |
102 | +extern void eosBayesFree(eosBayes* d); | |
102 | 103 | |
103 | 104 | |
104 | 105 | #endif /* EOS_BAYES_H */ |
@@ -88,6 +88,7 @@ extern void eosBayesRead(FILE* fpt, eosBayes* d, int mode); | ||
88 | 88 | /* eosBayesParameterOfMaxPosterior.c*/ |
89 | 89 | extern void eosBayesParameterOfMaxPosteriorGet(eosBayesDistribution* d, int nunDistribution, int mode); |
90 | 90 | |
91 | +extern void eosBayesFree(eosBayes* d); | |
91 | 92 | |
92 | 93 | |
93 | 94 | #endif /* EOS_BAYES_H */ |
@@ -0,0 +1,41 @@ | ||
1 | +/* | |
2 | +# %M% %Y% %I% | |
3 | +# The latest update : %G% at %U% | |
4 | +# | |
5 | +#%Z% eosBayesFree ver %I% | |
6 | +#%Z% Created by | |
7 | +#%Z% | |
8 | +#%Z% Usage : eosBayesFree | |
9 | +#%Z% Attention | |
10 | +#%Z% | |
11 | +*/ | |
12 | +static char __sccs_id[] = "%Z%eosBayesFree ver%I%; Date:%D% %Z%"; | |
13 | + | |
14 | +#include <stdio.h> | |
15 | +#include <string.h> | |
16 | +#include <stdlib.h> | |
17 | +#include "../inc/eosBayes.h" | |
18 | +#define DEBUG | |
19 | +#include "genUtil.h" | |
20 | + | |
21 | + | |
22 | +void eosBayesFree(eosBayes* d){ | |
23 | + | |
24 | + DEBUGPRINT("In eosBayesFree\n"); | |
25 | + | |
26 | + free(d->prior->value); | |
27 | + free(d->prior->prob); | |
28 | + | |
29 | + free(d->posterior->value); | |
30 | + free(d->posterior->prob); | |
31 | + | |
32 | + free(d->likelihood->value); | |
33 | + free(d->likelihood->prob); | |
34 | + | |
35 | + free(d->prior); | |
36 | + free(d->posterior); | |
37 | + free(d->likelihood); | |
38 | + | |
39 | + DEBUGPRINT("Compreated eosBayesFree\n"); | |
40 | + | |
41 | +} |
@@ -0,0 +1,30 @@ | ||
1 | +/* | |
2 | +# %M% %Y% %I% | |
3 | +# The latest update : %G% at %U% | |
4 | +# | |
5 | +#%Z% eosBayesFree ver %I% | |
6 | +#%Z% Created by | |
7 | +#%Z% | |
8 | +#%Z% Usage : eosBayesFree | |
9 | +#%Z% Attention | |
10 | +#%Z% | |
11 | +*/ | |
12 | +static char __sccs_id[] = "%Z%eosBayesFree ver%I%; Date:%D% %Z%"; | |
13 | + | |
14 | + | |
15 | +void eosBayesFree(eosBayes* d){ | |
16 | + | |
17 | + free(d->prior->value); | |
18 | + free(d->prior->prob); | |
19 | + | |
20 | + free(d->posterior->value); | |
21 | + free(d->posterior->prob); | |
22 | + | |
23 | + free(d->likelihood->value); | |
24 | + free(d->likelihood->prob); | |
25 | + | |
26 | + free(d->prior); | |
27 | + free(d->posterior); | |
28 | + free(d->likelihood); | |
29 | + | |
30 | +} |
@@ -46,6 +46,7 @@ main(int argc, char* argv[]) | ||
46 | 46 | eosBayesDistributionInfo llinfo; |
47 | 47 | |
48 | 48 | eosBayes out; |
49 | + | |
49 | 50 | ctfforbayes ctf; |
50 | 51 | intensityforbayes intensity; |
51 | 52 | defocuslikelihoodforbayes likelihood; |
@@ -69,16 +70,13 @@ main(int argc, char* argv[]) | ||
69 | 70 | |
70 | 71 | /*For CTF and intensity*/ |
71 | 72 | ctfforbayesInit(info.fptIn2,&ctf,0); |
72 | - intensityforbayesInit(&intensity,info.flagIn4,ctf.n,0); | |
73 | + intensityforbayesInit(&intensity,ctf.n,0); | |
73 | 74 | spatialfrequencyRead(info.fptIn2,&ctf,info.rmax,info.rmin,0); |
74 | - for(i=0;i<info.flagIn4;i++){ | |
75 | - intensityRead(info.In4[i],&intensity,i,0); | |
76 | - } | |
77 | 75 | ctfInfoRead(info.fptIn3,&ctfinfo,"",0); |
78 | - DEBUGPRINT4("kV:%f Cs:%f Ain:%f ctfMode:%ld\n",ctfinfo.kV,ctfinfo.Cs,ctfinfo.Ain,ctfinfo.mode); | |
76 | + DEBUGPRINT5("kV:%f Cs:%f Ain:%f Cc:%f ctfMode:%ld\n",ctfinfo.kV,ctfinfo.Cs,ctfinfo.Ain,ctfinfo.Cc,ctfinfo.mode); | |
79 | 77 | DEBUGPRINT1("flagIn4:%ld\n",info.flagIn4); |
80 | - DEBUGPRINT("ctf start\n"); | |
81 | - ctfFunctionforbayes(&ctf, &intensity,out.likelihood,&ctfinfo,out.numLikelihood,0,1); | |
78 | + | |
79 | + | |
82 | 80 | |
83 | 81 | /*For likelihood*/ |
84 | 82 | defocusLikelihoodInit(&likelihood,out,0); |
@@ -86,20 +84,14 @@ main(int argc, char* argv[]) | ||
86 | 84 | /*defocus estimation*/ |
87 | 85 | for(i=0;i<info.flagIn4;i++){ |
88 | 86 | |
89 | - DEBUGPRINT("set intensity\n"); | |
90 | - intensitySet(&ctf,intensity,i,0); | |
91 | - | |
92 | - | |
93 | - DEBUGPRINT("likelihood start\n"); | |
94 | - defocusLikelihood(&likelihood,ctf,&out,i,0); | |
95 | - LikelihoodChangeCheck(&out,i,0); | |
96 | - | |
87 | + intensityRead(info.In4[i],&intensity,i,0); | |
88 | + DEBUGPRINT("ctf start\n"); | |
89 | + ctfFunctionforbayes(&ctf, &intensity,&out,&ctfinfo,&likelihood,0,1); | |
97 | 90 | |
98 | 91 | DEBUGPRINT("estimate start\n"); |
99 | 92 | eosBayesEstimation(&out,0); |
100 | 93 | DistributionChangeCheck(&out,1); |
101 | 94 | |
102 | - | |
103 | 95 | DEBUGPRINT("change start\n"); |
104 | 96 | eosBayesPosteriortoPrior(&out,0); |
105 | 97 |
@@ -110,6 +102,9 @@ main(int argc, char* argv[]) | ||
110 | 102 | |
111 | 103 | eosBayesPriorWrite(info.fptOut,&out,0); |
112 | 104 | |
105 | + ctfforbayesFree(&ctf,&intensity,&likelihood); | |
106 | + eosBayesFree(&out); | |
107 | + | |
113 | 108 | exit(EXIT_SUCCESS); |
114 | 109 | } |
115 | 110 |