 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
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);
39 "Usage: bico [options] tomo.star",
40 "-------------------------------",
41 "Analyzes icosahedral subtomograms.",
44 "-find opp Type of correlation: worst, opposite, c5.",
45 "-analyze 0.1 Calculate statistics for vertices.",
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).",
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.",
59 "-output file.star Output parameter file.",
60 "-reconstruction file.ext Reconstruction file name.",
65 int main(
int argc,
char **argv)
71 double hires(0), lores(0);
83 for ( curropt = option; curropt; curropt = curropt->
next ) {
84 if ( curropt->
tag ==
"find" )
85 type = curropt->
value;
86 if ( curropt->
tag ==
"analyze" ) {
88 if ( ( threshold = curropt->
value.
real() ) < -0.99 )
89 cerr <<
"-analyze: A threshold must be specified!" << endl;
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" )
99 if ( curropt->
tag ==
"mask" )
101 if ( curropt->
tag ==
"Mask" )
103 if ( curropt->
tag ==
"special" )
104 specvert_file = curropt->
filename();
105 if ( curropt->
tag ==
"output" )
107 if ( curropt->
tag ==
"reconstruction" )
116 while ( optind < argc )
string_add(&file_list, argv[optind++]);
118 cerr <<
"Error: No parameter files specified!" << endl;
126 cerr <<
"Error: No input file read!" << endl;
132 if ( ref_file.
length() ) {
134 }
else if ( !analyze ) {
139 if ( !analyze && !pref ) {
140 cerr <<
"Error: No template map!" << endl;
145 if ( mask_file.
length() ) {
151 if ( fsmask_file.
length() ) {
152 pfsmask =
read_img(fsmask_file, 1, 0);
157 if ( maxres > hires ) maxres = hires;
163 if ( type[0] ==
'w' ) {
165 }
else if ( type[0] ==
'o' ) {
167 }
else if ( type ==
"c5" ) {
173 if ( specvert_file.
length() ) {
187 if ( pavg && reconsfile.
length() ) {
191 cout <<
"Writing " << filename << endl;
213 error_show(
"img_read_mask_orient", __FILE__, __LINE__);
231 pfsmrot = pfsmask->
copy();
270 vector<Bparticle*> varr(12);
272 for ( i=0, worst = vert; worst && i<12; worst = worst->
next, ++i )
276 dispatch_apply(11, dispatch_get_global_queue(0, 0), ^(
size_t i){
279 v->
fom[0] =
img_cc(p, pref, pfsmask, hires, lores);
283 #pragma omp parallel for
284 for ( i=0; i<12; ++i ) {
287 v->
fom[0] =
img_cc(p, pref, pfsmask, hires, lores);
292 for ( i=0; vert && i<12; vert = vert->
next, ++i ) {
294 cout << vert->
sel <<
tab << vert->
fom[0] << endl;
295 if ( cc_worst > vert->
fom[0] ) {
297 cc_worst = vert->
fom[0];
310 Bimage* pfsmask,
double hires,
double lores)
313 double at(
M_PI - 0.02), cc, cc_worst(1);
320 for ( i=0, vert2 = vert1; vert2 && i<12; vert2 = vert2->
next, ++i )
323 for ( i=0; vert && i<11; vert = vert->
next, ++i )
if ( vert->
fom[0] < -1 ) {
325 for ( j=i+1, vert2 = vert->
next; vert2 && j<12; vert2 = vert2->next, ++j )
327 if ( j<12 && vert2 ) {
329 cc =
img_cc(p1, p2, pfsmask, hires, lores);
331 vert->
fom[0] = vert2->
fom[0] = cc;
333 cout << vert->
sel <<
" - " << vert2->
sel <<
tab << cc << endl;
334 if ( cc_worst > cc ) {
344 for ( i=0, vert2 = vert1; vert2 && i<12; vert2 = vert2->
next, ++i )
348 worst->
sel = worst2->
sel = 2;
354 Bimage* pmask,
Bimage* pfsmask,
double hires,
double lores)
362 for ( i=1, vert2 = vert; vert2 && i<=12; vert2 = vert2->
next, ++i ) {
363 if ( vert2->
sel == 2 ) {
365 cc =
img_cc(p, pref, pfsmask, hires, lores);
387 Bimage* pfsmask,
double hires,
double lores)
390 double* cc =
new double[5];
395 vector<View> view_arr(5);
396 for ( i=0, v=views; v; v=v->
next, ++i ) view_arr[i] = *v;
400 dispatch_apply(4, dispatch_get_global_queue(0, 0), ^(
size_t i){
402 cc[i] =
img_cc(p, pref, pfsmask, hires, lores);
406 #pragma omp parallel for
407 for ( i=0; i<5; ++i ) {
409 cc[i] =
img_cc(p, pref, pfsmask, hires, lores);
415 for ( i=0; i<5; ++i ) {
417 cout << i <<
tab << cc[i] << endl;
418 if ( part->
fom[0] < cc[i] ) {
420 part->
fom[0] = cc[i];
421 part->
view = view_arr[i];
447 Bimage* pmask,
Bimage* pfsmask,
double hires,
double lores)
449 if ( hires < 2*project->rec->voxel_size[0] )
451 if ( lores < hires ) lores = 1e6;
454 cerr <<
"Error: No template map!" << endl;
468 cout <<
"Determining the special vertices:" << endl;
469 cout <<
"Resolution limits: " << hires <<
" - " << lores <<
" A" << endl;
471 cout <<
"Reference: " << pref->
file_name() << endl;
473 cout <<
"Real space mask: " << pmask->
file_name() << endl;
475 cout <<
"Frequency space mask: " << pfsmask->
file_name() << endl;
480 cout <<
"Reconstruction: " << rec->
frec << endl;
481 cout <<
"Particle\tSpecial vertex" << endl;
483 for ( i=1, vert = part = rec->
part; part; part = part->
next, ++i ) {
487 cout << vert->
group <<
tab << psel << endl;
521 Bimage* pfsmask,
double hires,
double lores)
523 if ( hires < 2*project->rec->voxel_size[0] )
525 if ( lores < hires ) lores = 1e6;
533 cout <<
"Determining the special vertices:" << endl;
534 cout <<
"Resolution limits: " << hires <<
" - " << lores <<
" A" << endl;
536 cout <<
"Real space mask: " << pmask->
file_name() << endl;
538 cout <<
"Frequency space mask: " << pfsmask->
file_name() << endl;
546 cout <<
"Reconstruction: " << rec->
frec << endl;
547 cout <<
"Particle\tVertex pair" << endl;
549 for ( i=1, vert = part = rec->
part; part; part = part->
next, ++i ) {
553 cout << vert->
group <<
tab << psel << endl;
570 cout <<
"Reconstruction: " << rec->
frec << endl;
571 cout <<
"Particle\tSpecial vertex" << endl;
573 for ( i=1, vert = part = rec->
part; part; part = part->
next, ++i ) {
577 cout << vert->
group <<
tab << psel << endl;
612 Bimage* pmask,
Bimage* pfsmask,
double hires,
double lores)
614 if ( hires < 2*project->rec->voxel_size[0] )
616 if ( lores < hires ) lores = 1e6;
618 long psel, n(0), nc(0);
623 cerr <<
"Error: No template map!" << endl;
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;
632 cout <<
"Real space mask: " << pmask->
file_name() << endl;
634 cout <<
"Frequency space mask: " << pfsmask->
file_name() << endl;
642 cout <<
"Reconstruction: " << rec->
frec << endl;
643 cout <<
"Particle\tBestC5" << endl;
645 for ( part = rec->
part; part; part = part->
next ) {
646 if ( part->
sel == 2 ) {
649 cout << part->
group <<
tab << psel << endl;
651 if ( psel > 1 ) nc++;
657 cout <<
"Number of view changes: " << nc <<
" (" << nc*100.0/n <<
"%)" << endl;
673 cout <<
"Transferring the special vertex orientations" << endl;
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 ) {
680 cout <<
"Reconstruction: " << rec->
frec << endl;
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 ) {
692 cerr <<
"Error: reconstruction " << rec->
id <<
" particle " << part->
id << endl;
699 cout <<
"Number of particles updated: " << npart << endl;
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);
717 cout <<
"Transferring the special vertex orientations" << endl;
721 cout <<
"Reconstruction: " << rec->
id << endl;
722 for ( part = vert = rec->
part; part; part = vert, npart++ ) {
726 for ( vert = part, i = i2 = 0; vert && vert->
group == part->
group;
727 vert = vert->
next, ++i ) {
729 fom[i] = vert->
fom[0];
730 if ( min > vert->
fom[0] ) {
734 if ( max < vert->fom[0] ) max = vert->
fom[0];
735 if ( vert->
sel == 1 ) {
743 for ( vert = part, i = nodd = 0; vert && vert->
group == part->
group;
744 vert = vert->
next, ++i ) {
747 fom[i] = (fom[i] - min)/avg;
748 if ( fom[i] <= threshold ) nodd++;
749 h = long(scale*fom[i] + 0.5);
751 if ( h > nh ) h = nh;
755 cout << part->
group <<
tab << avg <<
tab << i2 <<
tab << imin <<
tab << nodd << endl;
759 cerr <<
"Error: Too few vertices! (" << i <<
")" << endl;
764 cout <<
"Number of particles: " << npart << endl;
765 cout <<
"Number of odd vertices: " << noddtot << endl;
768 cout <<
"Bin\tFOM\tCount" << endl;
769 for ( h=0; h<bins; ++h )
770 cout << h <<
tab << h/scale <<
tab << fomhis[h] << endl;
A class for a command line input option.
Header file for reading and writing symmetry operators.
Functions for reconstruction.
int project_kill(Bproject *project)
Frees a whole project.
fft_plan fft_setup(fft_direction dir, int opt=0)
Sets up a plan for fast Fourier transforms.
long particle_worst_opposite_vertex(Bparticle *vert, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
long project_analyze_vertices(Bproject *project, double threshold)
View * symmetry_get_all_views(Bsymmetry *sym, View asu_view)
Get all symmetry-related views of one given view.
int string_kill(Bstring *list)
Kills a string linked list.
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
long particle_worst_vertex(Bparticle *vert, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
Vector3< double > voxel_size
Bimage * img_vertex_reconstruct(Bproject *project, Vector3< long > size, double maxres)
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Header file for general symmetry functions.
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.
long project_assign_special_vertex_orientations(Bproject *project, Bproject *project_specvert)
Header file for option handlers.
void view(double x, double y, double z, double a)
int zero_origin()
Shifts the origins to zero with wrapping.
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.
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)
void multiply(long j, Complex< double > cv)
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.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
long particle_cc_opposite_vertices(Bparticle *vert, Bimage *pmask, Bimage *pfsmask, double hires, double lores)
int rotate()
Rotates an image using parameters defined in the image in place.
General image parameter class.
Utilities for timing functions.
int center_wrap()
Centers an image with wrapping.
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)
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
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.
Header file for micrograph processing.
double img_cc(Bimage *p1, Bimage *p2, Bimage *pfsmask, double hires, double lores)
Header file for generalized linked list functions.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Bimage * project_reconstruct_3D(Bproject *project, long selnum, int calcfom, Vector3< long > size)
Transforms 3D maps and calculates an average.
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.
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.
int main(int argc, char **argv)
Bimage * img_read_orient_mask(Bstring &filename, Bimage *pmask, View view)
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
long particle_best_c5(Bparticle *part, Bimage *pref, Bimage *pmask, Bimage *pfsmask, double hires, double lores)