Bsoft  1.9
Bernard's software package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
img_reconstruct.cpp
Go to the documentation of this file.
1 
9 #include "mg_processing.h"
10 #include "img_reconstruct.h"
11 #include "img_ctf.h"
12 #include "Matrix3.h"
13 #include "Complex.h"
14 #include "linked_list.h"
15 #include "rwimg.h"
16 #include "utilities.h"
17 
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20 
22  float* weight, float* weight2, double part_weight,
23  int interp_type, Vector3<double> vscale)
24 {
25  size_t j;
26  long xx, yy, zz, jx, jy, jz;
27  double w(part_weight);
28  Vector3<long> coor;
30 
31  float* fom = pmap->FOM();
32 
33  if ( interp_type < 2 ) { // Nearest neighbour
34  coor = Vector3<long>((long) floor(m.x() + 0.5),
35  (long) floor(m.y() + 0.5),
36  (long) floor(m.z() + 0.5));
37  if ( interp_type == 1 ) { // Weighted nearest neighbour
38  d = m - coor;
39  d /= vscale;
40  w *= 1 - d.length();
41  }
42  if ( w > 0 ) {
43  j = pmap->index_wrap(coor);
44  pmap->add(j, cv * w);
45  fom[j] += w*cv.power();
46  weight[j] += w;
47  weight2[j] += w*w;
48  }
49  } else if ( interp_type == 2 ) { // Trilinear interpolation
50  coor = Vector3<long>((long) floor(m.x()),
51  (long) floor(m.y()),
52  (long) floor(m.z()));
53  d = m - coor;
54  for ( zz=0; zz<2; zz++ ) {
55  jz = coor.z() + zz;
56  if ( jz < 0 ) jz += pmap->sizeZ();
57  else if ( jz >= pmap->sizeZ() ) jz -= pmap->sizeZ();
58  d[2] = 1.0 - d[2];
59  for ( yy=0; yy<2; yy++ ) {
60  jy = coor.y() + yy;
61  if ( jy < 0 ) jy += pmap->sizeY();
62  else if ( jy >= pmap->sizeY() ) jy -= pmap->sizeY();
63  d[1] = 1.0 - d[1];
64  for ( xx=0; xx<2; xx++ ) {
65  jx = coor.x() + xx;
66  if ( jx < 0 ) jx += pmap->sizeX();
67  else if ( jx >= pmap->sizeX() ) jx -= pmap->sizeX();
68  d[0] = 1.0 - d[0];
69  w = d.volume() * part_weight;
70  j = pmap->index(jx, jy, jz);
71  pmap->add(j, cv * w);
72  fom[j] += w*cv.power();
73  weight[j] += w;
74  weight2[j] += w*w;
75  }
76  }
77  }
78  }
79 
80  return 0;
81 }
82 
109  float* weight, float* weight2, Bsymmetry* sym, double hi_res, double scale,
110  int ft_size, fft_plan plan, double part_weight,
111  int interp_type, CTFparam* em_ctf, int ctf_action)
112 {
113  if ( !p->data_pointer() ) return -1;
114 
115  if ( hi_res < 2*pmap->sampling().x() ) hi_res = 2*pmap->sampling().x();
116 
117  p->change_type(Float);
118 
119 // if ( p->rescale_to_avg_std(0, 1) ) return -1;
120 
121  p->calculate_background((size_t)0);
122 
123  Vector3<double> shift(-p->image->origin() + p->size()/2);
124 
125  double pad_ratio(ft_size*1.0L/p->sizeX());
126 
127  if ( pad_ratio > 1 ) {
128  pad_ratio *= pad_ratio;
129  part_weight /= pad_ratio;
130  p->pad(ft_size, FILL_BACKGROUND, p->image->background());
131 // p->pad(ft_size, FILL_AVERAGE, p->average());
132 // p->pad(ft_size, FILL_USER, 0);
133  }
134 
135  if ( verbose & VERB_DEBUG )
136  cout << "DEBUG img_pack_2D_in_recip_space: Doing FFT " << ft_size << "x" << ft_size << " now" << endl;
137 
138 // cout << "Pad ratio = " << pad_ratio << " Image size = " << p->size() << endl;
139  p->fft(plan, 1);
140 
141  if ( verbose & VERB_DEBUG )
142  cout << "DEBUG img_pack_2D_in_recip_space: FFT done" << endl;
143 
145 
146  if ( ctf_action ) img_ctf_apply(p, em_ctf, ctf_action, 0.2, 0, hi_res);
147 
148  double max_rad_sq = pmap->sampling().x()/hi_res;
149  if ( max_rad_sq > 0.5 ) max_rad_sq = 0.5;
150  max_rad_sq *= max_rad_sq;
151 
152  size_t i, j, x, y;
153  long xx, yy, zz, jx, jy, jz;
154  double w(1), d2;
155  size_t hx = (p->sizeX() - 1)/2, hy = (p->sizeY() - 1)/2;
156  Matrix3 mat(1), mf(1);
157  Vector3<long> coor;
158  Vector3<double> m, d, iv;
159  Vector3<double> invsize(1.0/pmap->sizeX(), 1.0/pmap->sizeY(), 1.0/pmap->sizeZ());
160  Vector3<double> vscale(pmap->size());
161  vscale /= scale*ft_size;
162  if ( pmap->sizeZ() < 2 ) vscale[2] = 1;
163 
164  if ( verbose & VERB_DEBUG )
165  cout << "DEBUG img_pack_2D_in_recip_space: vscale = " << vscale << endl;
166 
167  float* fom = pmap->FOM();
168 
169  if ( verbose & VERB_FULL )
170  cout << "Packing an image into reciprocal space up to " << hi_res << " A resolution" << endl << endl;
171 
172  View* v;
173  View asu_view(p->image->view());
174  View* view = symmetry_get_all_views(sym, asu_view);
175 
176  if ( verbose & VERB_DEBUG )
177  cout << "DEBUG img_pack_2D_in_recip_space: view = " << asu_view << endl;
178 
179  for ( v=view; v; v=v->next ) {
180  mat = v->matrix();
181  mf = vscale * mat;
182  if ( verbose & VERB_FULL )
183  cout << mat << shift << endl;
184 // cout << vscale << endl << mat << mf << endl;
185 // mb = mat.transpose();
186 
187  if ( verbose & VERB_DEBUG )
188  cout << mat << endl;
189 
190  for ( y=i=0; y<p->sizeY(); y++ ) {
191  iv[1] = y;
192  if ( y > hy ) iv[1] -= p->sizeY();
193  for ( x=0; x<p->sizeX(); x++, i++ ) {
194  iv[0] = x;
195  if ( x > hx ) iv[0] -= p->sizeX();
196  m = mf * iv;
197  d2 = (m * invsize).length2();
198  if ( d2 < max_rad_sq ) {
200  weight, weight2, part_weight, interp_type, vscale);
201  }
202  }
203  }
204  }
205 
206  kill_list((char *) view, sizeof(View));
207 
208  return 0;
209 }
210 
221 int part_ft_size(int xsize, double scale, int pad_factor)
222 {
223  if ( xsize <= 0 ) {
224  error_show("Error in part_ft_size", __FILE__, __LINE__);
225  cerr << "Size not set!" << endl << endl;
226  return 0;
227  }
228 
229  int ft_size = (int) (xsize*scale);
230 
231  if ( pad_factor < 1 ) return ft_size;
232 
233  if ( pad_factor > 8 ) pad_factor = 8;
234 
235  ft_size = findNextPowerOf((int)(pad_factor*xsize*scale), 2);
236 
237  if ( ft_size < xsize )
238  ft_size = findNextPowerOf(pad_factor*xsize, 2);
239 
240 // if ( ft_size < xsize/scale )
241 // ft_size = findNextPowerOf((int)(xsize/scale), 2);
242 
243  return ft_size;
244 }
245 
257 {
258  size_t i, cov(0);
259  size_t datasize = prec->sizeX()*prec->sizeY()*prec->sizeZ();
260  double data2, w;
261  Complex<double> cv;
262 
263  float* fom = prec->FOM();
264  float* weight = (float *) prec->next->data_pointer();
265  float* weight2 = prec->next->FOM();
266 
267  weight[0] = 0;
268 
269  prec->FOM_maximum(1);
270  for ( i=0; i<datasize; i++ ) {
271  if ( weight[i] > SMALLFLOAT ) {
272  prec->set(i, prec->complex(i) / weight[i]);
273  cov++;
274  w = weight[i]*weight[i] - weight2[i]; // Unbiased weighting
275  if ( w > 0.001 ) {
276  data2 = (prec->complex(i)).power(); // Signal power
277  fom[i] = (fom[i] - weight[i]*data2)/w; // Noise variance estimator with noise reduction
278  fom[i] = data2/fom[i] - 1; // SNR
279 // if ( fom[i] < 0 ) fom[i] = 0;
280  } else fom[i] = 0;
281  } else {
282  prec->set(i, cv);
283  fom[i] = 0;
284  }
285  }
286  fom[0] = 1; // The zero frequency contains no information
287 
288  return cov;
289 }
290 
315 Bimage* img_reconstruction_sum_weigh(Bimage** pacc, int imap, int nmaps, int nthreads, double hi_res)
316 {
317  int maps_per_class = nthreads;
318  int iclass = imap/nmaps;
319 
320  Bimage* prec = pacc[0]->copy_header();
321  prec->data_alloc();
322  float* fom = prec->FOM_initialize();
323 
324  Bimage* pweight = new Bimage(Float, TSimple, prec->size().x(), prec->size().y(), prec->size().z(), 1);
325  float* weight = (float *) pweight->data_pointer();
326  float* weight2 = pweight->FOM_initialize();
327  prec->next = pweight;
328 
329  size_t i, j, k, n(0);
330  size_t datasize = (size_t) prec->size().volume();
331  double data2, cc;
332  Complex<double> cv;
333  float* fom_acc;
334  float* w_acc;
335  float* w2_acc;
336 
337  size_t st(0), inc(1);
338  if ( nmaps == 2 ) {
339  st = imap%2;
340  inc = 2;
341  }
342  if ( nmaps == 3 && imap%3 ) {
343  st = imap%3 - 1;
344  inc = 2;
345  }
346 
347  for ( i=iclass*maps_per_class+st, j=st; j<maps_per_class; i+=inc, j+=inc ) {
348 // cout << "Doing map " << i << endl;
349  fom_acc = pacc[i]->FOM();
350  w_acc = (float *) pacc[i]->next->data_pointer();
351  w2_acc = pacc[i]->next->FOM();
352  for ( k=0; k<datasize; k++ ) {
353  prec->add(k, pacc[i]->complex(k));
354  fom[k] += fom_acc[k];
355  weight[k] += w_acc[k];
356  weight2[k] += w2_acc[k];
357  }
358  n++;
359  }
360 
361  if ( verbose & VERB_DEBUG )
362  cout << "DEBUG img_reconstruction_weigh: volumes accumulated: " << n << endl;
363 
364  weight[0] = fom[0] = 0;
365 
366  size_t hist[11], cov(0);
367  for ( j=0; j<11; j++ ) hist[j] = 0;
368  for ( i=0; i<datasize; i++ ) {
369  if ( weight[i] > SMALLFLOAT ) {
370  prec->set(i, prec->complex(i) / weight[i]);
371  cov++;
372  data2 = (prec->complex(i)).power(); // Signal power
373 // fom[i] = (fom[i] - (weight[i] - 1)*data2)/(weight[i]*weight[i]);
374  fom[i] /= weight[i];
375  if ( fom[i] < 0 ) fom[i] = 0;
376  cc = data2/(fom[i] + data2);
377  if ( cc > 0 ) cc = sqrt(cc);
378  else cc = 0;
379  } else {
380  prec->set(i, cv);
381  fom[i] = 0;
382  cc = 0;
383  }
384  j = (size_t) (10*cc + 0.5);
385  if ( j > 10 ) j = 10;
386  hist[j]++;
387  }
388  fom[0] = 1; // The zero frequency contains no information
389 
390  double Rf = prec->friedel_check();
391 // if ( Rf > 0.001 ) prec->friedel_apply();
392 
393 // double r3 = hi_res*hi_res*hi_res;
394 // double s3 = prec->sampling().volume();
395 // double n3 = (prec->sizeX() + 1)*(prec->sizeY() + 1)*(prec->sizeZ() + 1);
396  size_t vol = datasize;
397 
398  if ( verbose ) {
399  if ( inc == 1 )
400  cout << "Full reconstruction:" << endl;
401  else
402  cout << "Half reconstruction " << st+1 << ":" << endl;
403  cout << "Friedel symmetry residual: " << Rf << endl;
404  cout << "Coverage:" << endl;
405  cout << "FOM\tNumber\t%" << endl;
406  for ( j=0; j<11; j++ ) cout <<
407  j/10.0 << tab << hist[j] << tab << hist[j]*100.0/vol << endl;
408  cout << "Total number of voxels: " << vol << endl;
409  cout << "Total coverage: " << cov << endl;
410  cout << "Percentage coverage: " << cov*100.0/vol << " %" << endl << endl;
411  }
412 
413 // if ( verbose & VERB_PROCESS )
414 // if ( verbose && imap%nmaps == 0 )
415  if ( imap%nmaps == 0 )
416  img_reconstruction_stats(prec, hi_res);
417 
418  if ( verbose & VERB_DEBUG )
419  write_img("weight.map", pweight);
420 
421  delete pweight;
422  prec->next = NULL;
423 
424  prec->phase_shift_to_center();
425  prec->origin(prec->size()/2);
426 
427  return prec;
428 }
429 
439 int img_reconstruction_stats(Bimage* p, double resolution)
440 {
441  if ( p->compound_type() != TComplex ) return -1;
442 
443  if ( !p->FOM() ) return -1;
444 
445 
446  long i, n, x, y, z, xx, yy, zz;
447  long maxrad, iradius, iradius2;
448  double radius, rad_scale, rx, ry, rz;
449  double fraction, fraction2, pwr, noise, uw;
450  Vector3<double> realsize(p->real_size());
451  Vector3<double> freq_scale(1.0/realsize);
452 
453  rad_scale = realsize.x();
454  if ( rad_scale < realsize.y() ) rad_scale = realsize.y();
455  if ( rad_scale < realsize.z() ) rad_scale = realsize.z();
456  maxrad = p->sizeX();
457  if ( maxrad < p->sizeY() ) maxrad = p->sizeY();
458  if ( maxrad < p->sizeZ() ) maxrad = p->sizeZ();
459  if ( resolution > 0.1 )
460  maxrad = (long) (rad_scale/resolution);
461  else
462  maxrad = (long) (maxrad/2.0);
463 
464  if ( verbose & VERB_PROCESS ) {
465  cout << "Reconstruction statistics:" << endl;
466  cout << "Resolution limit: " << resolution << " A" << endl;
467  cout << "Maximum reciprocal radius: " << maxrad << endl;
468  cout << "Maximum FOM: " << p->FOM_maximum() << endl;
469  cout << endl;
470  }
471 
472  float* fom = p->FOM();
473  float* weight = (float *) p->next->data_pointer();
474  float* weight2 = (float *) p->next->FOM();
475 
476  float* s = new float[maxrad]; // Reciprocal distance
477  float* num = new float[maxrad]; // # reflections per shell
478  float* w = new float[maxrad]; // Weight sum per shell
479  float* f = new float[maxrad]; // FOM sum
480  float* a = new float[maxrad]; // Average power sum
481  float* np = new float[maxrad]; // Noise power sum
482  float* cov = new float[maxrad]; // # with FOM > 0
483  for ( i=0; i<maxrad; i++ ) s[i] = num[i] = w[i] = f[i] = a[i] = np[i] = cov[i] = 0;
484 
485  for ( i=n=0; n<p->images(); n++ ) {
486  for ( z=0; z<p->sizeZ(); z++ ) {
487  zz = z;
488  if ( z > (p->sizeZ() - 1)/2 ) zz -= p->sizeZ();
489  rz = zz*freq_scale.z();
490  for ( y=0; y<p->sizeY(); y++ ) {
491  yy = y;
492  if ( y > (p->sizeY() - 1)/2 ) yy -= p->sizeY();
493  ry = yy*freq_scale.y();
494  for ( x=0; x<p->sizeX(); x++, i++ ) {
495  xx = x;
496  if ( x > (p->sizeX() - 1)/2 ) xx -= p->sizeX();
497  rx = xx*freq_scale.x();
498  radius = rad_scale*sqrt(rx*rx + ry*ry + rz*rz);
499  iradius = (long) radius;
500  iradius2 = iradius + 1;
501  if ( iradius2 < maxrad ) {
502  fraction = radius - iradius;
503  fraction2 = 1.0 - fraction;
504  num[iradius] += fraction2;
505  num[iradius2] += fraction;
506  pwr = p->complex(i).power();
507  a[iradius] += fraction2 * pwr;
508  a[iradius2] += fraction * pwr;
509  f[iradius] += fraction2*fom[i];
510  f[iradius2] += fraction*fom[i];
511  w[iradius] += fraction2*weight[i];
512  w[iradius2] += fraction*weight[i];
513  if ( weight[i] ) {
514 // noise = 0;
515  noise = fom[i] - pwr;
516 // if ( weight[i] > SMALLFLOAT )
517 // noise = (fom[i] - pwr*(weight[i] - 1)/weight[i])/weight[i];
518 // noise = fom[i] - pwr*(weight[i] - 1)/weight[i];
519 // noise = (fom[i] - pwr)/weight[i];
520 // if ( weight[i] > 1 )
521 // noise = (fom[i] - pwr)/(weight[i]-1);
522  uw = weight[i]*weight[i] - weight2[i];
523  if ( uw > SMALLFLOAT )
524  noise = (fom[i] - pwr)*weight[i]/uw;
525 // if ( noise < SMALLFLOAT ) noise = SMALLFLOAT;
526  if ( noise < 0 ) noise = 0;
527  np[iradius] += fraction2*noise;
528  np[iradius2] += fraction*noise;
529  cov[iradius] += fraction2;
530  cov[iradius2] += fraction;
531  }
532  }
533  }
534  }
535  }
536  }
537 
538  double res, fsc, fscp(1), snr, snrp(10), sc(0), res_fsc(0), res_snr(0);
539  double fsc_cut(0.3), snr_cut(0.5);
540 
541  cout << "k\tn\tP\tS\tN\tR" << endl;
542  for ( i=1; i<maxrad; i++ ) if ( num[i] ) {
543 // cout << num[i] << tab << w[i] << tab << i*w[i]/num[i] << endl;
544  w[i] /= num[i];
545  f[i] /= num[i];
546  a[i] /= num[i];
547  np[i] /= num[i];
548  cov[i] /= num[i];
549 // np[i] = (f[i] - a[i])/w[i];
550 // np[i] = (f[i] - a[i])/sqrt(w[i]);
551 // np[i] /= w[i];
552 // np[i] *= 3.2;
553  cout << i << tab << 2*i*w[i] << tab << f[i] << tab << a[i] << tab << np[i] << tab << np[i]/a[i] << endl;
554  sc += np[i]/a[i];
555  }
556 // cout << "Average noise/amp ratio: " << sc/maxrad << endl;
557 
558  if ( verbose ) {
559  cout << "Radius\ts(1/A)\tRes(A)\tnRefl\tCov\tWeight\tNoise\tFSC\tSNR" << endl;
560  for ( i=1; i<maxrad; i++ ) {
561  s[i] = i/rad_scale;
562  res = rad_scale/i;
563  fsc = snr = noise = 0;
564  if ( num[i] ) {
565  noise = 2*sqrt(a[i]*np[i]);
566 // fsc = (a[i] + noise)/(f[i] + np[i]);
567 // fsc = (a[i] - noise))/f[i];
568  // van Heel
569 // fsc = (a[i] + (noise + np[i])/sqrt(num[i]))/(a[i] + noise/sqrt(num[i]) + np[i]);
570  // Simple
571 // fsc = a[i]/f[i];
572 // fsc = a[i]/(a[i]+np[i]+noise);
573  fsc = 1 - np[i]/a[i];
574 // fsc = 1 - np[i]/a[i] - 2*sqrt(np[i]/a[i]);
575 // fsc = 1 - (np[i] + 2*sqrt(a[i]*np[i]))/(a[i]-np[i]);
576  if ( fsc < 1 ) snr = fsc/(1 - fsc);
577  else snr = 1e10;
578  // Based on SSNR
579 // if ( isfinite(np[i]) && np[i] > 0 ) {
580 // snr = a[i]/(np[i] + 2*sqrt(a[i]*np[i])) - 1;
581 // snr = a[i]/np[i] - 1;
582 // if ( snr < 0 ) snr = 0;
583 // fsc = snr/(snr + 1);
584 // }
585  }
586  if ( fscp >= fsc_cut && fsc < fsc_cut ) {
587  sc = s[i] - (fsc_cut - fsc)/((fscp - fsc)*rad_scale);
588  res_fsc = 1/sc;
589  }
590  if ( snrp >= snr_cut && snr < snr_cut ) {
591  sc = s[i] - (snr_cut - snr)/((snrp - snr)*rad_scale);
592  res_snr = 1/sc;
593  }
594  fscp = fsc;
595  snrp = snr;
596  cout << i << tab << setprecision(4) << s[i] << tab
597  << setprecision(2) << res << tab << num[i] << tab
598  << setprecision(4) << cov[i] << tab
599  << setprecision(2) << w[i] << tab
600  << setprecision(6) << np[i] << tab
601  << setprecision(4) << fsc << tab << snr << endl;
602  }
603  cout << endl;
604  cout << "Resolution estimates:" << endl;
605  cout << "FSC(0.3): " << res_fsc << " A" << endl;
606  cout << "SNR(0.5): " << res_snr << " A" << endl << endl;
607  }
608 
609  delete[] s;
610  delete[] num;
611  delete[] w;
612  delete[] f;
613  delete[] a;
614  delete[] np;
615  delete[] cov;
616 
617  return 0;
618 }
619 
630  int nmaps, int nthreads)
631 {
632  if ( verbose & VERB_DEBUG )
633  cout << "DEBUG img_backprojection_accumulate:" << endl;
634 
635  int maps_per_class = nthreads;
636  int iclass = imap/nmaps;
637 
638  Bimage* prec = pacc[0]->copy_header();
639  prec->data_alloc();
640 
641  size_t i, j, k;
642  size_t datasize = (size_t) prec->size().volume();
643 
644  size_t st(0), inc(1);
645  if ( nmaps == 2 ) {
646  st = imap%2;
647  inc = 2;
648  }
649  if ( nmaps == 3 && imap%3 ) {
650  st = imap%3 - 1;
651  inc = 2;
652  }
653 
654  if ( verbose & VERB_DEBUG ) {
655  cout << "DEBUG img_backprojection_weigh: nmaps=" << nmaps << " imap=" << imap << endl;
656  cout << "DEBUG img_backprojection_weigh: maps_per_class=" << maps_per_class << " iclass=" << iclass << endl;
657  cout << "DEBUG img_backprojection_weigh: st=" << st << " inc=" << inc << endl;
658  }
659 
660  for ( i=iclass*maps_per_class+st, j=st; j<maps_per_class; i+=inc, j+=inc ) {
661 // cout << "Doing map " << i << endl;
662  for ( k=0; k<datasize; k++ )
663  prec->add(k, pacc[i]->complex(k));
664  }
665 
666  prec->statistics();
667  prec->calculate_background((size_t)0);
668 
669  if ( verbose & VERB_DEBUG )
670  cout << "DEBUG img_backprojection_weigh: Accumulation done" << endl;
671 
672  return prec;
673 }
674 
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1520
Type z()
Definition: Vector3.h:139
void sizeZ(size_t nz)
Definition: Bimage.h:312
Bimage * copy_header()
Definition: Bimage.h:518
#define FILL_BACKGROUND
Definition: utilities.h:167
void view(double x, double y, double z, double a)
Definition: Bimage.h:116
size_t img_reconstruction_weigh(Bimage *prec)
Weighs a reconstruction.
int img_pack_2D_in_recip_space(Bimage *p, Bimage *pmap, float *weight, float *weight2, Bsymmetry *sym, double hi_res, double scale, int ft_size, fft_plan plan, double part_weight, int interp_type, CTFparam *em_ctf, int ctf_action)
Packs a 2D Fourier transform into a 3D reciprocal space volume.
View * next
Definition: View.h:28
double length()
Definition: Vector3.h:196
#define SMALLFLOAT
Definition: utilities.h:43
int calculate_background(size_t nn)
Calculates the background for one sub-image.
int fft()
Definition: Bimage.h:663
Header file for general utilities.
#define VERB_DEBUG
Definition: utilities.h:105
int verbose
double background()
Definition: Bimage.h:107
CompoundType compound_type()
Definition: Bimage.h:287
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Class for complex numbers.
int error_show(const char *message, const char *file, int line)
Displays the error with file and line reference.
Definition: utilities.cpp:687
size_t index(size_t nx, size_t ny) const
Definition: Bimage.h:316
#define VERB_PROCESS
Definition: utilities.h:100
Vector3< size_t > size() const
Definition: Bimage.h:307
size_t statistics()
Calculates the statistics for an image.
3x3 Matrix manipulation functions
Definition: Bimage.h:51
General image parameter class.
Definition: Bimage.h:133
Vector3< double > real_size()
Definition: Bimage.h:417
unsigned char * data_alloc()
Definition: Bimage.h:207
Header file for generalized linked list functions.
float * FOM_initialize()
Allocates and initializes the FOM block.
Definition: Bimage.cpp:677
int phase_shift_to_center()
Phase shifts a set of reflections to the nominal center of the image origin.
Complex< double > complex(size_t j)
Returns a complex value at the given index.
Definition: Bimage.cpp:861
void sampling(double s)
Definition: Bimage.h:420
float * FOM()
Definition: Bimage.h:220
int img_reconstruction_stats(Bimage *p, double resolution)
Calculates Fourier shell statistics.
int phase_shift_to_origin()
Phase shifts a set of reflections to the image origin.
Type x()
Definition: Vector3.h:137
void origin(double x, double y, double z)
Definition: Bimage.h:113
void add(size_t j, double v)
Definition: Bimage.h:248
void set(size_t j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:953
size_t index_wrap(long nx, long ny, long nz) const
Definition: Bimage.h:331
double FOM_maximum()
Definition: Bimage.h:222
int write_img(const char *filename, Bimage *p)
General driver function to write multiple image formats This is the only image writing function that ...
Definition: rwimg.cpp:255
Bimage * next
Definition: Bimage.h:135
size_t images()
Definition: Bimage.h:418
Header file for CTF (contrast transfer function) functions.
unsigned char * data_pointer()
Definition: Bimage.h:212
void sizeX(size_t nx)
Definition: Bimage.h:310
Matrix3 matrix()
Definition: View.h:137
Header file for 2D and 3D reconstruction.
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.
int pad(size_t sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
void sizeY(size_t ny)
Definition: Bimage.h:311
Definition: View.h:26
Bimage * img_backprojection_accumulate(Bimage **pacc, int imap, int nmaps, int nthreads)
Accumulates multiple backprojections.
double friedel_check()
Checks Friedel symmetry.
Header file for micrograph processing.
Header file for 2D and 3D image I/O.
double power()
Definition: Complex.h:103
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
Definition: utilities.cpp:404
#define VERB_FULL
Definition: utilities.h:102
double volume()
Definition: Vector3.h:205
Type y()
Definition: Vector3.h:138
int img_ctf_apply(Bimage *p, CTFparam *em_ctf, int action, double wiener, double lores, double hires)
Definition: img_ctf.cpp:330
View * symmetry_get_all_views(Bsymmetry *sym, View asu_view)
Get all symmetry-related views of one given view.
Definition: symmetry.cpp:382
ostream & tab(ostream &out)
Definition: utilities.cpp:21
int img_reconstruction_interpolation(Complex< float > cv, Bimage *pmap, Vector3< double > m, float *weight, float *weight2, double part_weight, int interp_type, Vector3< double > vscale)
Bsub_image * image
Definition: Bimage.h:164
void origin(double ox, double oy, double oz)
Definition: Bimage.h:463
int part_ft_size(int xsize, double scale, int pad_factor)
Sets the Fourier transform size for 2D particle images for reconstruction.
Definition: ctf.h:24