EMAN::EMAN2Ctf Class Reference

EMAN2Ctf is the default CTF model used in EMAN2. More...

#include <ctf.h>

Inheritance diagram for EMAN::EMAN2Ctf:

Inheritance graph
[legend]
Collaboration diagram for EMAN::EMAN2Ctf:

Collaboration graph
[legend]
List of all members.

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)

Detailed Description

EMAN2Ctf is the default CTF model used in EMAN2.

Definition at line 222 of file ctf.h.


Constructor & Destructor Documentation

EMAN2Ctf::EMAN2Ctf (  ) 

Definition at line 470 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.

00471 {
00472         defocus = 0;
00473         dfdiff = 0;
00474         dfang = 0;
00475         bfactor = 0;
00476         ampcont = 0;
00477         voltage = 0;
00478         cs = 0;
00479         apix = 1.0;
00480         dsbg=-1;
00481         background.clear();
00482         snr.clear();
00483 }

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

EMAN2Ctf::~EMAN2Ctf (  ) 

Definition at line 486 of file ctf.cpp.

00487 {
00488 }


Member Function Documentation

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().

00265                 {
00266                         return (sqrt(1 - ampcont * ampcont/10000.0f));
00267                 }

float EMAN::EMAN2Ctf::calc_amplitude ( float  gamma  )  [inline, private]

Definition at line 302 of file ctf.h.

References ampcont, sqrt(), and v.

Referenced by compute_2d_complex().

00303                 {
00304                         float t1 = sqrt(1.0f - ampcont * ampcont/10000.0f) * sin(gamma);
00305                         float v = (t1 + ampcont/100.0f * cos(gamma));
00306                         return v;
00307                 }

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]

Definition at line 269 of file ctf.h.

References sqrt(), and EMAN::Ctf::voltage.

Referenced by calc_g1(), and calc_g2().

00270                 {
00271                         float lambda = 12.2639f / sqrt(voltage * 1000.0f + 0.97845f * voltage * voltage);
00272                         return lambda;
00273                 }

float EMAN::EMAN2Ctf::calc_noise ( float  s  )  [inline, private]

Definition at line 309 of file ctf.h.

References background, and dsbg.

Referenced by 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 643 of file ctf.cpp.

References Assert, background, calc_amp1(), calc_ctf1(), calc_g1(), calc_g2(), calc_gamma(), 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, LOGERR, max_int(), min_int(), norm(), and snr.

00644 {
00645         Assert(size > 0);
00646 
00647 //      float tmp_f1 =  sqrt((float) 2) * size / 2;
00648 //      int np = (int) ceil(tmp_f1) + 2;
00649         int np=size/2;
00650         vector < float >r;
00651 
00652         r.resize(np);
00653 
00654 //      float ds = 1 / (apix * size);
00655         float s = 0;
00656         float g1 = calc_g1();
00657         float g2 = calc_g2();
00658         float amp1 = calc_amp1();
00659 
00660         switch (type) {
00661         case CTF_AMP:
00662                 for (int i = 0; i < np; i++) {
00663                         float gamma = calc_gamma(g1, g2, s);
00664                         r[i] = calc_ctf1(amp1, gamma, s);
00665                         s += ds;
00666                 }
00667                 break;
00668 
00669         case CTF_SIGN:
00670                 for (int i = 0; i < np; i++) {
00671                         float gamma = calc_gamma(g1, g2, s);
00672                         r[i] = calc_ctf1(amp1, gamma, s)>=0?1.0f:-1.0f;
00673                         s += ds;
00674                 }
00675                 break;
00676 
00677         case CTF_BACKGROUND:
00678                 for (int i = 0; i < np; i++) {
00679                         float f = s/dsbg;
00680                         int j = (int)floor(f);
00681                         f-=j;
00682                         if (j>(int)background.size()-2) r[i]=background.back();
00683                         else r[i]=background[j]*(1.0f-f)+background[j+1]*f;
00684                         s+=ds;
00685                 }
00686                 break;
00687 
00688         case CTF_SNR:
00689                 for (int i = 0; i < np; i++) {
00690                         float f = s/dsbg;
00691                         int j = (int)floor(f);
00692                         f-=j;
00693                         if (j>(int)snr.size()-2) r[i]=snr.back();
00694                         else r[i]=snr[j]*(1.0f-f)+snr[j+1]*f;
00695 //                      printf("%d\t%f\n",j,snr[j]);
00696                         s+=ds;
00697                 }
00698                 break;
00699         case CTF_SNR_SMOOTH:
00700                 for (int i = 0; i < np; i++) {
00701                         float gamma = calc_gamma(g1, g2, s);    // we base the width of our smoothing on gamma
00702                         float f = s/dsbg;
00703                         int j = (int)floor(f);
00704 
00705                         double sum=0,norm=0;
00706                         for (int k=max_int(j-5,1); k<min_int(j+6,np); k++) {
00707                                 float s2=f-k;
00708                                 float e=exp(-14.0f*s2*s2/(gamma));
00709                                 if (k>(int)snr.size()) break;
00710                                 sum+=e*snr[k];
00711                                 norm+=e;
00712 //                              printf("%d\t%f\t%f\t%f\t%f\n",k,e,snr[k],sum,norm);
00713                         }
00714                         r[i]=(float)(norm==0?0:sum/norm);
00715                         s+=ds;
00716                 }
00717                 r[0]=0;
00718                 break;
00719 
00720         case CTF_WIENER_FILTER:
00721 //              if (!sf) {
00722 //                      LOGERR("CTF computation error, no SF found\n");
00723 //                      return r;
00724 //              }
00725 
00726                 for (int i = 0; i < np; i++) {
00727                         float f = s/dsbg;
00728                         int j = (int)floor(f);
00729                         float bg;
00730                         f-=j;
00731                         if (j>(int)snr.size()-2) {
00732 /*                              r[i]=snr.back();
00733                                 bg=background.back();*/
00734                                 r[i]=0;
00735                         }
00736                         else {
00737                                 r[i]=snr[j]*(1.0f-f)+snr[j+1]*f;
00738                                 bg=background[j]*(1.0f-f)+background[j+1]*f;
00739                         }
00740                         if (r[i]<0) r[i]=0;
00741                         r[i]=r[i]/(r[i]+1.0f);          // Full Wiener filter assuming perfect image with noise
00742 //                      r[i]=sqrt(r[i]/bg)/(r[i]+1.0);  // Wiener filter with 1/CTF term (sort of) to restore image then filter
00743                         s+=ds;
00744                 }
00745                 r[0]=0;
00746                 break;
00747 
00748         case CTF_TOTAL:
00749                 if (!sf) {
00750                         LOGERR("CTF computation error, no SF found\n");
00751                         return r;
00752                 }
00753 
00754                 for (int i = 0; i < np; i++) {
00755                         float gamma = calc_gamma(g1, g2, s);
00756                         if (sf) {
00757                                 r[i] = calc_ctf1(amp1, gamma, s);
00758 //                              r[i] = r[i] * r[i] * pow(10.0f, sf->get_yatx(s)) + calc_noise(s);
00759                         }
00760                         else {
00761                                 r[i] = calc_ctf1(amp1, gamma, s);
00762 //                              r[i] = r[i] * r[i] + calc_noise(s);
00763                         }
00764                         s += ds;
00765                 }
00766                 break;
00767         default:
00768                 break;
00769         }
00770 
00771         return r;
00772 }

void EMAN2Ctf::compute_2d_complex ( EMData image,
CtfType  type,
XYData struct_factor = 0 
)

Definition at line 783 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.

00784 {
00785         if (!image) {
00786                 LOGERR("image is null. cannot computer 2D complex CTF");
00787                 return;
00788         }
00789 
00790         if (image->is_complex() == false) {
00791                 LOGERR("compute_2d_complex can only work on complex images");
00792                 return;
00793         }
00794 
00795         int nx = image->get_xsize();
00796         int ny = image->get_ysize();
00797 
00798         if ((ny%2==1 && nx!=ny+1) || (ny%2==0 && nx != ny + 2)) {
00799                 printf("nx=%d  ny=%d\n",nx,ny);
00800                 LOGERR("compute_2d_complex only works on (nx, nx-2) images");
00801                 return;
00802         }
00803 
00804         float ds = 1.0f / (apix * ny);
00805         image->to_one();
00806 
00807         float *d = image->get_data();
00808         float g1 = calc_g1();
00809         float g2 = calc_g2();
00810         float amp1 = calc_amp1();
00811 
00812         if (type == CTF_BACKGROUND) {
00813                 for (int y = -ny/2; y < ny/2; y++) {
00814                         int y2=(y+ny)%ny;
00815                         int ynx = y2 * nx;
00816 
00817                         for (int x = 0; x < nx / 2; x++) {
00818                                 float s = (float) Util::hypot_fast(x, y ) * ds;
00819                                 d[x * 2 + ynx] = calc_noise(s);
00820                                 d[x * 2 + ynx + 1] = 0;                 // The phase is somewhat arbitrary
00821                         }
00822                 }
00823         }
00824         else if (type == CTF_AMP) {
00825                 for (int y = -ny/2; y < ny/2; y++) {
00826                         int y2=(y+ny)%ny;
00827                         int ynx = y2 * nx;
00828 
00829                         for (int x = 0; x < nx / 2; x++) {
00830                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00831                                 float gamma = calc_gamma(g1, g2, s);
00832                                 float v = calc_ctf1(amp1, gamma, s);
00833 //                              float v = calc_amplitude(gamma);
00834                                 d[x * 2 + ynx] = v;
00835                                 d[x * 2 + ynx + 1] = 0;
00836                         }
00837                 }
00838         }
00839         else if (type == CTF_SIGN) {
00840                 for (int y = -ny/2; y < ny/2; y++) {
00841                         int y2=(y+ny)%ny;
00842                         int ynx = y2 * nx;
00843                         for (int x = 0; x < nx / 2; x++) {
00844                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00845                                 float gamma = calc_gamma(g1, g2, s);
00846                                 float v = calc_amplitude(gamma);
00847                                 d[x * 2 + ynx] = v >= 0 ? 1.0f : -1.0f;
00848                                 d[x * 2 + ynx + 1] = 0;
00849                         }
00850                 }
00851         }
00852         else if (type == CTF_SNR) {
00853 
00854                 for (int y = -ny/2; y < ny/2; y++) {
00855                         int y2=(y+ny)%ny;
00856                         int ynx = y2 * nx;
00857 
00858                         for (int x = 0; x < nx / 2; x++) {
00859 
00860                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00861                                 float f = s/dsbg;
00862                                 int j = (int)floor(f);
00863                                 f-=j;
00864                                 if (j>(int)snr.size()-2) d[x*2+ynx]=snr.back();
00865                                 else d[x*2+ynx]=snr[j]*(1.0f-f)+snr[j+1]*f;
00866                                 d[x * 2 + ynx + 1] = 0;
00867                         }
00868                 }
00869                 d[0]=0;
00870         }
00871         else if (type == CTF_SNR_SMOOTH) {
00872                 for (int y = -ny/2; y < ny/2; y++) {
00873                         int y2=(y+ny)%ny;
00874                         int ynx = y2 * nx;
00875 
00876                         for (int x = 0; x < nx / 2; x++) {
00877 
00878                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00879                                 float f = s/dsbg;
00880                                 int j = (int)floor(f);
00881                                 f-=j;
00882                                 if (j>(int)snr.size()-2) d[x*2+ynx]=snr.back();
00883                                 else d[x*2+ynx]=snr[j]*(1.0f-f)+snr[j+1]*f;
00884                                 d[x * 2 + ynx + 1] = 0;
00885                         }
00886                 }
00887                 d[0]=0;
00888         }
00889         else if (type == CTF_WIENER_FILTER) {
00890                 if (dsbg==0) printf("Warning, DSBG set to 0\n");
00891                 for (int y = -ny/2; y < ny/2; y++) {
00892                         int y2=(y+ny)%ny;
00893                         int ynx = y2 * nx;
00894 
00895                         for (int x = 0; x < nx / 2; x++) {
00896 
00897                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00898                                 float f = s/dsbg;
00899                                 int j = (int)floor(f);
00900                                 float bg,snrf;
00901                                 f-=j;
00902                                 if (j>(int)snr.size()-2) {
00903 /*                                      bg=background.back();
00904                                         d[x*2+ynx]=snr.back()/(snr.back()+1.0);*/
00905                                         d[x*2+ynx]=0;
00906                                 }
00907                                 else {
00908                                         bg=background[j]*(1.0f-f)+background[j+1]*f;
00909                                         snrf=snr[j]*(1.0f-f)+snr[j+1]*f;
00910 
00911 //                                      printf("%d\t%f\n",x,sqrt(snrf/bg)/(snrf+1.0));
00912                                         if (snrf<0) snrf=0.0;
00913 //                                      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
00914                                         d[x*2+ynx]=snrf/(snrf+1);       // This is just the simple Wiener filter
00915 
00916                                 }
00917                                 d[x * 2 + ynx + 1] = 0;
00918                         }
00919                 }
00920                 d[0]=0;
00921         }
00922         else if (type == CTF_TOTAL) {
00923                 float amp1 = calc_amp1();
00924 
00925                 for (int y = -ny/2; y < ny/2; y++) {
00926                         int y2=(y+ny)%ny;
00927                         int ynx = y2 * nx;
00928 
00929                         for (int x = 0; x < nx / 2; x++) {
00930 
00931                                 float s = (float)Util::hypot_fast(x,y ) * ds;
00932                                 float gamma = calc_gamma(g1, g2, s);
00933                                 float f = calc_ctf1(amp1, gamma, s);
00934                                 float noise = 0;
00935                                 f = f * f;
00936 
00937                                 if (sf && s) {
00938                                         f *= pow(10.0f, sf->get_yatx(s));
00939                                 }
00940                                 f+=noise;
00941 
00942                                 d[x * 2 + ynx] *= f;
00943                                 d[x * 2 + ynx + 1] = 0;
00944                         }
00945                 }
00946         }
00947         else printf("Unknown CTF image mode\n");
00948 
00949         image->update();
00950 }

void EMAN2Ctf::compute_2d_real ( EMData image,
CtfType  type,
XYData struct_factor = 0 
)

Definition at line 775 of file ctf.cpp.

00776 {
00777 
00778 
00779 }

void EMAN2Ctf::copy_from ( const Ctf new_ctf  )  [virtual]

Implements EMAN::Ctf.

Definition at line 622 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.

00623 {
00624         if (new_ctf) {
00625                 const EMAN2Ctf *c = static_cast<const EMAN2Ctf *>(new_ctf);
00626                 defocus = c->defocus;
00627                 dfdiff = c->dfdiff;
00628                 dfang = c->dfang;
00629                 bfactor = c->bfactor;
00630                 ampcont = c->ampcont;
00631                 voltage = c->voltage;
00632                 cs = c->cs;
00633                 apix = c->apix;
00634                 dsbg = c->dsbg;
00635                 background = c->background;
00636                 snr = c->snr;
00637         }
00638 }

bool EMAN2Ctf::equal ( const Ctf ctf1  )  const [virtual]

Implements EMAN::Ctf.

Definition at line 954 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.

00955 {
00956         if (ctf1) {
00957                 const EMAN2Ctf *c = static_cast<const EMAN2Ctf *>(ctf1);
00958                 if (defocus != c->defocus ||
00959                         dfdiff != c->dfdiff ||
00960                         dfang != c->dfang ||
00961                         bfactor != c->bfactor ||
00962                         ampcont != c->ampcont ||
00963                         voltage != c->voltage ||
00964                         cs != c->cs ||
00965                         apix != c->apix ||
00966                         dsbg != c->dsbg ||
00967                         background.size() != c->background.size() ||
00968                         snr.size() != c->snr.size()
00969                         ) return false;
00970 
00971                 for (unsigned int i=0; i<background.size(); i++) {
00972                         if (background[i]!=c->background[i]) return false;
00973                 }
00974                 for (unsigned int i=0; i<snr.size(); i++) {
00975                         if (snr[i]!=c->snr[i]) return false;
00976                 }
00977                 return true;
00978         }
00979         return false;
00980 }

void EMAN2Ctf::from_dict ( const Dict dict  )  [virtual]

Implements EMAN::Ctf.

Definition at line 548 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.

00549 {
00550         defocus = (float)dict["defocus"];
00551         dfdiff = (float)dict["dfdiff"];
00552         dfang = (float)dict["dfang"];
00553         bfactor = (float)dict["bfactor"];
00554         ampcont = (float)dict["ampcont"];
00555         voltage = (float)dict["voltage"];
00556         cs = (float)dict["cs"];
00557         apix = (float)dict["apix"];
00558         dsbg = (float)dict["dsbg"];
00559         background = dict["background"];
00560         snr = dict["snr"];
00561 }

int EMAN2Ctf::from_string ( const string &  ctf  )  [virtual]

Implements EMAN::Ctf.

Definition at line 491 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.

00492 {
00493         Assert(ctf != "");
00494         char type=' ';
00495         int pos,i,j;
00496         int bglen=0,snrlen=0;
00497         float v;
00498         const char *s=ctf.c_str();
00499 
00500         sscanf(s, "%c%f %f %f %f %f %f %f %f %f %d%n",
00501                                    &type,&defocus, &dfdiff,&dfang,&bfactor,&ampcont,&voltage, &cs, &apix,&dsbg,&bglen,&pos);
00502         if (type!='E') throw InvalidValueException(type,"Trying to initialize Ctf object with bad string");
00503 
00504 
00505         background.resize(bglen);
00506         for (i=0; i<bglen; i++) {
00507                 if (sscanf(s+pos,",%f%n",&v,&j)<1) return(1);
00508                 background[i]=v;
00509                 pos+=j;
00510         }
00511 
00512         sscanf(s+pos," %d%n",&snrlen,&j);
00513         pos+=j;
00514         snr.resize(snrlen);
00515         for (i=0; i<snrlen; i++) {
00516                 if (sscanf(s+pos,",%f%n",&v,&j)<1) return(1);
00517                 snr[i]=v;
00518                 pos+=j;
00519         }
00520 
00521         return 0;
00522 
00523 }

void EMAN2Ctf::from_vector ( const vector< float > &  vctf  )  [virtual]

Implements EMAN::Ctf.

Definition at line 581 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().

00582 {
00583         int i;
00584         defocus = vctf[0];
00585         dfdiff = vctf[1];
00586         dfang = vctf[2];
00587         bfactor = vctf[3];
00588         ampcont = vctf[4];
00589         voltage = vctf[5];
00590         cs = vctf[6];
00591         apix = vctf[7];
00592         dsbg = vctf[8];
00593         background.resize((int)vctf[9]);
00594         for (i=0; i<(int)vctf[9]; i++) background[i]=vctf[i+10];
00595         snr.resize((int)vctf[i+10]);
00596         for (int j=0; j<(int)vctf[i+10]; j++) snr[j]=vctf[i+j+11];
00597 }

vector<float> EMAN::EMAN2Ctf::get_background (  )  [inline]

Definition at line 239 of file ctf.h.

References background.

00239 { return background;}

vector<float> EMAN::EMAN2Ctf::get_snr (  )  [inline]

Definition at line 237 of file ctf.h.

References snr.

00237 { return snr;}

void EMAN::EMAN2Ctf::set_background ( const vector< float > &  vf  )  [inline]

Definition at line 240 of file ctf.h.

References background.

00240 {background = vf;}

void EMAN::EMAN2Ctf::set_snr ( const vector< float > &  vf  )  [inline]

Definition at line 238 of file ctf.h.

References snr.

00238 {snr = vf;}

Dict EMAN2Ctf::to_dict (  )  const [virtual]

Implements EMAN::Ctf.

Definition at line 563 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.

00564 {
00565         Dict dict;
00566         dict["defocus"] = defocus;
00567         dict["dfdiff"] = dfdiff;
00568         dict["dfang"] = dfang;
00569         dict["bfactor"] = bfactor;
00570         dict["ampcont"] = ampcont;
00571         dict["voltage"] = voltage;
00572         dict["cs"] = cs;
00573         dict["apix"] = apix;
00574         dict["dsbg"] = dsbg;
00575         dict["background"] = background;
00576         dict["snr"] = snr;
00577 
00578         return dict;
00579 }

string EMAN2Ctf::to_string (  )  const [virtual]

Implements EMAN::Ctf.

Definition at line 525 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.

00526 {
00527         char ctf[256];
00528         sprintf(ctf, "E%1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %1.4g %d",
00529                         defocus, dfdiff, dfang, bfactor, ampcont, voltage, cs, apix, dsbg,(int)background.size());
00530 
00531         string ret=ctf;
00532         for (int i=0; i<(int)background.size(); i++) {
00533                 sprintf(ctf,",%1.3g",background[i]);
00534                 ret+=ctf;
00535         }
00536 
00537         sprintf(ctf, " %d",(int)snr.size());
00538         ret+=ctf;
00539         for (int i=0; i<(int)snr.size(); i++) {
00540                 sprintf(ctf,",%1.3g",snr[i]);
00541                 ret+=ctf;
00542         }
00543 
00544 
00545         return ret;
00546 }

vector< float > EMAN2Ctf::to_vector (  )  const [virtual]

Implements EMAN::Ctf.

Definition at line 599 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.

00600 {
00601         vector<float> vctf;
00602 
00603         vctf.push_back(defocus);
00604         vctf.push_back(dfdiff);
00605         vctf.push_back(dfang);
00606         vctf.push_back(bfactor);
00607         vctf.push_back(ampcont);
00608         vctf.push_back(voltage);
00609         vctf.push_back(cs);
00610         vctf.push_back(apix);
00611         vctf.push_back(dsbg);
00612         vctf.push_back((float)background.size());
00613         for (unsigned int i=0; i<background.size(); i++) vctf.push_back(background[i]);
00614         vctf.push_back((float)snr.size());
00615         for (unsigned int j=0; j<snr.size(); j++) vctf.push_back(snr[j]);
00616 
00617         return vctf;
00618 }


Member Data Documentation

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(), 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(), 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().


The documentation for this class was generated from the following files:
Generated on Tue May 25 17:15:55 2010 for EMAN2 by  doxygen 1.4.7