 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 "Usage: bpartsel [options] input.star [input.star]",
27 "-------------------------------------------------",
28 "Selects single particles for reconstruction and further processing.",
29 "Input particle selections are honoured, so that multiple restrictive selections",
30 " can be made. To reset for a new selection, use the -all option.",
33 "-check Check particle records.",
34 "-reconstructions Operate on reconstruction parameters rather than micrographs.",
35 "-renumber Renumber particles starting from 1 for each micrograph or reconstruction.",
36 "-all Reset selection to all particles before other selections.",
37 "-none Unset selection to all particles before other selections.",
38 "-mgselect 3-5,8,12-15 Select micrographs:",
39 " Argument: 4-11,34: Select by the indicated micrographs (first = 1).",
40 " Argument: part: Select only micrographs with selected particles.",
41 "-divide 3 Divide the project into a number of subsets of fields.",
42 "-consolidate 5 Consolidate selection under the given selection number.",
43 "-setnumber 3 Select given selection number and set others to zero.",
44 "-setfom 0.3 Set the FOM (must be in the range 0-1).",
45 "-setasu D3 Set the views to the asymmetric unit.",
46 "-setgroups Transfer selection numbers to groups.",
47 "-fixdefocus 0.15 Reset particle defocus differing from micrograph defocus.",
48 "-group 3022 Select particles belonging to this group.",
49 "-sets 20,1 Generate sets of this size of selected particles, ",
50 " with a flag not to select across micrograph or reconstruction boundaries.",
51 "-series 25,1 Select: Particles that are all selected in a series and generating sets",
52 " with a flag not to select across micrograph or reconstruction boundaries.",
53 "-frames 3,11 Select: Particles from a series of frames of a field-of-view.",
54 "-alternate 3 Select: Assign successive particles to different numbers.",
55 "-reselect psi,0.1,0.9 Reselect based on a range of values associated with this tag.",
56 "-origin 150,150,0,8 Select: Within a distance from the nominal origin: x,y,z,distance.",
57 "-View 0.2,-0.5,0.3,15 Select: Within an angular distance from a view: x,y,z,angle.",
58 "-sideview 17.8 Select: Side views within an angular distance from the equator.",
59 "-Euler 2,50,-30,2,0,40 Select: Euler angle ranges: psi, theta, phi.",
60 "-rank 4,1 Select a number of groups from FOM ranking and flag to adjust for defocus.",
61 "-fom 0.25,1 Select: FOM cutoff and flag to adjust for defocus.",
62 "-cv 0.55,1 Select: Cross validation cutoff and flag to adjust for defocus.",
63 "-exclusion 210 Select: Deselect overlapping particles (default 0).",
64 "-top 12.0,1 Select: number or % particles and flag to adjust for defocus, ranked by FOM[index].",
65 "-deviation -2.0 Select: FOM >= average + factor*standard_deviation, using FOM[index].",
66 "-angle 2.4 Select: difference angle between view vectors in focal or tilt series.",
67 "-closesttofocus Select: Particles from micrographs closest to focus.",
68 "-furthestfromfocus Select: Particles from micrographs furthest from focus.",
69 "-random 23.6% Select: random selection to get the given number, ",
70 " number in groups (g), fraction (<1) or percentage (%).",
71 "-bootstrap 527 Select: random selection with replacement up to the given number.",
72 "-views 4.5,7.2,3 Select: random selection within views defined on a grid with the ",
73 " given theta and phi step sizes (degrees) and up to the given number.",
74 "-bestviews 4.5,7.2,3 Select: best particles within views defined on a grid with the ",
75 " given theta and phi step sizes (degrees), up to the given number.",
76 "-maxsmooth 0.7,3,5,4.4 Select: above fraction specified by smoothed maxima surface.",
77 " given theta and phi step sizes and smoothing sigma (degrees).",
78 "-Fomfirst Set orientations to first in field-of-view series.",
79 "-Fombest Set orientations to best FOM[index] in field-of-view series.",
80 "-filament 60 Selects filament particles with clear direction based on percentage.",
81 "-deselect 4,6,22 Deselect particles with the listed selection numbers.",
82 "-getselection Prints all the selection numbers.",
83 "-show particle.fom Show particle parameters indicated by the tag or selection number.",
84 "-Fomhistogram 100,0.1.2 Show FOM histogram with parameters: bins, minimum and maximum.",
85 "-focus Show defocus minimum and maximum.",
86 "-reset defocus Reset particle defocus to micrograph defocus.",
87 "-delete Delete all non-selected particles from the parameter file.",
88 "-remove Do not write non-selected micrographs into the parameter file.",
91 "-verbose 7 Verbosity of output.",
92 "-symmetry C5 Point group symmetry (required with the -angle and -views options).",
93 "-index 1 FOM index to select on (default 0, options -setfom, -top, -deviation, -bestviews, -Fombest).",
96 "-output file.star Output parameter file.",
97 "-split 3 Split micrograph or reconstruction data blocks into individual files:",
98 " Argument: 1-6: number of digits inserted before extension",
99 " Argument: \"id\": micrograph ID's are used as file names.",
100 " Argument: \"set\": particle sets based on selection are used as output.",
101 "-Particle views.ps Postscript output with particle view and origin distributions.",
102 "-Micrograph out.ps Postscript output with particle micrograph distributions.",
103 "-FOM histogram.ps Postscript output with particle FOM distributions.",
104 "-classes Write stacks of particle images based on classes.",
111 ifstream f(filename.
c_str());
113 cerr <<
"File " << filename <<
" not read!" << endl;
130 cout << list << endl;
136 int main(
int argc,
char** argv)
145 double max_def_dev(0);
156 int select_series(0);
158 int frame_start(0), frame_end(1000);
161 double reselect_min(-1e37);
162 double reselect_max(1e37);
164 double dev_origin(0);
167 double side_angle(0);
168 double euler[6] = {0,0,0,0,0,0};
170 double angle_cutoff(0);
172 double fom_cutoff[5] = {0,0,0,0,0};
173 int fom_defocus_adjust[5] = {0,0,0,0,0};
175 double fom_percentage(-1);
177 double fom_std_factor(-1e37);
178 long random_number(0);
179 double random_fraction(0);
180 long random_group(0);
183 double threshfrac(0), maxsmooth(0);
185 double theta_step(0), phi_step(0);
186 int closest_to_focus(0);
187 int furthest_from_focus(0);
188 int select_first_in_series(0);
189 int select_best_in_series(0);
194 int delete_deselected(0);
199 double FOMmin(0), FOMmax(0);
204 int write_classes(0);
210 for ( curropt = option; curropt; curropt = curropt->
next ) {
211 if ( curropt->
tag ==
"check" ) check_flag = 1;
212 if ( curropt->
tag ==
"reconstructions" ) use_rec = 1;
213 if ( curropt->
tag ==
"renumber" ) renumber = 1;
214 if ( curropt->
tag ==
"all" ) all = 2;
215 if ( curropt->
tag ==
"none" ) unset = 1;
216 if ( curropt->
tag ==
"mgselect" ) mgselect = curropt->
value;
217 if ( curropt->
tag ==
"setasu" ) {
221 if ( curropt->
tag ==
"fixdefocus" ) {
222 if ( ( max_def_dev = curropt->
value.
real() ) < 0.001 )
223 cerr <<
"-fixdefocus: A defocus difference must be specified!" << endl;
225 if ( max_def_dev < 10 ) max_def_dev *= 1e4;
227 if ( curropt->
tag ==
"divide" )
229 cerr <<
"-divide: A number of subsets must be specified!" << endl;
230 if ( curropt->
tag ==
"consolidate" )
232 cerr <<
"-consolidate: A number must be specified!" << endl;
233 if ( curropt->
tag ==
"setnumber" )
235 cerr <<
"-setnumber: A selection number must be specified!" << endl;
236 if ( curropt->
tag ==
"sets" )
237 if ( curropt->
values(set_size, set_flag) < 1 )
238 cerr <<
"-sets: A set size must be specified!" << endl;
239 if ( curropt->
tag ==
"setgroups" ) set_groups = 1;
240 if ( curropt->
tag ==
"group" )
242 cerr <<
"-group: A group must be specified!" << endl;
243 if ( curropt->
tag ==
"series" )
244 if ( curropt->
values(select_series, set_flag) < 1 )
245 cerr <<
"-series: A set size must be specified!" << endl;
246 if ( curropt->
tag ==
"frames" )
247 if ( curropt->
values(frame_start, frame_end) < 1 )
248 cerr <<
"-frames: A starting frame must be specified!" << endl;
249 if ( curropt->
tag ==
"alternate" )
251 cerr <<
"-alternate: A number must be specified!" << endl;
252 if ( curropt->
tag ==
"setfom" ) {
253 if ( ( setfom = curropt->
value.
real() ) <= 0 )
254 cerr <<
"-setfom: A FOM value must be specified!" << endl;
256 if ( setfom < 0 || setfom > 1 ) {
257 cerr <<
"-setfom: The FOM value must be in the range 0-1! The FOM will not be changed." << endl;
262 if ( curropt->
tag ==
"reselect" ) {
263 tag_reselect = curropt->
value;
265 tag_reselect = *slist;
270 if ( curropt->
tag ==
"origin" )
271 if ( curropt->
values(origin[0], origin[1], origin[2], dev_origin) < 4 )
272 cerr <<
"-origin: A 3-value origin and a distance must be specified!" << endl;
273 if ( curropt->
tag ==
"View" ) {
274 view = curropt->
view();
277 if ( curropt->
tag ==
"sideview" ) {
278 if ( ( side_angle = curropt->
value.
real() ) < 0.01 )
279 cerr <<
"-sideview: An angle must be specified!" << endl;
281 side_angle *=
M_PI/180.0;
283 if ( curropt->
tag ==
"Euler" ) {
285 for (
size_t i=0; i<d.size(); i++ ) euler[i] = d[i] *
M_PI/180;
287 cerr <<
"-Euler: All 6 values for Euler angle ranges must be specified!" << endl;
289 if ( curropt->
tag ==
"rank" )
290 if ( curropt->
values(ngroups, fom_defocus_adjust[0]) < 1 )
291 cerr <<
"-rank: The number of groups must be specified!" << endl;
292 if ( curropt->
tag ==
"fom" ) {
293 if ( curropt->
values(fom_cutoff[0], fom_defocus_adjust[0]) < 1 )
294 cerr <<
"-fom: A FOM cutoff must be specified!" << endl;
296 if ( fom_defocus_adjust[0] > 0 ) fom_defocus_adjust[0] = 1;
298 if ( curropt->
tag ==
"cv" ) {
299 if ( curropt->
values(fom_cutoff[1], fom_defocus_adjust[1]) < 1 )
300 cerr <<
"-cv: A cross validation cutoff must be specified!" << endl;
302 if ( fom_defocus_adjust[1] > 0 ) fom_defocus_adjust[1] = 1;
304 if ( curropt->
tag ==
"exclusion" )
305 if ( ( excl_dist = curropt->
value.
real() ) <= 0 )
306 cerr <<
"-exclusion: An separation distance must be specified." << endl;
307 if ( curropt->
tag ==
"top" ) {
308 if ( curropt->
values(fom_percentage, fom_defocus_adjust[fom_index]) < 1 )
309 cerr <<
"-top: A percentage must be specified!" << endl;
311 fom_best = (int) fom_percentage;
315 if ( curropt->
tag ==
"deviation" )
316 if ( ( fom_std_factor = curropt->
value.
real() ) < 0.001 )
317 cerr <<
"-deviation: A standard deviation multiplying factor must be specified!" << endl;
318 if ( curropt->
tag ==
"angle" ) {
319 if ( ( angle_cutoff = curropt->
value.
real() ) < 1 )
320 cerr <<
"-angle: An angle cutoff must be specified!" << endl;
322 if ( angle_cutoff < 1 ) angle_cutoff = 1;
323 if ( angle_cutoff > 180 ) angle_cutoff = 180;
324 angle_cutoff *=
M_PI/180.0;
327 if ( curropt->
tag ==
"closesttofocus" )
328 closest_to_focus = 1;
329 if ( curropt->
tag ==
"furthestfromfocus" )
330 furthest_from_focus = 1;
331 if ( curropt->
tag ==
"Fombest" )
332 select_best_in_series = 1;
333 if ( curropt->
tag ==
"Fomfirst" )
334 select_first_in_series = 1;
335 if ( curropt->
tag ==
"filament" )
336 if ( ( filament = curropt->
value.
real() ) < 0.01 )
337 cerr <<
"-filament: A percentage must be specified!" << endl;
338 if ( curropt->
tag ==
"deselect" )
339 deselect = curropt->
value;
340 if ( curropt->
tag ==
"getselection" )
342 if ( curropt->
tag ==
"show" ) {
344 tag_show = curropt->
value;
345 if ( tag_show.
length() < 1 )
346 cerr <<
"-show: A selection number or tag must be specified!" << endl;
349 if ( curropt->
tag ==
"Fomhistogram" )
350 if ( curropt->
values(FOMbins, FOMmin, FOMmax) < 1 )
351 cerr <<
"-Fomhistogram: A number of bins must be specified!" << endl;
352 if ( curropt->
tag ==
"focus" )
354 if ( curropt->
tag ==
"random" ) {
357 cerr <<
"-random: A group must be specified!" << endl;
358 }
else if ( ( random_fraction = curropt->
value.
real() ) < 0.001 ) {
359 cerr <<
"-random: A number, fraction or percentage must be specified!" << endl;
362 random_fraction /= 100;
363 }
else if ( random_fraction >= 1.0 ) {
364 random_number = (long) random_fraction;
369 if ( curropt->
tag ==
"bootstrap" )
371 cerr <<
"-bootstrap: A number of particles must be specified!" << endl;
372 if ( curropt->
tag ==
"views" ) {
373 if ( curropt->
values(theta_step, phi_step, nviews) < 3 )
374 cerr <<
"-views: Two angles and a number of particles must be specified!" << endl;
376 theta_step *=
M_PI/180.0;
377 phi_step *=
M_PI/180.0;
380 if ( curropt->
tag ==
"bestviews" ) {
381 if ( curropt->
values(theta_step, phi_step, bestviews) < 3 )
382 cerr <<
"-bestviews: Two angles and a number of particles must be specified!" << endl;
384 theta_step *=
M_PI/180.0;
385 phi_step *=
M_PI/180.0;
388 if ( curropt->
tag ==
"maxsmooth" ) {
389 if ( curropt->
values(threshfrac, theta_step, phi_step, maxsmooth) < 4 )
390 cerr <<
"-maxsmooth: A fraction, two angles and a sigma value must be specified!" << endl;
392 theta_step *=
M_PI/180.0;
393 phi_step *=
M_PI/180.0;
394 maxsmooth *=
M_PI/180.0;
397 if ( curropt->
tag ==
"symmetry" )
399 if ( curropt->
tag ==
"index" ) {
401 cerr <<
"-index: A FOM index must be specified!" << endl;
402 else if ( fom_index < 0 || fom_index >=
NFOM ) fom_index = 0;
404 if ( curropt->
tag ==
"reset" )
405 reset = curropt->
value;
406 if ( curropt->
tag ==
"delete" )
407 delete_deselected = 1;
408 if ( curropt->
tag ==
"remove" ) write_flags |= 2;
409 if ( curropt->
tag ==
"output" )
411 if ( curropt->
tag ==
"split" ) {
415 cerr <<
"-split: An integer must be specified!" << endl;
419 if ( curropt->
tag ==
"Particle" ) {
423 if ( curropt->
tag ==
"Micrograph" ) {
427 if ( curropt->
tag ==
"FOM" ) {
431 if ( curropt->
tag ==
"classes" ) write_classes = 1;
439 while ( optind < argc )
string_add(&file_list, argv[optind++]);
441 cerr <<
"Error: No parameter or image files specified!" << endl;
449 cerr <<
"Error: Input file not read!" << endl;
463 if ( mgselect.
length() ) {
478 if ( tag_reselect.
length() )
496 if ( euler[0]+euler[2]+euler[4] != 0 || euler[1]+euler[3]+euler[5] != 0 )
499 for ( i=0; i<5; i++ ) {
500 if ( fom_cutoff[i] ) {
501 if ( fom_defocus_adjust[i] )
512 if ( fom_percentage >= 0 )
518 if ( fom_std_factor > -1e36 )
524 if ( closest_to_focus )
527 if ( furthest_from_focus )
530 if ( select_first_in_series )
533 if ( select_best_in_series )
541 else if ( random_fraction )
543 else if ( random_group )
571 if ( deselect.
length() ) {
586 if ( tag_show.
length() > 0 ) {
602 title =
"Particle view distributions";
605 title =
"Particle micrograph distributions";
619 for ( i=1, project2 =
project; project2; project2 = project2->
next, ++i ) {
623 }
else if (
split < 0 ) {
A class for a command line input option.
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.
int project_kill(Bproject *project)
Frees a whole project.
long part_set_selection(Bproject *project, int number)
Selects one selection number and sets all others to zero.
long part_set_first_view_in_series(Bproject *project)
Sets all orientation parameters for a particle to the first in the set.
Header file for postscript tools dealing with micrograph particle sets.
int string_kill(Bstring *list)
Kills a string linked list.
long project_show_selected_parameters(Bproject *project, int show)
Shows the selected particle parameters in a project.
int project_trim_class_averages(Bproject *project, Bstring &list)
Deletes selected class averages from the project..
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.
JSvalue project_defocus_range(Bproject *project)
Determines the minimum and maximum defocus values.
long project_divide(Bproject *project, long n)
Divides a project into a number of micrograph subsets.
Header file for general symmetry functions.
int bexit(int value)
Exit function for cleanup and debugging.
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.
long part_select_group(Bproject *project, int group)
Selects particles with a given group identifier.
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Header file for option handlers.
long project_show_class_averages(Bproject *project)
Shows the class averages in a project.
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.
int ps_mg_particle_positions(Bstring &filename, Bstring &title, Bproject *project)
Postscript plot of the positions of particles on micrographs.
long part_select_to_group(Bproject *project)
Transfer selection numbers to the group identifiers.
long part_deselect_from_list(Bproject *project, Bstring list)
Deselects particles with selection numbers from a list.
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.
long part_deselect_redundant(Bparticle *partlist, double excl_dist, int part_select, int fom_index)
Deselects particles overlapping with better ones.
long part_consolidate_selection(Bproject *project, int number)
Consolidates selected particles under one selection number.
long part_view_select(Bproject *project, View view, double angle)
Selects particles based on a distance from a reference view.
long part_set_multi_maps(Bproject *project, int part_select, int nmaps)
Sets selection for generating multiple maps.
long part_select_random_fraction(Bproject *project, double fraction)
Selects particles randomly based on a fraction of the total.
long values(T1 &v1, T2 &v2)
Header file for reading and writing micrograph parameters.
long project_show_selected(Bproject *project)
Shows the selected particles in a project.
long part_reset_selection(Bproject *project, int flag=0)
Resets selection to all particles.
long part_filament_direction(Bproject *project, double minpct)
Checks the direction of particles associated with filaments.
long part_select_furthest_from_focus(Bproject *project)
Deselects all particles except those from micrographs furthest from focus.
long part_deselect(Bproject *project, int fom_index, double fommin, double fommax=1e30)
Deselects particles below a given FOM cutoff.
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.
int ps_part_fom_histogram(Bstring &filename, Bproject *project)
Postscript plot of the particle FOM histogram.
long part_select_random_group(Bproject *project, long number)
Selects groups randomly to give at least a number of particles.
long part_side_view_select(Bproject *project, double angle)
Selects particles based on a distance from a side view.
long part_set_FOM(Bproject *project, int fom_index, double fom)
Sets the FOM for all particles.
int project_write_particle_classes(Bproject *project)
Writes particles to different stacks based on class.
long part_fix_defocus(Bproject *project, double max_dev)
Resets defocus values for particles thata are too far off.
int project_set_particle_asu_views(Bproject *project, Bstring &symmetry_asu)
Sets particle views within the asymmetric unit.
long project_show_fom_histogram(Bproject *project, long bins, double min, double max)
Shows a histogram of the FOM values.
Functions for CTF (contrast transfer function) processing.
Utilities for timing functions.
double part_fom_defocus_fit_deselect(Bproject *project, int fom_index, double cutoff)
Deselects particles below a given FOM cutoff, adjusted for the defocus.
long part_select_FOM_avg_std(Bproject *project, double factor, int fom_index)
Selects particles based on FOM average and standard deviation.
long part_select_best(Bproject *project, long number, int fom_index, int defocus_fit)
Selects the best particles based on the FOM.
vector< double > split_into_doubles(const Bstring &delim)
long part_select_percentage(Bproject *project, double percentage, int fom_index, int defocus_fit)
Selects a percentage of particles based on the FOM.
Bstring symmetry_string()
long project_show_selection_numbers(Bproject *project)
Shows the selection numbers for the particles in a project.
Header file for image processing from micrograph structures.
long project_show_part_parameter(Bproject *project, Bstring &tag)
Shows the particle parameter indicated by the tag in a project.
long part_select_bootstrap(Bproject *project, int number)
Selects a given number of particles randomly with replacement.
double timer_start()
Starts timer and prints the time.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
int project_split_write(Bstring &filename, Bproject *project)
Splits a project into sets of particle selections and write the files.
Header file for general utilities.
long part_select_FOM_groups(Bproject *project, int ngroups, int fom_index, int defocus_fit)
Selects groups of particles based on the FOM.
long part_select_sets(Bproject *project, int size, int flag)
Selects sets of particles, each set with the same size.
vector< string > split(const string &s)
Splits a string on whitespace.
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
long project_renumber_particles(Bproject *project)
Renumbers particles.
long part_select_series(Bproject *project, int size, int flag)
Select series where all are already selected.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
long part_unset_selection(Bproject *project)
Unsets selection to no particles.
Header file for micrograph processing.
long project_show_mg_parameter(Bproject *project, Bstring &tag)
Shows the micrograph parameter indicated by the tag in a project.
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
long part_delete_deselected(Bproject *project)
Deletes deselected particles and renumber the remaining.
long part_euler_angle_select(Bproject *project, double *euler6)
Selects particles based on Euler angle limits.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
long part_select_random(Bproject *project, long number)
Selects a specific number of particles randomly.
long part_select_frames(Bproject *project, int frame_start, int frame_end)
Select particles from frames in a series.
long project_select_with_particles(Bproject *project, long part_sel)
Selects micrographs with particles.
long project_reset(Bproject *project, Bstring &reset)
Reset a particle parameter from its micrograph.
bool contains(const Bstring &s)
long part_select_closest_to_focus(Bproject *project)
Deselects all particles except those from micrographs closest to focus.
int main(int argc, char **argv)
long part_select_micrograph(Bproject *project, Bstring &mgselect)
Sets selection to the micrographs indicated.
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.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Bstring read_list(Bstring filename)
long part_origin_select(Bproject *project, Vector3< double > origin, double distance)
Selects particles based on the distance from the nominal origin.