| Bsoft 2.0.5 Bernard's software package

bpartsel.cpp
Go to the documentation of this file.
1
9 #include "mg_processing.h"
10 #include "mg_img_proc.h"
11 #include "rwmg.h"
12 #include "mg_particle_select.h"
13 #include "ps_micrograph.h"
14 #include "symmetry.h"
15 #include "utilities.h"
16 #include "options.h"
17 #include "timer.h"
18
19 // Declaration of global variables
20 extern int verbose; // Level of output to the screen
21
22 // Usage assistance
23 const char* use[] = {
24 " ",
25 "Usage: bpartsel [options] input.star [input.star]",
26 "-------------------------------------------------",
27 "Selects single particles for reconstruction and further processing.",
28 "Input particle selections are honoured, so that multiple restrictive selections",
29 " can be made. To reset for a new selection, use the -all option.",
30 " ",
31 "Actions:",
32 "-check Check particle records.",
33 "-reconstructions Operate on reconstruction parameters rather than micrographs.",
34 "-renumber Renumber particles starting from 1 for each micrograph or reconstruction.",
35 "-all Reset selection to all particles before other selections.",
36 "-none Unset selection to all particles before other selections.",
37 "-mgselect 3-5,8,12-15 Select only the indicated micrographs (first = 1).",
38 "-divide 3 Divide the project into a number of subsets of fields.",
39 "-consolidate 5 Consolidate selection under the given selection number.",
40 "-setnumber 3 Select given selection number and set others to zero.",
41 "-setfom 0.3 Set the FOM (must be in the range 0-1).",
42 "-setasu D3 Set the views to the asymmetric unit.",
43 "-setgroups Transfer selection numbers to groups.",
44 "-fixdefocus 0.15 Reset particle defocus differing from micrograph defocus.",
45 "-group 3022 Select particles belonging to this group.",
46 "-sets 20,1 Generate sets of this size of selected particles, ",
47 " with a flag not to select across micrograph or reconstruction boundaries.",
48 "-series 25,1 Select: Particles that are all selected in a series and generating sets",
49 " with a flag not to select across micrograph or reconstruction boundaries.",
50 "-frames 3,11 Select: Particles from a series of frames of a field-of-view.",
51 "-alternate 3 Select: Assign successive particles to different numbers.",
52 "-reselect psi,0.1,0.9 Reselect based on a range of values associated with this tag.",
53 "-origin 150,150,0,8 Select: Within a distance from the nominal origin: x,y,z,distance.",
54 "-View 0.2,-0.5,0.3,15 Select: Within an angular distance from a view: x,y,z,angle.",
55 "-sideview 17.8 Select: Side views within an angular distance from the equator.",
56 "-Euler 2,50,-30,2,0,40 Select: Euler angle ranges: psi, theta, phi.",
57 "-rank 4,1 Select a number of groups from FOM ranking and flag to adjust for defocus.",
58 "-fom 0.25,1 Select: FOM cutoff and flag to adjust for defocus.",
59 "-cv 0.55,1 Select: Cross validation cutoff and flag to adjust for defocus.",
60 "-exclusion 210 Select: Deselect overlapping particles (default 0).",
61 "-top 12.0,1 Select: number or % particles and flag to adjust for defocus, ranked by FOM[index].",
62 "-deviation -2.0 Select: FOM >= average + factor*standard_deviation, using FOM[index].",
63 "-angle 2.4 Select: difference angle between view vectors in focal or tilt series.",
64 "-closesttofocus Select: Particles from micrographs closest to focus.",
65 "-furthestfromfocus Select: Particles from micrographs furthest from focus.",
66 "-random 23.6% Select: random selection to get the given number, ",
67 " number in groups (g), fraction (<1) or percentage (%).",
68 "-bootstrap 527 Select: random selection with replacement up to the given number.",
69 "-views 4.5,7.2,3 Select: random selection within views defined on a grid with the ",
70 " given theta and phi step sizes (degrees) and up to the given number.",
71 "-bestviews 4.5,7.2,3 Select: best particles within views defined on a grid with the ",
72 " given theta and phi step sizes (degrees), up to the given number.",
73 "-maxsmooth 0.7,3,5,4.4 Select: above fraction specified by smoothed maxima surface.",
74 " given theta and phi step sizes and smoothing sigma (degrees).",
75 "-Fomfirst Set orientations to first in field-of-view series.",
76 "-Fombest Set orientations to best FOM[index] in field-of-view series.",
77 "-filament 60 Selects filament particles with clear direction based on percentage.",
78 "-deselect 4,6,22 Deselect particles with the listed selection numbers.",
79 "-getselection Prints all the selection numbers.",
80 "-show particle.fom Show particle parameters indicated by the tag or selection number.",
81 "-Fomhistogram Show FOM histogram.",
82 "-delete Delete all non-selected particles.",
83 "-remove Do not write non-selected micrographs into the parameter file.",
84 " ",
85 "Parameters:",
86 "-verbose 7 Verbosity of output.",
87 "-symmetry C5 Point group symmetry (required with the -angle and -views options).",
88 "-index 1 FOM index to select on (default 0, options -setfom, -top, -deviation, -bestviews, -Fombest).",
89 " ",
90 "Output:",
91 "-output file.star Output parameter file.",
92 "-split 3 Split micrograph or reconstruction data blocks into individual files:",
93 " Argument: 1-6: number of digits inserted before extension",
94 " Argument: \"id\": micrograph ID's are used as file names.",
95 " Argument: \"set\": particle sets based on selection are used as output.",
96 "-Particle views.ps Postscript output with particle view and origin distributions.",
97 "-Micrograph out.ps Postscript output with particle micrograph distributions.",
98 "-FOM histogram.ps Postscript output with particle FOM distributions.",
99 "-classes Write stacks of particle images based on classes.",
100 " ",
101 NULL
102 };
103
104 Bstring read_list(Bstring filename)
105 {
106 ifstream f(filename.c_str());
107 if ( f.fail() ) {
108 cerr << "File " << filename << " not read!" << endl;
109 bexit(-1);
110 }
111
112 string s;
113 Bstring list;
114
115 f >> s;
116 list = s;
117
118 while ( !f.eof() ) {
119 f >> s;
120 list += "," + s;
121 }
122
123 f.close();
124
125 cout << list << endl;
126
127 return list;
128 }
129
130
131 int main(int argc, char** argv)
132 {
133 // Initializing variables
134 int check_flag(0); // Flag to check particle records
135 int use_rec(0); // Flag to process reconstructions
136 int split(0); // Output one big STAR file
137 int symmetry_asu(0); // Set views to the asymmetric unit
138 Bstring symmetry_string("C1"); // Point group string
139 int renumber(0); // Flag to renumber particles
140 double max_def_dev(0); // Maximum defocus deviation allowed
141 int reset(0); // Flag to reset selection
142 int unset(0); // Flag to unset selection
143 Bstring mgselect; // Micrograph selection
144 int divide(0); // Number of output project subsets
145 int consolidate(0); // Flag to combine selections
146 int set_number(0); // Selection number to keep
147 int set_groups(0); // Flag to transfer selection numbers to groups
148 int group(0); // Group to select
149 int set_size(0); // Size of sets
150 int set_flag(0); // Flag to keep set within micrograph
151 int select_series(0); // Size of sets and to select particles where all are selected in a series
152 int alternate(0); // Assign successive particles to different numbers
153 int frame_start(0), frame_end(1000); // Frame selection from a field-of-view series
154 double setfom(-1); // Set the FOM
155 Bstring tag_reselect; // STAR tag for reselection
156 double reselect_min(-1e37); // Reselection minimum
157 double reselect_max(1e37); // Reselection maximum
158 Vector3<double> origin; // Nominal origin
159 double dev_origin(0); // Maximum distance to accept
160 View view; // View to select around
161 double dev_angle(0); // Angle from view
162 double side_angle(0); // Angle from side view
163 double euler[6] = {0,0,0,0,0,0}; // Euler angle ranges
164 int ngroups(0); // Group selection turned off
165 double angle_cutoff(0); // No selection based on angle deviation between focal pairs
166 int fom_index(0); // Index of FOM
167 double fom_cutoff[5] = {0,0,0,0,0}; // No selection based on FOM
168 int fom_defocus_adjust[5] = {0,0,0,0,0}; // Flag to adjust the FOM cutoff by defocus
169 double excl_dist(0); // Minimum distance between particles
170 double fom_percentage(-1); // Percentage particles to accept
171 int fom_best(0); // Best number of particles to select
172 double fom_std_factor(-1e37); // FOM standard deviation multiplier for cutoff
173 long random_number(0); // Number of particles for random selection
174 double random_fraction(0); // Fraction of particles for random selection
175 long random_group(0); // Number of particles for random group selection
176 int bootstrap(0); // Number of particles for bootstrap selection
177 int nviews(0); // Number within views to select randomly
178 double threshfrac(0), maxsmooth(0);// Maxima smoothed surface for selection: fraction and sigma
179 int bestviews(0); // Best number within views to select
180 double theta_step(0), phi_step(0); // Anglular step sizes for views selection
181 int closest_to_focus(0); // Flag to select closest to focus
182 int furthest_from_focus(0); // Flag to select furthest from focus
183 int select_first_in_series(0); // Flag to select first in series
184 int select_best_in_series(0); // Flag to select best in series
185 int ps_flag(1); // Show bits: 1=views, 2=micrograph locations, 4=FOMs
186 double filament(0); // Flag and percentage to check filament directions
187 Bstring deselect; // List of particles to deselect
188 int delete_deselected(0); // Flag to delete deselected particles
189 int getselection(0); // Flag to show all selection numbers
190 int show(-1); // Show selected particles
191 Bstring tag_show; // STAR tag for parameter selection
192 int showFOMhisto(0); // Flag to show the FOM histogram
193 Bstring outfile; // Output parameter file name
194 Bstring outps; // Output postscript file name
195 Bstring FOMps; // Output postscript file name for FOM histogram
196 int write_classes(0); // Flag to write stacks of particle classes
197 int write_flags(0); // Flags to pass to the parameter file writing function
198
199 int i, optind;
200 Boption* option = get_option_list(use, argc, argv, optind);
201 Boption* curropt;
202 for ( curropt = option; curropt; curropt = curropt->next ) {
203 if ( curropt->tag == "check" ) check_flag = 1;
204 if ( curropt->tag == "reconstructions" ) use_rec = 1;
205 if ( curropt->tag == "renumber" ) renumber = 1;
206 if ( curropt->tag == "all" ) reset = 1;
207 if ( curropt->tag == "none" ) unset = 1;
208 if ( curropt->tag == "mgselect" ) mgselect = curropt->value;
209 if ( curropt->tag == "setasu" ) {
210 symmetry_asu = 1;
211 symmetry_string = curropt->symmetry_string();
212 }
213 if ( curropt->tag == "fixdefocus" ) {
214 if ( ( max_def_dev = curropt->value.real() ) < 0.001 )
215 cerr << "-fixdefocus: A defocus difference must be specified!" << endl;
216 else
217 if ( max_def_dev < 10 ) max_def_dev *= 1e4; // assume in um
218 }
219 if ( curropt->tag == "divide" )
220 if ( ( divide = curropt->value.integer() ) < 2 )
221 cerr << "-divide: A number of subsets must be specified!" << endl;
222 if ( curropt->tag == "consolidate" )
223 if ( ( consolidate = curropt->value.integer() ) < 1 )
224 cerr << "-consolidate: A number must be specified!" << endl;
225 if ( curropt->tag == "setnumber" )
226 if ( ( set_number = curropt->value.integer() ) < 1 )
227 cerr << "-setnumber: A selection number must be specified!" << endl;
228 if ( curropt->tag == "sets" )
229 if ( curropt->values(set_size, set_flag) < 1 )
230 cerr << "-sets: A set size must be specified!" << endl;
231 if ( curropt->tag == "setgroups" ) set_groups = 1;
232 if ( curropt->tag == "group" )
233 if ( ( group = curropt->value.integer() ) < 1 )
234 cerr << "-group: A group must be specified!" << endl;
235 if ( curropt->tag == "series" )
236 if ( curropt->values(select_series, set_flag) < 1 )
237 cerr << "-series: A set size must be specified!" << endl;
238 if ( curropt->tag == "frames" )
239 if ( curropt->values(frame_start, frame_end) < 1 )
240 cerr << "-frames: A starting frame must be specified!" << endl;
241 if ( curropt->tag == "alternate" )
242 if ( ( alternate = curropt->value.integer() ) < 2 )
243 cerr << "-alternate: A number must be specified!" << endl;
244 if ( curropt->tag == "setfom" ) {
245 if ( ( setfom = curropt->value.real() ) <= 0 )
246 cerr << "-setfom: A FOM value must be specified!" << endl;
247 else {
248 if ( setfom < 0 || setfom > 1 ) {
249 cerr << "-setfom: The FOM value must be in the range 0-1! The FOM will not be changed." << endl;
250 setfom = -1;
251 }
252 }
253 }
254 if ( curropt->tag == "reselect" ) {
255 tag_reselect = curropt->value;
256 Bstring* slist = tag_reselect.split(",");
257 tag_reselect = *slist;
258 reselect_min = slist->next->real();
259 reselect_max = slist->next->next->real();
260 string_kill(slist);
261 }
262 if ( curropt->tag == "origin" )
263 if ( curropt->values(origin[0], origin[1], origin[2], dev_origin) < 4 )
264 cerr << "-origin: A 3-value origin and a distance must be specified!" << endl;
265 if ( curropt->tag == "View" ) {
266 view = curropt->view();
267 if ( view.angle() ) dev_angle = view.angle();
268 }
269 if ( curropt->tag == "sideview" ) {
270 if ( ( side_angle = curropt->value.real() ) < 0.01 )
271 cerr << "-sideview: An angle must be specified!" << endl;
272 else
273 side_angle *= M_PI/180.0;
274 }
275 if ( curropt->tag == "Euler" ) {
276 vector<double> d = curropt->value.split_into_doubles(",");
277 for ( size_t i=0; i<d.size(); i++ ) euler[i] = d[i] * M_PI/180;
278 if ( d.size() < 6 )
279 cerr << "-Euler: All 6 values for Euler angle ranges must be specified!" << endl;
280 }
281 if ( curropt->tag == "rank" )
282 if ( curropt->values(ngroups, fom_defocus_adjust[0]) < 1 )
283 cerr << "-rank: The number of groups must be specified!" << endl;
284 if ( curropt->tag == "fom" ) {
285 if ( curropt->values(fom_cutoff[0], fom_defocus_adjust[0]) < 1 )
286 cerr << "-fom: A FOM cutoff must be specified!" << endl;
287 else
288 if ( fom_defocus_adjust[0] > 0 ) fom_defocus_adjust[0] = 1;
289 }
290 if ( curropt->tag == "cv" ) {
291 if ( curropt->values(fom_cutoff[1], fom_defocus_adjust[1]) < 1 )
292 cerr << "-cv: A cross validation cutoff must be specified!" << endl;
293 else
294 if ( fom_defocus_adjust[1] > 0 ) fom_defocus_adjust[1] = 1;
295 }
296 if ( curropt->tag == "exclusion" )
297 if ( ( excl_dist = curropt->value.real() ) <= 0 )
298 cerr << "-exclusion: An separation distance must be specified." << endl;
299 if ( curropt->tag == "top" ) {
300 if ( curropt->values(fom_percentage, fom_defocus_adjust[fom_index]) < 1 )
301 cerr << "-top: A percentage must be specified!" << endl;
302 if ( !curropt->value.contains("%") && !curropt->value.contains(".") ) {
303 fom_best = (int) fom_percentage;
304 fom_percentage = -1;
305 }
306 }
307 if ( curropt->tag == "deviation" )
308 if ( ( fom_std_factor = curropt->value.real() ) < 0.001 )
309 cerr << "-deviation: A standard deviation multiplying factor must be specified!" << endl;
310 if ( curropt->tag == "angle" ) {
311 if ( ( angle_cutoff = curropt->value.real() ) < 1 )
312 cerr << "-angle: An angle cutoff must be specified!" << endl;
313 else {
314 if ( angle_cutoff < 1 ) angle_cutoff = 1;
315 if ( angle_cutoff > 180 ) angle_cutoff = 180;
316 angle_cutoff *= M_PI/180.0;
317 }
318 }
319 if ( curropt->tag == "closesttofocus" )
320 closest_to_focus = 1;
321 if ( curropt->tag == "furthestfromfocus" )
322 furthest_from_focus = 1;
323 if ( curropt->tag == "Fombest" )
324 select_best_in_series = 1;
325 if ( curropt->tag == "Fomfirst" )
326 select_first_in_series = 1;
327 if ( curropt->tag == "filament" )
328 if ( ( filament = curropt->value.real() ) < 0.01 )
329 cerr << "-filament: A percentage must be specified!" << endl;
330 if ( curropt->tag == "deselect" )
331 deselect = curropt->value;
332 if ( curropt->tag == "getselection" )
333 getselection = 1;
334 if ( curropt->tag == "show" ) {
335 if ( ( show = curropt->value.integer() ) < 1 ) {
336 tag_show = curropt->value;
337 if ( tag_show.length() < 1 )
338 cerr << "-show: A selection number or tag must be specified!" << endl;
339 }
340 }
341 if ( curropt->tag == "Fomhistogram" )
342 showFOMhisto = 1;
343 if ( curropt->tag == "random" ) {
344 if ( curropt->value.contains("g") ) {
345 if ( ( random_group = curropt->value.integer() ) < 1 )
346 cerr << "-random: A group must be specified!" << endl;
347 } else if ( ( random_fraction = curropt->value.real() ) < 0.001 ) {
348 cerr << "-random: A number, fraction or percentage must be specified!" << endl;
349 } else {
350 if ( curropt->value.contains("%") ) {
351 random_fraction /= 100;
352 } else if ( random_fraction >= 1.0 ) {
353 random_number = (long) random_fraction;
354 random_fraction = 0;
355 }
356 }
357 }
358 if ( curropt->tag == "bootstrap" )
359 if ( ( bootstrap = curropt->value.integer() ) < 1 )
360 cerr << "-bootstrap: A number of particles must be specified!" << endl;
361 if ( curropt->tag == "views" ) {
362 if ( curropt->values(theta_step, phi_step, nviews) < 3 )
363 cerr << "-views: Two angles and a number of particles must be specified!" << endl;
364 else {
365 theta_step *= M_PI/180.0;
366 phi_step *= M_PI/180.0;
367 }
368 }
369 if ( curropt->tag == "bestviews" ) {
370 if ( curropt->values(theta_step, phi_step, bestviews) < 3 )
371 cerr << "-bestviews: Two angles and a number of particles must be specified!" << endl;
372 else {
373 theta_step *= M_PI/180.0;
374 phi_step *= M_PI/180.0;
375 }
376 }
377 if ( curropt->tag == "maxsmooth" ) {
378 if ( curropt->values(threshfrac, theta_step, phi_step, maxsmooth) < 4 )
379 cerr << "-maxsmooth: A fraction, two angles and a sigma value must be specified!" << endl;
380 else {
381 theta_step *= M_PI/180.0;
382 phi_step *= M_PI/180.0;
383 maxsmooth *= M_PI/180.0;
384 }
385 }
386 if ( curropt->tag == "symmetry" )
387 symmetry_string = curropt->symmetry_string();
388 if ( curropt->tag == "index" ) {
389 if ( ( fom_index = curropt->value.integer() ) < 0 )
390 cerr << "-index: A FOM index must be specified!" << endl;
391 else if ( fom_index < 0 || fom_index >= NFOM ) fom_index = 0;
392 }
393 if ( curropt->tag == "delete" )
394 delete_deselected = 1;
395 if ( curropt->tag == "remove" ) write_flags |= 2;
396 if ( curropt->tag == "output" )
397 outfile = curropt->filename();
398 if ( curropt->tag == "split" ) {
399 if ( curropt->value.contains("id") || curropt->value.contains("ID") ) split = 9;
400 else if ( curropt->value.contains("set") || curropt->value.contains("SET") ) split = -1;
401 else if ( ( split = curropt->value.integer() ) < 1 )
402 cerr << "-split: An integer must be specified!" << endl;
403 else
404 if ( split > 6 ) split = 6;
405 }
406 if ( curropt->tag == "Particle" ) {
407 outps = curropt->filename();
408 ps_flag |= 1;
409 }
410 if ( curropt->tag == "Micrograph" ) {
411 outps = curropt->filename();
412 ps_flag |= 2;
413 }
414 if ( curropt->tag == "FOM" ) {
415 FOMps = curropt->filename();
416 ps_flag |= 4;
417 }
418 if ( curropt->tag == "classes" ) write_classes = 1;
419 }
420 option_kill(option);
421
422 double ti = timer_start();
423
424 // Read all the parameter files
425 Bstring* file_list = NULL;
426 while ( optind < argc ) string_add(&file_list, argv[optind++]);
427 if ( !file_list ) {
428 cerr << "Error: No parameter or image files specified!" << endl;
429 bexit(-1);
430 }
431
432 Bproject* project = read_project(file_list, check_flag);
433 string_kill(file_list);
434
435 if ( !project ) {
436 cerr << "Error: Input file not read!" << endl;
437 bexit(-1);
438 }
439
440 if ( use_rec ) project->select = 1;
441
442 Bsymmetry* sym = init_point_group_symmetry(symmetry_string);
443
444 if ( renumber ) project_renumber_particles(project);
445
446 if ( reset ) part_reset_selection(project);
447
448 if ( unset ) part_unset_selection(project);
449
450 if ( mgselect.length() ) part_select_micrograph(project, mgselect);
451
452 if ( group > 0 ) part_select_group(project, group);
453
454 if ( consolidate ) part_consolidate_selection(project, consolidate);
455
456 if ( alternate > 0 ) part_set_multi_maps(project, -1, alternate);
457
458 if ( set_number ) part_set_selection(project, set_number);
459
460 if ( tag_reselect.length() )
461 part_reselect(project, tag_reselect, reselect_min, reselect_max);
462
463 if ( symmetry_asu )
464 project_set_particle_asu_views(project, symmetry_string);
465
466 if ( max_def_dev )
467 part_fix_defocus(project, max_def_dev);
468
469 if ( dev_origin )
470 part_origin_select(project, origin, dev_origin);
471
472 if ( dev_angle )
473 part_view_select(project, view, dev_angle);
474
475 if ( side_angle )
476 part_side_view_select(project, side_angle);
477
478 if ( euler[0]+euler[2]+euler[4] != 0 || euler[1]+euler[3]+euler[5] != 0 )
479 part_euler_angle_select(project, euler);
480
481 for ( i=0; i<5; i++ ) {
482 if ( fom_cutoff[i] ) {
483 if ( fom_defocus_adjust[i] )
484 part_fom_defocus_fit_deselect(project, i, fom_cutoff[i]);
485 else
486 part_deselect(project, i, fom_cutoff[i]);
487 }
488 }
489
490 if ( excl_dist )
491 part_deselect_redundant(project, excl_dist, -1, fom_index);
492
493
494 if ( fom_percentage >= 0 )
495 part_select_percentage(project, fom_percentage, fom_index, fom_defocus_adjust[fom_index]);
496
497 if ( fom_best > 0 )
498 part_select_best(project, fom_best, fom_index, fom_defocus_adjust[fom_index]);
499
500 if ( fom_std_factor > -1e36 )
501 part_select_FOM_avg_std(project, fom_std_factor, fom_index);
502
503 if ( angle_cutoff )
504 part_series_comparison(project, sym, angle_cutoff);
505
506 if ( closest_to_focus )
507 part_select_closest_to_focus(project);
508
509 if ( furthest_from_focus )
510 part_select_furthest_from_focus(project);
511
512 if ( select_first_in_series )
513 part_set_first_view_in_series(project);
514
515 if ( select_best_in_series )
516 part_set_best_view_in_series(project, fom_index);
517
518 if ( ngroups > 1 )
519 part_select_FOM_groups(project, ngroups, fom_index, fom_defocus_adjust[fom_index]);
520
521 if ( random_number )
522 part_select_random(project, random_number);
523 else if ( random_fraction )
524 part_select_random_fraction(project, random_fraction);
525 else if ( random_group )
526 part_select_random_group(project, random_group);
527
528 if ( bootstrap )
529 part_select_bootstrap(project, bootstrap);
530
531 if ( nviews )
532 part_select_random_within_view(project, sym, theta_step, phi_step, nviews);
533
534 if ( maxsmooth )
535 part_select_maxsmooth(project, sym, theta_step, phi_step, threshfrac, maxsmooth, fom_index);
536
537 if ( bestviews )
538 part_select_best_within_view(project, sym, theta_step, phi_step, bestviews, fom_index);
539
540 if ( setfom > -1 )
541 part_set_FOM(project, fom_index, setfom);
542
543 if ( select_series ) part_select_series(project, select_series, set_flag);
544
545 if ( set_size ) part_select_sets(project, set_size, set_flag);
546
547 if ( frame_start ) part_select_frames(project, frame_start, frame_end);
548
549 if ( filament > 0 ) part_filament_direction(project, filament);
550
551 if ( set_groups ) part_select_to_group(project);
552
553 if ( deselect.length() ) {
554 if ( deselect.contains(".") ) deselect = read_list(deselect);
555 part_deselect_from_list(project, deselect);
556 project_trim_class_averages(project, deselect);
557 deselect = 0;
558 }
559
560 if ( delete_deselected ) part_delete_deselected(project);
561
562 if ( verbose ) project_show_selected(project);
563 if ( verbose > VERB_RESULT ) project_show_class_averages(project);
564
565 if ( getselection ) project_show_selection_numbers(project);
566
567 if ( show > -1 ) project_show_selected_parameters(project, show);
568 if ( tag_show.length() > 0 ) project_show_parameter(project, tag_show);
569
570 Bstring title;
571 if ( showFOMhisto ) project_show_fom_histogram(project);
572
573 if ( FOMps.length() )
574 ps_part_fom_histogram(FOMps, project);
575
576 if ( outps.length() ) {
577 if ( ps_flag & 1 ) {
578 title = "Particle view distributions";
579 ps_particle_views_origins(outps, title, symmetry_string, project, -1);
580 } else {
581 title = "Particle micrograph distributions";
582 ps_mg_particle_positions(outps, title, project);
583 }
584 }
585
586 if ( write_classes )
587 project_write_particle_classes(project);
588
589 // Write an output parameter format file if a name is given
590 if ( project && ( outfile.length() || split == 9 ) ) {
591 project_update_comment(project, argc, argv);
592 if ( divide > 1 ) {
593 Bstring filename;
594 Bproject* project2;
595 project_divide(project, divide);
596 for ( i=1, project2 = project; project2; project2 = project2->next, ++i ) {
597 filename = outfile.pre_rev('.') + Bstring(i, "_%02d.") + outfile.post_rev('.');
598 write_project(filename, project2, write_flags);
599 }
600 } else if ( split < 0 ) {
601 project_split_write(outfile, project);
602 } else {
603 project->split = split;
604 write_project(outfile, project, write_flags);
605 }
606 }
607
608 kill_symmetry(sym);
609
610 project_kill(project);
611
612 if ( verbose & VERB_TIME )
613 timer_report(ti);
614
615 bexit(0);
616 }
617
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
part_select_best
long part_select_best(Bproject *project, long number, int fom_index, int defocus_fit)
Selects the best particles based on the FOM.
Definition: mg_particle_select.cpp:1026
part_set_selection
long part_set_selection(Bproject *project, int number)
Selects one selection number and sets all others to zero.
Definition: mg_particle_select.cpp:318
part_select_micrograph
long part_select_micrograph(Bproject *project, Bstring &mgselect)
Sets selection to the micrographs indicated.
Definition: mg_particle_select.cpp:245
rwmg.h
Header file for reading and writing micrograph parameters.
part_select_FOM_avg_std
long part_select_FOM_avg_std(Bproject *project, double factor, int fom_index)
Selects particles based on FOM average and standard deviation.
Definition: mg_particle_select.cpp:1082
Bstring::real
double real()
Definition: Bstring.cpp:545
ps_micrograph.h
Header file for postscript tools dealing with micrograph particle sets.
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:705
project_show_parameter
long project_show_parameter(Bproject *project, Bstring &tag)
Shows the particle parameter indicated by the tag in a project.
Definition: mg_processing.cpp:2783
Boption::symmetry_string
Bstring symmetry_string()
Definition: options.h:245
mg_particle_select.h
Select particles.
project_set_particle_asu_views
int project_set_particle_asu_views(Bproject *project, Bstring &symmetry_asu)
Sets particle views within the asymmetric unit.
Definition: mg_processing.cpp:3792
part_select_sets
long part_select_sets(Bproject *project, int size, int flag)
Selects sets of particles, each set with the same size.
Definition: mg_particle_select.cpp:1815
symmetry.h
Header file for general symmetry functions.
utilities.h
Header file for general utilities.
ps_part_fom_histogram
int ps_part_fom_histogram(Bstring &filename, Bproject *project)
Postscript plot of the particle FOM histogram.
Definition: ps_micrograph.cpp:382
Boption::value
Bstring value
Definition: options.h:30
project_trim_class_averages
int project_trim_class_averages(Bproject *project, Bstring &list)
Deletes selected class averages from the project..
Definition: mg_img_proc.cpp:919
Bproject::split
int split
Definition: mg_processing.h:337
Boption::tag
Bstring tag
Definition: options.h:29
mg_img_proc.h
Header file for image processing from micrograph structures.
read_list
Bstring read_list(Bstring filename)
Definition: bpartsel.cpp:104
project_write_particle_classes
int project_write_particle_classes(Bproject *project)
Writes particles to different stacks based on class.
Definition: mg_img_proc.cpp:849
read_project
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Definition: rwmg.cpp:140
Bstring::length
long length() const
Definition: Bstring.cpp:263
project
Bproject * project
Definition: bshow.cpp:31
project_show_fom_histogram
long project_show_fom_histogram(Bproject *project)
Shows a histogram of the FOM values.
Definition: mg_processing.cpp:2831
kill_symmetry
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Definition: symmetry.cpp:207
part_set_multi_maps
long part_set_multi_maps(Bproject *project, int part_select, int nmaps)
Sets selection for generating multiple maps.
Definition: mg_particle_select.cpp:564
part_select_frames
long part_select_frames(Bproject *project, int frame_start, int frame_end)
Select particles from frames in a series.
Definition: mg_particle_select.cpp:1898
part_select_random_group
long part_select_random_group(Bproject *project, long number)
Selects groups randomly to give at least a number of particles.
Definition: mg_particle_select.cpp:1266
part_view_select
long part_view_select(Bproject *project, View view, double angle)
Selects particles based on a distance from a reference view.
Definition: mg_particle_select.cpp:2104
part_euler_angle_select
long part_euler_angle_select(Bproject *project, double *euler6)
Selects particles based on Euler angle limits.
Definition: mg_particle_select.cpp:2203
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
part_select_furthest_from_focus
long part_select_furthest_from_focus(Bproject *project)
Deselects all particles except those from micrographs furthest from focus.
Definition: mg_particle_select.cpp:2673
project_show_selected
long project_show_selected(Bproject *project)
Shows the selected particles in a project.
Definition: mg_processing.cpp:2446
part_select_group
long part_select_group(Bproject *project, int group)
Selects particles with a given group identifier.
Definition: mg_particle_select.cpp:1766
Boption::filename
Bstring filename()
Definition: options.h:85
part_select_to_group
long part_select_to_group(Bproject *project)
Transfer selection numbers to the group identifiers.
Definition: mg_particle_select.cpp:1722
timer.h
Utilities for timing functions.
part_select_closest_to_focus
long part_select_closest_to_focus(Bproject *project)
Deselects all particles except those from micrographs closest to focus.
Definition: mg_particle_select.cpp:2643
part_select_maxsmooth
long part_select_maxsmooth(Bproject *project, Bsymmetry *sym, double theta_step, double phi_step, double threshfrac, double sigma, int fom_index)
Selects particles based on a smoothed maximum surface.
Definition: mg_particle_select.cpp:1520
Bstring::contains
bool contains(const Bstring &s)
Definition: Bstring.cpp:584
M_PI
#define M_PI
Definition: utilities.h:59
part_reselect
long part_reselect(Bproject *project, Bstring &tag, double reselect_min, double reselect_max)
Reselects particles identified by an input STAR tag and between a minimum and maximum.
Definition: mg_particle_select.cpp:723
use
const char * use[]
Definition: bpartsel.cpp:23
NFOM
#define NFOM
Definition: mg_processing.h:16
part_select_bootstrap
long part_select_bootstrap(Bproject *project, int number)
Selects a given number of particles randomly with replacement.
Definition: mg_particle_select.cpp:1357
Boption::view
View view()
Definition: options.h:259
part_select_random_fraction
long part_select_random_fraction(Bproject *project, double fraction)
Selects particles randomly based on a fraction of the total.
Definition: mg_particle_select.cpp:1217
Bstring::next
Bstring * next
Definition: Bstring.h:31
part_deselect
long part_deselect(Bproject *project, int fom_index, double fommin, double fommax=1e30)
Deselects particles below a given FOM cutoff.
Definition: mg_particle_select.cpp:442
Boption
A class for a command line input option.
Definition: options.h:26
part_series_comparison
double part_series_comparison(Bproject *project, Bsymmetry *sym, double angle_cutoff)
A function to select particles based on comparison of the orientations within a series.
Definition: mg_particle_select.cpp:802
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
part_consolidate_selection
long part_consolidate_selection(Bproject *project, int number)
Consolidates selected particles under one selection number.
Definition: mg_particle_select.cpp:284
init_point_group_symmetry
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
Definition: symmetry.cpp:39
part_origin_select
long part_origin_select(Bproject *project, Vector3< double > origin, double distance)
Selects particles based on the distance from the nominal origin.
Definition: mg_particle_select.cpp:2265
part_delete_deselected
long part_delete_deselected(Bproject *project)
Deletes deselected particles and renumber the remaining.
Definition: mg_particle_select.cpp:2703
part_side_view_select
long part_side_view_select(Bproject *project, double angle)
Selects particles based on a distance from a side view.
Definition: mg_particle_select.cpp:2155
part_deselect_redundant
long part_deselect_redundant(Bparticle *partlist, double excl_dist, int part_select, int fom_index)
Deselects particles overlapping with better ones.
Definition: mg_particle_select.cpp:494
verbose
int verbose
part_set_FOM
long part_set_FOM(Bproject *project, int fom_index, double fom)
Sets the FOM for all particles.
Definition: mg_particle_select.cpp:357
Bproject::next
Bproject * next
Definition: mg_processing.h:334
part_reset_selection
long part_reset_selection(Bproject *project)
Resets selection to all particles.
Definition: mg_particle_select.cpp:131
Bstring::split_into_doubles
vector< double > split_into_doubles(const Bstring &delim)
Definition: Bstring.cpp:665
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:428
Bsymmetry
Definition: symmetry.h:38
VERB_RESULT
#define VERB_RESULT
Definition: utilities.h:105
Boption::next
Boption * next
Definition: options.h:28
part_select_best_within_view
long part_select_best_within_view(Bproject *project, Bsymmetry *sym, double theta_step, double phi_step, int number, int fom_index)
Selects the best number of particles within each view.
Definition: mg_particle_select.cpp:1633
part_fom_defocus_fit_deselect
double part_fom_defocus_fit_deselect(Bproject *project, int fom_index, double cutoff)
Deselects particles below a given FOM cutoff, adjusted for the defocus.
Definition: mg_particle_select.cpp:2618
Bstring
Definition: Bstring.h:29
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
Bproject::select
int select
Definition: mg_processing.h:339
part_filament_direction
long part_filament_direction(Bproject *project, double minpct)
Checks the direction of particles associated with filaments.
Definition: mg_particle_select.cpp:2055
project_show_selected_parameters
long project_show_selected_parameters(Bproject *project, int show)
Shows the selected particle parameters in a project.
Definition: mg_processing.cpp:2674
project_divide
long project_divide(Bproject *project, long n)
Divides a project into a number of micrograph subsets.
Definition: mg_processing.cpp:1962
part_select_random
long part_select_random(Bproject *project, long number)
Selects a specific number of particles randomly.
Definition: mg_particle_select.cpp:1137
part_select_FOM_groups
long part_select_FOM_groups(Bproject *project, int ngroups, int fom_index, int defocus_fit)
Selects groups of particles based on the FOM.
Definition: mg_particle_select.cpp:919
Vector3< double >
part_select_series
long part_select_series(Bproject *project, int size, int flag)
Select series where all are already selected.
Definition: mg_particle_select.cpp:2395
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
part_select_random_within_view
long part_select_random_within_view(Bproject *project, Bsymmetry *sym, double theta_step, double phi_step, int number)
Selects a given number of particles within each view.
Definition: mg_particle_select.cpp:1416
View::angle
double angle()
Definition: View.h:95
project_show_selection_numbers
long project_show_selection_numbers(Bproject *project)
Shows the selection numbers for the particles in a project.
Definition: mg_processing.cpp:2391
part_fix_defocus
long part_fix_defocus(Bproject *project, double max_dev)
Resets defocus values for particles thata are too far off.
Definition: mg_particle_select.cpp:2751
View
Definition: View.h:26
show
int show(0)
ps_mg_particle_positions
int ps_mg_particle_positions(Bstring &filename, Bstring &title, Bproject *project)
Postscript plot of the positions of particles on micrographs.
Definition: ps_micrograph.cpp:30
part_select_percentage
long part_select_percentage(Bproject *project, double percentage, int fom_index, int defocus_fit)
Selects a percentage of particles based on the FOM.
Definition: mg_particle_select.cpp:969
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
Bstring::integer
long integer()
Definition: Bstring.cpp:539
mg_processing.h
Header file for micrograph processing.
part_set_best_view_in_series
long part_set_best_view_in_series(Bproject *project, int fom_index)
Sets all orientation parameters for a particle to the best in the set.
Definition: mg_particle_select.cpp:2351
main
int main(int argc, char **argv)
Definition: bpartsel.cpp:131
options.h
Header file for option handlers.
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:413
split
vector< string > split(const string &s)
Splits a string on whitespace.
Definition: string_util.cpp:92
project_renumber_particles
long project_renumber_particles(Bproject *project)
Renumbers particles.
Definition: mg_processing.cpp:3656
project_update_comment
int project_update_comment(Bproject *project, int n, char **strings)
Puts a set of strings and time in the main comment of a project.
Definition: rwmg.cpp:468
project_show_class_averages
long project_show_class_averages(Bproject *project)
Shows the class averages in a project.
Definition: mg_processing.cpp:2645
ps_particle_views_origins
int ps_particle_views_origins(Bstring &filename, Bstring &title, Bstring &symmetry_string, Bproject *project, int selection)
Generates asymmetric unit particle view and origin postscript plots.
Definition: ps_micrograph.cpp:121
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:273
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
Bproject
Definition: mg_processing.h:333
part_set_first_view_in_series
long part_set_first_view_in_series(Bproject *project)
Sets all orientation parameters for a particle to the first in the set.
Definition: mg_particle_select.cpp:2317
Bstring::split
Bstring * split()
Definition: Bstring.cpp:597
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:760
part_deselect_from_list
long part_deselect_from_list(Bproject *project, Bstring list)
Deselects particles with selection numbers from a list.
Definition: mg_particle_select.cpp:387
part_unset_selection
long part_unset_selection(Bproject *project)
Unsets selection to no particles.
Definition: mg_particle_select.cpp:166
project_split_write
int project_split_write(Bstring &filename, Bproject *project)
Splits a project into sets of particle selections and write the files.
Definition: rwmg.cpp:610