 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
26 "Usage: bmultislice [options] input.pdb/input_pot.img output.img",
27 "---------------------------------------------------------------",
28 "Simulates electron imaging using a multi-slice approach.",
29 "The output file contains the projection image.",
30 "The calculation of the atomic potential can be done in real space (fast but less accurate).",
31 "or in reciprocal space (slow but more accurate), both using atomic electron scattering curves.",
34 "-Volt 100 Set the acceleration voltage (required to calculate exit wave and final image).",
35 "-Defocus 1.2,1.0,47 Defocus average & deviation, and astigmatism angle (required to apply CTF).",
36 "-poisson Add poisson noise.",
37 "-gaussian 0.2 Add gaussian noise with the given signal-to-noise ratio.",
38 "-MTF 17.5 Set the MTF decay constant (required to impose MTF).",
41 "-verbose 7 Verbosity of output.",
42 "-datatype b Data type of the projection image (default floating point).",
43 "-size 100,80,70 Size (default automatic voxels).",
44 "-origin 0,0,0 Origin placement within image (default 0,0,0).",
45 "-sampling 1,1.3,1.1 Sampling in angstrom/voxel (default 1,1,1).",
46 "-thickness 20 Slice thickness in angstrom (default 10).",
47 "-resolution 8.5 Resolution limits (default Nyquest frequency).",
48 "-Cs 2.0 Set the spherical aberration, Cs (default 2.0 mm).",
49 "-Cc 2.0 Set the chromatic aberration, Cc (default 2.0 mm).",
50 "-Amplitude 0.07 Set the amplitude contrast (default 0.07).",
51 "-alpha 0.5 Set the source size (default 0.1 milliradians).",
52 "-energyspread 2e-5 Set the effective energy spread (default 1e-5).",
53 "-electrondose 35.5 Set the electron dose (default 20 angstrom/pixel).",
54 "-Bfactor 24.5 Set the overall temperature factor (default 0).",
55 "-type real Type of potential calculation (default reciprocal, other gauss).",
58 "-parameters param.star Parameter file name for electron scattering curves(default atom_prop.star).",
61 "-potential pot.img Output atomic potential image(s).",
62 "-wave wav.img Output exit wave image.",
67 int main(
int argc,
char **argv)
86 double energy_spread(1e-5);
101 for ( curropt = option; curropt; curropt = curropt->
next ) {
102 if ( curropt->
tag ==
"datatype" )
104 if ( curropt->
tag ==
"size" )
105 size = curropt->
size();
106 if ( curropt->
tag ==
"origin" ) {
107 origin = curropt->
origin();
110 if ( curropt->
tag ==
"sampling" ) {
111 sam = curropt->
scale();
114 if ( curropt->
tag ==
"thickness" )
115 if ( ( thickness = curropt->
value.
real() ) < 0.001 )
116 cerr <<
"-thickness: A slice thickness must be specified!" << endl;
117 if ( curropt->
tag ==
"resolution" )
118 if ( ( resolution = curropt->
value.
real() ) < 0.001 )
119 cerr <<
"-resolution: A resolution limit must be specified!" << endl;
120 if ( curropt->
tag ==
"Defocus" ) {
121 if ( curropt->
values(def_avg, def_dev, ast_angle) < 1 )
122 cerr <<
"-Defocus: At least the defocus average must be specified!" << endl;
124 if ( def_avg < 100 ) def_avg *= 1e4;
125 if ( def_dev < 100 ) def_dev *= 1e4;
126 ast_angle *=
M_PI/180;
129 if ( curropt->
tag ==
"Cs" ) {
130 if ( ( Cs = curropt->
value.
real() ) < 0.001 )
131 cerr <<
"-Cs: A Cs value must be specified!" << endl;
132 else if ( Cs < 1e3 ) Cs *= 1e7;
134 if ( curropt->
tag ==
"Cc" ) {
135 if ( ( Cc = curropt->
value.
real() ) < 0.001 )
136 cerr <<
"-Cc: A Cc value must be specified!" << endl;
137 else if ( Cc < 1e3 ) Cc *= 1e7;
139 if ( curropt->
tag ==
"Volt" ) {
140 if ( ( volt = curropt->
value.
real() ) < 0.001 )
141 cerr <<
"-Volt: A voltage must be specified!" << endl;
143 if ( volt < 1e3 ) volt *= 1e3;
145 if ( curropt->
tag ==
"Amplitude" ) {
146 if ( ( amp_fac = curropt->
value.
real() ) < 0 )
147 cerr <<
"-Amplitude: A fraction must be specified!" << endl;
149 if ( amp_fac > 1 ) amp_fac /= 100;
150 if ( amp_fac < 0 ) amp_fac = 0;
153 if ( curropt->
tag ==
"alpha" ) {
154 if ( ( alpha = curropt->
value.
real() ) < 0.001 )
155 cerr <<
"-alpha: A beam source size or divergence must be specified!" << endl;
157 if ( alpha > 0.01 ) alpha /= 1000;
158 if ( alpha < 0 ) alpha = 0;
161 if ( curropt->
tag ==
"energyspread" ) {
162 if ( ( energy_spread = curropt->
value.
real() ) < 0.001 )
163 cerr <<
"-energyspread: A energy spread must be specified!" << endl;
165 if ( energy_spread > 0.001 ) energy_spread /= 1e5;
166 if ( energy_spread < 0 ) energy_spread = 0;
169 if ( curropt->
tag ==
"electrondose" )
170 if ( ( dose = curropt->
value.
real() ) < 0.001 )
171 cerr <<
"-electrondose: The electron dose must be specified!" << endl;
172 if ( curropt->
tag ==
"poisson" )
174 if ( curropt->
tag ==
"gaussian" )
175 if ( ( gauss = curropt->
value.
real() ) < 0.0000001 )
176 cerr <<
"-gaussian: The signal-to-noise ratio must be specified!" << endl;
177 if ( curropt->
tag ==
"MTF" )
178 if ( ( kmtf = curropt->
value.
real() ) < 0.001 )
179 cerr <<
"-MTF: The MTF decay constant must be specified!" << endl;
180 if ( curropt->
tag ==
"Bfactor" )
181 if ( ( Bfactor = curropt->
value.
real() ) < 0.001 )
182 cerr <<
"-Bfactor: A temperature factor must be specified!" << endl;
183 if ( curropt->
tag ==
"type" ) {
188 if ( curropt->
tag ==
"Parameter" )
190 if ( curropt->
tag ==
"potential" )
191 potentialfile = curropt->
filename();
192 if ( curropt->
tag ==
"wave" )
200 Bstring filename(argv[optind]);
209 resolution, Bfactor, paramfile, pottype);
210 if ( potentialfile.
length() ) {
211 pgrate = ppot->
copy();
214 cout <<
"Writing the atomic potential image(s)" << endl;
223 pgrate =
read_img(argv[optind++], 1, -1);
224 if ( set_sampling ) pgrate->
sampling(sam);
228 if ( pgrate == NULL ) {
229 cerr <<
"Error: No coordinate or image file given!" << endl;
242 if ( exitwavefile.
length() ) {
244 pwav->
fft(FFTW_BACKWARD, 2);
248 cout <<
"Writing the exit wave image" << endl;
254 img_apply_complex_CTF(p, def_avg, def_dev, ast_angle, volt, Cs, Cc, sin(amp_fac), alpha, energy_spread);
256 p->
fft(FFTW_BACKWARD, 2);
275 if ( optind < argc ) {
280 cout <<
"Writing the simulated projection image" << endl;
284 if ( p != pgrate )
delete pgrate;
A class for a command line input option.
int rescale(double scale, double shift)
Rescales the image data with a given multiplier and offset.
void complex_to_intensities()
The intensities from a complex image is written to a simple image.
Generates and manipulates projects for multislice calculations.
Vector3< double > scale()
int molgroup_kill(Bmolgroup *molgroup)
Destroys a molecule group.
int img_calc_phase_grating(Bimage *p, double volt)
Calculates the phase grating approximation from the atomic potential.
Bimage * copy()
Copies the header information and data of an image into a new image structure.
void simple_to_complex()
A simple image is converted to a complex image.
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.
Bmolgroup * read_molecule(const char *filename, const char *select, const char *paramfile)
The generalized function for reading molecular files.
Header file for option handlers.
Vector3< double > origin()
double standard_deviation()
long values(T1 &v1, T2 &v2)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
int img_apply_complex_CTF(Bimage *p, double def_avg, double def_dev, double ast_angle, double volts, double Cs, double Cc, double amp_shift, double alpha, double energy_spread)
Applies a complex CTF function to a Fourier transform.
Header file for reading reflection files.
FourierType fourier_type()
int noise_gaussian(double ravg=0, double rstd=1)
Generates an image with a gaussian random distribution of densities.
Functions for CTF (contrast transfer function) processing.
General image parameter class.
CompoundType compound_type()
double average(long cc, double xf, double yf, double zf, long nn, double iscale)
Averages in 3D when scaling is less than 1.
Utilities for timing functions.
double timer_start()
Starts timer and prints the time.
int fspace_weigh_B_factor(double B, double resolution=0)
Weighs an image's amplitudes with B-factor (gaussian) curve.
Header file for general utilities.
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.
Generalized matrix class.
int noise_poisson(double ravg)
Generates an image with a poisson random distribution of densities.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
void sampling(long nn, Vector3< double > u)
DataType
Base data type specifier.
bool contains(const Bstring &s)
int main(int argc, char **argv)
Header file for functions to calculate a 3D map from atomic coordinates.
void complex_to_real()
The real part of a complex image is written to a simple image.
Bimage * img_calc_potential(Bmolgroup *molgroup, Vector3< long > size, Vector3< double > origin, Vector3< double > sam, double thickness, double resolution, double Bfactor, Bstring ¶mfile, int type)
Calculates the atomic potential.
Library routines used for atomic coordinates.
Bimage * img_calc_multi_slice(Bimage *pgrate, double thickness, double volt, double resolution)
Simulates the electron imaging process using a multi-slice approach.