| Bsoft 2.0.5 Bernard's software package

bdual.cpp
Go to the documentation of this file.
1
9 #include "rwmg.h"
10 #include "mg_processing.h"
11 #include "mg_img_proc.h"
12 #include "mg_tomography.h"
13 #include "mg_tomo_track.h"
14 #include "ps_micrograph.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
23 // Usage assistance
24 const char* use[] = {
25 " ",
26 "Usage: bdual [options] input1.star [input2.star]",
27 "------------------------------------------------",
28 "Handles dual tomographic tilt series of micrographs.",
29 "Expects exactly two input parameter files corresponding to the two tilt series.",
30 "Outputs only the second series to a parameter file.",
31 " ",
32 "Actions:",
33 "-seed 1.3,-95,75 Transfers seed markers from first to second series,",
34 " using the angular increment to test for rotation angle,",
35 " within the angular limits (default -180,180).",
36 "-refine Refines markers from the second series after transfer.",
37 "-transform Calculates the correct micrograph transformations for the 2nd series.",
38 "-deselect 5-9,33 Deselect markers by id from all micrographs and models.",
39 "-zcompare Compare Z coordinates of the first and second series.",
40 " ",
41 "Parameters:",
42 "-verbose 7 Verbosity of output.",
43 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
44 "-resolution 900,300 High and low resolution limits for cross-correlation (default 0.1,1000 angstrom).",
45 "-shiftlimit 155.5 Limit on micrograph shift search in pixels (default 20% of micrograph width).",
46 " ",
47 "Output:",
48 "-output file.star Output parameter file for 2nd series.",
49 "-Postscript out.ps Postscript output with Z coordinate error plots.",
50 "-bild out.bld BILD output with fitted marker models.",
51 " ",
52 NULL
53 };
54
55
56 int main(int argc, char** argv)
57 {
58 // Initializing variables
59 double rot_start(-180), rot_end(180); // Rotation search limits
60 double rot_step(0); // Rotation search step size for seed transfer
61 int refine(0); // Flag to refine seed markers
62 int transform(0); // Flag to transform micrograph parameters
63 Bstring deselect; // String specifying markers to deselect
64 int zcompare(0); // Flag to enable Z compare option
65 Vector3<double> sam; // Units for the three axes (A/pixel)
66 double hi_res(0), lo_res(1000); // Default resolution range
67 double shift_limit(-1); // Micrograph shift search limit
68 Bstring paramfile; // Output parameter file
69 Bstring psfile; // Output postscript file
70 Bstring bildfile; // Output bild file
71
72 int optind;
73 Boption* option = get_option_list(use, argc, argv, optind);
74 Boption* curropt;
75 for ( curropt = option; curropt; curropt = curropt->next ) {
76 if ( curropt->tag == "seed" ) {
77 if ( curropt->values(rot_step, rot_start, rot_end) < 1 )
78 cerr << "-rotation: A rotation angle step size must be specified." << endl;
79 else {
80 rot_step *= M_PI/180.0;
81 rot_start *= M_PI/180.0;
82 rot_end *= M_PI/180.0;
83 }
84 }
85 if ( curropt->tag == "refine" ) refine = 1;
86 if ( curropt->tag == "transform" ) transform = 1;
87 if ( curropt->tag == "deselect" ) deselect = curropt->value;
88 if ( curropt->tag == "zcompare" ) zcompare = 1 ;
89 if ( curropt->tag == "sampling" )
90 sam = curropt->sampling();
91 if ( curropt->tag == "resolution" ) {
92 if ( curropt->values(hi_res, lo_res) < 1 )
93 cerr << "-resolution: Resolution limits must be specified." << endl;
94 else if ( hi_res > lo_res )
95 swap(hi_res, lo_res);
96 }
97 if ( curropt->tag == "shiftlimit" )
98 if ( ( shift_limit = curropt->value.real() ) < 1 )
99 cerr << "-shiftlimit: A shift limit in pixels must be specified." << endl;
100 if ( curropt->tag == "output" )
101 paramfile = curropt->filename();
102 if ( curropt->tag == "Postscript" )
103 psfile = curropt->filename();
104 if ( curropt->tag == "bild" )
105 bildfile = curropt->filename();
106 }
107 option_kill(option);
108
109 double ti = timer_start();
110
111 // Read all the parameter files
112 Bstring* file_list = NULL;
113 if ( optind < argc ) string_add(&file_list, argv[optind++]);
114 if ( optind < argc ) string_add(&file_list, argv[optind++]);
115 if ( !file_list ) {
116 cerr << "Error: No parameter files specified!" << endl;
117 bexit(-1);
118 }
119
120 Bproject* project = read_project(file_list);
121 if ( !project || !project->field || !project->field->mg ) {
122 cerr << "Error: No first tilt series!" << endl;
123 bexit(-1);
124 }
125
126 if ( !project->field->next ) {
127 cerr << "Error: Two tilt series (fields) must be specified!" << endl;
128 bexit(-1);
129 }
130
131 project_update_comment(project, argc, argv);
132
133 project_sort_markers_by_id(project);
134
135 if ( deselect.length() )
136 project_deselect_markers(project, deselect);
137
138 if ( project->field->mg->origin[0] < 1 || project->field->mg->origin[1] < 1 )
139 project_set_nominal_mg_origins(project);
140
141 if ( sam[0] > 0 )
142 project_set_pixel_size(project, sam[0]);
143
144 if ( rot_step > 0 ) {
145 project_transfer_seed(project, rot_start, rot_end, rot_step, hi_res, lo_res, shift_limit);
146 project->field->select = 0;
147 if ( refine )
148 project_refine_markers(project, hi_res, lo_res);
149 project->field->select = 1;
150 }
151
152 if ( transform )
153 project_transform_dual(project);
154
155 if ( bildfile.length() )
156 marker_sets_to_bild(bildfile, project->rec->mark, project->rec->next->mark);
157
158 if ( zcompare )
159 project_dual_zcompare(project);
160
161 if ( psfile.length() )
162 ps_dual_zcompare(psfile, project);
163
164 // project_tomo_errors(project2);
165
166 // if ( transform )
167 // project_merge_rec_markers(project);
168
169 // if ( project->rec ) project_tomo_residuals(project, 1);
170
171 if ( paramfile.length() )
172 write_project(paramfile, project, 1, 1);
173
174 project_kill(project);
175
176 if ( verbose & VERB_TIME )
177 timer_report(ti);
178
179 bexit(0);
180 }
181
write_project
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Definition: rwmg.cpp:320
rwmg.h
Header file for reading and writing micrograph parameters.
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
Bproject::rec
Breconstruction * rec
Definition: mg_processing.h:344
Bfield::select
long select
Definition: mg_processing.h:262
Breconstruction::mark
Bmarker * mark
Definition: mg_processing.h:307
project_set_nominal_mg_origins
int project_set_nominal_mg_origins(Bproject *project)
Sets micrograph origins to the centers of the micrographs.
Definition: mg_img_proc.cpp:660
project_transfer_seed
int project_transfer_seed(Bproject *project, double rot_start, double rot_end, double rot_step, double hi_res, double lo_res, double shift_limit)
Transfers the seed markers from the first to the second project.
Definition: mg_tomo_track.cpp:1418
utilities.h
Header file for general utilities.
Boption::sampling
Vector3< double > sampling()
Definition: options.h:202
Boption::value
Bstring value
Definition: options.h:30
Boption::tag
Bstring tag
Definition: options.h:29
mg_img_proc.h
Header file for image processing from micrograph structures.
use
const char * use[]
Definition: bdual.cpp:24
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
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
Boption::filename
Bstring filename()
Definition: options.h:85
Bfield::next
Bfield * next
Definition: mg_processing.h:258
timer.h
Utilities for timing functions.
M_PI
#define M_PI
Definition: utilities.h:59
project_dual_zcompare
double project_dual_zcompare(Bproject *project)
Lists two sets of Z coordinates for comparison.
Definition: mg_tomo_track.cpp:1641
Boption
A class for a command line input option.
Definition: options.h:26
Bproject::field
Bfield * field
Definition: mg_processing.h:343
VERB_TIME
#define VERB_TIME
Definition: utilities.h:110
mg_tomography.h
Header file for single particle image processing in Bsoft.
Bmicrograph::origin
Vector3< double > origin
Definition: mg_processing.h:220
verbose
int verbose
mg_tomo_track.h
Functions to track fiducial markers in a tomographic series of images.
Bfield::mg
Bmicrograph * mg
Definition: mg_processing.h:264
ps_dual_zcompare
int ps_dual_zcompare(Bstring &filename, Bproject *project)
Generates a PostScript file that displays X by X, Y by Y, and Z by Z plots for diagnostic purposes.
Definition: ps_micrograph.cpp:965
project_sort_markers_by_id
int project_sort_markers_by_id(Bproject *project)
Sorts markers for each micrograph by ID number.
Definition: mg_tomography.cpp:647
Boption::next
Boption * next
Definition: options.h:28
Bstring
Definition: Bstring.h:29
project_kill
int project_kill(Bproject *project)
Frees a whole project.
Definition: mg_processing.cpp:1224
project_set_pixel_size
int project_set_pixel_size(Bproject *project, double pixel_size)
Sets the pixel size for all the micrographs.
Definition: mg_processing.cpp:3398
project_deselect_markers
long project_deselect_markers(Bproject *project, Bstring &deselect_list)
Deletes selected markers in a project hierarchy.
Definition: mg_tomography.cpp:1389
Vector3< double >
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:67
project_refine_markers
int project_refine_markers(Bproject *project, double hi_res, double lo_res)
Refines marker positions in a tomographic series.
Definition: mg_tomo_track.cpp:683
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:109
mg_processing.h
Header file for micrograph processing.
main
int main(int argc, char **argv)
Definition: bdual.cpp:56
marker_sets_to_bild
int marker_sets_to_bild(Bstring &filename, Bmarker *mark1, Bmarker *mark2)
Generates a bild file with the two marker sets.
Definition: marker.cpp:1237
options.h
Header file for option handlers.
project_transform_dual
int project_transform_dual(Bproject *project)
Calculates the transformation of the second tilt series to fit the first.
Definition: mg_tomo_track.cpp:1541
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
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
Breconstruction::next
Breconstruction * next
Definition: mg_processing.h:281
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:52
Bproject
Definition: mg_processing.h:333