 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
37 double nuavg,
double nustd)
48 cout <<
"Aligning particle images" << endl;
51 cout <<
"Rescale avg & stdev: " << nuavg <<
" " << nustd << endl;
56 for ( mg = field->
mg; mg; mg = mg->
next ) {
58 error_show(
"project_align_particles", __FILE__, __LINE__);
61 for ( n=0, part = mg->
part; part && n<p->images(); part = part->
next, n++ ) {
91 for ( n=0, part = rec->
part; part; part = part->
next, n++ ) {
102 error_show(
"project_align_particles", __FILE__, __LINE__);
122 cout <<
"Particles oriented: " << nc << endl << endl;
139 double nuavg,
double nustd)
141 long psel, n, np, nc(0);
150 cout <<
"Centering particle images" << endl;
151 cout <<
"Selection: ";
155 cout <<
"Rescale avg & stdev: " << nuavg <<
" " << nustd << endl;
160 for ( mg=field->
mg; mg; mg=mg->
next ) {
161 for ( np=0, part=mg->
part; part; part=part->
next, np++ ) ;
162 for ( n=0, part=mg->
part; part; part=part->
next, n++ ) {
164 error_show(
"project_center_particles", __FILE__, __LINE__);
211 for ( n=0, part = rec->
part; part && n<p->images(); part = part->
next, n++ ) {
222 error_show(
"project_align_particles", __FILE__, __LINE__);
244 cout <<
"Particles oriented: " << nc << endl << endl;
274 cout <<
"Setting the centers of particle images" << endl << endl;
277 for ( mg=field->
mg; mg; mg=mg->
next ) {
278 for ( part=mg->
part; part; part=part->
next ) {
289 error_show(
"mg_set_particle_centers", __FILE__, __LINE__);
323 double hires,
double lores,
int filter_flag)
328 cout <<
"Finding particle centers with resolution limits " << hires <<
" - " << lores <<
" A" << endl;
334 for ( mg=field->
mg; mg; mg=mg->
next )
358 double hires,
double lores,
int filter_flag)
363 cout <<
"Finding particle centers with resolution limits " << hires <<
" - " << lores <<
" A" << endl;
371 if ( npart < 1 )
return 0;
378 cout <<
"Finding particle origins from image " << p->
file_name() << endl;
380 for ( part=mg->
part; part; part=part->
next ) {
381 start = part->
loc - box_size/2;
382 pex = p->
extract(0, start, box_size);
415 double d, R(1e30), change(1e30);
425 cout <<
"Finding the centers of particle images" << endl << endl;
428 cout <<
"Iter\tR" << endl;
430 for ( iter=0; iter<max_iter && R > 0.1 && change > 0.001; iter++ ) {
431 if ( pref ) pref->
clear();
433 for ( mg=field->
mg; mg; mg=mg->
next ) {
434 for ( part=mg->
part; part; part=part->
next ) {
455 cout << shift1 << endl;
472 for ( mg=field->
mg; mg; mg=mg->
next ) {
473 for ( part=mg->
part; part; part=part->
next ) {
491 cout << origin << endl;
504 cout << iter+1 <<
tab << R << endl;
531 for ( part = mg->
part; part; part = part->
next ) {
542 translate = part->
ori - p->
size()/2;
551 if ( partpath.
length() > 1 )
563 if ( partpath.
length() > 1 )
586 if ( !partpath.
empty() )
if ( partpath[-1] !=
'/' ) partpath +=
"/";
594 if ( partpath.
length() > 1 )
595 mkdir(partpath.
c_str(), (mode_t)0755);
598 cout <<
"Masking particle images" << endl << endl;
604 dispatch_queue_t myq = dispatch_queue_create(NULL, NULL);
605 dispatch_apply(nmg, dispatch_get_global_queue(0, 0), ^(
size_t i){
607 dispatch_sync(myq, ^{
610 cout << setw(15) << mgarr[i]->
id <<
tab << n << endl;
615 #pragma omp parallel for
616 for (
long i=0; i<nmg; i++ ) {
622 cout << setw(15) << mgarr[i]->
id <<
tab << n << endl;
655 long nf, tp(0), tn(0), fp(0);
658 Bfield* field, *fieldcomp;
663 for ( fieldcomp = projcomp->
field; fieldcomp && fieldcomp->
id != field->
id; fieldcomp = fieldcomp->
next ) ;
665 for ( mg = field->
mg; mg ; mg = mg->
next ) {
666 for ( mgcomp = fieldcomp->
mg; mgcomp && mgcomp->
id != mg->
id; mgcomp = mgcomp->
next ) ;
669 for ( partcomp = mgcomp->
part; partcomp; partcomp = partcomp->
next ) {
671 partcomp->
fom[0] = 2*r;
673 for ( part = mg->
part; part; part = part->
next ) {
676 for ( partcomp = mgcomp->
part; partcomp; partcomp = partcomp->
next ) {
678 if ( d < r && partcomp->fom[0] > d ) {
679 partcomp->
fom[0] = d;
680 partcomp->
sel = part->
id;
681 part->
sel = partcomp->
id;
688 for ( partcomp = mgcomp->
part; partcomp; partcomp = partcomp->
next )
689 if ( partcomp->
sel < 1 ) fp++;
697 cout <<
"True positive: " << tp << endl;
698 cout <<
"True negative: " << tn << endl;
699 cout <<
"False positive: " << fp << endl << endl;
714 long i, j, nmg(0), nmgsel(0), npart(0), nptot(0), npsel(0);
715 double axis, axis_avg(0), axis_std(0), a1, da;
716 double tilt, tilt_avg(0), tilt_std(0);
717 double ddef, ddef_rmsd(0);
729 for ( mg = field->
mg; mg ; mg = mg->
next, nmg++ )
if ( mg->
select ) {
730 for ( i=0; i<3; i++ ) {
731 for ( j=0; j<3; j++ )
737 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
740 ddef_rmsd += ddef*ddef;
742 for ( i=0; i<3; i++ ) {
743 for ( j=0; j<3; j++ )
744 a[j][i] += loc[i]*loc[j];
751 if ( normal[2] < 0 ) normal = -normal;
752 axis = atan2(-normal[0], normal[1]);
753 tilt = acos(normal[2]);
764 ddef_rmsd = sqrt(ddef_rmsd/npart);
767 axis_std += axis*axis;
769 tilt_std += tilt*tilt;
773 cout << mg->
id <<
tab << npart <<
tab << ddef_rmsd <<
tab << axis*180.0/
M_PI <<
tab << tilt*180.0/
M_PI << endl;
779 axis_std = axis_std/nmgsel - axis_avg*axis_avg;
780 if ( axis_std > 0 ) axis_std = sqrt(axis_std);
782 tilt_std = tilt_std/nmgsel - tilt_avg*tilt_avg;
783 if ( tilt_std > 0 ) tilt_std = sqrt(tilt_std);
787 cout <<
"Number of micrographs: " << nmgsel <<
" (" << nmgsel*100.0/nmg <<
"%)" << endl;
788 cout <<
"Number of particles: " << npsel <<
" (" << npsel*100.0/nptot <<
"%)" << endl;
789 cout <<
"Axis average & stdev: " << axis_avg*180.0/
M_PI <<
tab << axis_std*180.0/
M_PI << endl;
790 cout <<
"Tilt average & stdev: " << tilt_avg*180.0/
M_PI <<
tab << tilt_std*180.0/
M_PI << endl;
808 double ca(cos(axis)), sa(sin(axis)), tt(tan(tilt));
816 for ( mg = field->
mg; mg ; mg = mg->
next )
if ( mg->
select ) {
817 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
double length2(vector< T > v)
long project_count_mg_particles(Bproject *project)
Counts all the particles in the project structure.
Header file for matrix functions.
Manipulates single particle images.
int truncate(double minim, double maxim, double setmin, double setmax)
Truncates image data to a given minimum and maximum.
Bimage * symmetrize_cylinder(int flag)
Calculates a cylindrically symmetrized map.
Header file for file checking functions.
int project_align_particles(Bproject *project, int part_select, double nuavg, double nustd)
Aligns single particle images based on orientation parameters.
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.
Bimage * copy()
Copies the header information and data of an image into a new image structure.
int center(int fill_type=0, double fill=0)
Centers an image.
Vector3< double > default_origin()
Header file for micrograph processing.
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 calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Bimage * rotate_project(Matrix3 mat, Vector3< double > translate, double radial_cutoff, int norm_flag=1)
Rotates a 3D map and projects it along the z-axis.
Bmicrograph ** project_micrograph_array(Bproject *project, long &nmg)
Sets up an array of selected micrograph pointers.
void view(double x, double y, double z, double a)
int shift_wrap(Vector3< double > vec)
Shifts an image.
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.
int project_center_particles(Bproject *project, int part_select, double nuavg, double nustd)
Centers single particle images based on the parametric center.
double standard_deviation()
double angle_set_negPI_to_PI(double angle)
Returns an angle between -PI and PI.
double distance(const Vector3 &v)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
void origin(double x, double y, double z)
void multiply(long j, Complex< double > cv)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int shift_background(double bkg)
Sets the background for each sub-image to a given value.
void add(long j, double v)
long mg_find_part_centers(Bmicrograph *mg, double hires, double lores, int filter_flag)
Finds the centers of picked particles within a micrograph.
long particles_mask(Bmicrograph *mg, Bimage *pmask, Bstring &partpath)
int rotate()
Rotates an image using parameters defined in the image in place.
long project_set_particle_defocus_from_tilt(Bproject *project, double axis, double tilt)
Finds the tilt axis from refined particle defocus values.
General image parameter class.
CompoundType compound_type()
Utilities for timing functions.
Bimage * project_find_particle_centers(Bproject *project, int max_iter, int part_select, double hires, double lores)
Calculates centers of single particle images.
Tcl_Obj * part_select(Bparticle *part, int objc, Tcl_Obj *CONST objv[])
double project_tilt_from_particle_defocus(Bproject *project)
Finds the tilt axis from refined particle defocus values.
Vector3< double > pixel_size
int replace(Bimage *img)
Replaces the data with that from the given image.
Header file for image processing from micrograph structures.
Header file for general utilities.
ostream & tab(ostream &out)
long project_compare_particles(Bproject *project, Bproject *projcomp)
Compares the coordinates of particles between two files.
Vector3< double > fit_plane(Matrix a, vector< double > b)
Solves for fitting a plane through a model.
void origin(double ox, double oy, double oz)
long project_find_part_centers_in_mgs(Bproject *project, double hires, double lores, int filter_flag)
Finds the centers of picked particles within a micrograph.
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
int filter_average(long kernel_size)
Applies an averaging filter to an image.
Header file for micrograph processing.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
long project_mask_particles(Bproject *project, Bimage *pmask, Bstring &partpath)
Calculates centers of single particle images.
Vector3< double > pixel_size
void sampling(long nn, Vector3< double > u)
Bimage * particle_read_img(Bparticle *part, int readflag)
Reads a particle image file.
long particle_count(Bparticle *part)
Counts the number of particles in a linked list.
int filter_extremes()
Filters the extremes out of a micrograph image.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.