 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 "Usage: breconstruct [options] input.star [input.star]",
27 "-----------------------------------------------------",
28 "Reconstructs 2D and 3D maps from single particle images.",
29 "Note: -classes and -bootstrap are mutually exclusive.",
32 "-mode 1 Symmetry mode: 0=during reconstruction (default), 1=after reconstruction,",
33 " 2=pick a random symmetry view for each particle.",
34 "-TwoD Generate a 2D reconstruction (default 3D).",
35 "-CTF flip Apply CTF correction to images before reconstruction (default not).",
36 "-rescale -0.1,5.2 Rescale reconstruction to an average and standard deviation.",
38 "Parameters for configuration:",
39 "-bootstrap Use particle selection numbers to weigh their contributions.",
40 "-filaments Generate one map per filament.",
41 "-classes 1,3-5 Class selection: can be all, selected, or any combination of numbers (default selected).",
42 "-fullmap Output one full map per class (default if -halfmaps not used).",
43 "-halfmaps Output 2 maps from half sets.",
44 "-threads 2 Threads per class (default 1, must be even for -halfmaps).",
47 "-verbose 7 Verbosity of output.",
48 "-datatype u Force writing of a new data type.",
49 "-size 100,120,90 Size of reconstruction (default from images).",
50 "-sampling 1.5 Reconstruction sampling (A/pixel; default from first particle image).",
51 "-scale 1.2 Scale or magnification of reconstruction compared to original images (default 1).",
52 "-resolution 20 Resolution limit (angstrom, default Nyquist).",
53 "-interpolation weighted Interpolation type: nearest (default), weighted, trilinear.",
54 "-pad 3 Image padding factor (default 2).",
55 "-symmetry D6 Symmetry: Point group identifier",
56 "-wiener 0.15 Wiener factor for CTF correction (default 0.2).",
59 "-reconstruction file.ext Reconstruction file name.",
60 "-fom file.ext Figure-of-merit file name.",
61 "-output file.star Output parameter file name.",
62 "-Postscript file.ps Postscript output filename.",
68 int main(
int argc,
char** argv)
73 double nuavg, nustd(0);
98 for ( curropt = option; curropt; curropt = curropt->
next ) {
99 if ( curropt->
tag ==
"mode" ) {
101 if ( sym_mode < 0 || sym_mode > 2 )
102 cerr <<
"-mode: A symmetry mode of 0, 1 or 2 must be specified!" << endl;
104 if ( curropt->
tag ==
"TwoD" )
106 if ( curropt->
tag ==
"CTF" )
108 if ( curropt->
tag ==
"rescale" ) {
109 if ( curropt->
values(nuavg, nustd) < 2 )
110 cerr <<
"-rescale: Both average and standard deviation must be specified!" << endl;
112 cerr <<
"-rescale: A positive standard deviation must be specified!" << endl;
114 if ( curropt->
tag ==
"datatype" )
116 if ( curropt->
tag ==
"size" )
117 map_size = curropt->
size();
118 if ( curropt->
tag ==
"sampling" )
119 sam = curropt->
scale();
120 if ( curropt->
tag ==
"scale" )
121 scale = curropt->
scale();
122 if ( curropt->
tag ==
"resolution" )
123 if ( ( resolution = curropt->
value.
real() ) < 1 )
124 cerr <<
"-resolution: A resolution limit must be specified!" << endl;
125 if ( curropt->
tag ==
"interpolation" ) {
126 if ( curropt->
value[0] ==
'n' ) interp_type = 0;
127 if ( curropt->
value[0] ==
'w' ) interp_type = 1;
128 if ( curropt->
value[0] ==
't' ) interp_type = 2;
131 if ( curropt->
tag ==
"bootstrap" )
133 if ( curropt->
tag ==
"classes" )
134 classes = curropt->
value;
135 if ( curropt->
tag ==
"fullmap" ) nmaps += 1;
136 if ( curropt->
tag ==
"halfmaps" ) nmaps += 2;
137 if ( curropt->
tag ==
"threads" )
139 cerr <<
"-threads: A number of threads must be specified!" << endl;
140 if ( curropt->
tag ==
"filaments" ) filaments = 1;
141 if ( curropt->
tag ==
"wiener" ) {
142 if ( ( wiener = curropt->
value.
real() ) < 0.000001 )
143 cerr <<
"-wiener: A Wiener factor must be specified!" << endl;
145 if ( wiener < 0.01 ) wiener = 0.01;
149 if ( curropt->
tag ==
"pad" )
151 cerr <<
"-pad: A positive factor must be specified!" << endl;
152 if ( curropt->
tag ==
"symmetry" )
154 if ( curropt->
tag ==
"reconstruction" )
156 if ( curropt->
tag ==
"fom" )
158 if ( curropt->
tag ==
"output" )
160 if ( curropt->
tag ==
"Postscript" )
169 while ( optind < argc )
string_add(&file_list, argv[optind++]);
171 cerr <<
"Error: No parameter files specified!" << endl;
179 cerr <<
"Error: No input file read!" << endl;
190 cout <<
"2D reciprocal space reconstruction:" << endl;
192 cout <<
"3D reciprocal space reconstruction:" << endl;
197 cerr <<
"Error: No particles selected!" << endl;
201 if ( nthreads < 2 ) nthreads = 2;
202 if ( nthreads > npart/2 ) nthreads = npart/2;
204 if ( nmaps < 1 ) nmaps = 1;
205 if ( !nmaps%2 ) nmaps = 2;
206 if ( nmaps > 3 ) nmaps = 3;
217 int ntotal = nclasses*nthreads;
219 if ( nmaps & 2 && nthreads%2 ) nthreads++;
230 if ( map_size.
volume() <= 0 )
233 if ( map_size.
volume() <= 0 ) {
234 error_show(
"Error in breconstruct", __FILE__, __LINE__);
235 cerr <<
"No particles to determine the size from!" << endl << endl;
240 if ( map_size[0] > ft_size ) ft_size = map_size[0];
247 cout <<
"Map size: " << map_size << endl;
248 cout <<
"Symmetry: " << sym->
label << endl;
249 cout <<
"Symmetry mode: " << sym_mode << endl;
250 cout <<
"Resolution limit: " << resolution <<
" A" << endl;
251 cout <<
"Scale: " << scale << endl;
252 cout <<
"Interpolation type: " << interp_type << endl;
253 cout <<
"CTF application type: " << ctf_action << endl;
254 if ( bootstrap ) cout <<
"Bootstrapping on" << endl;
255 cout <<
"Padding factor: " << pad_factor << endl;
256 cout <<
"Fourier transform size: " << ft_size <<
" x " << ft_size << endl << endl;
259 long memreq = (ntotal+nmaps)*5*map_size.
volume()*
sizeof(float);
265 dispatch_apply(ntotal, dispatch_get_global_queue(0, 0), ^(
size_t i){
268 resolution, scale, map_size, ft_size, plan,
269 interp_type, ctf_action, wiener, twoD_flag, bootstrap, (i==0));
273 #pragma omp parallel for
274 for ( i=0; i<ntotal; i++ ) {
277 resolution, scale, map_size, ft_size, plan,
278 interp_type, ctf_action, wiener, twoD_flag, bootstrap, (i==0));
286 cout <<
"Weighing " << nclasses*nmaps <<
" reconstructions" << endl;
289 dispatch_apply(nclasses*nmaps, dispatch_get_global_queue(0, 0), ^(
size_t i){
293 #pragma omp parallel for
294 for ( i=0; i<nclasses*nmaps; i++ )
298 for ( i=0; i<ntotal; i++ )
if ( pacc[i] )
delete pacc[i];
301 double fsccut[4] = {0.8,0.3,0.143,0};
302 double dprcut[4] = {0,0,0,0};
305 for ( i=nmaps-2; i<nmaps; i+=nmaps ) {
306 Bplot* plot = prec[i]->
fsc(prec[i+1], resolution);
314 cout <<
"Transforming " << nclasses*nmaps <<
" reconstructions to real space" << endl;
319 dispatch_apply(nclasses*nmaps, dispatch_get_global_queue(0, 0), ^(
size_t i){
323 if ( sym_mode == 1 ) prec[i]->symmetrize(sym, 1);
324 if ( nustd > 0 ) prec[i]->rescale_to_avg_std(nuavg, nustd);
328 #pragma omp parallel for
329 for ( i=0; i<nclasses*nmaps; i++ ) {
333 if ( sym_mode == 1 ) prec[i]->
symmetrize(sym, 1);
342 for ( i=0; i<nclasses*nmaps; i++ ) {
344 if ( nmaps == 2 ) imap = i%2 + 1;
345 else if ( nmaps == 3 ) imap = i%3;
346 if ( prec[i] && reconsfile.
length() ) {
349 filename = fomfile.
pre_rev(
'.');
350 if ( nclasses > 1 ) filename +=
Bstring(i%nmaps + 1,
"_%02d");
351 if ( imap ) filename +=
Bstring(imap,
"_%02d");
352 filename +=
"." + fomfile.
post_rev(
'.');
357 if ( nclasses > 1 )
id +=
Bstring(i/nmaps + 1,
"_%02d");
358 if ( imap )
id +=
Bstring(imap,
"_%02d");
359 filename =
id +
"." + reconsfile.
post_rev(
'.');
361 cout <<
"Writing " << filename << endl;
364 rec->
frec = filename;
374 cout <<
"Writing " << outfile << endl;
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)
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Vector3< double > scale()
int string_kill(Bstring *list)
Kills a string linked list.
Vector3< double > voxel_size
Header file for general symmetry functions.
int filter_sinc()
Weighs an image with a sinc function.
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.
int part_ft_size(int xsize, double scale, int pad_factor)
Sets the Fourier transform size for 2D particle images for reconstruction.
Header file for option handlers.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
void resolution_display(double *fsccut=NULL, double *dprcut=NULL)
int memory_check(long mem_required)
Checking if there is enough memory, abort if not.
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.
Bparticle * project_reconstruction_partlist(Bproject *project, int num_select, int bootstrap)
List of particle images for reciprocal space reconstruction.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Bimage * particle_reconstruct(Bparticle *partlist, Bsymmetry *sym, int sym_mode, double hi_res, Vector3< double > scale, Vector3< long > size, int ft_size, fft_plan plan, int interp_type=0, int ctf_action=0, double wiener=0.2, int twoD_flag=0, int bootstrap=0, int first=0)
Reciprocal space reconstruction from 2D particle images.
Bimage * img_reconstruction_sum_weigh(Bimage **pacc, int imap, int nmaps, int nthreads, double hi_res)
Combines and weighs a map from several partial maps and weight sets.
long project_count_mg_part_selected(Bproject *project)
Counts the number of particles in a project.
General image parameter class.
Utilities for timing functions.
Bparticle * part_find_first(Bproject *project)
Finds the first particle in a project.
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.
int main(int argc, char **argv)
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
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.
Bplot * fsc(double hi_res, double sampling_ratio=1)
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.
Generalized matrix class.
Header file for micrograph processing.
void sampling(double x, double y, double z)
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
DataType
Base data type specifier.
int particle_kill(Bparticle *part)
Frees a list of particles.
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
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.
long statistics()
Calculates the statistics for an image.
long part_set_filament_maps(Bproject *project)
Generates a selection number from the group number for each filament.
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.