 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
40 int fom_type,
double fom_cut,
FSI_Kernel*
kernel,
int ctf_apply,
int img_out)
43 long i, j, m, nsel(0);
44 double maxfom, CC, PD(0), R;
64 int* num =
new int[nmap+1];
65 float* fom =
new float[npart*nmap];
66 float* fom_avg =
new float[nmap+1];
67 float* fom_std =
new float[nmap+1];
69 for ( i=0; i<nmap+1; i++ ) fom_avg[i] = fom_std[i] = num[i] = 0;
70 for ( i=0; i<npart*nmap; i++ ) fom[i] = 0;
73 cout <<
"Classifying particles with respect to maps:" << endl;
74 cout <<
"Number of maps: " << nmap << endl;
75 cout <<
"Resolution range: " << resolution_hi <<
" - " << resolution_lo <<
" Å" << endl;
76 cout <<
"FOM type: " << fom_type << endl;
77 cout <<
"FOM cutoff: " << fom_cut << endl;
79 cout <<
"Applying CTF parameters" << endl;
81 cout <<
"Output projections" << endl;
83 cout <<
"Output differences" << endl;
94 cout << endl <<
"Map\tFile\tPart\t";
95 if ( fom_type == 1 ) cout <<
"R" << endl;
96 else if ( fom_type == 2 ) cout <<
"dPhi" << endl;
97 else cout <<
"CC" << endl;
102 return error_show(
"mg_classify", __FILE__, __LINE__);
107 if ( origin[0] <= 0 || origin[0] >= pmap->
sizeX() ) origin[0] = pmap->
sizeX()/2;
108 if ( origin[1] <= 0 || origin[1] >= pmap->
sizeY() ) origin[1] = pmap->
sizeY()/2;
109 if ( origin[2] <= 0 || origin[2] >= pmap->
sizeZ() ) origin[2] = pmap->
sizeZ()/2;
115 name_base =
Bstring(i+1,
"map%02d");
118 for ( mg=field->
mg; mg; mg=mg->
next ) {
121 return error_show(
"mg_classify", __FILE__, __LINE__);
125 filename = filename.
pre_rev(
'.') +
"_" + name_base +
"." + filename.
post_rev(
'.');
133 for ( j=0, part=mg->
part; part; part=part->
next, j++ ) {
136 return error_show(
"Error in mg_classify", __FILE__, __LINE__);
142 cout <<
"View and origin: " << part->
view <<
tab << part->
ori << endl;
144 if ( part->
mag ) mat *= part->
mag;
145 translate[0] = part->
ori[0] - pmap->
sizeX()/2;
146 translate[1] = part->
ori[1] - pmap->
sizeY()/2;
153 mapproj->
shift(translate);
170 if ( fom_type == 0 ) {
173 }
else if ( fom_type == 2 ) {
175 resolution_hi, resolution_lo, 1);
176 fom[m*nmap+i] = cos(PD);
180 if ( fom_type == 1 ) fom[m*nmap+i] = 1 - R;
186 if ( fom_type == 1 ) cout << R << endl;
187 else if ( fom_type == 2 ) cout << PD*180.0/
M_PI << endl;
188 else cout << CC << endl;
193 if ( img_out%2 == 1 ) {
195 cout <<
"Writing " << proj->
file_name() << endl;
201 cout <<
"Writing " << pdiff->
file_name() << endl;
217 cout << endl <<
"File\tPart\tMap\tFOM=";
218 if ( fom_type == 1 ) cout <<
"1-R" << endl;
219 else if ( fom_type == 2 ) cout <<
"cos(dPhi)" << endl;
220 else cout <<
"CC" << endl;
224 for ( mg=field->
mg; mg; mg=mg->
next ) {
225 for ( part=mg->
part; part; part=part->
next )
if ( part->
sel ) {
228 for ( i=0; i<nmap; i++ ) {
230 cout << mg->
fpart <<
tab << part->
id <<
tab << i+1 <<
tab << fom[m*nmap+i] << endl;
231 if ( maxfom < fom[m*nmap+i] ) {
232 maxfom = fom[m*nmap+i];
233 if ( maxfom >= fom_cut ) part->
sel = i+1;
237 fom_avg[part->
sel] += maxfom;
238 fom_std[part->
sel] += maxfom*maxfom;
239 part->
fom[0] = maxfom;
240 if ( part->
sel ) nsel++;
247 cout <<
"Map\tNumber\t%\tAvg\tStd" << endl;
248 for ( i=0; i<=nmap; i++ ) {
250 fom_avg[i] /= num[i];
251 fom_std[i] = fom_std[i]/num[i] - fom_avg[i]*fom_avg[i];
252 if ( fom_std[i] > 0 )
253 fom_std[i] = sqrt(fom_std[i]);
258 cout << i <<
tab << num[i] <<
tab << num[i]*100.0/npart <<
tab << fom_avg[i] <<
tab << fom_std[i] << endl;
long project_count_mg_particles(Bproject *project)
Counts all the particles in the project structure.
Header file for classification of raw single particle images with respect to multiple models.
int shift(Vector3< double > vec, int fill_type=0, double fill=0)
Shifts an image.
int img_ctf_apply_to_proj(Bimage *proj, CTFparam em_ctf, double defocus, double res_lo, double res_hi, fft_plan planf_2D, fft_plan planb_2D)
Applies a CTF to a projection image.
Bimage * central_section(Matrix3 mat, double resolution, FSI_Kernel *kernel)
Calculates a central section of a 3D fourier transform.
3x3 Matrix manipulation functions
Header file for micrograph processing.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
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.
void view(double x, double y, double z, double a)
int correct_background(long nn, int flag)
Corrects the background for one sub-image.
long count_list(char *list)
Counts the number of items in a linked list.
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)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
string insert(string &filename, string ins)
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
double correlate(Bimage *p)
Calculates correlation coefficient between two images.
Functions for CTF (contrast transfer function) processing.
General image parameter class.
unsigned char * data_alloc()
long mg_classify(Bproject *project, double resolution_hi, double resolution_lo, int fom_type, double fom_cut, FSI_Kernel *kernel, int ctf_apply, int img_out)
Classifies particle images with respect to a series of reference maps.
Vector3< double > pixel_size
int replace(Bimage *img)
Replaces the data with that from the given image.
Header file for image class.
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.
void origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
double linear_fit(Bimage *p, Bimage *pmask, double max_exclude)
Linear least squares fit of two images.
Header file for micrograph processing.
Header file for generalized linked list functions.
void invert()
Inverts the data in the image.
void sampling(long nn, Vector3< double > u)
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.
double average_phase_difference(Bimage *p, double res_hi, double res_lo, int weighting=1)
Calculates the average of the absolute phase difference between two images within given resolution sh...
long statistics()
Calculates the statistics for an image.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.