 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
19 int img_fft_times(
int ndim,
int minsize,
int maxsize,
int opt);
24 "Usage: bfft [options] file.hkl file.mrc",
25 "---------------------------------------",
26 "Fast Fourier transforms to and from image and reflection formats.",
29 "-inverse Backward transform (default forward).",
30 "-phaseshift Shift phase by half of the size.",
31 "-powerspectrum Calculate powerspectrum estimate (can be used with the -tile option).",
32 "-average Average multiple power spectra (can be used with the -tile option).",
33 "-logarithm Calculate the logarithm of the power spectrum.",
34 "-color 1.5 Generate a phase-coloured power spectrum: amplitude scaling.",
37 "-zeroorigin Zero the transform origin.",
38 "-halfshift Shift correlation map by half the size to put the origin in the middle.",
40 "-test 2,75,278,1 Test FFT execution time: dimensions,size min and max, and optimization flag.",
43 "-verbose 7 Verbosity of output.",
44 "-datatype u Force writing of a new data type.",
45 "-resolution 4.5,130 Resolution (default 0 - 10000 angstrom).",
46 "-free 15 % flagged for R-free calculations (default 10).",
47 "-origin 0,-10,30 Set origin, used with -size option (default 0,0,0).",
48 "-size 22,33,14 Size for transform or hkl input (voxels, default from data).",
49 "-sampling 2,3.5,1 Sampling (angstrom/voxel, a single value sets all three).",
50 "-unitcell 100,100,100,90,90,90 Unit cell parameters.",
51 "-symmetry 1 Space group.",
52 "-tile 1024,1024,1 Size of tiles for calculating a power spectrum.",
60 int main(
int argc,
char **argv)
77 double hires(0), lores(1e4);
85 double colour_phase_scale(0);
97 for ( curropt = option; curropt; curropt = curropt->
next ) {
98 if ( curropt->
tag ==
"datatype" )
100 if ( curropt->
tag ==
"inverse" ) setdir = FFTW_BACKWARD;
101 if ( curropt->
tag ==
"phaseshift" ) phase_shift = 1;
102 if ( curropt->
tag ==
"powerspectrum" ) setpower |= 1;
103 if ( curropt->
tag ==
"average" ) setpower |= 2;
104 if ( curropt->
tag ==
"logarithm" ) { setpower |= 8; }
105 if ( curropt->
tag ==
"halfshift" ) { setpower |= 4; halfshift = 1; }
106 if ( curropt->
tag ==
"color" )
107 if ( ( colour_phase_scale = curropt->
value.
real() ) < 0.001 )
108 cerr <<
"-color: A scale for the phase colours must be specified" << endl;
109 if ( curropt->
tag ==
"test" )
110 if ( curropt->
values(test_dim, test_minsize, test_maxsize, test_opt) < 2 )
111 cerr <<
"-test: At least the number of dimensions and one size must be specified" << endl;
112 if ( curropt->
tag ==
"zeroorigin" ) zero_origin = 1;
113 if ( curropt->
tag ==
"cone" ) {
114 if ( ( cone = curropt->
value.
real() ) < 1 )
115 cerr <<
"-cone: A cone angle must be specified" << endl;
118 if ( cone < 0 ) cone = -cone;
121 if ( curropt->
tag ==
"resolution" ) {
122 if ( curropt->
values(hires, lores) < 1 )
123 cerr <<
"-resolution: A high resolution limit must be specified" << endl;
127 if ( curropt->
tag ==
"weigh" )
129 if ( curropt->
tag ==
"cutoff" ) {
130 if ( ( fomcut = curropt->
value.
real() ) < 0.001 )
131 cerr <<
"-cutoff: FOM cutoff must be specified" << endl;
134 if ( fomcut < 0 ) fomcut = 0;
136 if ( curropt->
tag ==
"free" )
137 if ( ( pfree = curropt->
value.
real() ) < 0.001 )
138 cerr <<
"-free: %% reflections flagged must be specified" << endl;
139 if ( curropt->
tag ==
"origin" ) {
140 nuorigin = curropt->
origin();
143 if ( curropt->
tag ==
"size" )
144 size = curropt->
size();
145 if ( curropt->
tag ==
"sampling" )
146 sam = curropt->
scale();
147 if ( curropt->
tag ==
"unitcell" )
149 if ( curropt->
tag ==
"symmetry" )
151 cerr <<
"-symmetry: The space group number must be specified" << endl;
152 if ( curropt->
tag ==
"tile" )
153 tile_size = curropt->
size();
154 if ( curropt->
tag ==
"Postscript" )
162 fftwf_init_threads();
168 if ( test_dim && test_minsize )
169 img_fft_times(test_dim, test_minsize, test_maxsize, test_opt);
175 if ( optind >= argc-1 ) {
177 }
else if ( ( p =
read_img(argv[optind++], 1, -1) ) == NULL ) {
178 cerr <<
"File not read!" << endl;
192 if ( set_origin ) p->
origin(nuorigin);
210 cout <<
"DEBUG bfft: setpower=" << setpower << endl;
213 if ( tile_size.
volume() > 0 ) {
226 if ( p->
fft(setdir) )
227 return error_show(
"bfft", __FILE__, __LINE__);
241 if ( colour_phase_scale > 0 ) {
248 Bstring filename(
"ps_color_wheel.png");
257 if ( optind < argc ) {
266 fftwf_cleanup_threads();
290 long i, size, nprime;
293 double tvs, tvp, tvf;
297 if ( ndim < 1 ) ndim = 1;
298 if ( ndim > 3 ) ndim = 3;
299 if ( minsize < 1 ) minsize = 1;
300 if ( maxsize < minsize ) maxsize = minsize;
302 long n = maxsize - minsize + 1;
305 cout << endl <<
"Timing the execution of fast Fourier transforms:" << endl;
306 cout <<
"FFTW planner option: " << opt << endl;
307 cout <<
"Number of dimensions: " << ndim << endl;
308 cout <<
"Size range: " << minsize <<
" - " << maxsize << endl << endl;
309 cout <<
"Size\tPtime\tEtime\tPrime factors" << endl;
310 for ( size = minsize; size <= maxsize; size++ ) {
326 if ( p->
fft(plan, 0) )
327 return error_show(
"img_fft_times", __FILE__, __LINE__);
332 cout << size <<
tab << fixed << setprecision(5) << dtp <<
tab << dte;
333 for ( i=0; i<nprime; i++ ) cout <<
tab << prime[i];
337 t[size-minsize].
i = size;
338 t[size-minsize].
f = dte;
344 cout <<
"Ordered times:" << endl;
345 cout <<
"Size\tEtime" << endl;
346 for ( i=0, size=minsize; i<n; i++, size++ ) cout << t[i].i <<
tab << t[i].f << endl;
A class for a command line input option.
Header file for utility functions for use in qsort calls.
fft_plan fft_setup(fft_direction dir, int opt=0)
Sets up a plan for fast Fourier transforms.
int main(int argc, char **argv)
Vector3< double > scale()
size_t system_processors()
Returns the number of processors.
void zero_fourier_origin()
Zeroes the first voxel in each image.
int img_fft_times(int ndim, int minsize, int maxsize, int opt)
Tests the execution times for a series of image sizes.
int QsortSmallToLargeIntFloat(const void *x, const void *y)
Utility function for sorting int float pairs in qsort.
void unit_cell(UnitCell uc)
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.
Vector3< double > origin()
int phase_colour_wheel()
Generates a phase color wheel.
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.
Vector3< double > change_transform_size(Vector3< long > nusize)
Resizes a "standard" transform.
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
FourierType fourier_type()
int power_spectrum(int flags=0)
Calculates a power spectrum.
General image parameter class.
CompoundType compound_type()
Utilities for timing functions.
int center_wrap()
Centers an image with wrapping.
double timer_start()
Starts timer and prints the time.
long * prime_factors(long number, long &n)
Finds all the prime factor for the input number.
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.
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Bimage * intensities_phase_colored(double scale)
Generates a power spectrum with phases colored according to a color wheel.
void sampling(long nn, Vector3< double > u)
double getwalltime()
Returns the current time.
Bimage * powerspectrum_tiled(long img_num, Vector3< long > tile_size, int flags=0)
Prepares a tiled power spectrum from an image for determining CTF parameters.
DataType
Base data type specifier.
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.