 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
28 double theta_step,
double phi_step,
double alpha_step,
29 int part_select,
double hi_res,
double lo_res,
double scale,
31 int ctf_action,
double wiener,
int flags);
36 "Usage: bmaxpow [options] input.star [input.star]",
37 "------------------------------------------------",
38 "Finds orientations of particle images based on maximizing reciprocal space reconstruction power.",
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.",
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).",
56 "-reference file.pif Centering reference file (turns on centering).",
57 "-mask mask.mrc Real space 2D mask to be applied to particles.",
60 "-output file.star Output parameter file.",
61 "-ppx Write temporary particle parameter files to directory \"ppx\".",
67 int main(
int argc,
char** argv)
91 for ( curropt = option; curropt; curropt = curropt->
next ) {
92 if ( curropt->
tag ==
"all" )
94 if ( curropt->
tag ==
"center" )
96 if ( curropt->
tag ==
"select" )
98 cerr <<
"-select: A selection number must be specified!" << endl;
99 if ( curropt->
tag ==
"symmetry" )
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;
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;
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" )
119 cerr <<
"-pad: An integer factor must be specified!" << endl;
120 if ( curropt->
tag ==
"CTF" )
122 if ( curropt->
tag ==
"wiener" ) {
123 if ( ( wiener = curropt->
value.
real() ) < 0.000001 )
124 cerr <<
"-wiener: A Wiener factor must be specified!" << endl;
126 if ( wiener < 0.01 ) wiener = 0.01;
130 if ( curropt->
tag ==
"reference" )
132 if ( curropt->
tag ==
"mask" )
134 if ( curropt->
tag ==
"output" )
142 if ( hires > lores ) swap(hires, lores);
146 while ( optind < argc )
string_add(&file_list, argv[optind++]);
148 cerr <<
"Error: No parameter files specified!" << endl;
156 cerr <<
"Error: No input file read!" << endl;
168 }
else if ( center ) {
172 if ( pref )
delete pref;
179 if ( sym->
point > 101 )
181 part_select, hires, lores, 1, map_size, pmask, pad_factor,
182 ctf_action, wiener, flags);
185 if ( pmask )
delete pmask;
199 View view,
double hi_res,
double lo_res,
double scale)
215 if ( weight[i] > 2.5 ) {
216 fom += prec->
complex(i).power()/power[i];
222 else cout <<
"No overlapping voxels!" << endl;
230 View view,
double hi_res,
double lo_res,
double scale)
233 double pwr(0), avg(0), w(0), fom(0);
244 if ( weight[i] > 1.5 ) {
245 avg = prec->
complex(i).power();
247 w = pwr - avg/weight[i];
249 fom += (avg - pwr)/w;
255 else cout <<
"No overlapping voxels!" << endl;
263 View view,
double hi_res,
double lo_res,
double scale)
266 double pwr(0), avg(0), w(0), fom(0);
279 if ( weight[i] > 1.5 ) {
280 avg += prec->
complex(i).power();
289 if ( w ) fom = (avg - pwr)/(pwr - avg/w);
290 else cout <<
"No overlapping voxels!" << endl;
300 View view,
double hi_res,
double lo_res,
double scale)
303 double pwr(0), avg(0), w(0), fom(0);
316 if ( weight[i] > 1.5 ) {
317 avg += prec->
complex(i).power();
326 if ( n ) fom = (n*avg - pwr)/(pwr - avg);
327 else cout <<
"No overlapping voxels!" << endl;
357 double theta_step,
double phi_step,
double alpha_step,
358 double hi_res,
double lo_res,
double scale,
int pad_factor)
362 if ( hi_res < 2*p->sampling(0)[0]/scale ) hi_res = 2*p->
sampling(0)[0]/scale;
365 cout <<
"Finding the orientation based on maximum power up to " << hi_res <<
" A resolution" << endl;
368 double fomavg, bestfom;
376 for ( nviews=0, v=view; v; v=v->
next ) nviews++;
381 double* fom_arr =
new double[nviews];
383 for ( iv=0, v=view; v; v=v->
next, iv++ ) view_arr[iv] = *v;
386 cout <<
"x\ty\tz\ta\tFOM" << endl;
389 dispatch_apply(nviews, dispatch_get_global_queue(0, 0), ^(
size_t iv){
393 #pragma omp parallel for
394 for ( iv = 0; iv < nviews; iv++ )
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];
409 cout << bestview <<
tab << fomavg << endl;
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)
433 double part_scale(1);
438 error_show(
"part_find_maximum_power", __FILE__, __LINE__);
448 if ( part->
ori[0] <= 0 ) {
461 if ( part->
mag > 0 ) part_scale = scale/part->
mag;
462 else part_scale = scale;
475 if ( mg->
ctf && ctf_action )
479 phi_step, alpha_step, hi_res, lo_res, part_scale, pad_factor);
521 double theta_step,
double phi_step,
double alpha_step,
522 int part_select,
double hi_res,
double lo_res,
double scale,
524 int ctf_action,
double wiener,
int flags)
526 if ( pad_factor < 1 ) pad_factor = 1;
527 if ( pad_factor > 8 ) pad_factor = 8;
533 error_show(
"Error in project_maximum_power", __FILE__, __LINE__);
534 cerr <<
"No particles found! " << endl << endl;
541 error_show(
"Error in project_maximum_power", __FILE__, __LINE__);
542 cerr <<
"No particle image file name given for micrograph " << mg->
id << endl << endl;
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];
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;
565 if ( size[0] > 500 && hi_res > 4*mg->
pixel_size[0] ) size /= 2;
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;
579 cout <<
"Real space mask: " << pmask->
file_name() << endl << endl;
584 mkdir(
"ppx", O_CREAT );
592 cout <<
"Part\tx\ty\tz\ta\tFOMavg\tFOMmax\tRatio" << endl;
594 for ( mg=field->
mg; mg; mg=mg->
next ) {
595 for ( part=mg->
part; part; part=part->
next ) {
606 theta_step, phi_step, alpha_step, hi_res, lo_res, scale,
607 pad_factor, ctf_action, wiener, flags);
609 cout << part->
id <<
tab << setprecision(4) <<
614 part->
fom[0]/part->
fom[1] << endl;
618 cout <<
"Complete: " << nrec*100.0/nsel <<
"%\r" << flush;
A class for a command line input option.
int project_kill(Bproject *project)
Frees a whole project.
double img_reconstruct_one_v2(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
Bimage * project_find_particle_centers(Bproject *project, int max_iter, int part_select, double hires, double lores)
Calculates centers of single particle images.
Vector3< double > real_size()
Manipulates single particle images.
int string_kill(Bstring *list)
Kills a string linked list.
long fspace_reconstruction_weigh()
Weighs a reconstruction.
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
int update(CTFparam *ctf)
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)
int bexit(int value)
Exit function for cleanup and debugging.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
double background(long nn)
Vector3< long > size() const
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.
Header file for option handlers.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
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.
void view(double x, double y, double z, double a)
Bstring ppx_filename(Bstring &id, int part_id)
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.
long values(T1 &v1, T2 &v2)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Header file for reading and writing micrograph parameters.
void origin(double x, double y, double z)
long part_reset_selection(Bproject *project, int flag=0)
Resets selection to all particles.
void multiply(long j, Complex< double > cv)
double img_reconstruct_one(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
View * view_list_expand_angles(View *views, double amin, double amax, double astep)
Expands each view to several views with different rotation angles.
double img_reconstruct_one_v3(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
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.
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
Functions for CTF (contrast transfer function) processing.
General image parameter class.
Utilities for timing functions.
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
Bstring symmetry_string()
Complex< double > complex(long j)
Returns a complex value at the given index.
double timer_start()
Starts timer and prints the time.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
ostream & tab(ostream &out)
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).
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Header file for 2D and 3D image I/O.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
int main(int argc, char **argv)
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.
Header file for micrograph processing.
double img_reconstruct_one_v1(Bimage *p, Vector3< long > size, Bsymmetry *sym, View view, double hi_res, double lo_res, double scale)
int ppx_check(Bparticle *part, FOMType fom_tag[NFOM])
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Header file for generalized linked list functions.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
unsigned char * data_pointer()
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
Vector3< double > pixel_size
void sampling(long nn, Vector3< double > u)
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
int write_particle(Bstring &filename, Bparticle *part, int euler_flag, int omega_flag, FOMType fom_tag[NFOM])
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
void view(double vx, double vy, double vz, double va)
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.