| Bsoft 2.0.5 Bernard's software package

mg_tomo_resol.cpp
Go to the documentation of this file.
1
9 #include "mg_tomo_resol.h"
10 #include "mg_tomo_rec.h"
11 #include "mg_reconstruct.h"
12 #include "rwimg.h"
13 #include "mg_ctf.h"
14 #include "Complex.h"
15 #include "linked_list.h"
16 #include "utilities.h"
17
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20
21 Bplot* img_calculate_FRC_curve(vector<Bimage*> parr, double hi_res, double sampling_ratio);
22 double plot_calculate_resolution(Bplot* plot, double cutoff);
23 int plot_resolution(Bplot* plot, double hi_res, Bstring& psfile, Bstring& title);
24
25 int img_pack_2D_into_central_section_old(Bimage* p, Bimage* prec, Bimage* prec2,
26 long ft_size, int zsize, double scale, double hi_res,
27 Matrix3 matr, Matrix3 mat, int inplane);
28
29
62 vector<Bimage*> mg_tomo_res_reconstruct(Bproject* project, int micrograph_id, double hi_res,
63 double sampling_ratio, double scale, Vector3<long> size,
64 double fast_angle, int action, double wiener)
65 {
66 vector<Bimage*> parr;
67 long i;
68 int pad_factor(0);
69 Vector3<long> tile_size(128,128,1);
70
71 Bfield* field = project->field;
72 Bmicrograph* mg_res;
73 Bmicrograph* mg;
74
75 for ( mg_res = field->mg, i=0; mg_res && i < micrograph_id; mg_res = mg_res->next, i++ ) ;
76
77 if ( !mg_res ) {
78 error_show("Error in mg_tomo_res_reconstruct", __FILE__, __LINE__);
79 cerr << "Micrograph number " << micrograph_id << " not found!" << endl << endl;
80 return parr;
81 }
82
83 if ( !mg_res->select ) {
84 if ( verbose & VERB_FULL )
85 cout << "Skipping micrograph number %d!" << micrograph_id << endl << endl;
86 return parr;
87 }
88
89 if ( mg_res->fmg.length() < 0 ) {
90 error_show("Error in mg_tomo_res_reconstruct", __FILE__, __LINE__);
91 cerr << "No micrograph image file name given for micrograph " << mg_res->id << endl;
92 return parr;
93 }
94
95 if ( hi_res < 2*mg_res->pixel_size ) hi_res = 2*mg_res->pixel_size;
96
97 Bimage* pt;
98 Bimage* p = NULL;
99 if ( pad_factor < 1 && mg_res->fft.length() > 0 ) p = read_img(mg_res->fft, 1, mg_res->img_num);
100 else p = read_img(mg_res->fmg, 1, mg_res->img_num);
101
102 p->sampling(mg_res->pixel_size, mg_res->pixel_size, 1);
103 p->origin(mg_res->origin[0], mg_res->origin[1], 0.0);
104
105 if ( size[2] < 1 ) size[2] = p->sizeX();
106 if ( size.volume() < 1 ) size = Vector3<long>(p->size());
107 if ( size[2] > p->sizeX() ) size[2] = p->sizeX();
108 if ( size[2] > p->sizeY() ) size[2] = p->sizeY();
109
110 long ft_size = findNextPowerOf((int)(pad_factor*size[0]*scale), 2);
111 if ( ft_size < p->sizeX() ) ft_size = p->sizeX();
112 if ( ft_size < p->sizeY() ) ft_size = p->sizeY();
113
114 if ( verbose & VERB_DEBUG )
115 cout << "DEBUG mg_tomo_res_reconstruct: size=" << size << " ft_size=" << ft_size << endl;
116
117 if ( action )
118 img_ttf_apply(p, *(mg_res->ctf), action, wiener,
119 tile_size, mg_res->tilt_angle, mg_res->tilt_axis, 0, 0);
120
121 // Do transformation if not already done
122 if ( p->compound_type() == TSimple ) {
123 if ( pad_factor ) {
124 ft_size = findNextPowerOf((int)(pad_factor*size[0]*scale), 2);
125 p->calculate_background();
126 }
127 p->pad(ft_size, FILL_AVERAGE, p->average());
128 p->fft();
129 p->phase_shift_to_origin();
130 }
131
132 // Header structure for the final reconstruction
133 Bimage* prec = new Bimage(Float, TComplex, ft_size, ft_size, 1, 1);
134 prec->sampling(mg_res->pixel_size, mg_res->pixel_size, 1);
135 prec->origin(prec->size()/2);
136
137 Bimage* prec2 = prec->copy();
138
139 prec->next = new Bimage(Float, TSimple, prec->size(), 1);
140 prec2->next = new Bimage(Float, TSimple, prec2->size(), 1);
141
142 float* fom = (float *) prec->next->data_pointer();
143 float* fom2 = (float *) prec2->next->data_pointer();
144
145 long data_size = (long) prec->size().volume();
146
147 // if ( verbose & VERB_PROCESS ) {
148 if ( verbose ) {
149 cout << "NLOO resolution test:" << endl;
150 cout << "Micrograph: " << mg_res->id << " (" << mg_res->img_num << ")" << endl;
151 cout << "Tilt angle: " << mg_res->tilt_angle*180.0/M_PI << endl;
152 if ( fast_angle )
153 cout << "Maximum angular offset: " << fast_angle*180.0/M_PI << endl;
154 cout << "Fourier transform size: " << ft_size << " x " << ft_size << endl;
155 cout << "Reconstruction size: " << size << endl;
156 cout << "Resolution limit: " << hi_res << " A" << endl;
157 cout << "Sampling ratio: " << sampling_ratio << endl;
158 if ( action )
159 cout << "CTF correction: " << action << " (wiener=" << wiener << ")" << endl;
160 }
161
162 long nrec(0);
163 long nmg = count_list((char *) field->mg);
164
165 for ( mg=field->mg; mg; mg=mg->next ) if ( mg->select )
166 if ( fabs(mg->tilt_angle - mg_res->tilt_angle) <= fast_angle ) {
167 if ( verbose )
168 cout << "Reading image " << mg->img_num << " (micrograph " << mg->id << ")" << endl;
169 pt = NULL;
170 if ( mg->fft.length() > 0 )
171 pt = read_img(mg->fft, 1, 0);
172 if ( !pt ) {
173 if ( ( pt = read_img(mg->fmg, 1, mg->img_num) ) == NULL ) {
174 error_show("mg_tomo_res_reconstruct", __FILE__, __LINE__);
175 return parr;
176 }
177 }
178
179 if ( mg == mg_res ) mg->fom = p->average();
180
181 pt->origin(mg->origin[0], mg->origin[1], 0.0);
182
183 if ( action )
184 img_ttf_apply(pt, *(mg->ctf), action, wiener,
185 tile_size, mg->tilt_angle, mg->tilt_axis, 0, 0);
186
187 if ( pt->compound_type() == TSimple ) {
188 pt->pad(ft_size, FILL_AVERAGE, pt->average());
189 pt->fft();
190 pt->phase_shift_to_origin();
191 }
192
193 img_pack_2D_into_central_section_old(pt, prec, prec2, ft_size, size[2], 1, hi_res,
194 mg_res->matrix, mg->matrix, (mg==mg_res));
195 // img_pack_2D_into_central_section(pt, prec, prec2, ft_size, 1, hi_res,
196 // mg_res->matrix, mg->matrix, (mg==mg_res));
197
198 delete pt;
199
200 nrec++;
201
202 if ( verbose & ( VERB_TIME | VERB_PROCESS ) ) {
203 cout << "Complete: " << nrec*100.0/nmg << "%\r";
204 cout.flush();
205 }
206
207 }
208
209 if ( nrec < 1 ) {
210 delete prec;
211 delete prec2;
212 error_show("Error in mg_tomo_res_reconstruct: No micrographs used in this reconstruction!", __FILE__, __LINE__);
213 return parr;
214 }
215
216 if ( verbose )
217 cout << "Weighing reconstruction. " << endl;
218
219 for ( i=0; i<data_size; i++ ) {
220 if ( fom[i] ) prec->set(i, prec->complex(i) / fom[i]);
221 if ( fom2[i] ) prec2->set(i, prec2->complex(i) / fom2[i]);
222 fom[i] = fom[i]/(fom[i] + 1);
223 fom2[i] = fom2[i]/(fom2[i] + 1);
224 }
225
226 parr.push_back(p);
227 parr.push_back(prec);
228 parr.push_back(prec2);
229
230 return parr;
231 }
232
266 Bimage* mg_tomo_resolution(Bproject* project, int micrograph_id, double hi_res,
267 double sampling_ratio, double scale, Vector3<long> size,
268 double fast_angle, int action, double wiener, double cutoff, Bstring& psfile)
269 {
270 long i;
271 Bfield* field = project->field;
272 Bmicrograph* mg_res;
273
274 for ( mg_res = field->mg, i=0; mg_res && i < micrograph_id; mg_res = mg_res->next, i++ ) ;
275
276 if ( !mg_res ) {
277 error_show("Error in mg_tomo_resolution", __FILE__, __LINE__);
278 cerr << "Micrograph number " << micrograph_id << " not found!" << endl << endl;
279 return NULL;
280 }
281
282 vector<Bimage*> parr = mg_tomo_res_reconstruct(project, micrograph_id, hi_res,
283 sampling_ratio, scale, size, fast_angle, action, wiener);
284
285 Bplot* plot = img_calculate_FRC_curve(parr, hi_res, sampling_ratio);
286 double resolution = plot_calculate_resolution(plot, cutoff);
287 mg_res->fom = resolution;
288
289 Bstring filename(parr[0]->file_name());
290 Bstring title = "Resolution for " + filename + ": image " + Bstring(mg_res->img_num+1, "%d");
291 if ( psfile.length() > 0 ) plot_resolution(plot, hi_res, psfile, title);
292
293 if ( verbose )
294 cout << "Resolution: " << setprecision(2) << resolution << endl << endl;
295
296
297 delete parr[0];
298 delete parr[2];
299 delete plot;
300
301 return parr[1];
302 }
303
335 Bplot* project_tomo_resolution(Bproject* project, double hi_res,
336 double sampling_ratio, double scale, Vector3<long> size,
337 double fast_angle, int action, double wiener, double cutoff)
338 {
339 long nmg, i;
340 Bfield* field = project->field;
341 Bmicrograph* mg = NULL;
342 // Bstring title("Micrograph resolution for a tilt series");
343 Bstring label;
344
345 for ( nmg=0, field = project->field; field; field = field->next )
346 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) nmg++;
347
348 /* Bplot* plot = new Bplot(1, nmg, 2);
349 plot->title(title);
350 plot->page(0).title(title);
351 plot->page(0).columns(2);
352 for ( i=0; i<2; i++ ) plot->page(0).column(i).number(i);
353 plot->page(0).column(0).label("TiltAngle");
354 plot->page(0).column(1).label("NLOO");
355 plot->page(0).column(1).type(2);
356 plot->page(0).column(0).axis(1);
357 plot->page(0).column(1).axis(3);
358 plot->page(0).column(1).color(0,0,0);
359 */
360 Bplot* mgplot = NULL;
361
362 for ( i=0, field = project->field; field; field = field->next ) {
363 for ( mg = field->mg; mg; mg = mg->next, i++ ) if ( mg->select ) {
364 vector<Bimage*> parr = mg_tomo_res_reconstruct(project, i, hi_res,
365 sampling_ratio, scale, size, fast_angle, action, wiener);
366 if ( verbose )
367 cout << "Intensity: " << setprecision(2) << mg->fom << endl << endl;
368 mgplot = img_calculate_FRC_curve(parr, hi_res, sampling_ratio);
369 mg->fom = plot_calculate_resolution(mgplot, cutoff);
370 if ( verbose )
371 cout << "Resolution: " << setprecision(2) << mg->fom << endl << endl;
372 delete parr[0];
373 delete parr[1];
374 delete parr[2];
375 delete mgplot;
376 // (*plot)[i] = mg->tilt_angle*180.0/M_PI;
377 // (*plot)[i+nmg] = mg->fom;
378 }
379 }
380
381 // plot->page(0).axis(1).label("Tilt Angle (degrees)");
382 // plot->page(0).axis(3).label("Resolution (A)");
383
384 Bplot* plot = plot_tilt_resolution(project);
385 label = Bstring(cutoff, "NLOO cutoff: %g");
386 plot->page(0).add_text(label);
387
388 // Bstring filename(parr[0]->file_name());
389 // Bstring title = "Resolution for " + filename + ": image " + Bstring(mg_res->img_num+1, "%d");
390 // if ( psfile.length() > 0 ) plot_resolution(plot, hi_res, psfile, title);
391
392 return plot;
393 }
394
408 Bplot* project_tomo_particle_resolution(Bproject* project, double hi_res,
409 double sampling_ratio, double fast_angle, double cutoff)
410 {
411 long i, j, nmg(0);
412 long npart(0);
413 int pad_factor(0);
414 double scale(1), resolution;
415 Bfield* field, *field_res;
416 Bmicrograph* mg, *mg_res;
417 Breconstruction* rec;
418 Bparticle* partlist = NULL;
419 Bparticle* recpart = NULL;
420 Bparticle* part = NULL, *part_res = NULL;
421 Bimage* prec, *prec2;
422 Bimage* pmg;
423 Bimage* ppart, *ppart_res = NULL;
424 Bplot* plot = NULL;
425 Bstring psfile;
426
427 for ( rec = project->rec; rec; rec = rec->next )
428 if ( rec->part ) {
429 partlist = rec->part;
430 break;
431 }
432
433 if ( !partlist ) {
434 cerr << "No particle list found!" << endl << endl;
435 return NULL;
436 }
437
438 for ( nmg=0, field = project->field; field; field = field->next )
439 for ( mg = field->mg; mg; mg = mg->next ) nmg++;
440
441 if ( !nmg ) {
442 cerr << "No micrographs found!" << endl << endl;
443 return NULL;
444 }
445
446 for ( field = project->field; field; field = field->next ) {
447 for ( mg = field->mg; mg; mg = mg->next )
448 if ( mg && mg->part ) break;
449 if ( mg && mg->part ) break;
450 }
451
452 if ( !mg || !mg->part ) {
453 cerr << "No micrograph particles found!" << endl << endl;
454 return NULL;
455 }
456
457 double* res_avg = new double[nmg];
458 double* res_std = new double[nmg];
459 for ( i=0; i<nmg; i++ ) res_avg[i] = res_std[i] = 0;
460
461 Vector3<long> boxsize(mg->box_size);
462
463 if ( hi_res < 2*mg->pixel_size ) hi_res = 2*mg->pixel_size;
464
465 Vector3<double> realsize(boxsize[0]*mg->pixel_size, boxsize[1]*mg->pixel_size, 1);
466 double rad_scale = realsize[0];
467 if ( rad_scale < realsize[1] ) rad_scale = realsize[1];
468 if ( rad_scale < realsize[2] ) rad_scale = realsize[2];
469 if ( boxsize[0] > 256 ) rad_scale *= 256.0/boxsize[0];
470 long maxrad = (long) (rad_scale/hi_res);
471
472 int ft_size = boxsize[0];
473 if ( pad_factor ) ft_size = part_ft_size(boxsize[0], scale, pad_factor);
474
475 fft_plan planp = fft_setup_plan(ft_size, ft_size, 1, FFTW_FORWARD, 1);
476
477 if ( verbose ) {
478 cout << "Calculating individual particle resolutions:" << endl;
479 cout << "Number of micrographs: " << nmg << endl;
480 cout << "Particle size: " << boxsize << endl;
481 cout << "Fourier transform size: " << ft_size << " x " << ft_size << endl;
482 cout << "High resolution limit: " << hi_res << " A" << endl;
483 cout << "FRC cutoff: " << cutoff << endl;
484 cout << endl;
485 }
486
487 double s, sp, FRC, FRCp, fraction;
488 double* sum_r_2 = new double[maxrad] ;
489 double* sum_r2_2 = new double[maxrad] ;
490 double* sum_i_r = new double[maxrad] ;
491 double* sum_i_r2 = new double[maxrad] ;
492
493 for ( npart=0, recpart = partlist; recpart; recpart = recpart->next ) {
494 if ( verbose ) {
495 cout << "Resolution for particle " << recpart->id << ":" << endl;
496 cout << "#mg\tAngle\tNLOO(" << cutoff << ")" << endl;
497 }
498
499 for ( j=0; j<maxrad; j++ ) sum_r_2[j] = sum_r2_2[j] = sum_i_r[j] = sum_i_r2[j] = 0;
500
501 for ( i=0, field_res = project->field; field_res; field_res = field_res->next ) if ( field_res->select ) {
502 for ( mg_res = field_res->mg; mg_res; mg_res = mg_res->next ) if ( mg_res->select ) {
503 for ( part_res = mg_res->part; part_res; part_res = part_res->next )
504 if ( recpart->id == part_res->id ) break;
505
506 if ( part_res ) {
507
508 prec = new Bimage(Float, TComplex, ft_size, ft_size, 1, 1);
509 prec->sampling(mg_res->pixel_size, mg_res->pixel_size, 1);
510 prec->origin(prec->size()/2);
511
512 prec2 = prec->copy();
513
514 prec->next = new Bimage(Float, TSimple, prec->size(), 1);
515 prec2->next = new Bimage(Float, TSimple, prec2->size(), 1);
516
517 for ( field = project->field; field; field = field->next ) if ( field->select ) {
518 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select )
519 if ( fabs(mg->tilt_angle - mg_res->tilt_angle) <= fast_angle ) {
520 for ( part = mg->part; part; part = part->next )
521 if ( recpart->id == part->id ) break;
522
523 if ( part ) {
524 if ( ( pmg = read_img(mg->fmg, 1, mg->img_num) ) == NULL ) {
525 error_show("project_tomo_particle_resolution", __FILE__, __LINE__);
526 return NULL;
527 }
528 ppart = pmg->extract(0, part->loc - boxsize/2, boxsize);
529 delete pmg;
530 ppart->sampling(mg->pixel_size, mg->pixel_size, 1);
531 // ppart->image->origin(part->ori);
532 ppart->origin(part->ori);
533 ppart->image->view(part->view);
534 ppart->fft(planp);
535 ppart->phase_shift_to_origin();
536 img_pack_2D_into_central_section_old(ppart, prec, prec2,
537 ft_size, ppart->sizeX(), scale, hi_res,
538 mg_res->matrix, mg->matrix, (mg==mg_res));
539 if ( mg == mg_res ) ppart_res = ppart;
540 else delete ppart;
541 }
542 }
543 }
544 vector<Bimage*> parr;
545 parr.push_back(ppart_res);
546 parr.push_back(prec);
547 parr.push_back(prec2);
548 plot = img_calculate_FRC_curve(parr, hi_res, sampling_ratio);
549 resolution = plot_calculate_resolution(plot, cutoff);
550 delete ppart_res;
551 delete prec;
552 delete prec2;
553 for ( j=0; j<maxrad; j++ ) {
554 sum_r_2[j] += (*plot)[2*maxrad+j];
555 sum_r2_2[j] += (*plot)[3*maxrad+j];
556 sum_i_r[j] += (*plot)[4*maxrad+j];
557 sum_i_r2[j] += (*plot)[5*maxrad+j];
558 }
559 delete plot;
560 part_res->fom[0] = resolution;
561 res_avg[i] += resolution;
562 res_std[i] += resolution*resolution;
563 i++;
564 if ( verbose )
565 cout << i << tab << setprecision(2) << mg_res->tilt_angle*180.0/M_PI << tab << resolution << endl;
566 }
567 }
568 }
569 npart++;
570 if ( verbose ) {
571 cout << endl;
572 cout << "3D resolution: " << endl;
573 cout << "s(1/A)\tRes(A)\tNLOO3D" << endl;
574 sp = 0;
575 FRCp = 1;
576 resolution = 1/rad_scale;
577 for ( j=1; j<maxrad; j++ ) {
578 s = j/rad_scale;
579 if ( fabs(sum_i_r2[j]) < SMALLFLOAT || fabs(sum_i_r[j]) < SMALLFLOAT )
580 FRC = 0;
581 else
582 FRC = (sum_i_r2[j]*sqrt(sum_r_2[j]))/(sum_i_r[j]*sqrt(sum_r2_2[j]));
583 if ( FRC < 0 ) FRC = 0;
584 if ( FRC > cutoff ) resolution = 1/s;
585 if ( FRCp > cutoff && FRC <= cutoff ) {
586 fraction = (FRCp - cutoff)/(FRCp - FRC);
587 if ( sp ) resolution = (1-fraction)/sp + fraction/s;
588 }
589 sp = s;
590 FRCp = FRC;
591 cout << setprecision(4) << s << tab << setprecision(1) << 1/s << tab << setprecision(4) << FRC << endl;
592 }
593 cout << "NLOO3D resolution: " << resolution << endl << endl;
594 }
595 }
596
597 delete[] sum_r_2;
598 delete[] sum_r2_2;
599 delete[] sum_i_r;
600 delete[] sum_i_r2;
601
602 fft_destroy_plan(planp);
603
604 Bstring title("Particle resolution for a tilt series");
605 plot = new Bplot(1, nmg, 3);
606 plot->title(title);
607 plot->page(0).title(title);
608 plot->page(0).columns(3);
609 for ( i=0; i<3; i++ ) plot->page(0).column(i).number(i);
610 plot->page(0).column(0).label("TiltAngle");
611 plot->page(0).column(1).label("NLOOavg");
612 plot->page(0).column(2).label("NLOOstd");
613 // plot->page(0).axis(1).min(0);
614 // plot->page(0).axis(1).max(1/hi_res);
615 // plot->page(0).axis(1).inc(0.1/hi_res);
616 plot->page(0).column(1).type(2);
617 plot->page(0).column(2).type(3);
618 plot->page(0).column(0).axis(1);
619 plot->page(0).column(1).axis(3);
620 plot->page(0).column(2).axis(3);
621 plot->page(0).column(1).color(0,0,0);
622 plot->page(0).column(2).color(1,0,0);
623
624 Bstring label = Bstring(cutoff, "NLOO cutoff: %g");
625 plot->page(0).add_text(label);
626 label = Bstring(boxsize[0], "Box size: %g") + Bstring(boxsize[1], " x %g");
627 plot->page(0).add_text(label);
628
629 double min(1e37), max(0);
630
631 if ( verbose ) {
632 cout << "Average resolution for " << npart << " particles:" << endl;
633 cout << "#mg\tAngle\tFRCavg\tFRCstd" << endl;
634 }
635 for ( i=0, field = project->field; field; field = field->next ) {
636 for ( mg = field->mg; mg; mg = mg->next, i++ ) {
637 res_avg[i] /= npart;
638 res_std[i] = res_std[i]/npart - res_avg[i]*res_avg[i];
639 if ( res_std[i] > 0 ) res_std[i] = sqrt(res_std[i]);
640 else res_std[i] = 0;
641 if ( min > res_avg[i] - res_std[i] ) min = res_avg[i] - res_std[i];
642 if ( max < res_avg[i] + res_std[i] ) max = res_avg[i] + res_std[i];
643 (*plot)[i] = mg->tilt_angle*180.0/M_PI;
644 (*plot)[i+nmg] = res_avg[i];
645 (*plot)[i+2*nmg] = res_std[i];
646 if ( verbose )
647 cout << i+1 << tab << setprecision(2) << mg->tilt_angle*180.0/M_PI << tab <<
648 res_avg[i] << tab << res_std[i] << endl;
649 }
650 }
651 if ( verbose )
652 cout << endl;
653
654 delete[] res_avg;
655 delete[] res_std;
656
657 if ( verbose & VERB_DEBUG )
658 cout << "DEBUG project_tomo_particle_resolution: min=" << min << " max=" << max << endl;
659
660 plot->page(0).axis(1).label("Tilt Angle (degrees)");
661 plot->page(0).axis(3).label("Resolution (A)");
662 plot->page(0).axis(3).min(min);
663 plot->page(0).axis(3).max(max);
664
665 return plot;
666 }
667
689 long img_pack_2D_into_central_section(Bimage* p, Bimage* prec, Bimage* prec2,
690 long ft_size, double scale, double hi_res,
691 Matrix3 matr, Matrix3 mat, int inplane)
692 {
693 if ( !p->data_pointer() ) return 0;
694
695 if ( hi_res < 2*prec->sampling()[0] ) hi_res = 2*prec->sampling()[0];
696
697 if ( verbose & VERB_FULL )
698 cout << "Packing an image into reciprocal space up to " << hi_res << " A resolution" << endl << endl;
699
700 long i, j, x, y, kx, ky;
701 long ix, iy, ixx, iyy, nover(0);
702 double w, dx, dy, d2;
703 Vector3<double> m, d(0,0,1), iv;
704
705 // Vector3<double> vscale(prec->sizeX()/(scale*ft_size), prec->sizeY()/(scale*ft_size), 1/scale);
706
707 float* fom = (float *) prec->next->data_pointer();
708 float* fom2 = (float *) prec2->next->data_pointer();
709
710 int notinplane = 1 - inplane; // Flag to indicate if this image corresponds to testing image
711
712 if ( verbose & VERB_FULL & inplane ) cout << "In plane image" << endl;
713 if ( verbose & VERB_FULL )
714 cout << mat << endl;
715
716 double maxrad = p->sampling()[0]/hi_res;
717 double maxrad_sq = maxrad*maxrad; // Maximum radius squared on map scale
718 double ymin = floor(-maxrad*p->sizeY());
719 double ymax = -ymin;
720 double xmin = floor(-maxrad*p->sizeX());
721 double xmax = -xmin;
722
723 // Vector to calculate z-shift
724 Vector3<double> vn(matr[2][0]/matr[2][2], matr[2][1]/matr[2][2], 0);
725
726 matr = matr.transpose();
727 // matr = vscale * matr;
728
729 for ( iv[1]=ymin; iv[1]<=ymax; iv[1]+=1 ) {
730 if ( iv[1] >= 0 ) y = (long)iv[1];
731 else y = (long)(iv[1] + p->sizeY());
732 dy = iv[1]/p->sizeY();
733 for ( iv[0]=xmin; iv[0]<=xmax; iv[0]+=1 ) {
734 if ( iv[0] >= 0 ) x = (long)iv[0];
735 else x = (long)(iv[0] + p->sizeX());
736 dx = iv[0]/p->sizeX();
737 d2 = dx*dx + dy*dy;
738 if ( d2 <= maxrad_sq ) {
739 m = mat * iv;
740 m[2] = m.scalar(vn);
741 m = matr * m;
742 d[2] = fabs(m[2]);
743 if ( d[2] <= 1 ) {
744 ix = (long) floor(m[0]);
745 iy = (long) floor(m[1]);
746 d[0] = m[0] - ix;
747 d[1] = m[1] - iy;
748 i = y*p->sizeX() + x;
749 for ( ky=0; ky<2; ky++ ) {
750 iyy = iy + ky;
751 if ( iyy < 0 ) iyy += prec->sizeY();
752 d[1] = 1 - d[1];
753 for ( kx=0; kx<2; kx++ ) {
754 ixx = ix + kx;
755 if ( ixx < 0 ) ixx += prec->sizeX();
756 d[0] = 1 - d[0];
757 j = iyy*prec->sizeX() + ixx;
758 w = d.volume();
759 fom[j] += w;
760 prec->add(j, p->complex(i) * w);
761 if ( notinplane ) {
762 fom2[j] += w;
763 prec2->add(j, p->complex(i) * w);
764 }
765 }
766 }
767 nover++;
768 }
769 }
770 }
771 }
772
773 return nover;
774 }
775
776 int img_pack_2D_into_central_section_old(Bimage* p, Bimage* prec, Bimage* prec2,
777 long ft_size, int zsize, double scale, double hi_res,
778 Matrix3 matr, Matrix3 mat, int inplane)
779 {
780 if ( !p->data_pointer() ) return 0;
781
782 if ( hi_res < 2*prec->sampling()[0] ) hi_res = 2*prec->sampling()[0];
783
784 if ( verbose & VERB_FULL )
785 cout << "Packing an image into reciprocal space up to " << hi_res << " A resolution" << endl << endl;
786
787 long i, j, x, y, kx, ky;
788 long ix, iy, ixx, iyy;
789 double w, d2;
790 Vector3<double> m, d, iv;
791
792 Vector3<double> invsize(1.0/prec->sizeX(), 1.0/prec->sizeY(), 1.0/zsize);
793 Vector3<double> vscale(prec->sizeX()/(scale*ft_size), prec->sizeY()/(scale*ft_size), zsize/(scale*ft_size));
794
795 float* fom = (float *) prec->next->data_pointer();
796 float* fom2 = (float *) prec2->next->data_pointer();
797
798 int notinplane = 1 - inplane; // Flag to indicate if this image corresponds to testing image
799
800 if ( verbose & VERB_FULL & inplane ) cout << "In plane image" << endl;
801 if ( verbose & VERB_FULL )
802 cout << mat << endl;
803
804 double maxrad = prec->sampling()[0]/hi_res;
805 double maxrad_sq = maxrad*maxrad; // Maximum radius squared on map scale
806 double ymin = floor(-maxrad*p->sizeY());
807 double ymax = -ymin;
808 double xmin = floor(-maxrad*p->sizeX());
809 double xmax = -xmin;
810
811 Vector3<double> vt(mat[0][2], mat[1][2], 0);
812 if ( vt[0] || vt[1] ) vt.normalize();
813 vt *= 1 - mat[2][2]/matr[2][2];
814 // if ( fabs(mat[2]) > fabs(mat[5]) ) { if ( mat[2] > 0 ) vt *= -1; }
815 // else { if ( mat[5] > 0 ) vt *= -1; }
816 // if ( tilt_angle < 0 ) vt *= -1;
817 if ( mat[0][2] > 0 ) vt *= -1;
818 // vt = 0;
819
820 // cout << mat << endl;
821
822 mat = mat.transpose();
823 mat = vscale * mat;
824 mat = mat * matr;
825
826 for ( iv[1]=ymin; iv[1]<=ymax; iv[1]+=1 ) {
827 if ( iv[1] >= 0 ) y = (long)iv[1];
828 else y = (long)(p->sizeY() + iv[1]);
829 for ( iv[0]=xmin; iv[0]<=xmax; iv[0]+=1 ) {
830 if ( iv[0] >= 0 ) x = (long)iv[0];
831 else x = (long)(p->sizeX() + iv[0]);
832 m = mat * iv;
833 m += iv * vt;
834 d[2] = fabs(m[2]);
835 if ( d[2] <= 1 ) {
836 // d[2] = 1 - d[2];
837 d[2] = 1;
838 d2 = (m * invsize).length2();
839 if ( d2 <= maxrad_sq ) {
840 ix = (long) floor(m[0]);
841 iy = (long) floor(m[1]);
842 d[0] = m[0] - ix;
843 d[1] = m[1] - iy;
844 i = y*p->sizeX() + x;
845 for ( ky=0; ky<2; ky++ ) {
846 iyy = iy + ky;
847 if ( iyy < 0 ) iyy += prec->sizeY();
848 d[1] = 1 - d[1];
849 for ( kx=0; kx<2; kx++ ) {
850 ixx = ix + kx;
851 if ( ixx < 0 ) ixx += prec->sizeX();
852 d[0] = 1 - d[0];
853 j = iyy*prec->sizeX() + ixx;
854 w = d.volume();
855 fom[j] += w;
856 prec->add(j, p->complex(i) * w);
857 if ( notinplane ) {
858 fom2[j] += w;
859 prec2->add(j, p->complex(i) * w);
860 }
861 }
862 }
863 }
864 }
865 }
866 }
867
868 return 0;
869 }
870
871
879 Bplot* img_calculate_FRC_curve(vector<Bimage*> parr, double hi_res, double sampling_ratio)
880 {
881 if ( parr.size() < 3 ) return NULL;
882
883 Bimage* p = parr[0];
884 Bimage* prec = parr[1];
885 Bimage* prec2 = parr[2];
886
887 if ( !p->data_pointer() ) return NULL;
888
889 if ( hi_res < 2*prec->sampling()[0] ) hi_res = 2*prec->sampling()[0];
890
891 if ( sampling_ratio < 1 ) sampling_ratio = 1;
892
893 long i, j, x, y, z, iradius, iradius2, nt(0), nf(0);
894 long xx, yy, zz;
895 double rx, ry, rz, radius, fraction, fraction2, v;
896
897 Vector3<double> realsize(p->real_size());
898 Vector3<double> freq_scale(1.0/realsize);
899 double rad_scale_max(realsize[0]/sampling_ratio);
900 double rad_scale = realsize[0];
901 if ( rad_scale < realsize[1] ) rad_scale = realsize[1];
902 if ( rad_scale < realsize[2] ) rad_scale = realsize[2];
903
904 // if ( p->sizeX() > rad_scale_max ) rad_scale *= rad_scale_max/p->sizeX();
905 if ( rad_scale > rad_scale_max ) rad_scale = rad_scale_max;
906 long maxrad = (long) (rad_scale/hi_res);
907
908 if ( verbose & VERB_DEBUG )
909 cout << "DEBUG img_calculate_FRC_curve: maxrad=" << maxrad << endl;
910
911 vector<double> n(maxrad);
912 vector<double> sum_i_2(maxrad);
913 vector<double> sum_r_2(maxrad);
914 vector<double> sum_r2_2(maxrad);
915 vector<double> sum_i_r(maxrad);
916 vector<double> sum_i_r2(maxrad);
917
918 for ( i=0; i<maxrad; i++ )
919 n[i] = sum_i_2[i] = sum_r_2[i] = sum_r2_2[i] = sum_i_r[i] = sum_i_r2[i] = 0;
920
921 float* fom = (float *) prec2->next->data_pointer();
922
923 for ( i=z=0; z<p->sizeZ(); z++ ) {
924 zz = z;
925 if ( z > (p->sizeZ() - 1)/2 ) zz -= p->sizeZ();
926 rz = zz*freq_scale[2];
927 for ( y=0; y<p->sizeY(); y++ ) {
928 yy = y;
929 if ( y > (p->sizeY() - 1)/2 ) yy -= p->sizeY();
930 ry = yy*freq_scale[1];
931 for ( x=0; x<p->sizeX(); x++, i++ ) {
932 xx = x;
933 if ( x > (p->sizeX() - 1)/2 ) xx -= p->sizeX();
934 rx = xx*freq_scale[0];
935 radius = rad_scale*sqrt(rx*rx + ry*ry + rz*rz);
936 iradius = (long) radius;
937 iradius2 = iradius + 1;
938 // if ( fom[i] && ( iradius < maxrad ) ) {
939 if ( iradius2 < maxrad ) {
940 fraction = radius - iradius;
941 fraction2 = 1.0 - fraction;
942 v = (p->complex(i)).power();
943 sum_i_2[iradius] += fraction2*v;
944 sum_i_2[iradius2] += fraction*v;
945 v = (prec->complex(i)).power();
946 sum_r_2[iradius] += fraction2*v;
947 sum_r_2[iradius2] += fraction*v;
948 v = (prec2->complex(i)).power();
949 sum_r2_2[iradius] += fraction2*v;
950 sum_r2_2[iradius2] += fraction*v;
951 v = (p->complex(i)).real()*(prec->complex(i)).real() + (p->complex(i)).imag()*(prec->complex(i)).imag();
952 sum_i_r[iradius] += fraction2*v;
953 sum_i_r[iradius2] += fraction*v;
954 v = (p->complex(i)).real()*(prec2->complex(i)).real() + (p->complex(i)).imag()*(prec2->complex(i)).imag();
955 sum_i_r2[iradius] += fraction2*v;
956 sum_i_r2[iradius2] += fraction*v;
957 n[iradius] += fraction2;
958 n[iradius2] += fraction;
959 nt++;
960 if ( fom[i] ) nf++;
961 }
962 }
963 }
964 }
965
966 Bplot* plot = new Bplot(1, maxrad, 6);
967 (*plot)[0] = 0;
968 (*plot)[maxrad] = 1;
969
970 double s, FRC;
971
972 if ( verbose & VERB_PROCESS )
973 cout << "Pixel\ts\tResol\tsumI2\tsumR2\tsumRo2\tsumIR\tsumIRo\tFRC\tNum" << endl;
974 else if ( verbose )
975 cout << "Pixel\ts\tResol\tFRC" << endl;
976 for ( i=1; i<maxrad; i++ ) {
977 s = i/rad_scale;
978 FRC = 1.;
979 if ( sum_i_r[i] < SMALLFLOAT || sum_r2_2[i] < SMALLFLOAT )
980 FRC = 0;
981 else
982 // FRC = (sum_i_r2[i]*sqrt(sum_r_2[i]))/(sum_i_r[i]*sqrt(sum_r2_2[i]));
983 FRC = (sum_i_r2[i]/sum_i_r[i])*sqrt(sum_r_2[i]/sum_r2_2[i]);
984 if ( FRC > 1 ) FRC = 1;
985 if ( FRC < 0 ) FRC = 0;
986 if ( verbose & VERB_PROCESS )
987 cout << i << tab
988 << setprecision(4) << s << tab
989 << setprecision(2) << 1/s << tab
990 << setprecision(0) << sum_i_2[i] << tab
991 << sum_r_2[i] << tab << sum_r2_2[i] << tab
992 << sum_i_r[i] << tab << sum_i_r2[i] << tab
993 << setprecision(4) << FRC << tab
994 << setprecision(0) << n[i] << endl;
995 else if ( verbose )
996 cout << i << tab
997 << setprecision(4) << s << tab
998 << setprecision(2) << 1/s << tab
999 << setprecision(4) << FRC << endl;
1000 (*plot)[i] = s;
1001 j = i + maxrad;
1002 (*plot)[j] = FRC;
1003 j += maxrad;
1004 (*plot)[j] = sum_r_2[i];
1005 j += maxrad;
1006 (*plot)[j] = sum_r2_2[i];
1007 j += maxrad;
1008 (*plot)[j] = sum_i_r[i];
1009 j += maxrad;
1010 (*plot)[j] = sum_i_r2[i];
1011 }
1012
1013 if ( verbose & VERB_PROCESS ) {
1014 cout << "Total voxels: " << nt << endl;
1015 cout << "Coverage: " << nf << " (" << nf*100.0/nt << " %)" << endl;
1016 }
1017
1018 return plot;
1019 }
1020
1027 double plot_calculate_resolution(Bplot* plot, double cutoff)
1028 {
1029 double s, sp(0), FRC, FRCp(1), fraction, resolution(1000);
1030 long i, maxrad = (long) plot->rows();
1031
1032 for ( i=1; i<maxrad; i++ ) {
1033 s = (*plot)[i];
1034 FRC = (*plot)[i+maxrad];
1035 if ( FRC > cutoff ) resolution = 1/s;
1036 if ( FRCp > cutoff && FRC <= cutoff ) {
1037 fraction = (FRCp - cutoff)/(FRCp - FRC);
1038 if ( sp ) resolution = (1-fraction)/sp + fraction/s;
1039 }
1040 sp = s;
1041 FRCp = FRC;
1042 }
1043
1044 Bstring txt = Bstring(cutoff, "FSC(%g): ") + Bstring(resolution, "%g A");
1045 plot->page(0).add_text(txt);
1046
1047 return resolution;
1048 }
1049
1058 int plot_resolution(Bplot* plot, double hi_res, Bstring& psfile, Bstring& title)
1059 {
1060 plot->title("Resolution");
1061 plot->page(0).title(title);
1062 plot->page(0).columns(2);
1063 plot->page(0).column(1).number(1);
1064 plot->page(0).column(0).label("Resolution(A)");
1065 plot->page(0).column(1).label("FRC");
1066 plot->page(0).axis(1).min(0);
1067 plot->page(0).axis(1).max(1/hi_res);
1068 plot->page(0).axis(1).inc(0.1/hi_res);
1069 plot->page(0).axis(1).flags(1);
1070 plot->page(0).axis(3).min(0);
1071 plot->page(0).axis(3).max(1);
1072 plot->page(0).axis(3).inc(0.1);
1073 plot->page(0).column(1).type(2);
1074 plot->page(0).column(0).axis(1);
1075 plot->page(0).column(1).axis(3);
1076
1077 if ( psfile.length() > 0 ) ps_plot(psfile, plot);
1078
1079 return 0;
1080 }
1081
1089 Bplot* plot_tilt_resolution(Bproject* project)
1090 {
1091 long nmg(0), i;
1092 Bfield* field = project->field;
1093 Bmicrograph* mg = NULL;
1094 Bstring title("Micrograph resolution for a tilt series");
1095
1096 for ( nmg=0, field = project->field; field; field = field->next )
1097 for ( mg = field->mg; mg; mg = mg->next ) if ( mg->select ) nmg++;
1098
1099 Bplot* plot = new Bplot(1, nmg, 2);
1100 plot->title(title);
1101 plot->page(0).title(title);
1102 plot->page(0).columns(2);
1103 for ( i=0; i<2; i++ ) plot->page(0).column(i).number(i);
1104 plot->page(0).column(0).label("TiltAngle");
1105 plot->page(0).column(1).label("NLOO");
1106 plot->page(0).column(1).type(2);
1107 plot->page(0).column(0).axis(1);
1108 plot->page(0).column(1).axis(3);
1109 plot->page(0).column(1).color(0,0,0);
1110
1111 for ( i=0, field = project->field; field; field = field->next ) {
1112 for ( mg = field->mg; mg; mg = mg->next, i++ ) if ( mg->select ) {
1113 (*plot)[i] = mg->tilt_angle*180.0/M_PI;
1114 (*plot)[i+nmg] = mg->fom;
1115 }
1116 }
1117
1118 plot->page(0).axis(1).label("Tilt Angle (degrees)");
1119 plot->page(0).axis(3).label("Resolution (A)");
1120
1121 return plot;
1122 }
Baxis::inc
double inc()
Definition: Bplot.h:34
Bparticle::id
int id
Definition: mg_processing.h:92
Baxis::label
Bstring & label()
Definition: Bplot.h:28
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
Vector3::normalize
double normalize()
Definition: Vector3.h:236
Bsub_image::view
void view(double x, double y, double z, double a)
Definition: Bimage.h:143
Bfield::select
long select
Definition: mg_processing.h:262
Bparticle::view
View view
Definition: mg_processing.h:101
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
Baxis::min
double min()
Definition: Bplot.h:30
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:304
Bimage::add
void add(long j, double v)
Definition: Bimage.h:308
project_tomo_resolution
Bplot * project_tomo_resolution(Bproject *project, double hi_res, double sampling_ratio, double scale, Vector3< long > size, double fast_angle, int action, double wiener, double cutoff)
Estimating the resolution of the tomogram from an aligned tilt series.
Definition: mg_tomo_resol.cpp:335
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
Bplot::title
Bstring & title()
Definition: Bplot.h:189
Bmicrograph::img_num
int img_num
Definition: mg_processing.h:211
SMALLFLOAT
#define SMALLFLOAT
Definition: utilities.h:45
Bimage::fft
int fft()
Definition: Bimage.h:822
utilities.h
Header file for general utilities.
VERB_DEBUG
#define VERB_DEBUG
Definition: utilities.h:112
Breconstruction
Definition: mg_processing.h:280
Bcolumn::label
Bstring & label()
Definition: Bplot.h:63
Bimage::compound_type
CompoundType compound_type()
Definition: Bimage.h:351
Complex.h
Class for complex numbers.
verbose
int verbose
Matrix3
Definition: Matrix3.h:17
FILL_AVERAGE
#define FILL_AVERAGE
Definition: utilities.h:173
Bstring::length
long length() const
Definition: Bstring.cpp:263
Bmicrograph::pixel_size
double pixel_size
Definition: mg_processing.h:214
project
Bproject * project
Definition: bshow.cpp:31
count_list
long count_list(char *list)
Counts the number of items in a linked list.
Definition: linked_list.cpp:235
length2
double length2(vector< T > v)
Definition: Vector3.h:517
Bimage::complex
Complex< double > complex(long j)
Returns a complex value at the given index.
Definition: Bimage.cpp:1005
mg_tomo_resol.h
Functions to assess the resoltion of a tomographic tilt series.
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
Bcolumn::color
double * color()
Definition: Bplot.h:76
mg_ctf.h
Functions for CTF (contrast transfer function) processing.
TComplex
Definition: Bimage.h:59
Bpage::column
Bcolumn & column(long i)
Definition: Bplot.h:110
Bmicrograph::tilt_angle
double tilt_angle
Definition: mg_processing.h:217
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:76
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
TSimple
Definition: Bimage.h:58
Baxis::max
double max()
Definition: Bplot.h:32
Float
Definition: utilities.h:157
part_ft_size
int part_ft_size(int xsize, double scale, int pad_factor)
Sets the Fourier transform size for 2D particle images for reconstruction.
Definition: mg_reconstruct.cpp:37
Bmicrograph::matrix
Matrix3 matrix
Definition: mg_processing.h:222
Bimage
General image parameter class.
Definition: Bimage.h:163
Bimage::real_size
Vector3< double > real_size()
Definition: Bimage.h:487
Bmicrograph::tilt_axis
double tilt_axis
Definition: mg_processing.h:216
Bfield
Definition: mg_processing.h:257
M_PI
#define M_PI
Definition: utilities.h:59
linked_list.h
Header file for generalized linked list functions.
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
Bimage::extract
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Definition: Bimage_extract.cpp:21
Vector3::scalar
double scalar(const Vector3 &v) const
Definition: Vector3.h:247
Bcolumn::number
long number()
Definition: Bplot.h:61
Bmicrograph::select
long select
Definition: mg_processing.h:203
Bproject::field
Bfield * field
Definition: mg_processing.h:343
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
Bcolumn::type
long type()
Definition: Bplot.h:66
fft_plan
fftwf_plan fft_plan
Definition: fft.h:16
img_pack_2D_into_central_section
long img_pack_2D_into_central_section(Bimage *p, Bimage *prec, Bimage *prec2, long ft_size, double scale, double hi_res, Matrix3 matr, Matrix3 mat, int inplane)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
Definition: mg_tomo_resol.cpp:689
plot_resolution
int plot_resolution(Bplot *plot, double hi_res, Bstring &psfile, Bstring &title)
Plots the resolution curve in a plot structure.
Definition: mg_tomo_resol.cpp:1058
Bpage::axis
Baxis & axis(long id)
Definition: Bplot.h:117
Bpage::title
Bstring & title()
Definition: Bplot.h:100
Bimage::phase_shift_to_origin
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
Definition: Bimage_complex.cpp:327
Bmicrograph
Definition: mg_processing.h:200
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:373
Bimage::calculate_background
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Definition: Bimage_background.cpp:27
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
ps_plot
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Definition: ps_plot.cpp:128
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1096
Bimage::next
Bimage * next
Definition: Bimage.h:165
Bpage::add_text
void add_text(Bstring &s)
Definition: Bplot.h:122
img_pack_2D_into_central_section_old
int img_pack_2D_into_central_section_old(Bimage *p, Bimage *prec, Bimage *prec2, long ft_size, int zsize, double scale, double hi_res, Matrix3 matr, Matrix3 mat, int inplane)
Definition: mg_tomo_resol.cpp:776
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:261
Bparticle
Definition: mg_processing.h:89
Baxis::flags
long flags()
Definition: Bplot.h:38
Bstring
Definition: Bstring.h:29
Bimage::pad
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
Definition: Bimage_resize.cpp:351
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2695
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:377
Bmicrograph::fft
Bstring fft
Definition: mg_processing.h:209
Bplot::rows
void rows(long n)
Definition: Bplot.h:207
Bplot::page
Bpage & page(long i)
Definition: Bplot.h:211
Matrix3::transpose
Matrix3 transpose() const
Definition: Matrix3.h:268
Bmicrograph::box_size
Vector3< long > box_size
Definition: mg_processing.h:230
mg_tomo_resolution
Bimage * mg_tomo_resolution(Bproject *project, int micrograph_id, double hi_res, double sampling_ratio, double scale, Vector3< long > size, double fast_angle, int action, double wiener, double cutoff, Bstring &psfile)
Estimating the resolution of one micrograph in an aligned tilt series.
Definition: mg_tomo_resol.cpp:266
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:379
Vector3< long >
Bmicrograph::fmg
Bstring fmg
Definition: mg_processing.h:205
Bparticle::loc
Vector3< double > loc
Definition: mg_processing.h:99
fft_destroy_plan
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Definition: fft.cpp:87
mg_tomo_rec.h
Functions to do a tomographic reconstruction.
Bmicrograph::fom
double fom
Definition: mg_processing.h:236
fft_setup_plan
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
Definition: fft.cpp:31
project_tomo_particle_resolution
Bplot * project_tomo_particle_resolution(Bproject *project, double hi_res, double sampling_ratio, double fast_angle, double cutoff)
Estimates the resolution for each particle image in each micrograph.
Definition: mg_tomo_resol.cpp:408
Bpage::columns
void columns(long ncol)
Definition: Bplot.h:105
img_calculate_FRC_curve
Bplot * img_calculate_FRC_curve(vector< Bimage * > parr, double hi_res, double sampling_ratio)
Calculates the FRC/FSC for a micrograph or particle image in a series.
Definition: mg_tomo_resol.cpp:879
Bimage::average
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Definition: Bimage.cpp:1349
img_ttf_apply
int img_ttf_apply(Bimage *p, CTFparam ctf, int action, double wiener, Vector3< long > tile_size, double tilt, double axis, double res_lo, double res_hi)
Applies or corrects for the tilted contrast transfer function (TTF).
Definition: mg_ctf.cpp:388
mg_tomo_res_reconstruct
vector< Bimage * > mg_tomo_res_reconstruct(Bproject *project, int micrograph_id, double hi_res, double sampling_ratio, double scale, Vector3< long > size, double fast_angle, int action, double wiener)
Estimating the resolution of one micrograph in an aligned tilt series.
Definition: mg_tomo_resol.cpp:62
rwimg.h
Header file for 2D and 3D image I/O.
mg_reconstruct.h
Functions for reconstruction.
findNextPowerOf
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
Definition: utilities.cpp:433
plot_tilt_resolution
Bplot * plot_tilt_resolution(Bproject *project)
Plots the estimated resolution against the tilt angle.
Definition: mg_tomo_resol.cpp:1089
Vector3::volume
double volume()
Definition: Vector3.h:235
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:378
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:755
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:21
Bproject
Definition: mg_processing.h:333
Bimage::image
Bsub_image * image
Definition: Bimage.h:188
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:563
Bcolumn::axis
long axis()
Definition: Bplot.h:68
plot_calculate_resolution
double plot_calculate_resolution(Bplot *plot, double cutoff)
Calculates the resolution estimate from a FRC/FSC curve.
Definition: mg_tomo_resol.cpp:1027
Bplot
Definition: Bplot.h:146
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201