 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
24 "Usage: bbackproj [options] input.star [input.star]",
25 "--------------------------------------------------",
26 "Reconstructs 3D maps from single particles by backprojection.",
29 "-rescale -0.1,5.2 Rescale data to average and standard deviation.",
30 "-edge Smooth map with an oval edge.",
32 "Parameters for configuration:",
33 "-classes 1,3-5 Class selection: can be all, selected, or any combination of numbers (default selected).",
34 "-fullmap Output one full map per class (default if -halfmaps not used).",
35 "-halfmaps Output 2 maps from half sets.",
36 "-threads 2 Threads per class (default 1, must be even for -halfmaps).",
39 "-verbose 7 Verbosity of output.",
40 "-datatype u Force writing of a new data type.",
41 "-size 120,120,80 Output 3D volume size (default from input file).",
42 "-sampling 2,3.5,1 Sampling (angstrom/voxel, a single value sets all three).",
43 "-scale 1.2 Scale or magnification of reconstruction compared to original images (default 1).",
44 "-resolution 3.4 Resolution (angstrom).",
45 "-symmetry D6 Symmetry: Point group identifier.",
48 "-reconstruction file.map Output 3D reconstruction.",
49 "-output file.star Output parameter file name.",
54 int main(
int argc,
char **argv)
63 double nuavg, nustd(0);
75 for ( curropt = option; curropt; curropt = curropt->
next ) {
76 if ( curropt->
tag ==
"datatype" )
78 if ( curropt->
tag ==
"size" )
79 map_size = curropt->
size();
80 if ( curropt->
tag ==
"scale" )
81 if ( ( scale = curropt->
value.
real() ) < 0.0001 )
82 cerr <<
"-scale: A scale must be specified!" << endl;
83 if ( curropt->
tag ==
"resolution" )
84 if ( ( resolution = curropt->
value.
real() ) < 0.001 )
85 cerr <<
"-resolution: Resolution must be specified" << endl;
86 if ( curropt->
tag ==
"sampling" )
87 sam = curropt->
scale();
88 if ( curropt->
tag ==
"symmetry" )
90 if ( curropt->
tag ==
"rescale" ) {
91 if ( curropt->
values(nuavg, nustd) < 2 )
92 cerr <<
"-rescale: Both average and standard deviation must be specified!" << endl;
94 cerr <<
"-rescale: A positive standard deviation must be specified!" << endl;
96 if ( curropt->
tag ==
"edge" )
98 if ( curropt->
tag ==
"classes" )
99 classes = curropt->
value;
100 if ( curropt->
tag ==
"fullmap" ) nmaps += 1;
101 if ( curropt->
tag ==
"halfmaps" ) nmaps += 2;
102 if ( curropt->
tag ==
"threads" )
104 cerr <<
"-threads: A number of threads must be specified!" << endl;
105 if ( curropt->
tag ==
"reconstruction" )
107 if ( curropt->
tag ==
"output" )
114 if ( nmaps < 1 ) nmaps = 1;
115 if ( !nmaps%2 ) nmaps = 2;
116 if ( nmaps > 3 ) nmaps = 3;
117 if ( nmaps & 2 && nthreads%2 ) nthreads++;
121 while ( optind < argc )
string_add(&file_list, argv[optind++]);
123 cerr <<
"Error: No parameter files specified!" << endl;
131 cerr <<
"Error: No input file read!" << endl;
141 cout <<
"3D backprojection:" << endl;
148 long ntotal = nclasses*nthreads;
160 if ( map_size.
volume() <= 0 ) {
162 map_size = {ms[0], ms[1], ms[2]};
165 if ( map_size.
volume() <= 0 ) {
166 error_show(
"Error in bbackproj", __FILE__, __LINE__);
167 cerr <<
"No particles to determine the size from!" << endl << endl;
172 cout <<
"Map size: " << map_size << endl;
173 cout <<
"Resolution limit: " << resolution <<
" A" << endl;
174 cout <<
"Scale: " << scale << endl;
183 dispatch_apply(ntotal, dispatch_get_global_queue(0, 0), ^(
size_t i){
188 #pragma omp parallel for
189 for ( i=0; i<ntotal; i++ )
198 cout <<
"Combining " << nclasses*nmaps <<
" reconstructions" << endl;
202 dispatch_apply(nclasses*nmaps, dispatch_get_global_queue(0, 0), ^(
size_t i){
205 if ( smooth_oval ) prec[i]->
edge(1, map_size, start, 5,
FILL_USER, 0);
210 #pragma omp parallel for
211 for ( i=0; i<nclasses*nmaps; i++ ) {
214 if ( smooth_oval ) prec[i]->
edge(1, map_size, start, 5,
FILL_USER, 0);
220 for ( i=0; i<ntotal; i++ )
delete pacc[i];
224 for ( i=0; i<nclasses*nmaps; i++ ) {
226 if ( nmaps == 2 ) imap = i%2 + 1;
227 else if ( nmaps == 3 ) imap = i%3;
228 if ( prec[i] && reconsfile.
length() ) {
231 if ( imap )
id +=
Bstring(imap,
"_%02d");
232 filename = reconsfile;
236 rec->
frec = filename;
A class for a command line input option.
Functions for reconstruction.
int project_kill(Bproject *project)
Frees a whole project.
double symmetrize(Bstring &symmetry_string, int flag)
Vector3< double > scale()
int string_kill(Bstring *list)
Kills a string linked list.
int main(int argc, char **argv)
Vector3< double > voxel_size
Header file for general symmetry functions.
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 error_show(string message, string file, int line)
Displays the error with file and line reference.
Header file for option handlers.
long values(T1 &v1, T2 &v2)
Header file for reading and writing micrograph parameters.
void origin(double x, double y, double z)
int project_set_mg_pixel_size(Bproject *project, Vector3< double > pixel_size)
Sets the pixel size for all the micrographs.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int project_configure_for_reconstruction(Bproject *project, Bstring classes, long &nmaps, long &nthreads)
Sets up the particle selection for reconstruction.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
General image parameter class.
Utilities for timing functions.
Bimage * project_back_projection(Bproject *project, long num_select, Vector3< long > map_size, Vector3< double > sam, double scale, double resolution, fft_plan planf, fft_plan planb)
Back projects a set of 2D images into a 3D volume.
double timer_start()
Starts timer and prints the time.
Bproject * read_project(const char *filename, int flags=0)
Reading micrograph parameters from files.
Header file for general utilities.
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void change_type(char letter)
Get the data type indicated by a single letter code.
Header file for 2D and 3D image I/O.
int write_project(const char *filename, Bproject *project)
Writing micrograph parameters to a file.
Header file for micrograph processing.
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Vector3< double > pixel_size
Bimage * img_backprojection_accumulate(Bimage **pacc, int imap, int nmaps, int nthreads)
Accumulates multiple backprojections.
DataType
Base data type specifier.
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
int edge(int type, Vector3< long > rect, Vector3< double > start, double width, int fill_type=0, double fill=0)
Smooths the image edge with a soft rectangular function.
Vector3< long > project_set_reconstruction_size(Bproject *project, double scale, int twoD_flag)
Sets the reconstruction size for reconstruction from 2D particle images.
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.