Bsoft  2.1.0
Bernard's software package
bico.cpp
Go to the documentation of this file.
1 
10 #include "mg_processing.h"
11 #include "mg_reconstruct.h"
12 #include "rwmg.h"
13 #include "rwimg.h"
14 #include "rwsymop.h"
15 #include "symmetry.h"
16 #include "linked_list.h"
17 #include "utilities.h"
18 #include "options.h"
19 #include "timer.h"
20 
21 // Declaration of global variables
22 extern int verbose; // Level of output to the screen
23 
25 
28  Bimage* pmask, Bimage* pfsmask, double hires, double lores);
30  Bimage* pfsmask, double hires, double lores);
32  Bimage* pmask, Bimage* pfsmask, double hires, double lores);
34 long project_analyze_vertices(Bproject* project, double threshold);
35 
36 // Usage assistance
37 const char* use[] = {
38 " ",
39 "Usage: bico [options] tomo.star",
40 "-------------------------------",
41 "Analyzes icosahedral subtomograms.",
42 " ",
43 "Actions:",
44 "-find opp Type of correlation: worst, opposite, c5.",
45 "-analyze 0.1 Calculate statistics for vertices.",
46 " ",
47 "Parameters:",
48 "-verbose 7 Verbosity of output.",
49 "-resolution 15.6,200 Resolution limits for cross-correlation (default 0,inf).",
50 "-maxresolution 9.5 Maximum reconstruction resolution limit (default Nyquist).",
51 " ",
52 "Input:",
53 "-reference image.map Reference for cross-correlation.",
54 "-mask image.map Real space mask.",
55 "-Mask fsmask.mrc Frequency space mask (missing data).",
56 "-special vert.star Parameter file with special vertex orientations.",
57 " ",
58 "Output:",
59 "-output file.star Output parameter file.",
60 "-reconstruction file.ext Reconstruction file name.",
61 " ",
62 NULL
63 };
64 
65 int main(int argc, char **argv)
66 {
67  // Initialize variables
68  Bstring type; // Type of analysis: worst or opposite
69  int analyze(0); // Flag to calculate statistics
70  double threshold(-1); // Threshold for finding odd vertices
71  double hires(0), lores(0); // Limiting resolution for cross-correlation
72  double maxres(0); // Maximum reconstruction resolution
73  Bstring ref_file; // Reference template file name
74  Bstring mask_file; // Real space mask
75  Bstring fsmask_file; // Frequency space missing mask
76  Bstring specvert_file; // Special vertex parameter file
77  Bstring outfile; // Output parameter file name
78  Bstring reconsfile; // Output reconstruction file
79 
80  int optind;
81  Boption* option = get_option_list(use, argc, argv, optind);
82  Boption* curropt;
83  for ( curropt = option; curropt; curropt = curropt->next ) {
84  if ( curropt->tag == "find" )
85  type = curropt->value;
86  if ( curropt->tag == "analyze" ) {
87  analyze = 1;
88  if ( ( threshold = curropt->value.real() ) < -0.99 )
89  cerr << "-analyze: A threshold must be specified!" << endl;
90  }
91  if ( curropt->tag == "resolution" )
92  if ( curropt->values(hires, lores) < 1 )
93  cerr << "-resolution: A high resolution limit must be specified!" << endl;
94  if ( curropt->tag == "maxresolution" )
95  if ( ( maxres = curropt->value.real() ) < 0.1 )
96  cerr << "-maxresolution: A resolution limit must be specified!" << endl;
97  if ( curropt->tag == "reference" )
98  ref_file = curropt->filename();
99  if ( curropt->tag == "mask" )
100  mask_file = curropt->filename();
101  if ( curropt->tag == "Mask" )
102  fsmask_file = curropt->filename();
103  if ( curropt->tag == "special" )
104  specvert_file = curropt->filename();
105  if ( curropt->tag == "output" )
106  outfile = curropt->filename();
107  if ( curropt->tag == "reconstruction" )
108  reconsfile = curropt->filename();
109  }
110  option_kill(option);
111 
112  double ti = timer_start();
113 
114  // Read all the parameter files
115  Bstring* file_list = NULL;
116  while ( optind < argc ) string_add(&file_list, argv[optind++]);
117  if ( !file_list ) {
118  cerr << "Error: No parameter files specified!" << endl;
119  bexit(-1);
120  }
121 
122  Bproject* project = read_project(file_list);
123  string_kill(file_list);
124 
125  if ( project == NULL ) {
126  cerr << "Error: No input file read!" << endl;
127  bexit(-1);
128  }
129 
130  Vector3<long> size;
131  Bimage* pref = NULL;
132  if ( ref_file.length() ) {
133  pref = read_img(ref_file, 1, 0);
134  } else if ( !analyze ) {
135  pref = project_reconstruct_3D(project, -1, size, maxres);
136  write_img("reference.mrc", pref, 0);
137  }
138 
139  if ( !analyze && !pref ) {
140  cerr << "Error: No template map!" << endl;
141  bexit(-1);
142  }
143 
144  Bimage* pmask = NULL;
145  if ( mask_file.length() ) {
146  pmask = read_img(mask_file, 1, 0);
147  pref->multiply(pmask);
148  }
149 
150  Bimage* pfsmask = NULL;
151  if ( fsmask_file.length() ) {
152  pfsmask = read_img(fsmask_file, 1, 0);
153  if ( pfsmask->image->origin().length() < 1 )
154  pfsmask->center_wrap(); // Make sure the origin is in the center
155  }
156 
157  if ( maxres > hires ) maxres = hires;
158 
159  int done(0);
160  Bimage* pavg = NULL;
161 
162  if ( type.length() ) {
163  if ( type[0] == 'w' ) {
164  done = project_ico_worst_vertex(project, pref, pmask, pfsmask, hires, lores);
165  } else if ( type[0] == 'o' ) {
166  done = project_ico_opposite_vertex(project, pmask, pfsmask, hires, lores);
167  } else if ( type == "c5" ) {
168  done = project_ico_best_c5(project, pref, pmask, pfsmask, hires, lores);
169  }
170  if ( done ) pavg = img_vertex_reconstruct(project, size, maxres);
171  }
172 
173  if ( specvert_file.length() ) {
174  Bproject* project_specvert = read_project(specvert_file);
176  project_kill(project_specvert);
177  }
178 
179  if ( analyze ) project_analyze_vertices(project, threshold);
180 
181 
182  if ( project && outfile.length() )
183  write_project(outfile, project, 0, 0);
184 
185  long i(0);
186  Bstring filename(reconsfile);
187  if ( pavg && reconsfile.length() ) {
188  for ( Bimage* p = pavg; p; p = p->next ) {
189  if ( pavg->next ) filename = reconsfile.pre_rev('.') + Bstring(++i, "_%02d.") + reconsfile.post_rev('.');
190  if ( verbose )
191  cout << "Writing " << filename << endl;
192  write_img(filename, p, 0);
193  }
194  }
195 
197  delete pref;
198  delete pavg;
199  delete pmask;
200  delete pfsmask;
201 
202  if ( verbose & VERB_TIME )
203  timer_report(ti);
204 
205  bexit(0);
206 }
207 
208 Bimage* img_read_orient_mask(Bstring& filename, Bimage* pmask, View view)
209 {
210  Bimage* p = read_img(filename, 1, 0);
211 
212  if ( !p ) {
213  error_show("img_read_mask_orient", __FILE__, __LINE__);
214  return p;
215  }
216 
217  p->rotate(view);
218 
219  if ( pmask ) p->multiply(pmask);
220 
221  p->image->view(view);
222 
223  return p;
224 }
225 
226 double img_cc(Bimage* p1, Bimage* p2, Bimage* pfsmask, double hires, double lores)
227 {
228 // double cc(1);
229  Bimage* pfsmrot = NULL;
230  if ( pfsmask ) {
231  pfsmrot = pfsmask->copy();
232  if ( pfsmrot->image->origin().length() < 1 )
233  pfsmrot->center_wrap();
234  pfsmrot->rotate(p1->image->view());
235  pfsmrot->zero_origin();
236  }
237 
238  p1->find_shift(0, p2, pfsmrot, hires, lores, 0.5, planf, planb);
239 /*
240  if ( cc <= 1e-10 ) {
241  cerr << "Correlation coefficient too small! " << cc << endl;
242  bexit(-1);
243  }*/
244 
245  delete pfsmrot;
246 
247  return p1->image->FOM();
248 }
249 
251 {
252  Bimage* prec = project_reconstruct_3D(project, 1, size, maxres);
253 
254  delete prec->next;
255 
256  prec->next = project_reconstruct_3D(project, 2, size, maxres);
257 
258  delete prec->next->next;
259  prec->next->next = NULL;
260 
261  return prec;
262 }
263 
264 long particle_worst_vertex(Bparticle* vert, Bimage* pref, Bimage* pmask, Bimage* pfsmask, double hires, double lores)
265 {
266  long i, psel(0);
267  double cc_worst(1);
268  Bparticle* worst = NULL;
269 
270  vector<Bparticle*> varr(12);
271 
272  for ( i=0, worst = vert; worst && i<12; worst = worst->next, ++i )
273  varr[i] = worst;
274 
275 #ifdef HAVE_GCD
276  dispatch_apply(11, dispatch_get_global_queue(0, 0), ^(size_t i){
277  Bparticle* v = varr[i];
278  Bimage* p = img_read_orient_mask(v->fpart, pmask, v->view);
279  v->fom[0] = img_cc(p, pref, pfsmask, hires, lores);
280  delete p;
281  });
282 #else
283 #pragma omp parallel for
284  for ( i=0; i<12; ++i ) {
285  Bparticle* v = varr[i];
286  Bimage* p = img_read_orient_mask(v->fpart, pmask, v->view);
287  v->fom[0] = img_cc(p, pref, pfsmask, hires, lores);
288  delete p;
289  }
290 #endif
291 
292  for ( i=0; vert && i<12; vert = vert->next, ++i ) {
293  if ( verbose & VERB_FULL )
294  cout << vert->sel << tab << vert->fom[0] << endl;
295  if ( cc_worst > vert->fom[0] ) {
296  psel = vert->sel;
297  cc_worst = vert->fom[0];
298  worst = vert;
299  }
300  vert->sel = 1;
301  }
302 
303  if ( worst )
304  worst->sel = 2;
305 
306  return psel;
307 }
308 
310  Bimage* pfsmask, double hires, double lores)
311 {
312  long i, j, psel(0);
313  double at(M_PI - 0.02), cc, cc_worst(1);
314  Bparticle* vert1 = vert;
315  Bparticle* vert2;
316  Bparticle* worst = NULL;
317  Bparticle* worst2 = NULL;
318  Bimage *p1, *p2;
319 
320  for ( i=0, vert2 = vert1; vert2 && i<12; vert2 = vert2->next, ++i )
321  vert2->fom[0] = -2;
322 
323  for ( i=0; vert && i<11; vert = vert->next, ++i ) if ( vert->fom[0] < -1 ) {
324  p1 = img_read_orient_mask(vert->fpart, pmask, vert->view);
325  for ( j=i+1, vert2 = vert->next; vert2 && j<12; vert2 = vert2->next, ++j )
326  if ( vert->view.backward().angle(vert2->view.backward()) > at ) break;
327  if ( j<12 && vert2 ) {
328  p2 = img_read_orient_mask(vert2->fpart, pmask, vert2->view);
329  cc = img_cc(p1, p2, pfsmask, hires, lores);
330  delete p2;
331  vert->fom[0] = vert2->fom[0] = cc;
332  if ( verbose & VERB_FULL )
333  cout << vert->sel << " - " << vert2->sel << tab << cc << endl;
334  if ( cc_worst > cc ) {
335  psel = vert->sel;
336  cc_worst = cc;
337  worst = vert;
338  worst2 = vert2;
339  }
340  }
341  delete p1;
342  }
343 
344  for ( i=0, vert2 = vert1; vert2 && i<12; vert2 = vert2->next, ++i )
345  vert2->sel = 1;
346 
347  if ( worst )
348  worst->sel = worst2->sel = 2;
349 
350  return psel;
351 }
352 
354  Bimage* pmask, Bimage* pfsmask, double hires, double lores)
355 {
356  long i, psel(0);
357  double cc, cc1(0);
358  Bparticle* vert1 = NULL;
359  Bparticle* vert2;
360  Bimage* p;
361 
362  for ( i=1, vert2 = vert; vert2 && i<=12; vert2 = vert2->next, ++i ) {
363  if ( vert2->sel == 2 ) {
364  p = img_read_orient_mask(vert2->fpart, pmask, vert2->view);
365  cc = img_cc(p, pref, pfsmask, hires, lores);
366  delete p;
367  if ( vert1 ) {
368  if ( cc1 > cc ) {
369  vert1->sel = 1;
370  } else {
371  vert2->sel = 1;
372  psel = i;
373  }
374  break;
375  } else {
376  vert1 = vert2;
377  cc1 = cc;
378  psel = i;
379  }
380  }
381  }
382 
383  return psel;
384 }
385 
386 long particle_best_c5(Bparticle* part, Bimage* pref, Bimage* pmask,
387  Bimage* pfsmask, double hires, double lores)
388 {
389  long i, psel(0);
390  double* cc = new double[5];
391 
393  View* views = symmetry_get_all_views(sym, part->view);
394  View* v;
395  vector<View> view_arr(5);
396  for ( i=0, v=views; v; v=v->next, ++i ) view_arr[i] = *v;
397  kill_list((char *) views, sizeof(View));
398 
399 #ifdef HAVE_GCD
400  dispatch_apply(4, dispatch_get_global_queue(0, 0), ^(size_t i){
401  Bimage* p = img_read_orient_mask(part->fpart, pmask, view_arr[i]);
402  cc[i] = img_cc(p, pref, pfsmask, hires, lores);
403  delete p;
404  });
405 #else
406 #pragma omp parallel for
407  for ( i=0; i<5; ++i ) {
408  Bimage* p = img_read_orient_mask(part->fpart, pmask, view_arr[i]);
409  cc[i] = img_cc(p, pref, pfsmask, hires, lores);
410  delete p;
411  }
412 #endif
413 
414  part->fom[0] = -1;
415  for ( i=0; i<5; ++i ) {
416  if ( verbose & VERB_FULL )
417  cout << i << tab << cc[i] << endl;
418  if ( part->fom[0] < cc[i] ) {
419  psel = i+1;
420  part->fom[0] = cc[i];
421  part->view = view_arr[i];
422  }
423  }
424 
425  delete[] cc;
426 
427  return psel;
428 }
429 
447  Bimage* pmask, Bimage* pfsmask, double hires, double lores)
448 {
449  if ( hires < 2*project->rec->voxel_size[0] )
450  hires = 4*project->rec->voxel_size[0];
451  if ( lores < hires ) lores = 1e6;
452 
453  if ( !pref ) {
454  cerr << "Error: No template map!" << endl;
455  return 0;
456  }
457 
458  planf = pref->fft_setup(FFTW_FORWARD, 1);
459  planb = pref->fft_setup(FFTW_BACKWARD, 1);
460 
461  long i, psel;
462  Vector3<long> size;
463  Breconstruction* rec;
464  Bparticle* part;
465  Bparticle* vert;
466 
467  if ( verbose ) {
468  cout << "Determining the special vertices:" << endl;
469  cout << "Resolution limits: " << hires << " - " << lores << " A" << endl;
470  if ( pref )
471  cout << "Reference: " << pref->file_name() << endl;
472  if ( pmask )
473  cout << "Real space mask: " << pmask->file_name() << endl;
474  if ( pfsmask )
475  cout << "Frequency space mask: " << pfsmask->file_name() << endl;
476  }
477 
478  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
479  if ( verbose ) {
480  cout << "Reconstruction: " << rec->frec << endl;
481  cout << "Particle\tSpecial vertex" << endl;
482  }
483  for ( i=1, vert = part = rec->part; part; part = part->next, ++i ) {
484  if ( i == 12 ) {
485  psel = particle_worst_vertex(vert, pref, pmask, pfsmask, hires, lores);
486  if ( verbose )
487  cout << vert->group << tab << psel << endl;
488  vert = part->next;
489  i = 0;
490  }
491  }
492  }
493 
494 // delete pref;
495 
498 
499  return 1;
500 }
501 
521  Bimage* pfsmask, double hires, double lores)
522 {
523  if ( hires < 2*project->rec->voxel_size[0] )
524  hires = 4*project->rec->voxel_size[0];
525  if ( lores < hires ) lores = 1e6;
526 
527  long i, psel;
528  Breconstruction* rec;
529  Bparticle* part;
530  Bparticle* vert;
531 
532  if ( verbose ) {
533  cout << "Determining the special vertices:" << endl;
534  cout << "Resolution limits: " << hires << " - " << lores << " A" << endl;
535  if ( pmask )
536  cout << "Real space mask: " << pmask->file_name() << endl;
537  if ( pfsmask )
538  cout << "Frequency space mask: " << pfsmask->file_name() << endl;
539  }
540 
541  planf = fft_setup_plan(project->rec->box_size, FFTW_FORWARD, 1);
542  planb = fft_setup_plan(project->rec->box_size, FFTW_BACKWARD, 1);
543 
544  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
545  if ( verbose ) {
546  cout << "Reconstruction: " << rec->frec << endl;
547  cout << "Particle\tVertex pair" << endl;
548  }
549  for ( i=1, vert = part = rec->part; part; part = part->next, ++i ) {
550  if ( i == 12 ) {
551  psel = particle_cc_opposite_vertices(vert, pmask, pfsmask, hires, lores);
552  if ( verbose )
553  cout << vert->group << tab << psel << endl;
554  vert = part->next;
555  i = 0;
556  }
557  }
558  }
559 
560  Vector3<long> size;
561  Bimage* pavg = project_reconstruct_3D(project, 1, size, hires);
562 /*
563  if ( mask_file.length() ) {
564  pmask = read_img(mask_file, 1, 0);
565  pavg->multiply(pmask);
566  }
567 */
568  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
569  if ( verbose ) {
570  cout << "Reconstruction: " << rec->frec << endl;
571  cout << "Particle\tSpecial vertex" << endl;
572  }
573  for ( i=1, vert = part = rec->part; part; part = part->next, ++i ) {
574  if ( i == 12 ) {
575  psel = particle_worst_opposite_vertex(vert, pavg, pmask, pfsmask, hires, lores);
576  if ( verbose )
577  cout << vert->group << tab << psel << endl;
578  vert = part->next;
579  i = 0;
580  }
581  }
582  }
583 
586 
587  delete pavg;
588 
589  return 1;
590 }
591 
612  Bimage* pmask, Bimage* pfsmask, double hires, double lores)
613 {
614  if ( hires < 2*project->rec->voxel_size[0] )
615  hires = 4*project->rec->voxel_size[0];
616  if ( lores < hires ) lores = 1e6;
617 
618  long psel, n(0), nc(0);
619  Breconstruction* rec;
620  Bparticle* part;
621 
622  if ( !pref ) {
623  cerr << "Error: No template map!" << endl;
624  return 0;
625  }
626 
627  if ( verbose ) {
628  cout << "Determining the best 5-fold for each vertex:" << endl;
629  cout << "Resolution limits: " << hires << " - " << lores << " A" << endl;
630  cout << "Reference: " << pref->file_name() << endl;
631  if ( pmask )
632  cout << "Real space mask: " << pmask->file_name() << endl;
633  if ( pfsmask )
634  cout << "Frequency space mask: " << pfsmask->file_name() << endl;
635  }
636 
637  planf = fft_setup_plan(project->rec->box_size, FFTW_FORWARD, 1);
638  planb = fft_setup_plan(project->rec->box_size, FFTW_BACKWARD, 1);
639 
640  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
641  if ( verbose ) {
642  cout << "Reconstruction: " << rec->frec << endl;
643  cout << "Particle\tBestC5" << endl;
644  }
645  for ( part = rec->part; part; part = part->next ) {
646  if ( part->sel == 2 ) {
647  psel = particle_best_c5(part, pref, pmask, pfsmask, hires, lores);
648  if ( verbose )
649  cout << part->group << tab << psel << endl;
650  n++;
651  if ( psel > 1 ) nc++;
652  }
653  }
654  }
655 
656  if ( verbose )
657  cout << "Number of view changes: " << nc << " (" << nc*100.0/n << "%)" << endl;
658 
661 
662  return 1;
663 }
664 
666 {
667  long i, npart(0);
668 
669  Breconstruction* rec, *rec_sv;
670  Bparticle* part, *vert;
671 
672  if ( verbose )
673  cout << "Transferring the special vertex orientations" << endl;
674 
675  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
676  for ( rec_sv = project_specvert->rec; rec_sv; rec_sv = rec_sv->next )
677  if ( rec_sv->id == rec->id && rec->frec == rec_sv->frec ) break;
678  if ( rec_sv && rec_sv->part ) {
679  if ( verbose )
680  cout << "Reconstruction: " << rec->frec << endl;
681  vert = rec_sv->part;
682  for ( part = rec->part; part; part = part->next ) {
683  if ( part->id == vert->group ) {
684  for ( i=0; vert && i<12; vert = vert->next, ++i ) {
685  cout << part->id << tab << vert->id << tab << vert->sel << endl;
686  if ( vert->sel == 2 ) {
687  part->view = vert->view;
688  npart++;
689  }
690  }
691  } else {
692  cerr << "Error: reconstruction " << rec->id << " particle " << part->id << endl;
693  }
694  }
695  }
696  }
697 
698  if ( verbose )
699  cout << "Number of particles updated: " << npart << endl;
700 
701  return npart;
702 }
703 
704 
705 long project_analyze_vertices(Bproject* project, double threshold)
706 {
707  long i, i2, imin, npart(0), nvert(0), nodd, noddtot(0);
708  long h, nh(40), bins(nh+1);
709  double avg, max, min, min2, fommax(2), scale(nh/fommax);
710  vector<double> fom(12,0);
711  vector<long> fomhis(bins,0);
712 
713  Breconstruction* rec;
714  Bparticle* part, *vert;
715 
716  if ( verbose )
717  cout << "Transferring the special vertex orientations" << endl;
718 
719  for ( rec = project->rec; rec; rec = rec->next ) if ( rec->part ) {
720  if ( verbose )
721  cout << "Reconstruction: " << rec->id << endl;
722  for ( part = vert = rec->part; part; part = vert, npart++ ) {
723  avg = 0;
724  min = min2 = 1;
725  max = -1;
726  for ( vert = part, i = i2 = 0; vert && vert->group == part->group;
727  vert = vert->next, ++i ) {
728 // cout << vert->group << tab << vert->id << tab << vert->fom[0] << endl;
729  fom[i] = vert->fom[0];
730  if ( min > vert->fom[0] ) {
731  min = vert->fom[0];
732  imin = i;
733  }
734  if ( max < vert->fom[0] ) max = vert->fom[0];
735  if ( vert->sel == 1 ) {
736  avg += vert->fom[0];
737  } else {
738  i2 = i;
739  min2 = vert->fom[0];
740  }
741  }
742  avg /= 11;
743  for ( vert = part, i = nodd = 0; vert && vert->group == part->group;
744  vert = vert->next, ++i ) {
745 // fom[i] = (fom[i] - min)/(avg - min);
746 // fom[i] = fom[i]/max;
747  fom[i] = (fom[i] - min)/avg;
748  if ( fom[i] <= threshold ) nodd++;
749  h = long(scale*fom[i] + 0.5);
750  if ( h < 0 ) h = 0;
751  if ( h > nh ) h = nh;
752  fomhis[h]++;
753  }
754  if ( verbose )
755  cout << part->group << tab << avg << tab << i2 << tab << imin << tab << nodd << endl;
756  nvert += i;
757  noddtot += nodd;
758  if ( i < 12 )
759  cerr << "Error: Too few vertices! (" << i << ")" << endl;
760  }
761  }
762 
763  if ( verbose ) {
764  cout << "Number of particles: " << npart << endl;
765  cout << "Number of odd vertices: " << noddtot << endl;
766  }
767 
768  cout << "Bin\tFOM\tCount" << endl;
769  for ( h=0; h<bins; ++h )
770  cout << h << tab << h/scale << tab << fomhis[h] << endl;
771 
772  return npart;
773 }
774 
775 
Boption
A class for a command line input option.
Definition: options.h:26
rwsymop.h
Header file for reading and writing symmetry operators.
mg_reconstruct.h
Functions for reconstruction.
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:429
Bimage::fft_setup
fft_plan fft_setup(fft_direction dir, int opt=0)
Sets up a plan for fast Fourier transforms.
Definition: Bimage_fft.cpp:29
Breconstruction::part
Bparticle * part
Definition: mg_processing.h:307
Breconstruction::id
Bstring id
Definition: mg_processing.h:285
particle_worst_opposite_vertex
long particle_worst_opposite_vertex(Bparticle *vert, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Definition: bico.cpp:353
View::next
View * next
Definition: View.h:28
project_analyze_vertices
long project_analyze_vertices(Bproject *project, double threshold)
Definition: bico.cpp:705
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:347
symmetry_get_all_views
View * symmetry_get_all_views(Bsymmetry *sym, View asu_view)
Get all symmetry-related views of one given view.
Definition: symmetry.cpp:442
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:768
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
Bparticle::view
View view
Definition: mg_processing.h:102
Bstring
Definition: Bstring.h:29
particle_worst_vertex
long particle_worst_vertex(Bparticle *vert, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Definition: bico.cpp:264
Bimage::next
Bimage * next
Definition: Bimage.h:179
Breconstruction::voxel_size
Vector3< double > voxel_size
Definition: mg_processing.h:295
Bparticle
Definition: mg_processing.h:90
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:436
img_vertex_reconstruct
Bimage * img_vertex_reconstruct(Bproject *project, Vector3< long > size, double maxres)
Definition: bico.cpp:250
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2702
symmetry.h
Header file for general symmetry functions.
Boption::next
Boption * next
Definition: options.h:28
Vector3< long >
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:280
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
error_show
int error_show(string message, string file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:719
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:103
project_assign_special_vertex_orientations
long project_assign_special_vertex_orientations(Bproject *project, Bproject *project_specvert)
Definition: bico.cpp:665
Breconstruction::box_size
Vector3< long > box_size
Definition: mg_processing.h:299
Bstring::real
double real()
Definition: Bstring.cpp:553
options.h
Header file for option handlers.
View
Definition: View.h:26
Bsub_image::view
void view(double x, double y, double z, double a)
Definition: Bimage.h:157
Bimage::zero_origin
int zero_origin()
Shifts the origins to zero with wrapping.
Definition: Bimage_transform.cpp:722
Bimage::find_shift
int find_shift(Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
Calculates a cross-correlation map to find the shift for the pair of images.
Definition: Bimage_correlate.cpp:929
Bsub_image::FOM
double FOM()
Definition: Bimage.h:165
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
Bsymmetry
Definition: symmetry.h:38
planf
fft_plan planf
Definition: bico.cpp:24
project
Bproject * project
Definition: bshow.cpp:33
Boption::tag
Bstring tag
Definition: options.h:29
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:77
rwmg.h
Header file for reading and writing micrograph parameters.
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:136
Bimage::multiply
void multiply(long j, Complex< double > cv)
Definition: Bimage.h:325
project_ico_opposite_vertex
long project_ico_opposite_vertex(Bproject *project, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Determines the special vertex for icosahedral symmetry and returns two maps.
Definition: bico.cpp:520
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:281
View::backward
View backward()
Definition: View.h:118
Bparticle::fpart
Bstring fpart
Definition: mg_processing.h:92
fft_destroy_plan
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Definition: fft.cpp:87
particle_cc_opposite_vertices
long particle_cc_opposite_vertices(Bparticle *vert, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Definition: bico.cpp:309
Bimage::rotate
int rotate()
Rotates an image using parameters defined in the image in place.
Definition: Bimage_transform.cpp:255
Boption::value
Bstring value
Definition: options.h:30
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:421
Bimage
General image parameter class.
Definition: Bimage.h:177
verbose
int verbose
timer.h
Utilities for timing functions.
Bproject
Definition: mg_processing.h:336
Bparticle::sel
long sel
Definition: mg_processing.h:104
use
const char * use[]
Definition: bico.cpp:37
VERB_TIME
#define VERB_TIME
Definition: utilities.h:114
Bimage::center_wrap
int center_wrap()
Centers an image with wrapping.
Definition: Bimage_transform.cpp:708
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:245
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:61
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:141
M_PI
#define M_PI
Definition: utilities.h:63
utilities.h
Header file for general utilities.
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:22
Breconstruction
Definition: mg_processing.h:283
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
Bstring::length
long length() const
Definition: Bstring.cpp:263
init_point_group_symmetry
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
Definition: symmetry.cpp:39
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:76
rwimg.h
Header file for 2D and 3D image I/O.
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:321
Bparticle::group
int group
Definition: mg_processing.h:94
mg_processing.h
Header file for micrograph processing.
fft_plan
fftwf_plan fft_plan
Definition: fft.h:20
Bparticle::next
Bparticle * next
Definition: mg_processing.h:91
img_cc
double img_cc(Bimage *p1, Bimage *p2, Bimage *pfsmask, double hires, double lores)
Definition: bico.cpp:226
linked_list.h
Header file for generalized linked list functions.
Boption::filename
Bstring filename()
Definition: options.h:85
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:111
project_reconstruct_3D
Bimage * project_reconstruct_3D(Bproject *project, long selnum, int calcfom, Vector3< long > size)
Transforms 3D maps and calculates an average.
Definition: mg_reconstruct.cpp:1263
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Breconstruction::frec
Bstring frec
Definition: mg_processing.h:290
project_ico_worst_vertex
long project_ico_worst_vertex(Bproject *project, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Determines the special vertex for icosahedral symmetry and returns two maps.
Definition: bico.cpp:446
planb
fft_plan planb
Definition: bico.cpp:24
project_ico_best_c5
long project_ico_best_c5(Bproject *project, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Determines the best 5-fold orientation of the vertex wrt a reference.
Definition: bico.cpp:611
main
int main(int argc, char **argv)
Definition: bico.cpp:65
img_read_orient_mask
Bimage * img_read_orient_mask(Bstring &filename, Bimage *pmask, View view)
Definition: bico.cpp:208
View::angle
double angle()
Definition: View.h:98
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:713
Bparticle::id
int id
Definition: mg_processing.h:93
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:284
particle_best_c5
long particle_best_c5(Bparticle *part, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Definition: bico.cpp:386