| Bsoft 2.0.5 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
27 int project_maximum_power(Bproject* project, Bsymmetry* sym,
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 project_update_comment(project, argc, argv);
161
162 if ( reset ) part_reset_selection(project);
163
164 Bimage* pref = NULL;
165 int max_iter(10);
166
167 if ( reffile.length() ) {
168 pref = read_img(reffile, 1, 0);
169 project_set_particle_centers(project, pref, part_select, hires, lores);
170 } else if ( center ) {
171 pref = project_find_particle_centers(project, max_iter, part_select, hires, lores);
172 }
173
174 if ( pref ) delete pref;
175
176 Bimage* pmask = NULL;
177 if ( maskfile.length() )
178 pmask = read_img(maskfile, 1, 0);
179
180 Bsymmetry* sym = init_point_group_symmetry(symmetry_string);
181 if ( sym->point > 101 )
182 project_maximum_power(project, sym, theta_step, phi_step, alpha_step,
183 part_select, hires, lores, 1, map_size, pmask, pad_factor,
184 ctf_action, wiener, flags);
185
186 kill_symmetry(sym);
187 if ( pmask ) delete pmask;
188
189 if ( outfile.length() )
190 write_project(outfile, project, 0, 0);
191
192 project_kill(project);
193
194 if ( verbose & VERB_TIME )
195 timer_report(ti);
196
197 bexit(0);
198 }
199
200 double img_reconstruct_one(Bimage* p, Vector3<long> size, Bsymmetry* sym,
201 View view, double hi_res, double lo_res, double scale)
202 {
203 long i, n;
204 double fom(0);
205
206 Bimage* prec = new Bimage(Float, TComplex, size, 1);
207
208 prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, scale, 1, 0);
209
210 prec->fspace_reconstruction_weigh();
211
212 float* power = (float *) prec->next->data_pointer();
213 float* weight = (float *) prec->next->next->data_pointer();
214
215 for ( i=n=0; i<prec->image_size(); i++ ) {
216 if ( weight[i] > 2.5 ) {
217 fom += prec->complex(i).power()/power[i];
218 n++;
219 }
220 }
221
222 if ( n ) fom /= n;
223 else cout << "No overlapping voxels!" << endl;
224
225 delete prec;
226
227 return fom;
228 }
229
230 double img_reconstruct_one_v3(Bimage* p, Vector3<long> size, Bsymmetry* sym,
231 View view, double hi_res, double lo_res, double scale)
232 {
233 long i, n;
234 double pwr(0), avg(0), w(0), fom(0);
235
236 Bimage* prec = new Bimage(Float, TComplex, size, 1);
237
238 prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, scale, 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
262 double img_reconstruct_one_v2(Bimage* p, Vector3<long> size, Bsymmetry* sym,
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
268 Bimage* prec = new Bimage(Float, TComplex, size, 1);
269
270 prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, scale, 1, 0);
271
272 // prec->fspace_reconstruction_weigh();
273
274 float* power = (float *) prec->next->data_pointer();
275 float* weight = (float *) prec->next->next->data_pointer();
276
277 for ( i=n=0; i<prec->image_size(); i++ ) {
278 if ( weight[i] > 1.5 ) {
279 avg += prec->complex(i).power();
280 pwr += power[i];
281 w += weight[i];
282 // fom += power[i] - prec->complex(i).power();
283 // n++;
284 }
285 }
286 // if ( n ) fom /= n;
287 // else cout << "No overlapping voxels!" << endl;
288 if ( w ) fom = (avg - pwr)/(pwr - avg/w);
289 else cout << "No overlapping voxels!" << endl;
290
291 // fom = 1/(1+fom);
292
293 delete prec;
294
295 return fom;
296 }
297
298 double img_reconstruct_one_v1(Bimage* p, Vector3<long> size, Bsymmetry* sym,
299 View view, double hi_res, double lo_res, double scale)
300 {
301 long i, n;
302 double pwr(0), avg(0), w(0), fom(0);
303
304 Bimage* prec = new Bimage(Float, TComplex, size, 1);
305
306 prec->fspace_pack_2D(p, view, sym, hi_res, lo_res, scale, 1, 0);
307
308 prec->fspace_reconstruction_weigh();
309
310 float* power = (float *) prec->next->data_pointer();
311 float* weight = (float *) prec->next->next->data_pointer();
312
313 for ( i=n=0; i<prec->image_size(); i++ ) {
314 if ( weight[i] > 1.5 ) {
315 avg += prec->complex(i).power();
316 pwr += power[i];
317 w += weight[i];
318 // fom += power[i] - prec->complex(i).power();
319 n++;
320 }
321 }
322 // if ( n ) fom /= n;
323 // else cout << "No overlapping voxels!" << endl;
324 if ( n ) fom = (n*avg - pwr)/(pwr - avg);
325 else cout << "No overlapping voxels!" << endl;
326
327 fom = 1/(1+fom);
328
329 delete prec;
330
331 return fom;
332 }
333
354 double img_find_maximum_power(Bimage* p, Vector3<long> size, Bsymmetry* sym,
355 double theta_step, double phi_step, double alpha_step,
356 double hi_res, double lo_res, double scale, int pad_factor)
357 {
358 if ( !p->data_pointer() ) return 0;
359
360 if ( hi_res < 2*p->sampling()[0]/scale ) hi_res = 2*p->sampling()[0]/scale;
361
362 if ( verbose & VERB_FULL )
363 cout << "Finding the orientation based on maximum power up to " << hi_res << " A resolution" << endl;
364
365 long iv, nviews;
366 double fomavg, bestfom;
367 View* v;
368 View* view = asymmetric_unit_views(sym, theta_step, phi_step, 1);
369 View* view2 = view_list_expand_angles(view, -M_PI, M_PI - alpha_step/2, alpha_step);
370 kill_list((char *) view, sizeof(View));
371 view = view2;
372 View bestview;
373
374 for ( nviews=0, v=view; v; v=v->next ) nviews++;
375
376 // cout << "number of views = " << nviews << endl;
377
378 View* view_arr = new View[nviews];
379 double* fom_arr = new double[nviews];
380
381 for ( iv=0, v=view; v; v=v->next, iv++ ) view_arr[iv] = *v;
382
383 if ( verbose & VERB_FULL )
384 cout << "x\ty\tz\ta\tFOM" << endl;
385
386 #ifdef HAVE_GCD
387 dispatch_apply(nviews, dispatch_get_global_queue(0, 0), ^(size_t iv){
388 fom_arr[iv] = img_reconstruct_one(p, size, sym, view_arr[iv], hi_res, lo_res, scale);
389 });
390 #else
391 #pragma omp parallel for
392 for ( iv = 0; iv < nviews; iv++ )
393 fom_arr[iv] = img_reconstruct_one(p, size, sym, view_arr[iv], hi_res, lo_res, scale);
394 #endif
395
396 for ( iv = 0, bestfom = -1e30, fomavg = 0; iv < nviews; iv++ ) {
397 fomavg += fom_arr[iv];
398 if ( bestfom < fom_arr[iv] ) {
399 bestfom = fom_arr[iv];
400 bestview = view_arr[iv];
401 }
402 }
403
404 fomavg /= nviews;
405
406 if ( verbose & VERB_FULL )
407 cout << bestview << tab << fomavg << endl;
408
409 delete[] view_arr;
410 delete[] fom_arr;
411 kill_list((char *) view, sizeof(View));
412
413 p->view(bestview);
414 p->image->FOM(fomavg);
415
416 return bestfom;
417 }
418
419 double part_find_maximum_power(Bparticle* part,
420 Vector3<long> size, Bimage* pmask, long ft_size, Bsymmetry* sym,
421 double theta_step, double phi_step, double alpha_step,
422 double hi_res, double lo_res, double scale, int pad_factor,
423 int ctf_action, double wiener, int flags)
424 {
425 FOMType fom_tag[NFOM] = {FOM_CC, FOM_CC_AVG};
426
427 if ( flags & CHECK_PPX )
428 if ( ppx_check(part, fom_tag) )
429 return part->fom[0];
430
431 double part_scale(1);
432 Bimage* p = NULL;
433 Bmicrograph* mg = part->mg;
434
435 if ( ( p = read_img(mg->fpart, 1, part->id - 1) ) == NULL ) {
436 error_show("part_find_maximum_power", __FILE__, __LINE__);
437 return -1;
438 }
439
440 CTFparam em_ctf;
441 if ( mg->ctf ) em_ctf.update(mg->ctf);
442 if ( part->def > 0 ) em_ctf.defocus_average(part->def);
443
444 if ( pmask ) p->multiply(pmask);
445
446 if ( part->ori[0] <= 0 ) {
447 if ( p->image->origin()[0] <= 0 ) part->ori = p->size()/2;
448 else part->ori = p->image->origin();
449 }
450 p->image->origin(part->ori);
451
452 p->view(part->view);
453
454 if ( size[2] < 2 ) {
455 if ( p->image->view()[2] >= 0 ) p->image->view(0,0,1,0);
456 else p->image->view(0,0,-1,0);
457 }
458
459 if ( part->mag > 0 ) part_scale = scale/part->mag;
460 else part_scale = scale;
461
462 p->rescale_to_avg_std(0, 1);
463 p->calculate_background();
464
465 p->pad(ft_size, FILL_BACKGROUND, p->background(long(0)));
466
467 p->fft();
468
469 p->phase_shift_to_origin();
470
471 p->sampling(mg->pixel_size, mg->pixel_size, 1);
472
473 if ( mg->ctf && ctf_action )
474 img_ctf_apply(p, em_ctf, ctf_action, wiener, 0, hi_res);
475
476 part->fom[0] = img_find_maximum_power(p, size, sym, theta_step,
477 phi_step, alpha_step, hi_res, lo_res, part_scale, pad_factor);
478
479 part->view = p->image->view();
480 part->fom[1] = p->image->FOM();
481
482 delete p;
483 // cout << "Particle done" << endl;
484
485 if ( flags & WRITE_PPX ) {
486 Bstring ppx_name = ppx_filename(part->mg->id, part->id);
487 write_particle(ppx_name, part, 0, 0, fom_tag);
488 ppx_name = 0;
489 }
490
491 return part->fom[0];
492 }
493
518 int project_maximum_power(Bproject* project, Bsymmetry* sym,
519 double theta_step, double phi_step, double alpha_step,
520 int part_select, double hi_res, double lo_res, double scale,
521 Vector3<long> size, Bimage* pmask, int pad_factor,
522 int ctf_action, double wiener, int flags)
523 {
524 if ( pad_factor < 1 ) pad_factor = 1;
525 if ( pad_factor > 8 ) pad_factor = 8;
526
527 Bfield* field = project->field;
528 Bmicrograph* mg = field->mg;
529 Bparticle* part = mg->part;
530 Bimage* p = read_img(mg->fpart, 0, 0);
531 p->sampling(mg->pixel_size, mg->pixel_size, 1);
532
533 if ( !mg->fpart.length() ) {
534 error_show("Error in project_maximum_power", __FILE__, __LINE__);
535 cerr << "No particle image file name given for micrograph " << mg->id << endl << endl;
536 return 0;
537 }
538
539 if ( size.volume() < 1 ) {
540 size[0] = p->sizeX();
541 if ( size[0] < p->sizeY() ) size[0] = p->sizeY();
542 if ( size[0] < p->sizeZ() ) size[0] = p->sizeZ();
543 size[2] = size[1] = size[0];
544 }
545
546 if ( size[0] > 2*p->real_size()[0]/hi_res )
547 size[2] = size[1] = size[0] = 2*p->real_size()[0]/hi_res;
548
549 long ft_size = findNextPowerOf((long)(pad_factor*size[0]*scale), 2);
550 // if ( ft_size < p->sizeX() ) ft_size = p->sizeX();
551 if ( ft_size < p->sizeX() ) ft_size = findNextPowerOf(p->sizeX(), 2);
552
553 delete p;
554
555 if ( size[0] > 500 && hi_res > 4*mg->pixel_size ) size /= 2;
556
557 // if ( verbose & VERB_PROCESS ) {
558 if ( verbose ) {
559 cout << "Finding particle orientations by maximum power:" << endl;
560 cout << "Map size: " << size << endl;
561 cout << "Symmetry: " << sym->label << endl;
562 cout << "Angular steps: " << alpha_step*180.0/M_PI
563 << " " << theta_step*180.0/M_PI << " " << phi_step*180.0/M_PI << endl;
564 cout << "Scale: " << scale << endl;
565 cout << "Resolution limits: " << hi_res << " - " << lo_res << " A" << endl;
566 cout << "Fourier transform size: " << ft_size << " x " << ft_size << endl;
567 cout << "CTF application type: " << ctf_action << endl;
568 if ( pmask )
569 cout << "Real space mask: " << pmask->file_name() << endl << endl;
570 }
571
572 // Directory for individual particle parameter files
573 if ( flags & WRITE_PPX ) {
574 mkdir("ppx", O_CREAT );
575 chmod("ppx", 0755);
576 }
577
578 long nrec(0), psel;
579 long nsel = project_count_mg_part_selected(project);
580
581 if ( verbose )
582 cout << "Part\tx\ty\tz\ta\tFOMavg\tFOMmax\tRatio" << endl;
583 for ( field=project->field; field; field=field->next ) {
584 for ( mg=field->mg; mg; mg=mg->next ) {
585 for ( part=mg->part; part; part=part->next ) {
586 psel = 0;
587 if ( part->sel ) {
588 if ( part_select < 0 ) {
589 psel = 1;
590 } else if ( part->sel == part_select ) {
591 psel = 1;
592 }
593 }
594 if ( psel ) { // Use only selected images
595 part_find_maximum_power(part, size, pmask, ft_size, sym,
596 theta_step, phi_step, alpha_step, hi_res, lo_res, scale,
597 pad_factor, ctf_action, wiener, flags);
598 if ( verbose )
599 cout << part->id << tab << part->view[0] << tab <<
600 part->view[1] << tab << part->view[2] << tab <<
601 part->view.angle()*180.0/M_PI << tab <<
602 part->fom[1] << tab << part->fom[0] << tab <<
603 part->fom[0]/part->fom[1] << endl;
604
605 nrec++;
606 if ( verbose & ( VERB_TIME | VERB_PROCESS ) )
607 cout << "Complete: " << nrec*100.0/nsel << "%\r" << flush;
608 }
609 }
610 }
611 }
612
613 return 0;
614 }
615
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
Bparticle::id
int id
Definition: mg_processing.h:92
rwmg.h
Header file for reading and writing micrograph parameters.
Bstring::real
double real()
Definition: Bstring.cpp:545
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
Bparticle::mag
double mag
Definition: mg_processing.h:94
FILL_BACKGROUND
#define FILL_BACKGROUND
Definition: utilities.h:174
Bsub_image::view
void view(double x, double y, double z, double a)
Definition: Bimage.h:143
Bparticle::view
View view
Definition: mg_processing.h:101
Bimage::sampling
Vector3< double > sampling()
Definition: Bimage.h:505
Boption::symmetry_string
Bstring symmetry_string()
Definition: options.h:245
View::next
View * next
Definition: View.h:28
mg_particle_select.h
Select particles.
Bmicrograph::id
Bstring id
Definition: mg_processing.h:202
Bimage::image_size
long image_size()
Definition: Bimage.h:267
SMALLFLOAT
#define SMALLFLOAT
Definition: utilities.h:45
Bimage::fft
int fft()
Definition: Bimage.h:822
utilities.h
Header file for general utilities.
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:200
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
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:408
CTFparam::update
int update(CTFparam *ctf)
Definition: ctf.h:77
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
project_count_mg_part_selected
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
Definition: mg_processing.cpp:833
Bparticle::fom
double fom[NFOM]
Definition: mg_processing.h:102
WRITE_PPX
#define WRITE_PPX
Definition: mg_processing.h:26
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:140
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
Bimage::complex
Complex< double > complex(long j)
Returns a complex value at the given index.
Definition: Bimage.cpp:1005
kill_symmetry
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Definition: symmetry.cpp:207
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:107
part_select
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Definition: tcltk_bmg.cpp:432
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:230
Bimage::multiply
void multiply(long j, Complex< double > cv)
Definition: Bimage.h:312
mg_ctf.h
Functions for CTF (contrast transfer function) processing.
TComplex
Definition: Bimage.h:59
CHECK_PPX
#define CHECK_PPX
Definition: mg_processing.h:27
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:354
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
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:76
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:260
FOM_CC_AVG
Definition: mg_processing.h:44
Boption::filename
Bstring filename()
Definition: options.h:85
ppx_filename
Bstring ppx_filename(Bstring &mg_id, int part_id)
Definition: rwmg.cpp:412
Bfield::next
Bfield * next
Definition: mg_processing.h:258
Bmicrograph::part
Bparticle * part
Definition: mg_processing.h:239
timer.h
Utilities for timing functions.
Float
Definition: utilities.h:157
M_PI_4
#define M_PI_4
Definition: utilities.h:65
Bimage
General image parameter class.
Definition: Bimage.h:163
Bmicrograph::fpart
Bstring fpart
Definition: mg_processing.h:207
Boption::size
Vector3< long > size()
Definition: options.h:163
Bimage::real_size
Vector3< double > real_size()
Definition: Bimage.h:487
Bparticle::sel
long sel
Definition: mg_processing.h:103
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.
Bimage::fspace_pack_2D
int fspace_pack_2D(Bimage *p, Matrix3 mat, double hi_res=0, double lo_res=0, double scale=1, double part_weight=1, int interp_type=0)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
Definition: Bimage_reconstruct.cpp:109
Bmicrograph::ctf
CTFparam * ctf
Definition: mg_processing.h:238
Bparticle::mg
Bmicrograph * mg
Definition: mg_processing.h:104
Bsymmetry::point
int point
Definition: symmetry.h:39
NFOM
#define NFOM
Definition: mg_processing.h:16
mg_particles.h
Manipulates single particle images.
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:419
ppx_check
int ppx_check(Bparticle *part, FOMType fom_tag[NFOM])
Definition: rwmg.cpp:418
Boption
A class for a command line input option.
Definition: options.h:26
write_particle
int write_particle(Bstring &filename, Bparticle *part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
Definition: rwmg.cpp:403
use
const char * use[]
Definition: bmaxpow.cpp:34
Bproject::field
Bfield * field
Definition: mg_processing.h:343
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
Bsub_image::FOM
double FOM()
Definition: Bimage.h:151
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:238
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
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
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:230
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
FOM_CC
Definition: mg_processing.h:41
Bmicrograph
Definition: mg_processing.h:200
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:570
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
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:127
Bparticle::ori
Vector3< double > ori
Definition: mg_processing.h:100
part_reset_selection
long part_reset_selection(Bproject *project)
Resets selection to all particles.
Definition: mg_particle_select.cpp:131
Bimage::fspace_reconstruction_weigh
long fspace_reconstruction_weigh()
Weighs a reconstruction.
Definition: Bimage_reconstruct.cpp:412
Bimage::view
void view(double vx, double vy, double vz, double va)
Definition: Bimage.h:589
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
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:298
Bsymmetry::label
Bstring label
Definition: symmetry.h:41
Bsymmetry
Definition: symmetry.h:38
Bimage::next
Bimage * next
Definition: Bimage.h:165
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:261
Boption::next
Boption * next
Definition: options.h:28
Bparticle
Definition: mg_processing.h:89
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::sizeX
void sizeX(long nx)
Definition: Bimage.h:377
FULL_ASU
#define FULL_ASU
Definition: mg_processing.h:22
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
FOMType
FOMType
Definition: mg_processing.h:38
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:379
Vector3< long >
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
View::angle
double angle()
Definition: View.h:95
View
Definition: View.h:26
Boption::ctf_action
int ctf_action()
Definition: options.h:303
main
int main(int argc, char **argv)
Definition: bmaxpow.cpp:67
CTFparam::defocus_average
double defocus_average()
Definition: ctf.h:100
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bparticle::def
double def
Definition: mg_processing.h:95
Bstring::integer
long integer()
Definition: Bstring.cpp:539
mg_processing.h
Header file for micrograph processing.
verbose
int verbose
rwimg.h
Header file for 2D and 3D image I/O.
options.h
Header file for option handlers.
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
findNextPowerOf
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
Definition: utilities.cpp:433
Vector3::volume
double volume()
Definition: Vector3.h:235
project_update_comment
int project_update_comment(Bproject *project, int n, char **strings)
Puts a set of strings and time in the main comment of a project.
Definition: rwmg.cpp:468
Bparticle::next
Bparticle * next
Definition: mg_processing.h:90
VERB_FULL
#define VERB_FULL
Definition: utilities.h:109
Bimage::background
double background(long nn)
Definition: Bimage.h:542
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:378
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_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:518
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
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
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760
CTFparam
Definition: ctf.h:26
Bmicrograph::next
Bmicrograph * next
Definition: mg_processing.h:201