 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
35 double hires,
double lores,
double search_radius,
38 long i, nviews, ibest(0);
43 for ( nviews=0, v=views; v; v=v->
next ) nviews++;
46 double* cc =
new double[nviews];
49 for ( i=0, v=views; v; v=v->
next, i++ ) view_arr[i] = *v;
51 if ( search_radius < 0 ) search_radius = ptemp->
sizeX()/4;
63 ori = ptemp->
size()/2;
68 cout <<
"Finding a template in a map:" << endl;
69 cout <<
"Template: " << ptemp->
file_name() << endl;
71 cout <<
"Template origin: " << ptemp->
image->
origin() << endl;
73 cout <<
"Number of views: " << nviews << endl;
74 cout <<
"Resolution range: ";
75 if ( lores <= 0 ) cout <<
"inf";
77 cout <<
" - " << hires <<
" A" << endl;
78 cout <<
"Shift search radius: " << search_radius <<
" pixels" << endl;
80 cout <<
"Frequency space mask: " << pmask->
file_name() << endl;
87 dispatch_apply(nviews, dispatch_get_global_queue(0, 0), ^(
size_t k){
92 #pragma omp parallel for
93 for ( i=0; i<nviews; i++ ) {
100 cout <<
"View\ttx\tty\ttz\tvx\tvy\tvz\tva\tCC" << endl;
101 for ( i=0; i<nviews; i++ ) {
102 if ( best < cc[i] ) {
107 cout << i <<
tab << setprecision(2) << translate[i] <<
tab
108 << setprecision(4) << view_arr[i] <<
tab << cc[i] << endl;
111 bestview = view_arr[ibest];
121 cout <<
"Best view:\t" << ibest <<
tab << setprecision(2) << translate[ibest] <<
tab
122 << setprecision(4) << bestview <<
tab << best << endl;
128 currshift = translate[ibest];
152 double hires,
double lores,
Bimage* pmask,
153 double threshold,
Bimage* pfit)
161 if ( z > 1 ) prot = ptemp->
rotate(
size(), mat);
178 for ( i=0; i<datasize; i++ ) {
179 if ( (*pfit->
next)[i] < (*pcc)[i] ) {
183 if ( fommax < (*pcc)[i] ) fommax = (*pcc)[i];
209 double alpha_step,
double hires,
double lores,
210 Bimage* pmask,
double threshold)
215 double alpha_max(
TWOPI - alpha_step/2);
217 double fommin(1), fommax(0), fomavg(0), fomstd(0);
222 alpha_min = alpha - alpha_step;
223 alpha_max = alpha + alpha_step;
224 }
else if ( alpha_step >= 1.999*
M_PI ) mode = 2;
235 if ( ori.
sum() == 0 ) {
240 for ( nviews=0, v=
view; v; v=v->
next )
241 for ( a=alpha_min; a<=alpha_max; a+=alpha_step ) nviews++;
246 for ( a=alpha_min; a<=alpha_max; a+=alpha_step, i++ ) {
248 if ( mode < 2 ) view_arr[i][3] = a;
252 cout <<
"Finding a template in a map:" << endl;
253 cout <<
"Number of views: " << nviews << endl;
254 cout <<
"Alpha step size: " << alpha_step*180.0/
M_PI << endl;
255 cout <<
"Origin: " << ori << endl;
263 cout <<
"View\tCCmax" << endl;
265 for ( i=0; i<nviews; i++ ) {
266 fommax =
search_volume_view(ptemp, view_arr[i], hires, lores, pmask, threshold, pfit);
268 cout << view_arr[i] <<
tab << fommax << endl;
271 for ( i=0, fommax=-1, fommin=1, fomavg=fomstd=0; i<datasize; i++ ) {
272 a = (*pfit->
next)[i];
273 if ( fommin > a ) fommin = a;
274 if ( fommax < a ) fommax = a;
283 fomstd = fomstd/datasize - fomavg*fomavg;
284 if ( fomstd > 0 ) fomstd = sqrt(fomstd);
286 cout <<
"FOM minimum and maximum: " << fommin <<
" " << fommax << endl;
287 cout <<
"FOM average: " << fomavg << endl;
288 cout <<
"FOM standard deviation: " << fomstd << endl << endl;
Bimage * cross_correlate(Bimage *p, double hires, double lores, fft_plan planf, fft_plan planb)
Calculates a cross-correlation map by Fast Fourier transformation.
void set(long j, double v)
Sets a single value at the given index.
Matrix3 transpose() const
Bimage()
Initializes an image.
Vector3< long > size() const
Header file for option handlers.
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 origin(double x, double y, double z)
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
int rotate()
Rotates an image using parameters defined in the image in place.
Vector3< double > rotate_cross_correlate(Bimage *pref, View view, double hires, double lores, double search_radius, Bimage *pmask, double &cc, fft_plan planf, fft_plan planb)
General image parameter class.
Utilities for timing functions.
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.
double search_volume_view(Bimage *ptemp, View view, double hires, double lores, Bimage *pmask, double threshold, Bimage *pfit)
Searches a 2D/3D density map for a template using a specific view.
vector< Vector3< double > > sampling()
double search_views(Bimage *ptemp, View *view, double hires, double lores, double search_radius, Bimage *pmask, View &currview, Vector3< double > &currshift)
Searches a 2D/3D density map for a template.
void sampling(long nn, Vector3< double > u)
Bimage * search_volume(Bimage *ptemp, View *view, double alpha, double alpha_step, double hires, double lores, Bimage *pmask, double threshold)
Searches a 2D/3D density map for a template.
void view(double vx, double vy, double vz, double va)
bool check_if_same_size(Bimage *p)
Check if two images are the same size.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.