 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
24 "Usage: bmg [options] input.star/input.img [input.star/input.img]",
25 "----------------------------------------------------------------",
26 "Manipulates micrograph parameter files.",
27 "If the input files are images, a new parameter file will be created.",
30 "-reconstructions Operate on reconstruction parameters rather than micrographs.",
31 "-getfield field1 Get a single field from a parameter file.",
32 "-getmicrograph mg1 Get a single micrograph from a parameter file.",
33 "-selected Show selected particles.",
34 "-histogram 80,0.01 Histogram of magnification values of selected particles.",
35 "-add Add micrograph coordinates and particle origins.",
36 "-Euler Convert orientations from views to Euler angles.",
37 "-View Convert orientations from Euler angles to views.",
38 "-flip y Reverse the particle coordinates in the micrographs along the given axis.",
39 "-oriflip y Reverse the particle origins along the given axis.",
40 "-toview -2.5,5.5,9,45 Transform particle orientations relative to this view.",
41 "-toeuler 45,30,10 Transform particle orientations relative to these Euler angles.",
42 "-remove Do not write non-selected micrographs into the parameter file.",
44 "Actions dealing with file references:",
45 "-check Check if files can be found.",
46 "-filenames Delete file names of files not found.",
48 "Actions for generating parameters from images:",
49 "-extract part Extract views from images: mg, frame, rec, part, fil.",
51 "Actions modifiying images:",
52 "-write Write particle views into images.",
53 "-bin 3 Bin micrographs by given kernel size, new file names with a \"_b<n>\" insert.",
54 "-changepixelsize 3.68 Change the pixel size and all associated size parameters.",
57 "-verbose 7 Verbosity of output.",
58 "-numberperfield 3 Number of micrographs per field-of-view (default 1).",
59 "-fieldID dbgd Set the field ID (multiple micrographs will get numbered ID's).",
60 "-mgpath dir/subdir Set micrograph file paths.",
61 "-framepath dir/subdir Set micrograph frames file paths.",
62 "-pspath dir/subdir Set power spectrum file paths.",
63 "-partpath dir/subdir Set particle file paths.",
64 "-filpath dir/subdir Set filament file paths.",
65 "-samemgpart Set micrograph and particle file names to be the same.",
66 "-Scansampling 3.6 Set scan sampling or pixel size (um/pixel).",
67 "-mgpixelsize 1.2,1.15,1 Set micrograph pixel size (angstrom/pixel, one value sets all).",
68 "-partpixelsize 2.3,2.2,1 Set particle pixel size (angstrom/pixel, one value sets all).",
69 "-boxsize 55 Set particle box size (default from parameter file).",
70 "-mgorigin 1256,1256,1 Set micrograph origins (voxels).",
71 "-partorigin 215,215,1 Set particle origins (voxels).",
73 "Actions setting microscope and CTF parameters:",
74 "-Magnification 38500 Set magnification.",
75 "-electrondose 35.5 Set electron dose (electrons/angstrom)",
76 "-Defocus 1.8,0.3,-34 Set defocus average, deviation, and astigmatism angle (um, degrees).",
77 "-Astigmatism 0.3,-34 Set defocus deviation and astigmatism angle (um, degrees).",
78 "-Cs 2.0 Set spherical aberration, Cs (mm).",
79 "-Volt 100 Set acceleration voltage (kV).",
80 "-Amplitude 0.07 Set amplitude contrast (fraction)",
81 "-alpha 0.15 Set illumination half-angle (milliradians).",
82 "-basetype 2 Baseline type: (default 1)",
83 " Type 1: Polynomial with 5 coefficients.",
84 " Type 2: Double Gaussian with 5 coefficients.",
85 " Type 3: EMAN style with 4 coefficients.",
86 "-baseline 1,1.5,-2.6,12.9,30,118 Baseline type and 4 or 5 coefficients: (default 1,0,0,0,0)",
87 "-envtype 3 Envelope type: (default 4)",
88 " Type 1: Single gaussian (2 coefficients).",
89 " Type 2: Single gaussian with constant (3 coefficients).",
90 " Type 3: Double gaussian (4 coefficients).",
91 " Type 4: Double gaussian with constant (5 coefficients).",
92 "-reset defocus Reset particle defocus to micrograph defocus.",
95 "-input input.star Input master parameter file to merge in data blocks from other input files.",
96 "-revert part.star,15 Replace file names with those in this file,",
97 " with a flag indicating: 1=mg, 2=ps, 4=rec, 8=part.",
98 "-replacectf ctf.star Replace CTF parameters with those in this file.",
99 "-replacepart part.star Replace particle parameters with those in this file.",
100 "-validate mg.xsd Validate XML input file(s) with this schema.",
101 "-ppx update Process files in directory \"ppx\":",
102 " update: Update particle records in the parameter file.",
103 " list: List existing ppx files.",
104 " absent: List absent ppx files.",
107 "-output output.star Output parameter file (required any time \"-split\" is used to indicate the type).",
108 "-split 3 Split micrograph or reconstruction data blocks into individual files:",
109 " Argument: 1-6: number of digits inserted before extension",
110 " Argument: \"id\": micrograph ID's are used as file names (no -output required).",
111 " Argument: \"field\": field ID's are used as file names (no -output required).",
112 "-dump file.txt Dump all the particle origins and views.",
117 int main (
int argc,
char **argv)
131 int show_selected(0);
133 double histo_inc(0.01);
140 double magnification(0);
157 double base[5] = {1,0,0,0,0};
159 double env[5] = {1,-10,0,0,0};
186 for ( curropt = option; curropt; curropt = curropt->
next ) {
187 if ( curropt->
tag ==
"reconstructions" ) use_rec = 1;
188 if ( curropt->
tag ==
"getfield" ) {
189 get_field = curropt->
value;
190 if ( get_field.
length() < 1 )
191 cerr <<
"-getfield: A field ID must be specified!" << endl;
193 if ( curropt->
tag ==
"getmicrograph" ) {
194 get_mg = curropt->
value;
195 if ( get_mg.
length() < 1 )
196 cerr <<
"-getmicrograph: A micrograph ID must be specified!" << endl;
198 if ( curropt->
tag ==
"selected" )
200 if ( curropt->
tag ==
"histogram" )
201 if ( curropt->
values(bins, histo_inc) < 1 ) {
202 cerr <<
"-histogram: The number of bins must be specified!" << endl;
205 if ( curropt->
tag ==
"numberperfield" )
207 cerr <<
"-numberperfield: The number of micrographs in a field-of-view must be specified!" << endl;
210 if ( curropt->
tag ==
"add" )
212 if ( curropt->
tag ==
"toview" ) {
213 view = curropt->
view();
215 if ( curropt->
tag ==
"toeuler" ) {
216 euler = curropt->
euler();
219 if ( curropt->
tag ==
"remove" ) write_flags |= 2;
220 if ( curropt->
tag ==
"check" ) read_flags |= 8;
221 if ( curropt->
tag ==
"filenames" ) read_flags |= 24;
222 if ( curropt->
tag ==
"bin" )
224 cerr <<
"-bin: A binning value must be specified!" << endl;
225 if ( curropt->
tag ==
"extract" ) extract = curropt->
value;
226 if ( curropt->
tag ==
"write" )
228 if ( curropt->
tag ==
"changepixelsize" )
229 new_pixel_size = curropt->
scale();
230 if ( curropt->
tag ==
"fieldID" ) {
231 field_id = curropt->
value;
232 if ( field_id.
length() < 1 )
233 cerr <<
"-fieldID: A field ID must be specified!" << endl;
235 if ( curropt->
tag ==
"mgpath" ) {
236 mgpath = curropt->
value;
237 if ( mgpath.
length() < 1 )
238 cerr <<
"-mgpath: The micrograph file path must be specified!" << endl;
240 if ( mgpath[-1] !=
'/' ) mgpath +=
"/";
242 if ( curropt->
tag ==
"framepath" ) {
243 framepath = curropt->
value;
244 if ( framepath.
length() < 1 )
245 cerr <<
"-framepath: The micrograph frames file path must be specified!" << endl;
247 if ( framepath[-1] !=
'/' ) framepath +=
"/";
249 if ( curropt->
tag ==
"pspath" ) {
250 pspath = curropt->
value;
251 if ( pspath.
length() < 1 )
252 cerr <<
"-pspath: The power spectrum file path must be specified!" << endl;
254 if ( pspath[-1] !=
'/' ) pspath +=
"/";
256 if ( curropt->
tag ==
"partpath" ) {
257 partpath = curropt->
value;
258 if ( partpath.
length() < 1 )
259 cerr <<
"-partpath: The particle file path must be specified!" << endl;
261 if ( partpath[-1] !=
'/' ) partpath +=
"/";
263 if ( curropt->
tag ==
"filpath" ) {
264 filpath = curropt->
value;
265 if ( filpath.
length() < 1 )
266 cerr <<
"-filpath: The filament file path must be specified!" << endl;
268 if ( filpath[-1] !=
'/' ) filpath +=
"/";
270 if ( curropt->
tag ==
"samemgpart" )
272 if ( curropt->
tag ==
"Magnification" )
273 if ( ( magnification = curropt->
value.
real() ) < 0.00001 )
274 cerr <<
"-Magnification: The magnification must be specified!" << endl;
275 if ( curropt->
tag ==
"Scansampling" ) {
276 if ( ( sampling = curropt->
value.
real() ) < 0.0001 )
277 cerr <<
"-Scansampling: The scan sampling must be specified!" << endl;
278 else if ( sampling < 1e3 ) sampling *= 1e4;
280 if ( curropt->
tag ==
"mgpixelsize" )
281 mg_pixel = curropt->
scale();
282 if ( curropt->
tag ==
"partpixelsize" )
283 part_pixel = curropt->
scale();
284 if ( curropt->
tag ==
"boxsize" )
286 cerr <<
"-boxsize: A particle box size in pixels must be specified" << endl;
287 if ( curropt->
tag ==
"mgorigin" )
288 mgorigin = curropt->
origin();
289 if ( curropt->
tag ==
"partorigin" )
290 partorigin = curropt->
origin();
291 if ( curropt->
tag ==
"electrondose" )
292 if ( ( dose = curropt->
value.
real() ) < 0.001 )
293 cerr <<
"-electrondose: The electron dose must be specified!" << endl;
294 if ( curropt->
tag ==
"Defocus" ) {
295 if ( curropt->
values(def_avg, def_dev, ast_angle) < 1 )
296 cerr <<
"-Defocus: A defocus value must be specified!" << endl;
298 if ( def_avg < 1e3 ) def_avg *= 1e4;
299 if ( def_dev < 1e3 ) def_dev *= 1e4;
300 ast_angle *=
M_PI/180.0;
303 if ( curropt->
tag ==
"Astigmatism" ) {
304 if ( curropt->
values(def_dev, ast_angle) < 1 )
305 cerr <<
"-Defocus: A defocus value must be specified!" << endl;
307 if ( def_dev < 1e3 ) def_dev *= 1e4;
308 ast_angle *=
M_PI/180.0;
311 if ( curropt->
tag ==
"Cs" ) {
312 if ( ( Cs = curropt->
value.
real() ) < 0.001 )
313 cerr <<
"-Cs: A Cs value must be specified!" << endl;
314 else if ( Cs < 1e3 ) Cs *= 1e7;
316 if ( curropt->
tag ==
"Volt" ) {
317 if ( ( Volts = curropt->
value.
real() ) < 1 )
318 cerr <<
"-Volt: A voltage must be specified!" << endl;
319 else if ( Volts < 1e3 ) Volts *= 1e3;
321 if ( curropt->
tag ==
"Amplitude" ) {
322 if ( ( Amp = curropt->
value.
real() ) < 0.00001 )
323 cerr <<
"-Amplitude: A fraction must be specified!" << endl;
324 else if ( Amp > 1 ) Amp /= 100;
326 if ( curropt->
tag ==
"alpha" ) {
327 if ( ( alpha = curropt->
value.
real() ) < 0.00000001 )
328 cerr <<
"-alpha: The illumination half-angle must be specified!" << endl;
330 if ( alpha > 0.01 ) alpha /= 1000;
332 if ( curropt->
tag ==
"basetype" ) {
334 if ( basetype < 1 || basetype > 3 ) {
336 cerr <<
"Warning: The baseline type must be 1, 2 or 3. Reset to 1." << endl;
340 if ( curropt->
tag ==
"baseline" ) {
342 for (
size_t i=0; i<d.size(); i++ )
base[i] = d[i];
344 cerr <<
"-baseline: At least one coefficient must be specified!" << endl;
348 if ( curropt->
tag ==
"envtype" ) {
350 if ( envtype < 1 || envtype > 4 ) {
352 cerr <<
"Warning: The envelope type must be 1, 2, 3 or 4. Reset to 4." << endl;
356 if ( curropt->
tag ==
"envelope" ) {
358 for (
size_t i=0; i<d.size(); i++ ) env[i] = d[i];
360 cerr <<
"-envelope: At least an envelope amplitude must be specified!" << endl;
364 if ( curropt->
tag ==
"reset" )
365 reset = curropt->
value;
366 if ( curropt->
tag ==
"Euler" )
368 if ( curropt->
tag ==
"View" )
370 if ( curropt->
tag ==
"flip" ) {
375 if ( curropt->
tag ==
"oriflip" ) {
380 if ( curropt->
tag ==
"input" )
382 if ( curropt->
tag ==
"revert" ) {
383 revertfilenames = curropt->
value.
pre(
',');
386 if ( curropt->
tag ==
"replacectf" )
387 replacectffile = curropt->
filename();
388 if ( curropt->
tag ==
"replacepart" )
389 replacepartfile = curropt->
filename();
390 if ( curropt->
tag ==
"validate" )
392 if ( curropt->
tag ==
"ppx" ) ppx = curropt->
value;
393 if ( curropt->
tag ==
"output" )
395 if ( curropt->
tag ==
"split" ) {
399 cerr <<
"-split: An integer must be specified!" << endl;
403 if ( curropt->
tag ==
"dump" )
408 if ( pspath.
length() < 1 && mgpath.
length() ) pspath = mgpath;
413 if ( masterfile.
length() )
418 while ( optind < argc )
string_add(&file_list, argv[optind++]);
420 cerr <<
"Error: No parameter or image files specified!" << endl;
425 project2 =
read_project(file_list, xsdfile, read_flags);
441 if ( revertfilenames.
length() ) {
442 project2 =
read_project(revertfilenames, xsdfile, read_flags);
447 if ( replacectffile.
length() ) {
448 project2 =
read_project(replacectffile, xsdfile, read_flags);
453 if ( replacepartfile.
length() ) {
454 project2 =
read_project(replacepartfile, xsdfile, read_flags);
460 else if ( ppx[0] ==
'l' ) {
463 }
else if ( ppx[0] ==
'a' ) {
478 }
else if ( new_pixel_size[0] ) {
576 if ( to_views && !to_euler )
579 if ( to_euler && !to_views )
int project_set_envelope(Bproject *project, int type, double *coeff)
Sets the envelope equations of all the micrographs.
A class for a command line input option.
int project_flip_particle_coordinates(Bproject *project, int flip)
Reverses one or more particle coordinates.
int project_kill(Bproject *project)
Frees a whole project.
int project_split_field_write(Bproject *project)
Splits a project into sets of particle selections and write the files.
Vector3< double > scale()
int project_set_powerspectrum_path(Bproject *project, Bstring &path)
Sets the path to powerspectrum files for all the micrographs.
int project_update(Bproject *project, Bproject *proj_new, int fom_index)
Updates an existing project with new information.
int string_kill(Bstring *list)
Kills a string linked list.
int project_merge_CTF_parameters(Bproject *project, Bproject *ctfproject)
Puts CTF parameters from one project into another.
long project_show_hierarchy(Bproject *project)
Shows the project hierarchy.
int project_bin_micrographs(Bproject *project, int bin, Bstring mgpath, Bstring partpath)
Bins all micrographs a project.
long project_update_from_ppx(Bproject *project)
Updates a project with ppx files.
Header file for file checking functions.
int project_set_dose(Bproject *project, double dose)
Sets the electron dose of all the micrographs.
string base(string &filename)
long project_list_ppx(Bproject *project, int flag)
Lists existing ppx files for a project.
int project_set_part_pixel_size(Bproject *project, Vector3< double > pixel_size)
Sets the pixel size for all the particles.
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.
int project_set_baseline(Bproject *project, int type, double *coeff)
Sets the baseline equations of all the micrographs.
int project_set_frame_path(Bproject *project, Bstring &path)
Sets the path to micrograph frames files for all the micrographs.
int project_set_volts(Bproject *project, double volts)
Sets the acceleration voltage of all the micrographs.
int project_set_field_id(Bproject *project, int nseries, Bstring &field_id)
Sets the field id's according to a regular series.
Header file for option handlers.
int project_set_alpha(Bproject *project, double alpha)
Sets the beam source size/divergence angle of all the micrographs.
long part_set_sequential(Bproject *project)
Selects one selection number and sets all others to zero.
int project_set_micrograph_origins(Bproject *project, Vector3< double > origin)
Sets micrograph origins to the given origin.
Vector3< double > origin()
long values(T1 &v1, T2 &v2)
Header file for reading and writing micrograph parameters.
int project_set_mg_pixel_size(Bproject *project, Vector3< double > pixel_size)
Sets the pixel size for all the micrographs.
long project_show_selected(Bproject *project)
Shows the selected particles in a project.
int project_merge_part_parameters(Bproject *project, Bproject *partproject)
Puts particle parameters from one project into another.
int project_set_particle_path(Bproject *project, Bstring &path)
Sets the path to particle files for all the micrographs.
long project_show_mag_histogram(Bproject *project, long bins, double increment)
Shows the histogram for magnification values for selected particles.
long project_dump(Bproject *project, Bstring &filename)
Dumps particle info in the project hierarchy.
int project_set_astigmatism(Bproject *project, double def_dev, double ast_angle)
Sets the defocus deviation and astigmatism angle of all the micrographs.
Functions for CTF (contrast transfer function) processing.
Bproject * project_create_from_images(Bstring *file_list, Bstring type)
Creates a project structure using image file names.
int project_rotate_particle_views(Bproject *project, View view)
Rotates particle views with respect to a reference view.
vector< double > split_into_doubles(const Bstring &delim)
Header file for image processing from micrograph structures.
int project_set_views_in_images(Bproject *project)
Sets views in particle images from the project parameter structure.
int project_equal_mg_part_files(Bproject *project)
Sets micrograph and particle files to be the same.
int project_set_filament_path(Bproject *project, Bstring &path)
Sets the path to filament files for all the micrographs.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
int project_select_field(Bproject *project, Bstring &field_id)
Selects a field from the project and deletes the rest.
vector< string > split(const string &s)
Splits a string on whitespace.
int project_select_micrograph(Bproject *project, Bstring &mg_id)
Selects a micrograph from the project and deletes the rest.
int project_set_particle_box_size(Bproject *project, Vector3< long > box_size)
Sets particle box size to the given value.
int project_revert_filenames(Bproject *project, Bproject *project_old, int flag)
Reverts file names to what it was in an old project.
int project_set_particle_origins(Bproject *project, Vector3< double > origin)
Sets particle origins to given values.
int project_set_views_from_images(Bproject *project)
Gets views from particle images.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
int main(int argc, char **argv)
int project_flip_origins(Bproject *project, int flip)
Flip origin coordinates.
Header file for micrograph processing.
int project_set_scan_sampling(Bproject *project, double sampling)
Sets the scan sampling for all the micrographs.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
int project_set_amp_shift(Bproject *project, double amp_shift)
Sets the amplitude contribution of all the micrographs.
int project_set_magnification(Bproject *project, double mag)
Sets the magnification for all the micrographs.
long project_reset(Bproject *project, Bstring &reset)
Reset a particle parameter from its micrograph.
int project_change_pixel_size(Bproject *project, Vector3< double > new_pixel_size, Bstring mgpath, Bstring partpath)
Changes all the micrograph fields linked to the pixel size.
bool contains(const Bstring &s)
int project_add_origins_to_coords(Bproject *project)
Adds the particle origins to the micrograph coordinates.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
int project_set_coherence_envelope(Bproject *project)
Replaces envelope equations with those based on partial coherence in all micrographs.
int project_set_defocus(Bproject *project, double def_avg, double def_dev, double ast_angle)
Sets the defocus values of all the micrographs.
int project_set_micrograph_path(Bproject *project, Bstring &path)
Sets the path to micrograph files for all the micrographs.
FileType file_type(const char *filename)
Checks the file type using the extension and contents.
int project_set_Cs(Bproject *project, double Cs)
Sets the spherical aberation constant of all the micrographs.