#include <ctf.h>
Inheritance diagram for EMAN::EMAN2Ctf:
Public Member Functions | |
vector< float > | get_snr () |
void | set_snr (const vector< float > &vf) |
vector< float > | get_background () |
void | set_background (const vector< float > &vf) |
EMAN2Ctf () | |
EMAN2Ctf (const vector< float > &vf) | |
~EMAN2Ctf () | |
vector< float > | compute_1d (int size, float ds, CtfType type, XYData *struct_factor=0) |
void | compute_2d_real (EMData *image, CtfType type, XYData *struct_factor=0) |
void | compute_2d_complex (EMData *image, CtfType type, XYData *struct_factor=0) |
int | from_string (const string &ctf) |
string | to_string () const |
void | from_dict (const Dict &dict) |
Dict | to_dict () const |
void | from_vector (const vector< float > &vctf) |
vector< float > | to_vector () const |
void | copy_from (const Ctf *new_ctf) |
bool | equal (const Ctf *ctf1) const |
Public Attributes | |
float | dfdiff |
float | dfang |
float | ampcont |
float | dsbg |
vector< float > | background |
vector< float > | snr |
Private Member Functions | |
float | calc_amp1 () |
float | calc_lambda () |
float | calc_g1 () |
float | calc_g2 () |
float | calc_gamma (float g1, float g2, float s) |
float | calc_ctf1 (float g, float gamma, float s) |
float | calc_amplitude (float gamma) |
float | calc_noise (float s) |
Definition at line 222 of file ctf.h.
EMAN2Ctf::EMAN2Ctf | ( | ) |
Definition at line 473 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00474 { 00475 defocus = 0; 00476 dfdiff = 0; 00477 dfang = 0; 00478 bfactor = 0; 00479 ampcont = 0; 00480 voltage = 0; 00481 cs = 0; 00482 apix = 1.0; 00483 dsbg=-1; 00484 background.clear(); 00485 snr.clear(); 00486 }
EMAN::EMAN2Ctf::EMAN2Ctf | ( | const vector< float > & | vf | ) | [inline] |
Definition at line 244 of file ctf.h.
References from_vector().
00244 {from_vector(vf);} //for unpickling
float EMAN::EMAN2Ctf::calc_amp1 | ( | ) | [inline, private] |
Definition at line 264 of file ctf.h.
References ampcont, and sqrt().
Referenced by compute_1d(), and compute_2d_complex().
float EMAN::EMAN2Ctf::calc_amplitude | ( | float | gamma | ) | [inline, private] |
float EMAN::EMAN2Ctf::calc_ctf1 | ( | float | g, | |
float | gamma, | |||
float | s | |||
) | [inline, private] |
Definition at line 296 of file ctf.h.
References ampcont, and EMAN::Ctf::bfactor.
Referenced by compute_1d(), and compute_2d_complex().
00297 { 00298 float r = exp(-(bfactor/4.0f * s * s)) * (g * sin(gamma) + ampcont/100.0f * cos(gamma)); 00299 return r; 00300 }
float EMAN::EMAN2Ctf::calc_g1 | ( | ) | [inline, private] |
Definition at line 275 of file ctf.h.
References calc_lambda(), and EMAN::Ctf::cs.
Referenced by compute_1d(), and compute_2d_complex().
00276 { 00277 float lambda = calc_lambda(); 00278 float g1 = 2.5e6f * cs * lambda * lambda * lambda; 00279 return g1; 00280 }
float EMAN::EMAN2Ctf::calc_g2 | ( | ) | [inline, private] |
Definition at line 282 of file ctf.h.
References calc_lambda(), and EMAN::Ctf::defocus.
Referenced by compute_1d(), and compute_2d_complex().
00283 { 00284 float lambda = calc_lambda(); 00285 float g2 = 5000.0f * -defocus * lambda; 00286 return g2; 00287 }
float EMAN::EMAN2Ctf::calc_gamma | ( | float | g1, | |
float | g2, | |||
float | s | |||
) | [inline, private] |
Definition at line 289 of file ctf.h.
Referenced by compute_1d(), and compute_2d_complex().
00290 { 00291 float s2 = s * s; 00292 float gamma = (float) (-2 * M_PI * (g1 * s2 * s2 + g2 * s2)); 00293 return gamma; 00294 }
float EMAN::EMAN2Ctf::calc_lambda | ( | ) | [inline, private] |
float EMAN::EMAN2Ctf::calc_noise | ( | float | s | ) | [inline, private] |
Definition at line 309 of file ctf.h.
References background, and dsbg.
Referenced by compute_1d(), and compute_2d_complex().
00310 { 00311 int si=(int)(s/dsbg); 00312 if (si>(int)background.size()||si<0) return background.back(); 00313 return background[si]; 00314 }
vector< float > EMAN2Ctf::compute_1d | ( | int | size, | |
float | ds, | |||
CtfType | type, | |||
XYData * | struct_factor = 0 | |||
) |
Definition at line 647 of file ctf.cpp.
References Assert, background, calc_amp1(), calc_ctf1(), calc_g1(), calc_g2(), calc_gamma(), calc_noise(), EMAN::Ctf::CTF_AMP, EMAN::Ctf::CTF_BACKGROUND, EMAN::Ctf::CTF_SIGN, EMAN::Ctf::CTF_SNR, EMAN::Ctf::CTF_SNR_SMOOTH, EMAN::Ctf::CTF_TOTAL, EMAN::Ctf::CTF_WIENER_FILTER, div(), dsbg, EMAN::XYData::get_yatx(), InvalidValueException, max_int(), min_int(), snr, x, and y.
Referenced by EMAN::CtfSimProcessor::process().
00648 { 00649 Assert(size > 0); 00650 00651 // float tmp_f1 = sqrt((float) 2) * size / 2; 00652 // int np = (int) ceil(tmp_f1) + 2; 00653 int np=size/2; 00654 vector < float >r; 00655 00656 r.resize(np); 00657 00658 // float ds = 1 / (apix * size); 00659 float s = 0; 00660 float g1 = calc_g1(); 00661 float g2 = calc_g2(); 00662 float amp1 = calc_amp1(); 00663 00664 switch (type) { 00665 case CTF_AMP: 00666 for (int i = 0; i < np; i++) { 00667 float gamma = calc_gamma(g1, g2, s); 00668 r[i] = calc_ctf1(amp1, gamma, s); 00669 s += ds; 00670 } 00671 break; 00672 00673 case CTF_SIGN: 00674 for (int i = 0; i < np; i++) { 00675 float gamma = calc_gamma(g1, g2, s); 00676 r[i] = calc_ctf1(amp1, gamma, s)>=0?1.0f:-1.0f; 00677 s += ds; 00678 } 00679 break; 00680 00681 case CTF_BACKGROUND: 00682 for (int i = 0; i < np; i++) { 00683 float f = s/dsbg; 00684 int j = (int)floor(f); 00685 f-=j; 00686 if (j>(int)background.size()-2) r[i]=background.back(); 00687 else r[i]=background[j]*(1.0f-f)+background[j+1]*f; 00688 s+=ds; 00689 } 00690 break; 00691 00692 case CTF_SNR: 00693 if (snr.size()<1) { 00694 throw InvalidValueException("CTF_SNR"," ERROR: No SNR info in CTF header."); 00695 break; 00696 } 00697 for (int i = 0; i < np; i++) { 00698 float f = s/dsbg; 00699 int j = (int)floor(f); 00700 f-=j; 00701 if (j>(int)snr.size()-2) r[i]=snr.back(); 00702 else r[i]=snr[j]*(1.0f-f)+snr[j+1]*f; 00703 // printf("%d\t%f\n",j,snr[j]); 00704 s+=ds; 00705 } 00706 break; 00707 case CTF_SNR_SMOOTH: 00708 // This apparently complicated routine tries to make a nice smooth and accurate SNR curve. It does this 00709 // by fitting local regions of the SNR vs the theoretical SNR (theoretical CTF^2/measured background), 00710 // then taking the slope of the result times the theoretical SNR to produce a local SNR estimate 00711 00712 { // <- is to permit new temporary value allocation 00713 vector < float >tsnr; // theoretical SNR 00714 tsnr.resize(np); 00715 vector < float >dsnr; // data SNR 00716 dsnr.resize(np); 00717 00718 float s0=s; 00719 00720 for (int i = 0; i < np; i++) { 00721 float gamma = calc_gamma(g1, g2, s); 00722 tsnr[i] = calc_ctf1(amp1, gamma, s); // ctf amp 00723 00724 // background value 00725 float f = s/dsbg; 00726 int j = (int)floor(f); 00727 f-=j; 00728 float bg; 00729 if (j>(int)background.size()-2) bg=background.back(); 00730 else bg=background[j]*(1.0f-f)+background[j+1]*f; 00731 if (bg <=0) bg=.001f; 00732 00733 tsnr[i] = tsnr[i]*tsnr[i]/bg; // This is now a SNR curve 00734 if (sf && s) { 00735 tsnr[i] *= sf->get_yatx(s); 00736 } 00737 00738 00739 // This is the SNR computed from the data without fitting 00740 if (j>(int)snr.size()-2) dsnr[i]=snr.back(); 00741 else dsnr[i]=snr[j]*(1.0f-f)+snr[j+1]*f; 00742 00743 s+=ds; 00744 } 00745 00746 int npsm=np/25; // 1/2 number of points to smooth over, 25 is arbitrary 00747 if (npsm<2) npsm=2; 00748 00749 s=s0; 00750 for (int i = 1; i < np; i++) { 00751 // simple linear regression embedded here 00752 double sum = 0; 00753 double sum_x = 0; 00754 double sum_y = 0; 00755 double sum_xx = 0; 00756 double sum_xy = 0; 00757 00758 for (int k=max_int(i-npsm,1); k<=min_int(i+npsm,np-1); k++) { 00759 double y = dsnr[k]; 00760 double x = tsnr[k]; 00761 00762 sum_x += x; 00763 sum_y += y; 00764 sum_xx += x * x; 00765 sum_xy += x * y; 00766 sum++; 00767 } 00768 00769 double div = sum * sum_xx - sum_x * sum_x; 00770 // if (div == 0) { 00771 // div = 0.0000001f; 00772 // } 00773 00774 // *intercept = (float) ((sum_xx * sum_y - sum_x * sum_xy) / div); 00775 // *slope = (float) ((sum * sum_xy - sum_x * sum_y) / div); 00776 00777 if (div!=0.0) r[i]=(float) ((sum * sum_xy - sum_x * sum_y) / div)*tsnr[i]; 00778 else r[i]=0.0; 00779 if (r[i]<0) r[i]=0; 00780 00781 s+=ds; 00782 } 00783 r[0]=0; 00784 } 00785 break; 00786 00787 case CTF_WIENER_FILTER: 00788 // if (!sf) { 00789 // LOGERR("CTF computation error, no SF found\n"); 00790 // return r; 00791 // } 00792 00793 for (int i = 0; i < np; i++) { 00794 float f = s/dsbg; 00795 int j = (int)floor(f); 00796 float bg; 00797 f-=j; 00798 if (j>(int)snr.size()-2) { 00799 /* r[i]=snr.back(); 00800 bg=background.back();*/ 00801 r[i]=0; 00802 } 00803 else { 00804 r[i]=snr[j]*(1.0f-f)+snr[j+1]*f; 00805 bg=background[j]*(1.0f-f)+background[j+1]*f; 00806 } 00807 if (r[i]<0) r[i]=0; 00808 r[i]=r[i]/(r[i]+1.0f); // Full Wiener filter assuming perfect image with noise 00809 // r[i]=sqrt(r[i]/bg)/(r[i]+1.0); // Wiener filter with 1/CTF term (sort of) to restore image then filter 00810 s+=ds; 00811 } 00812 r[0]=0; 00813 break; 00814 00815 case CTF_TOTAL: 00816 00817 for (int i = 0; i < np; i++) { 00818 float gamma = calc_gamma(g1, g2, s); 00819 if (sf) { 00820 r[i] = calc_ctf1(amp1, gamma, s); 00821 r[i] = r[i] * r[i] * sf->get_yatx(s) + calc_noise(s); 00822 } 00823 else { 00824 r[i] = calc_ctf1(amp1, gamma, s); 00825 r[i] = r[i] * r[i] + calc_noise(s); 00826 } 00827 s += ds; 00828 } 00829 break; 00830 default: 00831 break; 00832 } 00833 00834 return r; 00835 }
Definition at line 846 of file ctf.cpp.
References EMAN::Ctf::apix, background, calc_amp1(), calc_amplitude(), calc_ctf1(), calc_g1(), calc_g2(), calc_gamma(), calc_noise(), EMAN::Ctf::CTF_AMP, EMAN::Ctf::CTF_BACKGROUND, EMAN::Ctf::CTF_SIGN, EMAN::Ctf::CTF_SNR, EMAN::Ctf::CTF_SNR_SMOOTH, EMAN::Ctf::CTF_TOTAL, EMAN::Ctf::CTF_WIENER_FILTER, dsbg, EMAN::EMData::get_data(), EMAN::EMData::get_xsize(), EMAN::XYData::get_yatx(), EMAN::EMData::get_ysize(), EMAN::Util::hypot_fast(), EMAN::EMData::is_complex(), LOGERR, nx, ny, snr, EMAN::EMData::to_one(), EMAN::EMData::update(), v, x, and y.
00847 { 00848 if (!image) { 00849 LOGERR("image is null. cannot computer 2D complex CTF"); 00850 return; 00851 } 00852 00853 if (image->is_complex() == false) { 00854 LOGERR("compute_2d_complex can only work on complex images"); 00855 return; 00856 } 00857 00858 int nx = image->get_xsize(); 00859 int ny = image->get_ysize(); 00860 00861 if ((ny%2==1 && nx!=ny+1) || (ny%2==0 && nx != ny + 2)) { 00862 printf("nx=%d ny=%d\n",nx,ny); 00863 LOGERR("compute_2d_complex only works on (nx, nx-2) images"); 00864 return; 00865 } 00866 00867 float ds = 1.0f / (apix * ny); 00868 image->to_one(); 00869 00870 float *d = image->get_data(); 00871 float g1 = calc_g1(); 00872 float g2 = calc_g2(); 00873 float amp1 = calc_amp1(); 00874 00875 if (type == CTF_BACKGROUND) { 00876 for (int y = -ny/2; y < ny/2; y++) { 00877 int y2=(y+ny)%ny; 00878 int ynx = y2 * nx; 00879 00880 for (int x = 0; x < nx / 2; x++) { 00881 float s = (float) Util::hypot_fast(x, y ) * ds; 00882 d[x * 2 + ynx] = calc_noise(s); 00883 d[x * 2 + ynx + 1] = 0; // The phase is somewhat arbitrary 00884 } 00885 } 00886 } 00887 else if (type == CTF_AMP) { 00888 for (int y = -ny/2; y < ny/2; y++) { 00889 int y2=(y+ny)%ny; 00890 int ynx = y2 * nx; 00891 00892 for (int x = 0; x < nx / 2; x++) { 00893 float s = (float)Util::hypot_fast(x,y ) * ds; 00894 float gamma = calc_gamma(g1, g2, s); 00895 float v = calc_ctf1(amp1, gamma, s); 00896 // float v = calc_amplitude(gamma); 00897 d[x * 2 + ynx] = v; 00898 d[x * 2 + ynx + 1] = 0; 00899 } 00900 } 00901 } 00902 else if (type == CTF_SIGN) { 00903 for (int y = -ny/2; y < ny/2; y++) { 00904 int y2=(y+ny)%ny; 00905 int ynx = y2 * nx; 00906 for (int x = 0; x < nx / 2; x++) { 00907 float s = (float)Util::hypot_fast(x,y ) * ds; 00908 float gamma = calc_gamma(g1, g2, s); 00909 float v = calc_amplitude(gamma); 00910 d[x * 2 + ynx] = v >= 0 ? 1.0f : -1.0f; 00911 d[x * 2 + ynx + 1] = 0; 00912 } 00913 } 00914 } 00915 else if (type == CTF_SNR) { 00916 00917 for (int y = -ny/2; y < ny/2; y++) { 00918 int y2=(y+ny)%ny; 00919 int ynx = y2 * nx; 00920 00921 for (int x = 0; x < nx / 2; x++) { 00922 00923 float s = (float)Util::hypot_fast(x,y ) * ds; 00924 float f = s/dsbg; 00925 int j = (int)floor(f); 00926 f-=j; 00927 if (j>(int)snr.size()-2) d[x*2+ynx]=snr.back(); 00928 else d[x*2+ynx]=snr[j]*(1.0f-f)+snr[j+1]*f; 00929 d[x * 2 + ynx + 1] = 0; 00930 } 00931 } 00932 d[0]=0; 00933 } 00934 else if (type == CTF_SNR_SMOOTH) { 00935 for (int y = -ny/2; y < ny/2; y++) { 00936 int y2=(y+ny)%ny; 00937 int ynx = y2 * nx; 00938 00939 for (int x = 0; x < nx / 2; x++) { 00940 00941 float s = (float)Util::hypot_fast(x,y ) * ds; 00942 float f = s/dsbg; 00943 int j = (int)floor(f); 00944 f-=j; 00945 if (j>(int)snr.size()-2) d[x*2+ynx]=snr.back(); 00946 else d[x*2+ynx]=snr[j]*(1.0f-f)+snr[j+1]*f; 00947 d[x * 2 + ynx + 1] = 0; 00948 } 00949 } 00950 d[0]=0; 00951 } 00952 else if (type == CTF_WIENER_FILTER) { 00953 if (dsbg==0) printf("Warning, DSBG set to 0\n"); 00954 for (int y = -ny/2; y < ny/2; y++) { 00955 int y2=(y+ny)%ny; 00956 int ynx = y2 * nx; 00957 00958 for (int x = 0; x < nx / 2; x++) { 00959 00960 float s = (float)Util::hypot_fast(x,y ) * ds; 00961 float f = s/dsbg; 00962 int j = (int)floor(f); 00963 float bg,snrf; 00964 f-=j; 00965 if (j>(int)snr.size()-2) { 00966 /* bg=background.back(); 00967 d[x*2+ynx]=snr.back()/(snr.back()+1.0);*/ 00968 d[x*2+ynx]=0; 00969 } 00970 else { 00971 bg=background[j]*(1.0f-f)+background[j+1]*f; 00972 snrf=snr[j]*(1.0f-f)+snr[j+1]*f; 00973 00974 // printf("%d\t%f\n",x,sqrt(snrf/bg)/(snrf+1.0)); 00975 if (snrf<0) snrf=0.0; 00976 // d[x*2+ynx]=sqrt(snrf/bg)/(snrf+1.0); // Note that this is a Wiener filter with a 1/CTF term to compensate for the filtration already applied, but needs to be multiplied by the structure factor 00977 d[x*2+ynx]=snrf/(snrf+1); // This is just the simple Wiener filter 00978 00979 } 00980 d[x * 2 + ynx + 1] = 0; 00981 } 00982 } 00983 d[0]=0; 00984 } 00985 else if (type == CTF_TOTAL) { 00986 float amp1 = calc_amp1(); 00987 00988 for (int y = -ny/2; y < ny/2; y++) { 00989 int y2=(y+ny)%ny; 00990 int ynx = y2 * nx; 00991 00992 for (int x = 0; x < nx / 2; x++) { 00993 00994 float s = (float)Util::hypot_fast(x,y ) * ds; 00995 float gamma = calc_gamma(g1, g2, s); 00996 float f = calc_ctf1(amp1, gamma, s); 00997 float noise = 0; 00998 f = f * f; 00999 01000 if (sf && s) { 01001 f *= sf->get_yatx(s); 01002 } 01003 f+=noise; 01004 01005 d[x * 2 + ynx] *= f; 01006 d[x * 2 + ynx + 1] = 0; 01007 } 01008 } 01009 } 01010 else printf("Unknown CTF image mode\n"); 01011 01012 image->update(); 01013 }
void EMAN2Ctf::copy_from | ( | const Ctf * | new_ctf | ) | [virtual] |
Implements EMAN::Ctf.
Definition at line 626 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00627 { 00628 if (new_ctf) { 00629 const EMAN2Ctf *c = static_cast<const EMAN2Ctf *>(new_ctf); 00630 defocus = c->defocus; 00631 dfdiff = c->dfdiff; 00632 dfang = c->dfang; 00633 bfactor = c->bfactor; 00634 ampcont = c->ampcont; 00635 voltage = c->voltage; 00636 cs = c->cs; 00637 apix = c->apix; 00638 dsbg = c->dsbg; 00639 background = c->background; 00640 snr = c->snr; 00641 } 00642 }
bool EMAN2Ctf::equal | ( | const Ctf * | ctf1 | ) | const [virtual] |
Implements EMAN::Ctf.
Definition at line 1017 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
01018 { 01019 if (ctf1) { 01020 const EMAN2Ctf *c = static_cast<const EMAN2Ctf *>(ctf1); 01021 if (defocus != c->defocus || 01022 dfdiff != c->dfdiff || 01023 dfang != c->dfang || 01024 bfactor != c->bfactor || 01025 ampcont != c->ampcont || 01026 voltage != c->voltage || 01027 cs != c->cs || 01028 apix != c->apix || 01029 dsbg != c->dsbg || 01030 background.size() != c->background.size() || 01031 snr.size() != c->snr.size() 01032 ) return false; 01033 01034 for (unsigned int i=0; i<background.size(); i++) { 01035 if (background[i]!=c->background[i]) return false; 01036 } 01037 for (unsigned int i=0; i<snr.size(); i++) { 01038 if (snr[i]!=c->snr[i]) return false; 01039 } 01040 return true; 01041 } 01042 return false; 01043 }
void EMAN2Ctf::from_dict | ( | const Dict & | dict | ) | [virtual] |
Implements EMAN::Ctf.
Definition at line 552 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00553 { 00554 defocus = (float)dict["defocus"]; 00555 dfdiff = (float)dict["dfdiff"]; 00556 dfang = (float)dict["dfang"]; 00557 bfactor = (float)dict["bfactor"]; 00558 ampcont = (float)dict["ampcont"]; 00559 voltage = (float)dict["voltage"]; 00560 cs = (float)dict["cs"]; 00561 apix = (float)dict["apix"]; 00562 dsbg = (float)dict["dsbg"]; 00563 background = dict["background"]; 00564 snr = dict["snr"]; 00565 }
int EMAN2Ctf::from_string | ( | const string & | ctf | ) | [virtual] |
Implements EMAN::Ctf.
Definition at line 494 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, Assert, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, InvalidValueException, snr, v, and EMAN::Ctf::voltage.
00495 { 00496 Assert(ctf != ""); 00497 char type=' '; 00498 int pos=-1,i,j; 00499 int bglen=0,snrlen=0; 00500 float v; 00501 const char *s=ctf.c_str(); 00502 00503 sscanf(s, "%c%f %f %f %f %f %f %f %f %f %d%n", 00504 &type,&defocus, &dfdiff,&dfang,&bfactor,&cont,&voltage, &cs, &apix,&dsbg,&bglen,&pos); 00505 if (type!='E') throw InvalidValueException(type,"Trying to initialize Ctf object with bad string"); 00506 if (pos==-1) throw InvalidValueException(s," Invalid CTF string"); 00507 00508 00509 background.resize(bglen); 00510 for (i=0; i<bglen; i++) { 00511 if (sscanf(s+pos,",%f%n",&v,&j)<1) return(1); 00512 background[i]=v; 00513 pos+=j; 00514 } 00515 00516 sscanf(s+pos," %d%n",&snrlen,&j); 00517 pos+=j; 00518 snr.resize(snrlen); 00519 for (i=0; i<snrlen; i++) { 00520 if (sscanf(s+pos,",%f%n",&v,&j)<1) return(1); 00521 snr[i]=v; 00522 pos+=j; 00523 } 00524 00525 return 0; 00526 00527 }
void EMAN2Ctf::from_vector | ( | const vector< float > & | vctf | ) | [virtual] |
Implements EMAN::Ctf.
Definition at line 585 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
Referenced by EMAN2Ctf().
00586 { 00587 int i; 00588 defocus = vctf[0]; 00589 dfdiff = vctf[1]; 00590 dfang = vctf[2]; 00591 bfactor = vctf[3]; 00592 ampcont = vctf[4]; 00593 voltage = vctf[5]; 00594 cs = vctf[6]; 00595 apix = vctf[7]; 00596 dsbg = vctf[8]; 00597 background.resize((int)vctf[9]); 00598 for (i=0; i<(int)vctf[9]; i++) background[i]=vctf[i+10]; 00599 snr.resize((int)vctf[i+10]); 00600 for (int j=0; j<(int)vctf[i+10]; j++) snr[j]=vctf[i+j+11]; 00601 }
vector<float> EMAN::EMAN2Ctf::get_background | ( | ) | [inline] |
vector<float> EMAN::EMAN2Ctf::get_snr | ( | ) | [inline] |
void EMAN::EMAN2Ctf::set_background | ( | const vector< float > & | vf | ) | [inline] |
void EMAN::EMAN2Ctf::set_snr | ( | const vector< float > & | vf | ) | [inline] |
Dict EMAN2Ctf::to_dict | ( | ) | const [virtual] |
Implements EMAN::Ctf.
Definition at line 567 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00568 { 00569 Dict dict; 00570 dict["defocus"] = defocus; 00571 dict["dfdiff"] = dfdiff; 00572 dict["dfang"] = dfang; 00573 dict["bfactor"] = bfactor; 00574 dict["ampcont"] = ampcont; 00575 dict["voltage"] = voltage; 00576 dict["cs"] = cs; 00577 dict["apix"] = apix; 00578 dict["dsbg"] = dsbg; 00579 dict["background"] = background; 00580 dict["snr"] = snr; 00581 00582 return dict; 00583 }
string EMAN2Ctf::to_string | ( | ) | const [virtual] |
Implements EMAN::Ctf.
Definition at line 529 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00530 { 00531 char ctf[256]; 00532 sprintf(ctf, "E%1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %d", 00533 defocus, dfdiff, dfang, bfactor, ampcont, voltage, cs, apix, dsbg,(int)background.size()); 00534 00535 string ret=ctf; 00536 for (int i=0; i<(int)background.size(); i++) { 00537 sprintf(ctf,",%1.3g",background[i]); 00538 ret+=ctf; 00539 } 00540 00541 sprintf(ctf, " %d",(int)snr.size()); 00542 ret+=ctf; 00543 for (int i=0; i<(int)snr.size(); i++) { 00544 sprintf(ctf,",%1.3g",snr[i]); 00545 ret+=ctf; 00546 } 00547 00548 00549 return ret; 00550 }
vector< float > EMAN2Ctf::to_vector | ( | ) | const [virtual] |
Implements EMAN::Ctf.
Definition at line 603 of file ctf.cpp.
References ampcont, EMAN::Ctf::apix, background, EMAN::Ctf::bfactor, EMAN::Ctf::cs, EMAN::Ctf::defocus, dfang, dfdiff, dsbg, snr, and EMAN::Ctf::voltage.
00604 { 00605 vector<float> vctf; 00606 00607 vctf.push_back(defocus); 00608 vctf.push_back(dfdiff); 00609 vctf.push_back(dfang); 00610 vctf.push_back(bfactor); 00611 vctf.push_back(ampcont); 00612 vctf.push_back(voltage); 00613 vctf.push_back(cs); 00614 vctf.push_back(apix); 00615 vctf.push_back(dsbg); 00616 vctf.push_back((float)background.size()); 00617 for (unsigned int i=0; i<background.size(); i++) vctf.push_back(background[i]); 00618 vctf.push_back((float)snr.size()); 00619 for (unsigned int j=0; j<snr.size(); j++) vctf.push_back(snr[j]); 00620 00621 return vctf; 00622 }
float EMAN::EMAN2Ctf::ampcont |
Definition at line 229 of file ctf.h.
Referenced by calc_amp1(), calc_amplitude(), calc_ctf1(), copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), EMAN::CtfSimProcessor::process(), to_dict(), to_string(), and to_vector().
vector<float> EMAN::EMAN2Ctf::background |
Definition at line 234 of file ctf.h.
Referenced by calc_noise(), compute_1d(), compute_2d_complex(), copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), get_background(), set_background(), to_dict(), to_string(), and to_vector().
float EMAN::EMAN2Ctf::dfang |
Definition at line 227 of file ctf.h.
Referenced by copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), to_dict(), to_string(), and to_vector().
float EMAN::EMAN2Ctf::dfdiff |
Definition at line 226 of file ctf.h.
Referenced by copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), to_dict(), to_string(), and to_vector().
float EMAN::EMAN2Ctf::dsbg |
Definition at line 233 of file ctf.h.
Referenced by calc_noise(), compute_1d(), compute_2d_complex(), copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), EMAN::CtfSimProcessor::process(), to_dict(), to_string(), and to_vector().
vector<float> EMAN::EMAN2Ctf::snr |
Definition at line 235 of file ctf.h.
Referenced by compute_1d(), compute_2d_complex(), copy_from(), EMAN2Ctf(), equal(), from_dict(), from_string(), from_vector(), get_snr(), set_snr(), to_dict(), to_string(), and to_vector().