Bsoft  2.1.0
Bernard's software package
bmaxpow.cpp
Go to the documentation of this file.
1 
9 #include "rwmg.h"
10 #include "mg_processing.h"
11 #include "mg_particles.h"
12 #include "mg_particle_select.h"
13 #include "mg_ctf.h"
14 #include "rwimg.h"
15 #include "linked_list.h"
16 #include "utilities.h"
17 #include "options.h"
18 #include "timer.h"
19 
20 #include <sys/stat.h>
21 #include <fcntl.h>
22 
23 
24 // Declaration of global variables
25 extern int verbose; // Level of output to the screen
26 
28  double theta_step, double phi_step, double alpha_step,
29  int part_select, double hi_res, double lo_res, double scale,
30  Vector3<long> size, Bimage* pmask, int pad_factor,
31  int ctf_action, double wiener, int flags);
32 
33 // Usage assistance
34 const char* use[] = {
35 " ",
36 "Usage: bmaxpow [options] input.star [input.star]",
37 "------------------------------------------------",
38 "Finds orientations of particle images based on maximizing reciprocal space reconstruction power.",
39 " ",
40 "Actions:",
41 "-all Reset selection to all particles before other selections (default not).",
42 "-center Center particles before determining orientation (default not).",
43 "-symmetry C5 Point group symmetry to find orientations.",
44 " ",
45 "Parameters:",
46 "-verbose 7 Verbosity of output.",
47 "-select 14 Selection number of particles to process (default all selected).",
48 "-size 100,120,90 Size of reconstruction (default from images).",
49 "-angles 8.8,2.5,5.2 Step size for alpha, theta and phi, one value sets all (default 45 degrees).",
50 "-resolution 10,500 Resolution limits for finding centers (angstrom, default 20,1000).",
51 "-pad 3 Image padding factor (default 0, no padding).",
52 "-CTF flip Apply CTF correction to images before reconstruction (default not).",
53 "-wiener 0.15 Wiener factor for CTF correction (default 0.2).",
54 " ",
55 "Input:",
56 "-reference file.pif Centering reference file (turns on centering).",
57 "-mask mask.mrc Real space 2D mask to be applied to particles.",
58 " ",
59 "Output:",
60 "-output file.star Output parameter file.",
61 "-ppx Write temporary particle parameter files to directory \"ppx\".",
62 " ",
63 NULL
64 };
65 
66 
67 int main(int argc, char** argv)
68 {
69  // Initializing variables
70  int reset(0); // Keep selection as read from file
71  int center(0); // Flag to turn centering on
72  int part_select(-1); // Process all selected particles
73  Vector3<long> map_size; // Size of reconstruction
74  int pad_factor(0); // Image padding factor
75  int ctf_action(0); // Default no CTF operation
76  double wiener(0.2); // Wiener for CTF correction
77  double hires(20); // High resolution limit
78  double lores(1000); // Low resolution limit
79  double theta_step(M_PI_4); // Theta angular step size.
80  double phi_step(M_PI_4); // Phi angular step size.
81  double alpha_step(M_PI_4); // Alpha angular step size (in-plane).
82  Bstring symmetry_string; // No symmetry specified
83  Bstring reffile; // Reference image for centering
84  Bstring maskfile; // Mask to be applied to particles
85  Bstring outfile; // Output parameter file
86  int flags(FULL_ASU); // Flags for processing options
87 
88  int i, optind;
89  Boption* option = get_option_list(use, argc, argv, optind);
90  Boption* curropt;
91  for ( curropt = option; curropt; curropt = curropt->next ) {
92  if ( curropt->tag == "all" )
93  reset = 1;
94  if ( curropt->tag == "center" )
95  center = 1;
96  if ( curropt->tag == "select" )
97  if ( ( part_select = curropt->value.integer() ) < 1 )
98  cerr << "-select: A selection number must be specified!" << endl;
99  if ( curropt->tag == "symmetry" )
100  symmetry_string = curropt->symmetry_string();
101  if ( curropt->tag == "size" )
102  map_size = curropt->size();
103  if ( curropt->tag == "angles" ) {
104  if ( ( i = curropt->values(alpha_step, theta_step, phi_step) ) < 1 )
105  cerr << "-angles: An angle step size must be specified!" << endl;
106  else {
107  if ( i < 2 ) phi_step = theta_step = alpha_step;
108  else if ( i < 3 ) phi_step = theta_step;
109  alpha_step *= M_PI/180.0;
110  theta_step *= M_PI/180.0;
111  phi_step *= M_PI/180.0;
112  }
113  }
114  if ( curropt->tag == "resolution" )
115  if ( curropt->values(hires, lores) < 1 )
116  cerr << "-resolution: A resolution limit must be specified!" << endl;
117  if ( curropt->tag == "pad" )
118  if ( ( pad_factor = curropt->value.integer() ) < 0 )
119  cerr << "-pad: An integer factor must be specified!" << endl;
120  if ( curropt->tag == "CTF" )
121  ctf_action = curropt->ctf_action();
122  if ( curropt->tag == "wiener" ) {
123  if ( ( wiener = curropt->value.real() ) < 0.000001 )
124  cerr << "-wiener: A Wiener factor must be specified!" << endl;
125  else {
126  if ( wiener < 0.01 ) wiener = 0.01;
127 // if ( wiener > 1 ) wiener = 1;
128  }
129  }
130  if ( curropt->tag == "reference" )
131  reffile = curropt->filename();
132  if ( curropt->tag == "mask" )
133  maskfile = curropt->filename();
134  if ( curropt->tag == "output" )
135  outfile = curropt->filename();
136  if ( curropt->tag == "ppx" ) flags |= WRITE_PPX | CHECK_PPX;
137  }
138  option_kill(option);
139 
140  double ti = timer_start();
141 
142  if ( hires > lores ) swap(hires, lores);
143 
144  // Read all the parameter files
145  Bstring* file_list = NULL;
146  while ( optind < argc ) string_add(&file_list, argv[optind++]);
147  if ( !file_list ) {
148  cerr << "Error: No parameter files specified!" << endl;
149  bexit(-1);
150  }
151 
152  Bproject* project = read_project(file_list);
153  string_kill(file_list);
154 
155  if ( project == NULL ) {
156  cerr << "Error: No input file read!" << endl;
157  bexit(-1);
158  }
159 
160  if ( reset ) part_reset_selection(project, 3);
161 
162  Bimage* pref = NULL;
163  int max_iter(10);
164 
165  if ( reffile.length() ) {
166  pref = read_img(reffile, 1, 0);
167  project_set_particle_centers(project, pref, part_select, hires, lores);
168  } else if ( center ) {
169  pref = project_find_particle_centers(project, max_iter, part_select, hires, lores);
170  }
171 
172  if ( pref ) delete pref;
173 
174  Bimage* pmask = NULL;
175  if ( maskfile.length() )
176  pmask = read_img(maskfile, 1, 0);
177 
178  Bsymmetry* sym = init_point_group_symmetry(symmetry_string);
179  if ( sym->point > 101 )
180  project_maximum_power(project, sym, theta_step, phi_step, alpha_step,
181  part_select, hires, lores, 1, map_size, pmask, pad_factor,
182  ctf_action, wiener, flags);
183 
184  kill_symmetry(sym);
185  if ( pmask ) delete pmask;
186 
187  if ( outfile.length() )
188  write_project(outfile, project, 0, 0);
189 
191 
192  if ( verbose & VERB_TIME )
193  timer_report(ti);
194 
195  bexit(0);
196 }
197 
199  View view, double hi_res, double lo_res, double scale)
200 {
201  long i, n;
202  double fom(0);
203  Vector3<double> vscale(scale, scale, scale);
204 
205  Bimage* prec = new Bimage(Float, TComplex, size, 1);
206 
207  prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, vscale, 1, 0);
208 
210 
211  float* power = (float *) prec->next->data_pointer();
212  float* weight = (float *) prec->next->next->data_pointer();
213 
214  for ( i=n=0; i<prec->image_size(); i++ ) {
215  if ( weight[i] > 2.5 ) {
216  fom += prec->complex(i).power()/power[i];
217  n++;
218  }
219  }
220 
221  if ( n ) fom /= n;
222  else cout << "No overlapping voxels!" << endl;
223 
224  delete prec;
225 
226  return fom;
227 }
228 
230  View view, double hi_res, double lo_res, double scale)
231 {
232  long i, n;
233  double pwr(0), avg(0), w(0), fom(0);
234  Vector3<double> vscale(scale, scale, scale);
235 
236  Bimage* prec = new Bimage(Float, TComplex, size, 1);
237 
238  prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, vscale, 1, 0);
239 
240  float* power = (float *) prec->next->data_pointer();
241  float* weight = (float *) prec->next->next->data_pointer();
242 
243  for ( i=n=0; i<prec->image_size(); i++ ) {
244  if ( weight[i] > 1.5 ) {
245  avg = prec->complex(i).power();
246  pwr = power[i];
247  w = pwr - avg/weight[i];
248  if ( w > SMALLFLOAT ) {
249  fom += (avg - pwr)/w;
250  n++;
251  }
252  }
253  }
254  if ( n ) fom /= n;
255  else cout << "No overlapping voxels!" << endl;
256 
257  delete prec;
258 
259  return fom;
260 }
261 
263  View view, double hi_res, double lo_res, double scale)
264 {
265  long i, n;
266  double pwr(0), avg(0), w(0), fom(0);
267  Vector3<double> vscale(scale, scale, scale);
268 
269  Bimage* prec = new Bimage(Float, TComplex, size, 1);
270 
271  prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, vscale, 1, 0);
272 
273 // prec->fspace_reconstruction_weigh();
274 
275  float* power = (float *) prec->next->data_pointer();
276  float* weight = (float *) prec->next->next->data_pointer();
277 
278  for ( i=n=0; i<prec->image_size(); i++ ) {
279  if ( weight[i] > 1.5 ) {
280  avg += prec->complex(i).power();
281  pwr += power[i];
282  w += weight[i];
283 // fom += power[i] - prec->complex(i).power();
284 // n++;
285  }
286  }
287 // if ( n ) fom /= n;
288 // else cout << "No overlapping voxels!" << endl;
289  if ( w ) fom = (avg - pwr)/(pwr - avg/w);
290  else cout << "No overlapping voxels!" << endl;
291 
292 // fom = 1/(1+fom);
293 
294  delete prec;
295 
296  return fom;
297 }
298 
300  View view, double hi_res, double lo_res, double scale)
301 {
302  long i, n;
303  double pwr(0), avg(0), w(0), fom(0);
304  Vector3<double> vscale(scale, scale, scale);
305 
306  Bimage* prec = new Bimage(Float, TComplex, size, 1);
307 
308  prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, vscale, 1, 0);
309 
311 
312  float* power = (float *) prec->next->data_pointer();
313  float* weight = (float *) prec->next->next->data_pointer();
314 
315  for ( i=n=0; i<prec->image_size(); i++ ) {
316  if ( weight[i] > 1.5 ) {
317  avg += prec->complex(i).power();
318  pwr += power[i];
319  w += weight[i];
320 // fom += power[i] - prec->complex(i).power();
321  n++;
322  }
323  }
324 // if ( n ) fom /= n;
325 // else cout << "No overlapping voxels!" << endl;
326  if ( n ) fom = (n*avg - pwr)/(pwr - avg);
327  else cout << "No overlapping voxels!" << endl;
328 
329  fom = 1/(1+fom);
330 
331  delete prec;
332 
333  return fom;
334 }
335 
357  double theta_step, double phi_step, double alpha_step,
358  double hi_res, double lo_res, double scale, int pad_factor)
359 {
360  if ( !p->data_pointer() ) return 0;
361 
362  if ( hi_res < 2*p->sampling(0)[0]/scale ) hi_res = 2*p->sampling(0)[0]/scale;
363 
364  if ( verbose & VERB_FULL )
365  cout << "Finding the orientation based on maximum power up to " << hi_res << " A resolution" << endl;
366 
367  long iv, nviews;
368  double fomavg, bestfom;
369  View* v;
370  View* view = asymmetric_unit_views(sym, theta_step, phi_step, 1);
371  View* view2 = view_list_expand_angles(view, -M_PI, M_PI - alpha_step/2, alpha_step);
372  kill_list((char *) view, sizeof(View));
373  view = view2;
374  View bestview;
375 
376  for ( nviews=0, v=view; v; v=v->next ) nviews++;
377 
378 // cout << "number of views = " << nviews << endl;
379 
380  View* view_arr = new View[nviews];
381  double* fom_arr = new double[nviews];
382 
383  for ( iv=0, v=view; v; v=v->next, iv++ ) view_arr[iv] = *v;
384 
385  if ( verbose & VERB_FULL )
386  cout << "x\ty\tz\ta\tFOM" << endl;
387 
388 #ifdef HAVE_GCD
389  dispatch_apply(nviews, dispatch_get_global_queue(0, 0), ^(size_t iv){
390  fom_arr[iv] = img_reconstruct_one(p, size, sym, view_arr[iv], hi_res, lo_res, scale);
391  });
392 #else
393 #pragma omp parallel for
394  for ( iv = 0; iv < nviews; iv++ )
395  fom_arr[iv] = img_reconstruct_one(p, size, sym, view_arr[iv], hi_res, lo_res, scale);
396 #endif
397 
398  for ( iv = 0, bestfom = -1e30, fomavg = 0; iv < nviews; iv++ ) {
399  fomavg += fom_arr[iv];
400  if ( bestfom < fom_arr[iv] ) {
401  bestfom = fom_arr[iv];
402  bestview = view_arr[iv];
403  }
404  }
405 
406  fomavg /= nviews;
407 
408  if ( verbose & VERB_FULL )
409  cout << bestview << tab << fomavg << endl;
410 
411  delete[] view_arr;
412  delete[] fom_arr;
413  kill_list((char *) view, sizeof(View));
414 
415  p->view(bestview);
416  p->image->FOM(fomavg);
417 
418  return bestfom;
419 }
420 
422  Vector3<long> size, Bimage* pmask, long ft_size, Bsymmetry* sym,
423  double theta_step, double phi_step, double alpha_step,
424  double hi_res, double lo_res, double scale, int pad_factor,
425  int ctf_action, double wiener, int flags)
426 {
427  FOMType fom_tag[NFOM] = {FOM_CC, FOM_CC_AVG};
428 
429  if ( flags & CHECK_PPX )
430  if ( ppx_check(part, fom_tag) )
431  return part->fom[0];
432 
433  double part_scale(1);
434  Bimage* p = NULL;
435  Bmicrograph* mg = part->mg;
436 
437  if ( ( p = read_img(mg->fpart, 1, part->id - 1) ) == NULL ) {
438  error_show("part_find_maximum_power", __FILE__, __LINE__);
439  return -1;
440  }
441 
442  CTFparam em_ctf;
443  if ( mg->ctf ) em_ctf.update(mg->ctf);
444  if ( part->def > 0 ) em_ctf.defocus_average(part->def);
445 
446  if ( pmask ) p->multiply(pmask);
447 
448  if ( part->ori[0] <= 0 ) {
449  if ( p->image->origin()[0] <= 0 ) part->ori = p->size()/2;
450  else part->ori = p->image->origin();
451  }
452  p->image->origin(part->ori);
453 
454  p->view(part->view);
455 
456  if ( size[2] < 2 ) {
457  if ( p->image->view()[2] >= 0 ) p->image->view(0,0,1,0);
458  else p->image->view(0,0,-1,0);
459  }
460 
461  if ( part->mag > 0 ) part_scale = scale/part->mag;
462  else part_scale = scale;
463 
464  p->rescale_to_avg_std(0, 1);
466 
467  p->pad(ft_size, FILL_BACKGROUND, p->background(long(0)));
468 
469  p->fft();
470 
472 
473  p->sampling(mg->pixel_size);
474 
475  if ( mg->ctf && ctf_action )
476  img_ctf_apply(p, em_ctf, ctf_action, wiener, 0, hi_res);
477 
478  part->fom[0] = img_find_maximum_power(p, size, sym, theta_step,
479  phi_step, alpha_step, hi_res, lo_res, part_scale, pad_factor);
480 
481  part->view = p->image->view();
482  part->fom[1] = p->image->FOM();
483 
484  delete p;
485 // cout << "Particle done" << endl;
486 
487  if ( flags & WRITE_PPX ) {
488  Bstring ppx_name = ppx_filename(part->mg->id, part->id);
489  write_particle(ppx_name, part, 0, 0, fom_tag);
490  ppx_name = 0;
491  }
492 
493  return part->fom[0];
494 }
495 
521  double theta_step, double phi_step, double alpha_step,
522  int part_select, double hi_res, double lo_res, double scale,
523  Vector3<long> size, Bimage* pmask, int pad_factor,
524  int ctf_action, double wiener, int flags)
525 {
526  if ( pad_factor < 1 ) pad_factor = 1;
527  if ( pad_factor > 8 ) pad_factor = 8;
528 
529  Bfield* field = project->field;
531 
532  if ( !part ) {
533  error_show("Error in project_maximum_power", __FILE__, __LINE__);
534  cerr << "No particles found! " << endl << endl;
535  return 0;
536  }
537 
538  Bmicrograph* mg = part->mg;
539 
540  if ( !mg->fpart.length() ) {
541  error_show("Error in project_maximum_power", __FILE__, __LINE__);
542  cerr << "No particle image file name given for micrograph " << mg->id << endl << endl;
543  return 0;
544  }
545 
546  Bimage* p = read_img(mg->fpart, 0, 0);
547  p->sampling(mg->pixel_size);
548 
549  if ( size.volume() < 1 ) {
550  size[0] = p->sizeX();
551  if ( size[0] < p->sizeY() ) size[0] = p->sizeY();
552  if ( size[0] < p->sizeZ() ) size[0] = p->sizeZ();
553  size[2] = size[1] = size[0];
554  }
555 
556  if ( size[0] > 2*p->real_size()[0]/hi_res )
557  size[2] = size[1] = size[0] = 2*p->real_size()[0]/hi_res;
558 
559  long ft_size = findNextPowerOf((long)(pad_factor*size[0]*scale), 2);
560 // if ( ft_size < p->sizeX() ) ft_size = p->sizeX();
561  if ( ft_size < p->sizeX() ) ft_size = findNextPowerOf(p->sizeX(), 2);
562 
563  delete p;
564 
565  if ( size[0] > 500 && hi_res > 4*mg->pixel_size[0] ) size /= 2;
566 
567 // if ( verbose & VERB_PROCESS ) {
568  if ( verbose ) {
569  cout << "Finding particle orientations by maximum power:" << endl;
570  cout << "Map size: " << size << endl;
571  cout << "Symmetry: " << sym->label << endl;
572  cout << "Angular steps: " << alpha_step*180.0/M_PI
573  << " " << theta_step*180.0/M_PI << " " << phi_step*180.0/M_PI << endl;
574  cout << "Scale: " << scale << endl;
575  cout << "Resolution limits: " << hi_res << " - " << lo_res << " A" << endl;
576  cout << "Fourier transform size: " << ft_size << " x " << ft_size << endl;
577  cout << "CTF application type: " << ctf_action << endl;
578  if ( pmask )
579  cout << "Real space mask: " << pmask->file_name() << endl << endl;
580  }
581 
582  // Directory for individual particle parameter files
583  if ( flags & WRITE_PPX ) {
584  mkdir("ppx", O_CREAT );
585  chmod("ppx", 0755);
586  }
587 
588  long nrec(0), psel;
590 
591  if ( verbose )
592  cout << "Part\tx\ty\tz\ta\tFOMavg\tFOMmax\tRatio" << endl;
593  for ( field=project->field; field; field=field->next ) {
594  for ( mg=field->mg; mg; mg=mg->next ) {
595  for ( part=mg->part; part; part=part->next ) {
596  psel = 0;
597  if ( part->sel ) {
598  if ( part_select < 0 ) {
599  psel = 1;
600  } else if ( part->sel == part_select ) {
601  psel = 1;
602  }
603  }
604  if ( psel ) { // Use only selected images
605  part_find_maximum_power(part, size, pmask, ft_size, sym,
606  theta_step, phi_step, alpha_step, hi_res, lo_res, scale,
607  pad_factor, ctf_action, wiener, flags);
608  if ( verbose )
609  cout << part->id << tab << setprecision(4) <<
610  part->view[0] << tab <<
611  part->view[1] << tab << part->view[2] << tab <<
612  part->view.angle()*180.0/M_PI << tab <<
613  part->fom[1] << tab << part->fom[0] << tab <<
614  part->fom[0]/part->fom[1] << endl;
615 
616  nrec++;
617  if ( verbose & ( VERB_TIME | VERB_PROCESS ) )
618  cout << "Complete: " << nrec*100.0/nsel << "%\r" << flush;
619  }
620  }
621  }
622  }
623 
624  return 0;
625 }
626 
Boption
A class for a command line input option.
Definition: options.h:26
CHECK_PPX
#define CHECK_PPX
Definition: mg_processing.h:27
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:429
mg_particle_select.h
Select particles.
Bmicrograph::id
Bstring id
Definition: mg_processing.h:203
img_reconstruct_one_v2
double img_reconstruct_one_v2(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
Definition: bmaxpow.cpp:262
project_find_particle_centers
Bimage * project_find_particle_centers(Bproject *project, int max_iter, int part_select, double hires, double lores)
Calculates centers of single particle images.
Definition: mg_particles.cpp:411
Bmicrograph
Definition: mg_processing.h:201
View::next
View * next
Definition: View.h:28
WRITE_PPX
#define WRITE_PPX
Definition: mg_processing.h:26
Bimage::real_size
Vector3< double > real_size()
Definition: Bimage.h:500
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:392
mg_particles.h
Manipulates single particle images.
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:768
Bimage::fspace_reconstruction_weigh
long fspace_reconstruction_weigh()
Weighs a reconstruction.
Definition: Bimage_reconstruct.cpp:412
FULL_ASU
#define FULL_ASU
Definition: mg_processing.h:22
Bsymmetry::point
int point
Definition: symmetry.h:39
M_PI_4
#define M_PI_4
Definition: utilities.h:69
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
NFOM
#define NFOM
Definition: mg_processing.h:16
Bstring
Definition: Bstring.h:29
CTFparam::update
int update(CTFparam *ctf)
Definition: ctf.h:81
Bimage::next
Bimage * next
Definition: Bimage.h:179
Bparticle
Definition: mg_processing.h:90
Bproject::field
Bfield * field
Definition: mg_processing.h:346
part_find_maximum_power
double part_find_maximum_power(Bparticle *part, Vector3< long > size, Bimage *pmask, long ft_size, Bsymmetry *sym, double theta_step, double phi_step, double alpha_step, double hi_res, double lo_res, double scale, int pad_factor, int ctf_action, double wiener, int flags)
Definition: bmaxpow.cpp:421
Bstring::integer
long integer()
Definition: Bstring.cpp:547
FOMType
FOMType
Definition: mg_processing.h:38
Boption::next
Boption * next
Definition: options.h:28
Vector3< long >
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:390
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
TComplex
@ TComplex
Definition: Bimage.h:60
Bimage::background
double background(long nn)
Definition: Bimage.h:549
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:386
Bparticle::mg
Bmicrograph * mg
Definition: mg_processing.h:105
project_set_particle_centers
int project_set_particle_centers(Bproject *project, Bimage *pref, int part_select, double hires, double lores)
Calculates centers of single particle images by cross-correlation with a reference.
Definition: mg_particles.cpp:263
Bstring::real
double real()
Definition: Bstring.cpp:553
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:242
options.h
Header file for option handlers.
Bimage::calculate_background
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Definition: Bimage_background.cpp:27
asymmetric_unit_views
View * asymmetric_unit_views(Bsymmetry *sym, double theta_step, double phi_step, int flag)
Initializes a well-distributed set of views in an asymmetric unit.
Definition: symmetry.cpp:564
View
Definition: View.h:26
Bsub_image::view
void view(double x, double y, double z, double a)
Definition: Bimage.h:157
ppx_filename
Bstring ppx_filename(Bstring &id, int part_id)
Definition: rwmg.cpp:415
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:208
Bfield
Definition: mg_processing.h:260
Bsub_image::FOM
double FOM()
Definition: Bimage.h:165
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
Bsymmetry
Definition: symmetry.h:38
img_find_maximum_power
double img_find_maximum_power(Bimage *p, Vector3< long > size, Bsymmetry *sym, double theta_step, double phi_step, double alpha_step, double hi_res, double lo_res, double scale, int pad_factor)
Determines the orientation of a particle image by maximum power.
Definition: bmaxpow.cpp:356
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
part_reset_selection
long part_reset_selection(Bproject *project, int flag=0)
Resets selection to all particles.
Definition: mg_particle_select.cpp:133
Bimage::multiply
void multiply(long j, Complex< double > cv)
Definition: Bimage.h:325
img_reconstruct_one
double img_reconstruct_one(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
Definition: bmaxpow.cpp:198
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:391
SMALLFLOAT
#define SMALLFLOAT
Definition: utilities.h:46
Bimage::fft
int fft()
Definition: Bimage.h:830
view_list_expand_angles
View * view_list_expand_angles(View *views, double amin, double amax, double astep)
Expands each view to several views with different rotation angles.
Definition: View.cpp:435
Bimage::image_size
long image_size()
Definition: Bimage.h:290
img_reconstruct_one_v3
double img_reconstruct_one_v3(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
Definition: bmaxpow.cpp:229
FOM_CC_AVG
@ FOM_CC_AVG
Definition: mg_processing.h:44
project_maximum_power
int project_maximum_power(Bproject *project, Bsymmetry *sym, double theta_step, double phi_step, double alpha_step, int part_select, double hi_res, double lo_res, double scale, Vector3< long > size, Bimage *pmask, int pad_factor, int ctf_action, double wiener, int flags)
Determines the orientation of each particle from the maximum power of its reconstruction.
Definition: bmaxpow.cpp:520
Boption::ctf_action
int ctf_action()
Definition: options.h:291
Boption::value
Bstring value
Definition: options.h:30
project_count_mg_part_selected
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
Definition: mg_select.cpp:437
mg_ctf.h
Functions for CTF (contrast transfer function) processing.
Bimage
General image parameter class.
Definition: Bimage.h:177
timer.h
Utilities for timing functions.
part_find_first
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
Definition: mg_processing.cpp:283
Bproject
Definition: mg_processing.h:336
part_select
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:563
Bparticle::sel
long sel
Definition: mg_processing.h:104
Boption::symmetry_string
Bstring symmetry_string()
Definition: options.h:233
Bimage::complex
Complex< double > complex(long j)
Returns a complex value at the given index.
Definition: Bimage.cpp:1027
VERB_TIME
#define VERB_TIME
Definition: utilities.h:114
use
const char * use[]
Definition: bmaxpow.cpp:34
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
FOM_CC
@ FOM_CC
Definition: mg_processing.h:41
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
Boption::size
Vector3< long > size()
Definition: options.h:163
Bstring::length
long length() const
Definition: Bstring.cpp:263
img_ctf_apply
int img_ctf_apply(Bimage *p, CTFparam em_ctf, int action, double wiener, double lores, double hires)
Applies or corrects for the contrast transfer function (CTF).
Definition: mg_ctf.cpp:237
Bparticle::def
double def
Definition: mg_processing.h:96
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
CTFparam
Definition: ctf.h:28
Vector3::volume
double volume()
Definition: Vector3.h:237
rwimg.h
Header file for 2D and 3D image I/O.
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:241
Bfield::next
Bfield * next
Definition: mg_processing.h:261
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:321
main
int main(int argc, char **argv)
Definition: bmaxpow.cpp:67
Bimage::fspace_pack_2D
int fspace_pack_2D(Bimage *p, Matrix3 mat, double hi_res, double lo_res, Vector3< double > scale, double part_weight=1, int interp_type=0)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
Definition: Bimage_reconstruct.cpp:107
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:101
mg_processing.h
Header file for micrograph processing.
img_reconstruct_one_v1
double img_reconstruct_one_v1(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
Definition: bmaxpow.cpp:299
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:106
ppx_check
int ppx_check(Bparticle *part, FOMType fom_tag[NFOM])
Definition: rwmg.cpp:441
Bparticle::next
Bparticle * next
Definition: mg_processing.h:91
kill_symmetry
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Definition: symmetry.cpp:207
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
verbose
int verbose
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:284
FILL_BACKGROUND
#define FILL_BACKGROUND
Definition: utilities.h:178
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:347
Bmicrograph::pixel_size
Vector3< double > pixel_size
Definition: mg_processing.h:215
Bimage::sampling
void sampling(long nn, Vector3< double > u)
Definition: Bimage.h:514
Bsymmetry::label
Bstring label
Definition: symmetry.h:41
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
write_particle
int write_particle(Bstring &filename, Bparticle *part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
Definition: rwmg.cpp:406
Bparticle::mag
double mag
Definition: mg_processing.h:95
Float
@ Float
Definition: utilities.h:161
View::angle
double angle()
Definition: View.h:98
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:202
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:713
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:267
findNextPowerOf
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
Definition: utilities.cpp:397
Bparticle::id
int id
Definition: mg_processing.h:93
Bimage::view
void view(double vx, double vy, double vz, double va)
Definition: Bimage.h:596
Bimage::rescale_to_avg_std
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
Definition: Bimage_rescale.cpp:163