Bsoft  2.1.0
Bernard's software package
bproject.cpp
Go to the documentation of this file.
1 
9 #include "rwimg.h"
10 #include "matrix_util.h"
11 #include "symmetry.h"
12 #include "ps_views.h"
13 #include "linked_list.h"
14 #include "options.h"
15 #include "utilities.h"
16 #include "timer.h"
17 
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20 
21 // Function prototypes
22 Matrix img_compare_projections(Bimage* p, double SNR, double hires, double lores, double shift_limit);
23 int img_compare_projections_lowpass(Bimage* p, double SNR, double shift_limit);
24 JSvalue js_views(View* views);
25 
26 // Usage assistance
27 const char* use[] = {
28 " ",
29 "Usage: bproject [options] input.img output.img",
30 "----------------------------------------------",
31 "Projects a 3D map and calculating comparison statistics of the projections.",
32 "If the input is a 2D image, it is assumed to be projections.",
33 " ",
34 "Actions:",
35 "-axis y,2 Project down a major axis (x, y, z).",
36 " and a flag for minimum (1) or maximum (2).",
37 "-kernel 6,2 Reciprocal space projection: kernel size and power.",
38 "-average 7,5,3 Averaging/smoothing filter before projection: kernel size.",
39 "-rescale -0.1,5.2 Rescale data to average and standard deviation (after -truncate).",
40 "-View 0.3,-0.5,0.8,33 View to generate symmetry-related projections.",
41 "-Tilt -65,72,2.5,55 Tilt series of projections with angle min, max, step and axis angle.",
42 "-side 15 Generate side view projections within the given angle from the equator.",
43 "-compare 0.02,15 Compare projections, with the given SNR imposed and shift limit (default off).",
44 "-random 24 Generate a number of random projections.",
45 "-asu Change to views to fit into the asymmetric unit.",
46 "-edgewidth 80 Gaussian width of edge to background (default 0).",
47 " ",
48 "Parameters:",
49 "-verbose 7 Verbosity of output.",
50 "-datatype u Force writing of a new data type.",
51 "-origin 10,-10,20 Origin for rotation (voxels, default 0,0,0).",
52 "-sampling 2,3.5,1 Sampling (angstrom/voxel, a single value sets all three).",
53 "-resolution 15.6,200 High and low resolution limits (default 0,1e30).",
54 "-fill 127 Fill value for resizing: average (default), background, or value.",
55 "-symmetry D6 Symmetry: Point group identifier.",
56 "-angles 8,6 Step sizes for theta and phi in the asymmetric unit, one value sets both.",
57 "-noinplanerotation No in-plane rotations applied to projections (default applied).",
58 "-nonormalization No normalization applied to projections (default applied).",
59 "-unitcell 10,23,77,90,90,90 Unit cell parameters.",
60 " ",
61 "Output:",
62 "-Plotviews plot.ps Output postscript file with a plot of projection vectors.",
63 "-json views.json Output JSON file with views.",
64 "-Matrix cc.dat Projection comparison matrix.",
65 "-Map cc.map Projection comparison matrix in an image.",
66 " ",
67 NULL
68 };
69 
70 int main(int argc, char **argv)
71 {
72  // Initialize variables
73  DataType nudatatype(Unknown_Type); // Conversion to new type
74  char axis('n'); // Projection axis
75  int flags(1); // Flags to modify axis-projection
76  int kernel_width(0); // Reciprocal space kernel width
77  int kernel_power(2); // Reciprocal space kernel power
78  Vector3<long> average_kernel; // Average filter kernel size
79  double nuavg(0), nustd(0); // Rescaling to average and stdev
80  Vector3<double> origin; // Origin
81  int set_origin(0); // Flag to set origin
82  Vector3<double> sam; // Units for the three axes (A/pixel)
83  double hires(0), lores(1e30); // High resolution limit
84  Bstring symmetry_string("C1"); // Default: asymmetric or C1 point group
85  double theta_step(0); // Angular step size for theta
86  double phi_step(0); // Angular step size for phi
87  double ang_min(0), ang_max(0), ang_step(0), ang_axis(0); // Tilt series
88  double side_ang(-1); // Side view variation angle
89  double edge_width(0); // Gaussian width of edge
90  int setfill(0);
91  double fill(0);
92  int fill_type(FILL_BACKGROUND); // Fill type for resizing
93  double compare_snr(0); // SNR to compare projections
94  double shift_limit(-1); // Shift limit for projection comparison
95  int lowpass(0); // Flag to do low-pass range comparison
96  int asu(0); // Flag to change views to ASU
97  int nviews(0); // Number of views
98  int spacegroup(0); // Spacegroup
99  UnitCell uc(0,0,0,M_PI_2,M_PI_2,M_PI_2);
100  int view_flag(1); // Flag for projection generation
101  View theview; // View to generate symmetry-related projections
102  int symviews(0); // Flag to generate symmetry-related projections
103  int ps_flag(0); // Flag for postscript output
104  Bstring ps_file;
105  Bstring js_file;
106  Bstring matrix_file;
107  Bstring map_file;
108 
109  int i, optind;
110  Boption* option = get_option_list(use, argc, argv, optind);
111  Boption* curropt;
112  for ( curropt = option; curropt; curropt = curropt->next ) {
113  if ( curropt->tag == "axis" ) {
114  if ( ( axis = curropt->value[0] ) < 'a' )
115  cerr << "-axis: An axis for projection must be specified!" << endl;
116  if ( curropt->value.post(',').length() ) {
117  i = 2 * curropt->value.post(',').integer();
118  flags |= i;
119  }
120  }
121  if ( curropt->tag == "kernel" )
122  if ( curropt->values(kernel_width, kernel_power) < 1 )
123  cerr << "-kernel: At least the kernel size must be specified!" << endl;
124  if ( curropt->tag == "average" ) {
125  if ( ( i = curropt->values(average_kernel[0],
126  average_kernel[1], average_kernel[2]) ) < 1 )
127  cerr << "-average: The kernel edge size must be specified!" << endl;
128  else
129  if ( i < 2 ) average_kernel[2] = average_kernel[1] = average_kernel[0];
130  }
131  if ( curropt->tag == "rescale" )
132  if ( curropt->values(nuavg, nustd) < 2 )
133  cerr << "-rescale: Both average and standard deviation must be specified!" << endl;
134  if ( curropt->tag == "datatype" )
135  nudatatype = curropt->datatype();
136  if ( curropt->tag == "origin" ) {
137  if ( curropt->value[0] == 'c' ) {
138  set_origin = 2;
139  } else {
140  origin = curropt->origin();
141  set_origin = 1;
142  }
143  }
144  if ( curropt->tag == "sampling" )
145  sam = curropt->scale();
146  if ( curropt->tag == "resolution" )
147  if ( curropt->values(hires, lores) < 1 )
148  cerr << "-resolution: A resolution limit must be specified!" << endl;
149  if ( curropt->tag == "fill" ) {
150  if ( ! ( fill = curropt->value.real() ) )
151  cerr << "-fill: A fill value must be specified!" << endl;
152  else
153  setfill = 1;
154  }
155  if ( curropt->tag == "compare" )
156  if ( curropt->values(compare_snr, shift_limit, lowpass) < 1 )
157  cerr << "-compare: A SNR value must be specified!" << endl;
158  if ( curropt->tag == "asu" )
159  asu = 1;
160  if ( curropt->tag == "edgewidth" )
161  if ( ( edge_width = curropt->value.real() ) < 0.001 )
162  cerr << "-edgewidth: An edge width must be specified!" << endl;
163  if ( curropt->tag == "random" )
164  if ( ( nviews = curropt->value.integer() ) < 1 )
165  cerr << "-random: A number of views must be specified!" << endl;
166  if ( curropt->tag == "symmetry" )
167  symmetry_string = curropt->symmetry_string();
168  if ( curropt->tag == "angles" ) {
169  if ( ( i = curropt->values(theta_step, phi_step) ) < 1 )
170  cerr << "-angles: An angle step size must be specified!" << endl;
171  else {
172  theta_step *= M_PI/180.0;
173  if ( i < 2 ) phi_step = theta_step;
174  else phi_step *= M_PI/180.0;
175  }
176  }
177  if ( curropt->tag == "unitcell" )
178  uc = curropt->unit_cell();
179  if ( curropt->tag == "noinplanerotation" )
180  view_flag |= 2;
181  if ( curropt->tag == "nonormalization" )
182  view_flag |= 4;
183  if ( curropt->tag == "View" ) {
184  theview = curropt->view();
185  symviews = ps_flag = 1;
186  }
187  if ( curropt->tag == "Tilt" ) {
188  if ( curropt->values(ang_min, ang_max, ang_step, ang_axis) < 3 )
189  cerr << "-Tilt: Three angles must be specified!" << endl;
190  else {
191  ang_min *= M_PI/180.0;
192  ang_max *= M_PI/180.0;
193  ang_step *= M_PI/180.0;
194  ang_axis *= M_PI/180.0;
195  }
196  }
197  if ( curropt->tag == "side" ) {
198  if ( ( side_ang = curropt->value.real() ) < 0.001 )
199  cerr << "-side: One angle must be specified!" << endl;
200  else
201  side_ang *= M_PI/180.0;
202  }
203  if ( curropt->tag == "Plotviews" )
204  ps_file = curropt->filename();
205  if ( curropt->tag == "json" )
206  js_file = curropt->filename();
207  if ( curropt->tag == "Matrix" )
208  matrix_file = curropt->filename();
209  if ( curropt->tag == "Map" )
210  map_file = curropt->filename();
211  }
212  option_kill(option);
213 
214  double ti = timer_start();
215 
216 #ifdef HAVE_GCD
217  fftwf_init_threads();
218 // fftwf_plan_with_nthreads(system_processors());
219 #endif
220  if ( verbose )
221  cout << "Number of threads: " << system_processors() << endl;
222 
223  Bsymmetry* sym = init_point_group_symmetry(symmetry_string);
224  View* views = NULL;
225 
226  if ( axis == 'n' ) {
227  if ( nviews ) {
228  views = random_views(nviews);
229  } else if ( side_ang > -1 ) {
230  views = side_views(sym, side_ang, theta_step, phi_step);
231  } else if ( ang_step ) {
232  views = tilt_views(ang_min, ang_max, ang_step, ang_axis);
233  } else if ( symviews ) {
234  views = symmetry_get_all_views(sym, theview);
235  } else if ( theta_step && phi_step ) {
236  views = asymmetric_unit_views(sym, theta_step, phi_step, view_flag);
237  ps_flag = 1;
238  }
239  if ( views ) {
240  nviews = count_list((char *) views);
241  if ( verbose )
242  cout << "Generating " << nviews << " projections" <<endl << endl;
243  if ( asu ) change_views_to_asymmetric_unit(sym, views);
244  if ( ps_file.length() )
245  ps_views(ps_file, symmetry_string, views, ps_flag);
246  if ( js_file.length() ) {
247  string fn(js_file.c_str());
248  JSvalue js = js_views(views);
249  js.write(fn);
250  }
251  }
252  } else if ( axis == 'z' ) {
253  views = new View(0,0,1,0);
254  } else if ( axis == 'y' ) {
255  views = new View(0,1,0,0);
256  } else if ( axis == 'x' ) {
257  views = new View(1,0,0,0);
258  }
259 
260  kill_symmetry(sym);
261 
262  if ( optind >= argc ) {
263  if ( views ) kill_list((char *) views, sizeof(View));
264  bexit(0);
265  }
266 
267  FSI_Kernel* kernel = NULL;
268  if ( kernel_width > 1 )
269  kernel = new FSI_Kernel(kernel_width, kernel_power);
270 
271  // Read image file
272  int dataflag(0);
273  if ( optind < argc - 1 ) dataflag = 1;
274  if ( compare_snr ) dataflag = 1;
275 
276  Bimage* p = read_img(argv[optind++], dataflag, -1);
277  if ( p == NULL ) bexit(-1);
278 
279  if ( nudatatype == Unknown_Type )
280  nudatatype = p->data_type(); // Preserve the old type
281 
282  if ( spacegroup ) p->space_group(spacegroup);
283 
284  if ( sam.volume() ) p->sampling(sam);
285 
286  if ( set_origin ) {
287  if ( set_origin == 2 ) p->origin(p->size()/2);
288  else p->origin(origin);
289  }
290 
292  if ( setfill ) p->background(fill);
293 
294  if ( uc.check() ) p->unit_cell(uc);
295 
296  if ( average_kernel[0] > 0 ) p->filter_average(average_kernel);
297 
298  Bimage* proj = p;
299  if ( axis != 'n' ) {
300  proj = p->project(axis, flags);
301  } else if ( p->sizeZ() > 1 && views ) {
302  if ( kernel )
303  proj = p->project(views, hires, kernel);
304  else
305  proj = p->project(views, !(view_flag&4));
306  }
307 
308  if ( views ) kill_list((char *) views, sizeof(View));
309 
310  Vector3<long> size((int)(proj->sizeX() - 2*edge_width),
311  (int)(proj->sizeY() - 2*edge_width), (int)(proj->sizeZ() - 2*edge_width));
312  origin[0] = origin[1] = origin[2] = edge_width;
313  if ( edge_width ) proj->edge(1, size, origin, edge_width, fill_type, fill);
314 
315  if ( nustd > 0 ) proj->rescale_to_avg_std(nuavg, nustd);
316 
317 // Matrix cc;
318 // Bimage* pmat;
319  if ( compare_snr > 0 ) {
320  if ( lowpass ) {
321  img_compare_projections_lowpass(proj, compare_snr, shift_limit);
322  } else {
323  Matrix cc = img_compare_projections(proj, compare_snr, hires, lores, shift_limit);
324  if ( matrix_file.length() ) cc.write(matrix_file);
325  if ( map_file.length() ) {
326  Bimage* pmat = new Bimage(cc, 1);
327  write_img(map_file, pmat, 0);
328  delete pmat;
329  }
330  }
331  }
332 
333  if ( optind < argc ) {
334  proj->change_type(nudatatype);
335  write_img(argv[optind], proj, 0);
336  }
337 
338  if ( p != proj ) delete p;
339  delete proj;
340  if ( kernel ) delete kernel;
341 
342 #ifdef HAVE_GCD
343  fftwf_cleanup_threads();
344 #endif
345 
346  if ( verbose & VERB_TIME )
347  timer_report(ti);
348 
349  bexit(0);
350 }
351 
352 /*
353  Compares all test images against one reference projection (i)
354 */
355 double img_compare_one_projection(Bimage* p, Bimage* pref, long i,
356  double hires, double lores, double radius, double sigma,
358 {
359  long j;
360  double cc1(0);
361  Bimage* px;
362 
363  Bimage* prefx = pref->extract(i);
364 
365  for ( j=0; j<p->images(); j++ ) {
366  px = p->extract(j);
367  px->find_shift(prefx, NULL, hires, lores, radius, sigma, 0, planf, planb, cc1);
368  (*cc)[i][j] = cc1;
369 // cc[j] = (px->image->origin() - prefx->image->origin()).length();
370 // cout << "Shift: " << (px->image->origin() - prefx->image->origin()).length() << endl;
371  delete px;
372  }
373 
374  delete prefx;
375 
376  return 0;
377 }
378 
379 Matrix* img_compare_projections_driver(Bimage* p, double SNR, double hires, double lores, double shift_limit)
380 {
381  if ( lores <= 0 ) lores = 1e30;
382  if ( hires < p->sampling(0)[0] ) hires = p->sampling(0)[0];
383  if ( hires > lores ) swap(hires, lores);
384  if ( shift_limit < 0 ) shift_limit = 1e30;
385 
386  p->change_type(Float);
387 
388  Bimage* pt = p->copy();
389 
390  if ( SNR < 101 ) pt->noise_gaussian(0, pt->standard_deviation()/sqrt(SNR));
391 
392 // write_img("pt.pif", pt);
393 
394  long n(p->images());
395  double sigma(0);
396 
397  Matrix* cc = new Matrix(n, n);
398 
399  fft_plan planf = p->fft_setup(FFTW_FORWARD, 1);
400  fft_plan planb = p->fft_setup(FFTW_BACKWARD, 1);
401 
402 #ifdef HAVE_GCD
403  dispatch_apply(n, dispatch_get_global_queue(0, 0), ^(size_t i){
404  img_compare_one_projection(pt, p, i, hires, lores, shift_limit, sigma, cc, planf, planb);
405  });
406 #else
407 #pragma omp parallel for
408  for ( long i=0; i<n; i++ )
409  img_compare_one_projection(pt, p, i, hires, lores, shift_limit, sigma, cc, planf, planb);
410 #endif
411 
414 
415  delete pt;
416 
417  return cc;
418 }
419 
420 
430 Matrix img_compare_projections(Bimage* p, double SNR, double hires, double lores, double shift_limit)
431 {
432  Matrix* ccp = img_compare_projections_driver(p, SNR, hires, lores, shift_limit);
433  Matrix cc = *ccp;
434 
435  long i, j, m, n(p->images()), nw(0), im;
436  double ccmax(0), ccmax1, ccavg(0), ccstd(0);
437 
438  if ( verbose & VERB_FULL )
439  cout << "Image1\tImage2\tCC" << endl;
440  for ( j=0; j<n; ++j ) {
441  im = 0;
442  ccmax1 = -1;
443  for ( i=0; i<n; ++i ) {
444  if ( ccmax1 < cc[i][j] ) {
445  ccmax1 = cc[i][j];
446  im = i;
447  }
448  if ( i == j ) ccmax += cc[i][j];
449  else {
450  ccavg += cc[i][j];
451  ccstd += cc[i][j]*cc[i][j];
452  }
453  if ( verbose & VERB_FULL )
454  cout << setprecision(5) << i << tab << j << tab << cc[i][j] << endl;
455  }
456  if ( j != im ) nw++;
457  if ( verbose )
458  cout << j << tab << im << tab << ccmax1 << endl;
459  }
460 
461  m = n*(n-1);
462  ccmax /= n;
463  ccavg /= m;
464  ccstd = ccstd/m - ccavg * ccavg;
465  if ( ccstd > 0 ) ccstd = sqrt(ccstd);
466  else ccstd = 0;
467 
468  if ( verbose ) {
469  cout << "Correlating all projections:" << endl;
470  cout << "Imposed SNR: " << SNR << endl;
471  cout << "Resolution limits: " << hires << " " << lores << endl;
472  cout << "Shift limit: " << shift_limit << endl;
473  cout << "CC maximum: " << ccmax << endl;
474  cout << "CC average: " << ccavg << endl;
475  cout << "CC standard deviation: " << ccstd << endl;
476  cout << "Fraction incorrect: " << nw*1.0/n << endl;
477  cout << "Relative maximum sigma units: " << (ccmax - ccavg)/ccstd << endl;
478  cout << "Fisher's z-transform: " << fishers_z_transform(ccmax) << endl;
479  if ( verbose & VERB_PROCESS )
480  cout << cc << endl;
481  }
482 
483  return cc;
484 }
485 
493 int img_compare_projections_lowpass(Bimage* p, double SNR, double shift_limit)
494 {
495 
496  unsigned long i, j, k, m, n(p->images());
497  double hires, lores(p->real_size()[0]);
498  double ccmax, ccavg, ccstd, cct;
499  Matrix* ccp;
500  Matrix cc;
501 
502  if ( verbose )
503  cout << "ResLim\tk\tCCmax\tCCavg\tCCstd\tCCth" << endl;
504  for ( hires = p->sampling(0)[0]; hires < lores; hires *= 2 ) {
505  ccp = img_compare_projections_driver(p, SNR, hires, lores, shift_limit);
506  cc = *ccp;
507 
508  ccmax = ccavg = ccstd = 0;
509  for ( m=i=0; i<n; i++ ) {
510  for ( j=0; j<n; j++, m++ ) {
511  if ( i == j ) ccmax += cc[i][j];
512  else {
513  ccavg += cc[i][j];
514  ccstd += cc[i][j]*cc[i][j];
515  }
516  if ( verbose & VERB_FULL )
517  cout << setprecision(5) << i << tab << j << tab << cc[i][j] << endl;
518  }
519  }
520 
521  m -= n;
522  ccmax /= n;
523  ccavg /= m;
524  ccstd = ccstd/m - ccavg * ccavg;
525  if ( ccstd > 0 ) ccstd = sqrt(ccstd);
526  else ccstd = 0;
527 
528  k = (unsigned long) (p->real_size()[0]/hires);
529  cct = p->sampling(0)[0]/hires;
530  cct *= M_PI*cct;
531  if ( cct > 1 ) cct = 1;
532  cct = sqrt(SNR/(SNR + cct));
533 
534  delete ccp;
535 
536  if ( verbose )
537  cout << hires << tab << k << tab << ccmax << tab << ccavg << tab << ccstd << tab << cct << endl;
538  }
539 
540  return 0;
541 }
542 
544 {
545  View* v;
546  vector<double> vv;
547  JSvalue js(JSarray);
548 
549  for ( v = views; v; v = v->next ) {
550  vv = v->array();
551  vv[3] *= 180.0/M_PI;
552  js.push_back(JSvalue(vv));
553  }
554 
555  return js;
556 }
557 
Boption
A class for a command line input option.
Definition: options.h:26
Bimage::fft_setup
fft_plan fft_setup(fft_direction dir, int opt=0)
Sets up a plan for fast Fourier transforms.
Definition: Bimage_fft.cpp:29
View::next
View * next
Definition: View.h:28
Bimage::real_size
Vector3< double > real_size()
Definition: Bimage.h:500
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:392
JSarray
@ JSarray
Definition: json.h:27
matrix_util.h
Utility functions for matrices.
Boption::unit_cell
UnitCell unit_cell()
Definition: options.h:279
Boption::scale
Vector3< double > scale()
Definition: options.h:190
symmetry_get_all_views
View * symmetry_get_all_views(Bsymmetry *sym, View asu_view)
Get all symmetry-related views of one given view.
Definition: symmetry.cpp:442
kill_list
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Definition: linked_list.cpp:214
system_processors
size_t system_processors()
Returns the number of processors.
Definition: utilities.cpp:193
Bstring
Definition: Bstring.h:29
Bstring::integer
long integer()
Definition: Bstring.cpp:547
Bimage::copy
Bimage * copy()
Copies the header information and data of an image into a new image structure.
Definition: Bimage.cpp:2702
Boption::datatype
DataType datatype()
Definition: options.h:93
symmetry.h
Header file for general symmetry functions.
random_views
View * random_views(int nviews)
Calculates a set of random views.
Definition: View.cpp:147
Boption::next
Boption * next
Definition: options.h:28
verbose
int verbose
Vector3< long >
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:390
Bimage::unit_cell
void unit_cell(UnitCell uc)
Definition: Bimage.h:608
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:280
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
Bimage::background
double background(long nn)
Definition: Bimage.h:549
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:386
Bstring::real
double real()
Definition: Bstring.cpp:553
options.h
Header file for option handlers.
Bimage::calculate_background
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Definition: Bimage_background.cpp:27
asymmetric_unit_views
View * asymmetric_unit_views(Bsymmetry *sym, double theta_step, double phi_step, int flag)
Initializes a well-distributed set of views in an asymmetric unit.
Definition: symmetry.cpp:564
View
Definition: View.h:26
Bstring::post
Bstring post(char c)
Definition: Bstring.cpp:402
Bimage::find_shift
int find_shift(Bimage *pref, Bimage *pmask, double hires, double lores, double radius, double sigma, int refine_flag)
Calculates a cross-correlation map to find the shift for the pair of images.
Definition: Bimage_correlate.cpp:929
Boption::origin
Vector3< double > origin()
Definition: options.h:180
Boption::view
View view()
Definition: options.h:247
VERB_PROCESS
#define VERB_PROCESS
Definition: utilities.h:111
Bsymmetry
Definition: symmetry.h:38
count_list
long count_list(char *list)
Counts the number of items in a linked list.
Definition: linked_list.cpp:235
M_PI_2
#define M_PI_2
Definition: utilities.h:66
Bimage::standard_deviation
double standard_deviation()
Definition: Bimage.h:544
Bstring::c_str
const char * c_str()
Definition: Bstring.h:70
change_views_to_asymmetric_unit
int change_views_to_asymmetric_unit(Bsymmetry *sym, View *view)
Change the views to those in the asymmetric unit.
Definition: symmetry.cpp:828
planf
fft_plan planf
Definition: bico.cpp:24
img_compare_projections
Matrix img_compare_projections(Bimage *p, double SNR, double hires, double lores, double shift_limit)
Compares a set of projections from a 3D density map.
Definition: bproject.cpp:430
Bimage::images
long images()
Definition: Bimage.h:504
Boption::tag
Bstring tag
Definition: options.h:29
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
read_img
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
Definition: rwimg.cpp:77
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:281
Bimage::project
Bimage * project(char axis, int flags=1)
Projects a 3D image to a 2D image down one of the three major axes.
Definition: Bimage_project.cpp:31
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:391
fft_destroy_plan
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
Definition: fft.cpp:87
img_compare_projections_lowpass
int img_compare_projections_lowpass(Bimage *p, double SNR, double shift_limit)
Compares a set of projections from a 3D density map.
Definition: bproject.cpp:493
Boption::value
Bstring value
Definition: options.h:30
Bimage::noise_gaussian
int noise_gaussian(double ravg=0, double rstd=1)
Generates an image with a gaussian random distribution of densities.
Definition: Bimage_noise.cpp:72
Bimage
General image parameter class.
Definition: Bimage.h:177
timer.h
Utilities for timing functions.
View::array
vector< double > array()
Definition: View.h:103
Unknown_Type
@ Unknown_Type
Definition: utilities.h:151
JSvalue
Definition: json.h:53
Boption::symmetry_string
Bstring symmetry_string()
Definition: options.h:233
use
const char * use[]
Definition: bproject.cpp:27
VERB_TIME
#define VERB_TIME
Definition: utilities.h:114
ps_views
int ps_views(Bstring &filename, Bstring &symmetry_string, View *view, int flags)
Generates postscript plot of views on the unit sphere.
Definition: ps_views.cpp:34
JSvalue::push_back
void push_back(const JSvalue &val)
Definition: json.h:197
side_views
View * side_views(Bsymmetry *sym, double side_ang, double theta_step, double phi_step)
Initializes a set of views around the z-axis for helical projection.
Definition: symmetry.cpp:763
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:61
Bimage::data_type
DataType data_type()
Definition: Bimage.h:362
M_PI
#define M_PI
Definition: utilities.h:63
utilities.h
Header file for general utilities.
UnitCell::check
bool check()
Definition: UnitCell.h:34
tab
ostream & tab(ostream &out)
Definition: utilities.cpp:22
Bstring::length
long length() const
Definition: Bstring.cpp:263
init_point_group_symmetry
Bsymmetry * init_point_group_symmetry(Bstring symmetry_string)
Sets up a symmetry structure from a string identifier.
Definition: symmetry.cpp:39
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:76
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:570
img_compare_projections_driver
Matrix * img_compare_projections_driver(Bimage *p, double SNR, double hires, double lores, double shift_limit)
Definition: bproject.cpp:379
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1765
Vector3::volume
double volume()
Definition: Vector3.h:237
rwimg.h
Header file for 2D and 3D image I/O.
tilt_views
View * tilt_views(double ang_min, double ang_max, double ang_step, double axis)
Initializes a set of views tilted around the y axis.
Definition: View.cpp:70
Bimage::filter_average
int filter_average(long kernel_size)
Applies an averaging filter to an image.
Definition: Bimage_filter.cpp:207
Bimage::extract
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Definition: Bimage_extract.cpp:21
fft_plan
fftwf_plan fft_plan
Definition: fft.h:20
Bimage::space_group
long space_group()
Definition: Bimage.h:598
kill_symmetry
int kill_symmetry(Bsymmetry *sym)
Deallocates a symmetry structure.
Definition: symmetry.cpp:207
linked_list.h
Header file for generalized linked list functions.
Boption::filename
Bstring filename()
Definition: options.h:85
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:111
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Matrix::write
void write(Bstring &filename)
Definition: Matrix.h:95
FILL_BACKGROUND
#define FILL_BACKGROUND
Definition: utilities.h:178
main
int main(int argc, char **argv)
Definition: bproject.cpp:70
planb
fft_plan planb
Definition: bico.cpp:24
fishers_z_transform
double fishers_z_transform(double value)
Calculates Fisher's z-transform.
Definition: math_util.cpp:249
Bimage::sampling
void sampling(long nn, Vector3< double > u)
Definition: Bimage.h:514
UnitCell
Definition: UnitCell.h:22
DataType
DataType
Base data type specifier.
Definition: utilities.h:150
Matrix
Definition: Matrix.h:22
Bimage::edge
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.
Definition: Bimage_edit.cpp:321
JSvalue::write
void write(string filename)
Definition: json.h:373
Float
@ Float
Definition: utilities.h:161
img_compare_one_projection
double img_compare_one_projection(Bimage *p, Bimage *pref, long i, double hires, double lores, double radius, double sigma, Matrix *cc, fft_plan planf, fft_plan planb)
Definition: bproject.cpp:355
ps_views.h
Header file for postscript tools dealing with views.
kernel
Definition: kernlut.h:14
js_views
JSvalue js_views(View *views)
Definition: bproject.cpp:543
FSI_Kernel
Definition: FSI_Kernel.h:14
Bimage::rescale_to_avg_std
int rescale_to_avg_std(double nuavg, double nustd)
Rescales the image data to a given average and standard deviation.
Definition: Bimage_rescale.cpp:163