 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
22 "Usage: bradial [options] input.img output.img",
23 "---------------------------------------------",
24 "Calculates radial profiles of 2D and 3D images.",
25 "The origin within the image will be used by default to calculate a radial profile.",
26 "To use the radial fit, the sampling (voxel sizes) for the two images",
27 " must be within 20 % correct. Successive calibrations with the same input",
28 " will not necessarily give the exact same factors on output because ",
29 " the simplex algorithm with random initial parameters is used.",
32 "-subtractbackground Calculate and subtract the background before calculating radial profiles.",
33 "-radial Radial average profile.",
34 "-elliptical 1.2,20 Elliptical average profile with given ellipticity and angle.",
36 "-Radialps 15.5,1 Radial power spectrum up to a given resolution (in angstrom).",
37 " and a flag to average multiple power spectra.",
38 "-polar 156,24,35 Polar image: annuli, phi steps, theta steps.",
39 "-cylindrical 124,36 Cylindrical image: annuli, phi steps.",
40 "-shells Calculate radial shells projected along the z-axis.",
41 "-expand 150,150,1 Size to generate a 2D or 3D image from a radial profile (use with -origin).",
42 "-average Average multiple images before writing an output image.",
43 "-logarithm Calculate logarithm of radial power spectrum.",
44 "-reslice -z+xy Reslice (switch axes) after all other operations.",
45 "-coverage 1.4 Shell coverage for the given threshold.",
48 "-verbose 7 Verbosity of output.",
49 "-datatype u Force writing of a new data type.",
50 "-sampling 1.5,1.5,1.5 Sampling (default from image; a single value can be given).",
51 "-origin 0,-10,30 Set the origin for radial profile (default image origin).",
52 "-minmax 4,123 Minimum and maximum radii for radial and volume profiles (angstrom).",
53 "-step 2.68 Step size for radial profiles (default pixel size in angstrom).",
54 "-wrap Flag to wrap around image boundaries (default not).",
57 "-fit file.img Map to fit radial profile of input image to.",
58 "-Mask mask.tif Mask to limit calculations.",
61 "-Postscript rad.ps Postscript output file name.",
66 int main(
int argc,
char **argv)
73 int subtract_background(0);
79 double minrad(0), maxrad(0);
80 double ellipticity(1);
83 int nannuli(-1), ntheta(-1), nphi(-1);
88 double threshold(-1e37);
99 for ( curropt = option; curropt; curropt = curropt->
next ) {
100 if ( curropt->
tag ==
"subtractbackground" )
101 subtract_background = 1;
102 if ( curropt->
tag ==
"datatype" )
104 if ( curropt->
tag ==
"origin" ) {
105 if ( curropt->
value[0] ==
'c' ) {
108 origin = curropt->
origin();
112 if ( curropt->
tag ==
"sampling" )
113 sam = curropt->
scale();
114 if ( curropt->
tag ==
"polar" )
115 if ( curropt->
values(nannuli, nphi, ntheta) < 3 )
116 cerr <<
"-polar: All three dimensions must be specified!" << endl;
117 if ( curropt->
tag ==
"cylindrical" )
118 if ( curropt->
values(nannuli, nphi) < 2 )
119 cerr <<
"-cylindrical: Both dimensions must be specified!" << endl;
120 if ( curropt->
tag ==
"shells" )
122 if ( curropt->
tag ==
"radial" ) setradial = 1;
123 if ( curropt->
tag ==
"elliptical" ) {
124 if ( curropt->
values(ellipticity, angle) < 2 )
125 cerr <<
"-elliptical: Both ellipticity and angle must be specified!" << endl;
131 if ( curropt->
tag ==
"volume" ) {
132 if ( ( threshold = curropt->
value.
real() ) < -1e30 )
133 cerr <<
"-volume: A threshold must be specified!" << endl;
137 if ( curropt->
tag ==
"Radialps" )
138 if ( curropt->
values(resolution, avg_flag) < 1 )
139 cerr <<
"-Radialps: A resolution limit must be specified!" << endl;
140 if ( curropt->
tag ==
"expand" )
141 expand_size = curropt->
size();
142 if ( curropt->
tag ==
"average" )
144 if ( curropt->
tag ==
"logarithm" )
146 if ( curropt->
tag ==
"reslice" ) {
148 cerr <<
"-reslice: The order of x, y and z must be specified!" << endl;
150 order = curropt->
value;
154 if ( curropt->
tag ==
"coverage" ) {
158 if ( curropt->
tag ==
"fit" ) {
160 if ( mapfile.
length() ) setradial = 1;
162 if ( curropt->
tag ==
"minmax" )
163 if ( curropt->
values(minrad, maxrad) < 1 )
164 cerr <<
"-minmax: At least a minimum must be specified!" << endl;
165 if ( curropt->
tag ==
"step" )
166 if ( ( step = curropt->
value.
real() ) < 0.1 )
167 cerr <<
"-step: A step size must be specified!" << endl;
168 if ( curropt->
tag ==
"wrap" )
170 if ( curropt->
tag ==
"Mask" )
172 if ( curropt->
tag ==
"Postscript" )
180 if ( setradial || resolution || optind < argc - 1 ) dataflag = 1;
183 cerr <<
"Error: No input file read!" << endl;
192 if ( optind < argc ) outfile = argv[optind];
197 if ( subtract_background ) {
204 double* fit_result = NULL;
225 if ( set_origin == 2 ) p->
origin(p->
size()/2);
229 long minpix(minrad/(step*p->
sampling(0)[0]));
230 long maxpix(maxrad/(step*p->
sampling(0)[0]));
234 if ( p->
sizeY() > 1 ) {
235 prad = p->
radial(minpix, maxpix, step, ellipticity, angle, pmask, wrap);
242 title =
"Radial fit";
245 title =
"Radial plot";
250 plot =
new Bplot(1, nx, n);
257 for ( i=1; i<n; i++ ) {
273 if ( pmap->
sizeY() > 1 ) {
274 pmaprad = pmap->
radial(minpix, maxpix, step, ellipticity, angle, pmask, wrap);
281 for ( i=0; i<nx; i++ ) (*plot)[i] = prad->
sampling(0)[0]*i;
282 for ( i=0, k=nx; i<nx; i++, k++ ) (*plot)[k] = (*pmaprad)[i];
283 for ( i=0; i<nx; i++, k++ ) {
287 if ( j >= 0 && j < nx-1 )
288 (*plot)[k] = fit_result[1]*((1-f)*(*prad)[j] + f*(*prad)[j+1]) + fit_result[2];
291 scale[0] = scale[1] = scale[2] = fit_result[0];
294 cout <<
"DEBUG bradial: Scale = " << scale[0] << endl;
295 if ( outfile.
length() > 0 ) {
302 cout <<
"Radial averages:" << endl;
304 for ( j=0; j<prad->
images(); j++ ) cout <<
tab << j+1;
308 for ( i=0; i<nx; i++ ) {
309 if ( prad->
sampling(0)[0]*i >= minrad ) {
311 for ( j=0; j<prad->
images(); j++ ) cout <<
tab << (*prad)[nx*j+i];
316 for ( i=0; i<nx; i++ ) (*plot)[i] = prad->
sampling(0)[0]*i;
317 for ( i=0, k=nx; i<nx*prad->
images(); i++, k++ ) (*plot)[k] = (*prad)[i];
323 }
else if ( resolution > 0 ) {
332 title =
"Radial power spectrum";
335 plot =
new Bplot(1, nx, n);
342 for ( i=1; i<n; i++ ) {
356 for ( i=0; i<nx; i++ ) (*plot)[i] = p->
sampling(0)[0]*i;
357 for ( i=0, k=nx; i<nx*p->
images(); i++, k++ ) (*plot)[k] = (*p)[i];
359 }
else if ( expand_size.
volume() > 0 ) {
364 }
else if ( nannuli > -1 ) {
365 if ( ntheta > 0 && p->
sizeZ() > 1 )
372 }
else if ( set_shells ) {
374 }
else if ( coverage ) {
378 if ( psfile.
length() && plot )
385 if ( setreslice ) p->
reslice(order);
392 if ( pmap )
delete pmap;
393 if ( prad )
delete prad;
394 if ( pmaprad )
delete pmaprad;
395 if ( pmask )
delete pmask;
396 if ( plot )
delete plot;
A class for a command line input option.
Bimage * fspace_radial_power(double resolution, double sampling_ratio=1)
Calculates the radial power spectrum from a Fourier transform.
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
Vector3< double > scale()
void reslice(const char *order)
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.
Bimage * radial(long minrad, long maxrad, double rad_step=1, int wrap=0)
Calculates the radial average of an image.
double background(long nn)
Vector3< long > size() const
Header file for option handlers.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
int transform(Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
Transforms an image by translation, rotation, scaling and skewing, in place.
Vector3< double > origin()
int radial_shells()
Calculates an image with slices representing radial shell projections.
Header file for postscript output functions.
Bimage * cartesian_to_cylindrical(long nannuli, long nphi, int flag=0)
Calculates an image with cylindrical coordinates.
double * radial_fit(Bimage *pref)
Fits a radial profile to a reference radial profile.
Bimage * radial_coverage(double threshold, double rad_step=1)
Calculates the coverage in each radial shell.
long values(T1 &v1, T2 &v2)
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
void origin(double x, double y, double z)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Bimage * radial_to_full(Vector3< long > nusize, Vector3< double > origin)
Generates a full 2D or 3D image from a radial profile in a 1D image.
General image parameter class.
CompoundType compound_type()
Utilities for timing functions.
double timer_start()
Starts timer and prints the time.
Header file for general utilities.
ostream & tab(ostream &out)
double timer_report(double lasttime)
Reports the time elapsed since a given time.
void origin(double ox, double oy, double oz)
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 option_kill(Boption *option)
Deallocates a linked list of option structures.
unsigned char * data_pointer()
void sampling(long nn, Vector3< double > u)
int subtract_background()
Subtracts the background for each sub-image.
DataType
Base data type specifier.
void logarithm()
Calculates the logarithm of the image data.
Bimage * cartesian_to_spherical(long nannuli, long nphi, long ntheta)
Calculates an image with spherical coordinates.
int main(int argc, char **argv)