 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
21 double angle_inc,
double threshold,
long exclusion,
double mask_rad);
28 "Usage: bmatch [options] img.mrc cc.map",
29 "--------------------------------------",
30 "Searching an image with a set of 2D templates/references",
31 "Orientations are taken from the input projections.",
37 "-verbose 7 Verbosity of output.",
38 "-datatype u Force writing of a new data type.",
39 "-sampling 2,3.5,1 Sampling before rescaling (angstrom/voxel, a single value sets all three).",
40 "-resolution 25,200 Resolution limits (angstrom).",
41 "-angle 2.5 Angular increment (default 3 degrees).",
42 "-origin 0.8,-10,15.7 Set the origin (default from input image).",
43 "-threshold 0.24 Threshold to find correlation peaks.",
44 "-exclusion 150 Minimum distance between correlation peaks.",
45 "-radius 50 Mask radius (slightly bigger than particle).",
48 "-reference file.pif Input reference projections file.",
51 "-output newmod.star New model file.",
56 int main(
int argc,
char **argv)
66 double angle_inc(
M_PI/60);
67 double threshold(0.1);
76 for ( curropt = option; curropt; curropt = curropt->
next ) {
77 if ( curropt->
tag ==
"datatype" )
79 if ( curropt->
tag ==
"origin" ) {
80 if ( curropt->
value[0] ==
'c' ) {
83 origin = curropt->
origin();
87 if ( curropt->
tag ==
"resolution" )
88 if ( curropt->
values(res_hi, res_lo) < 1 )
89 cerr <<
"-resolution: A resolution limit must be specified!" << endl;
90 if ( curropt->
tag ==
"angle" )
91 if ( ( angle_inc = curropt->
value.
real() ) < 0.1 )
92 cerr <<
"-angle: An angle must be specified!" << endl;
93 if ( curropt->
tag ==
"sampling" )
94 sampling = curropt->
scale();
95 if ( curropt->
tag ==
"threshold" )
96 if ( ( threshold = curropt->
value.
real() ) < 0.001 )
97 cerr <<
"-threshold: A resolution limit must be specified!" << endl;
98 if ( curropt->
tag ==
"exclusion" )
100 cerr <<
"-exclusion: A minimum distance between peaks must be specified!" << endl;
101 if ( curropt->
tag ==
"radius" )
102 if ( ( mask_rad = curropt->
value.
real() ) < 0.001 )
103 cerr <<
"-radius: A mask radius in pixels must be specified!" << endl;
104 if ( curropt->
tag ==
"reference" )
106 if ( curropt->
tag ==
"output" )
116 if ( ( p =
read_img(argv[optind++], 1, -1) ) == NULL ) {
117 cerr <<
"Error: File not read!" << endl;
122 if ( set_origin == 2 ) p->
origin(p->
size()/2);
126 if ( ref_filename.
length() ) {
127 if ( ( pref =
read_img(ref_filename, 1, -1) ) == NULL ) {
128 cerr <<
"Error: File not read!" << endl;
134 if ( set_origin == 2 ) pref->
origin(p->
size()/2);
135 else pref->
origin(origin);
141 if ( sampling.
volume() > 0 ) {
143 if ( pref ) pref->
sampling(sampling);
148 model =
img_match(p, pref, res_hi, res_lo, angle_inc, threshold, exclusion, mask_rad);
167 double angle_inc,
double threshold,
long exclusion,
double mask_rad)
175 for (
long n = 0; n < p->
images(); ++n ) {
177 angle_inc, threshold, exclusion, mask_rad,
planf,
planb);
191 if ( pref1->
size() != size ) {
207 if ( angle_inc <
M_PI/180 ) angle_inc =
M_PI/180;
210 double angle, amin(0), amax(
TWOPI), ccmax(0), ccmax1;
233 cout <<
"Global search for image " << img_num <<
":" << endl;
234 cout <<
"Proj\tvx\tvy\tvz\tva\tccmax" << setprecision(4) << endl;
236 for ( nn=0; nn<pref->
images(); ++nn ) {
241 for ( angle = amin; angle <= amax; angle += angle_inc ) {
244 if ( !pcc1 )
bexit(-1);
245 for ( j=0; j<pcc1->
image_size(); ++j )
if ( (*pcc)[j] < (*pcc1)[j] ) {
246 pcc->
set(j, (*pcc1)[j]);
250 if ( ccmax1 < pcc1->maximum() ) ccmax1 = pcc1->
maximum();
256 if ( ccmax < ccmax1 ) ccmax = ccmax1;
262 if ( threshold >= ccmax ) {
263 threshold = 0.95*ccmax;
265 cout <<
"Adjusting threshold to " << threshold << endl;
274 for ( i=j=0; i<ppeak->
image_size(); ++i )
if ( (*ppeak)[i] ) j++;
277 cout <<
"Number of peaks: " << j << endl << endl;
282 cout <<
"Adjusting threshold to " << threshold << endl;
283 cout <<
"Local search for image " << img_num <<
":" << endl;
284 cout <<
"x\ty\tz\tvx\tvy\tvz\tva\tccmax" << setprecision(4) << endl;
288 for ( i=j=0; i<ppeak->
image_size(); ++i )
if ( (*ppeak)[i] ) {
294 start[0] = coor[0] - mask_rad;
295 start[1] = coor[1] - mask_rad;
303 amin = (*pang)[i] - 10*angle_inc;
304 amax = (*pang)[i] + 10*angle_inc;
307 for ( angle = amin; angle <= amax; angle += angle_inc ) {
310 if ( !pcc1 )
bexit(-1);
313 if ( (*pcc)[i] < pcc1->
image->
FOM() ) {
318 if ( ccmax1 < pcc1->image->FOM() ) ccmax1 = pcc1->
image->
FOM();
326 if ( p->
sizeX() > 1 && nucoor[0] >= p->
sizeX()/2 ) nucoor[0] -= p->
sizeX();
327 if ( p->
sizeY() > 1 && nucoor[1] >= p->
sizeY()/2 ) nucoor[1] -= p->
sizeY();
328 if ( p->
sizeZ() > 1 && nucoor[2] >= p->
sizeZ()/2 ) nucoor[2] -= p->
sizeZ();
330 cout << nucoor <<
tab << view <<
tab << ccmax1 << endl;
331 if ( ccmax1 >= threshold ) {
341 cout <<
"Number of peaks: " << j << endl << endl;
A class for a command line input option.
void coordinates(long i, long &nx, long &ny, long &nz)
Vector3< double > scale()
Header file for reading and writing atomic model files.
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.
Bcomponent * component_add(Bcomponent **comp, Bstring &id)
Adds a component to a linked list.
Bimage * copy()
Copies the header information and data of an image into a new image structure.
int find_peak(double radius=1e30, double sigma=0)
Finds the peak in an image to the nearest voxel.
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.
Vector3< long > size() const
Header file for option handlers.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
void view(double x, double y, double z, double a)
Vector3< double > origin()
Bmodel * model_init(Bstring &id)
Initializes a model structure.
long values(T1 &v1, T2 &v2)
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.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Bmodel * img_match_one(Bimage *p, long img_num, Bimage *pref, double res_hi, double res_lo, double angle_inc, double threshold, long exclusion, double mask_rad, fft_plan planf, fft_plan planb)
int rotate()
Rotates an image using parameters defined in the image in place.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
Bmodel * img_match(Bimage *p, Bimage *pref, double res_hi, double res_lo, double angle_inc, double threshold, long exclusion, double mask_rad)
General image parameter class.
Utilities for timing functions.
Vector3< T1 > vector3_set_PBC(Vector3< T1 > coord, Vector3< T2 > box)
Bimage * region_peaks(long kernel_size, double threshold, int flood=0, int wrap=0)
Generates a segmented image from peaks above a threshold value.
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
int write_model(Bstring &filename, Bmodel *model)
Writes model parameters.
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.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void origin(double ox, double oy, double oz)
Header file for 2D and 3D image I/O.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Bmodel * model_add(Bmodel **model, Bstring &id)
Adds a model to a linked list.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
int main(int argc, char **argv)
Bcomptype * model_add_type_by_id(Bmodel *model, Bstring &id)
Add a type to a model if the identifier does not exist already.
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
Bimage * img_reference_prepare(Bimage *pref, long nn, Vector3< long > size)
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
int edge(int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0)
Smooths the image edge with a soft rectangular function.