Xmipp  v3.23.11-Nereus
Classes | Functions | Variables | Friends
CTF support classes
Collaboration diagram for CTF support classes:

Classes

class  PrecomputedForCTF
 
class  CTFDescription1D
 
class  CTFDescription
 

Functions

 CTFDescription1D::CTFDescription1D ()
 
void CTFDescription1D::read (const FileName &fn, bool disable_if_not_K=true)
 
void CTFDescription1D::readFromMetadataRow (const MetaData &MD, size_t id, bool disable_if_not_K=true)
 
void CTFDescription1D::readFromMdRow (const MDRow &row, bool disable_if_not_K=true)
 
void CTFDescription1D::setRow (MDRow &row) const
 
void CTFDescription1D::write (const FileName &fn)
 
static void CTFDescription1D::defineParams (XmippProgram *program)
 Define parameters in the command line. More...
 
void CTFDescription1D::readParams (XmippProgram *program)
 Read parameters from the command line. More...
 
void CTFDescription1D::clear ()
 Clear. More...
 
void CTFDescription1D::clearNoise ()
 Clear noise. More...
 
void CTFDescription1D::clearPureCtf ()
 Clear pure CTF. More...
 
void CTFDescription1D::changeSamplingRate (double newTm)
 
void CTFDescription1D::produceSideInfo ()
 Produce Side information. More...
 
void CTFDescription1D::precomputeValues (double X)
 Precompute values for a given frequency. More...
 
void CTFDescription1D::precomputeValues (const MultidimArray< double > &cont_x_freq)
 Precompute values for an image. More...
 
void CTFDescription1D::precomputeValues (int i)
 Precompute values for a given frequency. More...
 
double CTFDescription1D::getValueAt (bool show=false) const
 Compute CTF at (U,V). Continuous frequencies. More...
 
double CTFDescription1D::getValueDampingAt (bool show=false) const
 Compute CTF damping at (U,V). Continuous frequencies. More...
 
double CTFDescription1D::getValuePureAt (bool show=false) const
 Compute CTF pure at (U,V). Continuous frequencies. More...
 
double CTFDescription1D::getValuePureNoKAt () const
 Compute CTF pure at (U,V). Continuous frequencies. More...
 
double CTFDescription1D::getValueNoiseAt (bool show=false) const
 Compute noise at (X,Y). Continuous frequencies, notice it is squared. More...
 
double CTFDescription1D::getValuePureWithoutDampingAt (bool show=false) const
 Compute pure CTF without damping at (U,V). Continuous frequencies. More...
 
void CTFDescription1D::getSineAndCosineParts (double &sine_part, double &cosine_part, double E, double u2, double deltaf, bool show) const
 
double CTFDescription1D::getValuePureNoPrecomputedAt (double X, bool show=false) const
 Compute CTF pure at (U,V). Continuous frequencies. More...
 
void CTFDescription1D::lookFor (int n, const Matrix1D< double > &u, Matrix1D< double > &freq, int iwhat=0)
 
void CTFDescription1D::applyCTF (MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
 Apply CTF to an image. More...
 
void CTFDescription1D::applyCTF (MultidimArray< double > &I, double Ts, bool absPhase=false)
 Apply CTF to an image. More...
 
void CTFDescription1D::correctPhase (MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts)
 Correct phase flip of an image. More...
 
void CTFDescription1D::correctPhase (MultidimArray< double > &I, double Ts)
 Correct phase flip of an image. More...
 
template<class T1 , class T2 >
void CTFDescription1D::generateCTF (const MultidimArray< T1 > &sample_image, MultidimArray< T2 > &CTF, double Ts=-1)
 
void CTFDescription1D::getProfile (double fmax, int nsamples, MultidimArray< double > &profiles)
 
void CTFDescription1D::getAverageProfile (double fmax, int nsamples, MultidimArray< double > &profiles)
 
template<class T >
double CTFDescription1D::initCTF (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
 Function to initialize CTF to avoid duplicated code. More...
 
template<class T >
void CTFDescription1D::generateCTF (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
 Generate CTF image. More...
 
template<class T >
void CTFDescription1D::generateCTFWithoutDamping (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
 
bool CTFDescription1D::hasPhysicalMeaning ()
 
void CTFDescription1D::forcePhysicalMeaning ()
 
void generateCTFImageWith2CTFs (const MetaData &MD1, const MetaData &MD2, int Xdim, MultidimArray< double > &imgOut)
 
double errorBetween2CTFs (MetaData &MD1, MetaData &MD2, size_t dim, double minFreq=0.05, double maxFreq=0.25)
 
double errorMaxFreqCTFs (MetaData &MD1, double phaseRad=HALFPI)
 
double errorMaxFreqCTFs2D (MetaData &MD1, MetaData &MD2, size_t xDim=256, double phaseRad=HALFPI)
 
void generatePSDCTFImage (MultidimArray< double > &img, const MetaData &MD)
 
 CTFDescription::CTFDescription ()
 
 CTFDescription::CTFDescription (CTFDescription1D copy)
 
void CTFDescription::read (const FileName &fn, bool disable_if_not_K=true)
 
void CTFDescription::readFromMetadataRow (const MetaData &MD, size_t id, bool disable_if_not_K=true)
 
void CTFDescription::readFromMdRow (const MDRow &row, bool disable_if_not_K=true)
 
void CTFDescription::setRow (MDRow &row) const
 
void CTFDescription::write (const FileName &fn)
 
static void CTFDescription::defineParams (XmippProgram *program)
 Define parameters in the command line. More...
 
void CTFDescription::readParams (XmippProgram *program)
 Read parameters from the command line. More...
 
void CTFDescription::clear ()
 Clear. More...
 
void CTFDescription::clearNoise ()
 Clear noise. More...
 
void CTFDescription::clearPureCtf ()
 Clear pure CTF. More...
 
void CTFDescription::changeSamplingRate (double newTm)
 
void CTFDescription::produceSideInfo ()
 Produce Side information. More...
 
void CTFDescription::precomputeValues (double X, double Y)
 Precompute values for a given frequency. More...
 
void CTFDescription::precomputeValues (const MultidimArray< double > &cont_x_freq, const MultidimArray< double > &cont_y_freq)
 Precompute values for an image. More...
 
void CTFDescription::precomputeValues (int i, int j)
 Precompute values for a given frequency. More...
 
double CTFDescription::getValueAt (bool show=false) const
 Compute CTF at (U,V). Continuous frequencies. More...
 
double CTFDescription::getValueArgument (bool show=false) const
 Compute pure CTF without damping at (U,V). Continuous frequencies. More...
 
double CTFDescription::getPhaseAt () const
 Get Phase of the CTF. More...
 
double CTFDescription::getValuePureNoPrecomputedAtxy (double X, double Y, bool show=false) const
 Compute CTF pure at (U,V). Continuous frequencies. More...
 
double CTFDescription::getValuePureNoDampingNoPrecomputedAt (double X, double Y) const
 Compute CTF pure at (U,V). Continuous frequencies. More...
 
double CTFDescription::getDeltafNoPrecomputed (double X, double Y) const
 Deltaf at a given direction. More...
 
double CTFDescription::getValueNoiseAt (bool show=false) const
 Compute noise at (X,Y). Continuous frequencies, notice it is squared. More...
 
void CTFDescription::lookFor (int n, const Matrix1D< double > &u, Matrix1D< double > &freq, int iwhat=0)
 
void CTFDescription::applyCTF (MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
 Apply CTF to an image. More...
 
void CTFDescription::applyCTF (MultidimArray< double > &I, double Ts, bool absPhase=false)
 Apply CTF to an image. More...
 
void CTFDescription::correctPhase (MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts)
 Correct phase flip of an image. More...
 
void CTFDescription::correctPhase (MultidimArray< double > &I, double Ts)
 Correct phase flip of an image. More...
 
template<class T1 , class T2 >
void CTFDescription::generateCTF (const MultidimArray< T1 > &sample_image, MultidimArray< T2 > &CTF, double Ts=-1)
 
void CTFDescription::getProfile (double angle, double fmax, int nsamples, MultidimArray< double > &profiles)
 
void CTFDescription::getAverageProfile (double fmax, int nsamples, MultidimArray< double > &profiles)
 
template<class T >
void CTFDescription::generateCTF (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
 Generate CTF image. More...
 
template<class T >
void CTFDescription::generateCTFWithoutDamping (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
 
template<class T >
void CTFDescription::generateEnvelope (int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1)
 
bool CTFDescription::hasPhysicalMeaning ()
 
void CTFDescription::forcePhysicalMeaning ()
 

Variables

double PrecomputedForCTF::u_sqrt
 
double PrecomputedForCTF::u
 
double PrecomputedForCTF::u2
 
double PrecomputedForCTF::u3
 
double PrecomputedForCTF::u4
 
double PrecomputedForCTF::ang
 
double PrecomputedForCTF::deltaf
 
double CTFDescription1D::lambda
 
double CTFDescription1D::K1
 
double CTFDescription1D::K2
 
double CTFDescription1D::K3
 
double CTFDescription1D::K4
 
double CTFDescription1D::K5
 
double CTFDescription1D::K6
 
double CTFDescription1D::K7
 
double CTFDescription1D::Ksin
 
double CTFDescription1D::Kcos
 
double CTFDescription1D::D
 
PrecomputedForCTF CTFDescription1D::precomputed
 
std::vector< PrecomputedForCTFCTFDescription1D::precomputedImage
 
int CTFDescription1D::precomputedImageXdim
 
double CTFDescription1D::K
 Global gain. By default, 1. More...
 
double CTFDescription1D::Tm
 Sampling rate (A/pixel) More...
 
double CTFDescription1D::kV
 Accelerating Voltage (in KiloVolts) More...
 
double CTFDescription1D::Defocus
 Defocus (in Angstroms). Negative values are underfocused. More...
 
double CTFDescription1D::Cs
 Spherical aberration (in milimeters). Typical value 5.6. More...
 
double CTFDescription1D::Ca
 Chromatic aberration (in milimeters). Typical value 2. More...
 
double CTFDescription1D::espr
 
double CTFDescription1D::ispr
 Objective lens stability (deltaI/I) (ppm). Typical value 1. More...
 
double CTFDescription1D::alpha
 Convergence cone semiangle (in mrad). Typical value 0.5. More...
 
double CTFDescription1D::DeltaF
 Longitudinal mechanical displacement (ansgtrom). Typical value 100. More...
 
double CTFDescription1D::DeltaR
 Transversal mechanical displacement (ansgtrom). Typical value 3. More...
 
double CTFDescription1D::Q0
 Factor for the importance of the Amplitude contrast. More...
 
double CTFDescription1D::x0
 In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined. More...
 
double CTFDescription1D::xF
 In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined. More...
 
double CTFDescription1D::y0
 In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined. More...
 
double CTFDescription1D::yF
 In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined. More...
 
bool CTFDescription1D::isLocalCTF
 Local CTF determination. More...
 
bool CTFDescription1D::enable_CTFnoise
 Enable CTFnoise part. More...
 
bool CTFDescription1D::enable_CTF
 Enable CTF part. More...
 
double CTFDescription1D::base_line
 Global base_line. More...
 
double CTFDescription1D::gaussian_K
 Gain for the gaussian term. More...
 
double CTFDescription1D::sigma1
 Gaussian width. More...
 
double CTFDescription1D::Gc1
 Gaussian center. More...
 
double CTFDescription1D::sqrt_K
 Gain for the square root term. More...
 
double CTFDescription1D::sq
 Sqrt width. More...
 
double CTFDescription1D::gaussian_K2
 Gain for the second Gaussian term. More...
 
double CTFDescription1D::sigma2
 Second Gaussian width. More...
 
double CTFDescription1D::Gc2
 Second Gaussian center. More...
 
double CTFDescription1D::bgR1
 
double CTFDescription1D::bgR2
 
double CTFDescription1D::bgR3
 
double CTFDescription1D::envR0
 
double CTFDescription1D::envR1
 
double CTFDescription1D::envR2
 
double CTFDescription1D::freq_max
 
double CTFDescription1D::phase_shift
 
double CTFDescription1D::VPP_radius
 
double CTFDescription::rad_azimuth
 
double CTFDescription::defocus_average
 
double CTFDescription::defocus_deviation
 
double CTFDescription::rad_gaussian
 
double CTFDescription::rad_gaussian2
 
double CTFDescription::rad_sqrt
 
double CTFDescription::DeltafU
 Global gain. By default, 1. More...
 
double CTFDescription::DeltafV
 Defocus in V (in Angstroms). Negative values are underfocused. More...
 
double CTFDescription::azimuthal_angle
 Azimuthal angle (between X and U) in degrees. More...
 
double CTFDescription::sigmaU
 Spherical aberration (in milimeters). Typical value 5.6. More...
 
double CTFDescription::sigmaV
 Gaussian width V. More...
 
double CTFDescription::cU
 Gaussian center for U. More...
 
double CTFDescription::cV
 Gaussian center for V. More...
 
double CTFDescription::gaussian_angle
 Gaussian angle. More...
 
double CTFDescription::sqU
 Gain for the square root term. More...
 
double CTFDescription::sqV
 Sqrt width V. More...
 
double CTFDescription::sqrt_angle
 Sqrt angle. More...
 
double CTFDescription::sigmaU2
 Second Gaussian width U. More...
 
double CTFDescription::sigmaV2
 Second Gaussian width V. More...
 
double CTFDescription::cU2
 Second Gaussian center for U. More...
 
double CTFDescription::cV2
 Second Gaussian center for V. More...
 
double CTFDescription::gaussian_angle2
 Second Gaussian angle. More...
 

Friends

std::ostream & CTFDescription1D::operator<< (std::ostream &out, const CTFDescription1D &ctf)
 Show. More...
 
std::ostream & CTFDescription::operator<< (std::ostream &out, const CTFDescription &ctf)
 Show. More...
 

Detailed Description

Function Documentation

◆ applyCTF() [1/4]

void CTFDescription1D::applyCTF ( MultidimArray< std::complex< double > > &  FFTI,
const MultidimArray< double > &  I,
double  Ts,
bool  absPhase = false 
)

Apply CTF to an image.

Definition at line 800 of file ctf.cpp.

801 {
802  Matrix1D<int> idx(2);
803  Matrix1D<double> freq(2);
804  if ( ZSIZE(FFTI) > 1 )
805  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Apply_CTF only works on 2D images, not 3D.");
806 
807  double iTs=1.0/Ts;
809  {
810  XX(idx) = j;
811  YY(idx) = i;
812  FFT_idx2digfreq(I, idx, freq);
813  precomputeValues(XX(freq)*iTs);
814  double ctf = getValueAt();
815  if (absPhase)
816  ctf=fabs(ctf);
817  A2D_ELEM(FFTI, i, j) *= ctf;
818  }
819 }
#define A2D_ELEM(v, i, j)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:417
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
#define XX(v)
Definition: matrix1d.h:85
#define ZSIZE(v)
#define j
#define YY(v)
Definition: matrix1d.h:93
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173

◆ applyCTF() [2/4]

void CTFDescription1D::applyCTF ( MultidimArray< double > &  I,
double  Ts,
bool  absPhase = false 
)

Apply CTF to an image.

Definition at line 821 of file ctf.cpp.

822 {
823  FourierTransformer transformer;
825  transformer.setReal(I);
826  transformer.FourierTransform();
827  applyCTF(transformer.fFourier, I, Ts, absPhase);
828  transformer.inverseFourierTransform();
829 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
MultidimArray< std::complex< double > > fFourier
Definition: xmipp_fftw.h:70
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166
void applyCTF(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
Apply CTF to an image.
Definition: ctf.cpp:800

◆ applyCTF() [3/4]

void CTFDescription::applyCTF ( MultidimArray< std::complex< double > > &  FFTI,
const MultidimArray< double > &  I,
double  Ts,
bool  absPhase = false 
)

Apply CTF to an image.

Definition at line 1521 of file ctf.cpp.

1522 {
1523  Matrix1D<int> idx(2);
1524  Matrix1D<double> freq(2);
1525  if ( ZSIZE(FFTI) > 1 )
1526  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Apply_CTF only works on 2D images, not 3D.");
1527 
1528  double iTs=1.0/Ts;
1530  {
1531  XX(idx) = j;
1532  YY(idx) = i;
1533  FFT_idx2digfreq(I, idx, freq);
1534  precomputeValues(XX(freq)*iTs, YY(freq)*iTs);
1535  double ctf = getValueAt();
1536  if (absPhase)
1537  ctf=fabs(ctf);
1538  A2D_ELEM(FFTI, i, j) *= ctf;
1539  }
1540 }
#define A2D_ELEM(v, i, j)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
#define XX(v)
Definition: matrix1d.h:85
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:1050
#define ZSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
#define j
#define YY(v)
Definition: matrix1d.h:93
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173

◆ applyCTF() [4/4]

void CTFDescription::applyCTF ( MultidimArray< double > &  I,
double  Ts,
bool  absPhase = false 
)

Apply CTF to an image.

Definition at line 1542 of file ctf.cpp.

1543 {
1544  FourierTransformer transformer;
1545  MultidimArray<double> FFTI;
1546  transformer.setReal(I);
1547  transformer.FourierTransform();
1548  applyCTF(transformer.fFourier, I, Ts, absPhase);
1549  transformer.inverseFourierTransform();
1550 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
MultidimArray< std::complex< double > > fFourier
Definition: xmipp_fftw.h:70
void applyCTF(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts, bool absPhase=false)
Apply CTF to an image.
Definition: ctf.cpp:1521
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166

◆ changeSamplingRate() [1/2]

void CTFDescription1D::changeSamplingRate ( double  newTm)
inline

Change sampling rate. It is advisable to change the sampling rate just after reading the CTF parameters. However, unless you use precomputed values, there should not be any problem of changing it at a later stage.

Definition at line 367 of file ctf.h.

368  {
369  Tm=newTm;
370  }
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240

◆ changeSamplingRate() [2/2]

void CTFDescription::changeSamplingRate ( double  newTm)
inline

Change sampling rate. It is advisable to change the sampling rate just after reading the CTF parameters. However, unless you use precomputed values, there should not be any problem of changing it at a later stage.

Definition at line 994 of file ctf.h.

995  {
996  Tm=newTm;
997  }
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240

◆ clear() [1/2]

void CTFDescription1D::clear ( )

Clear.

Definition at line 610 of file ctf.cpp.

611 {
612  enable_CTF = true;
613  enable_CTFnoise = false;
614  isLocalCTF = false;
615  clearNoise();
616  clearPureCtf();
617  y0=x0=xF=yF=0;
618 }
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
void clearNoise()
Clear noise.
Definition: ctf.cpp:620
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
void clearPureCtf()
Clear pure CTF.
Definition: ctf.cpp:630
double y0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:267
double x0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:263
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double xF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:265
double yF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:269

◆ clear() [2/2]

void CTFDescription::clear ( )

Clear.

Definition at line 1366 of file ctf.cpp.

1367 {
1369  clearNoise();
1370  clearPureCtf();
1371 }
void clearPureCtf()
Clear pure CTF.
Definition: ctf.cpp:1384
void clearNoise()
Clear noise.
Definition: ctf.cpp:1373
void clear()
Clear.
Definition: ctf.cpp:610

◆ clearNoise() [1/2]

void CTFDescription1D::clearNoise ( )

Clear noise.

Definition at line 620 of file ctf.cpp.

621 {
622  base_line = 0;
623  Gc1 = sigma1 = gaussian_K = 0;
624  sq = sqrt_K = 0;
625  Gc2 = sigma2 = gaussian_K2 = 0;
626  bgR1 = bgR2 = bgR3 = 0.0;
627  isLocalCTF = false;
628 }
double bgR1
Definition: ctf.h:295
double bgR2
Definition: ctf.h:296
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sq
Sqrt width.
Definition: ctf.h:287
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double bgR3
Definition: ctf.h:297
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285

◆ clearNoise() [2/2]

void CTFDescription::clearNoise ( )

Clear noise.

Definition at line 1373 of file ctf.cpp.

1374 {
1375  base_line = 0;
1376  cU = cV = sigmaU = sigmaV = gaussian_angle = gaussian_K = 0;
1377  sqU = sqV = sqrt_K = sqrt_angle = 0;
1379  bgR1 = bgR2 = bgR3 = 0.0;
1380  VPP_radius = phase_shift = 0.0;
1381  isLocalCTF = false;
1382 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double bgR1
Definition: ctf.h:295
double bgR2
Definition: ctf.h:296
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double cU
Gaussian center for U.
Definition: ctf.h:875
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double sqV
Sqrt width V.
Definition: ctf.h:885
double bgR3
Definition: ctf.h:297
double sigmaV
Gaussian width V.
Definition: ctf.h:873
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
double VPP_radius
Definition: ctf.h:306
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877

◆ clearPureCtf() [1/2]

void CTFDescription1D::clearPureCtf ( )

Clear pure CTF.

Definition at line 630 of file ctf.cpp.

631 {
632  enable_CTF = true;
633  enable_CTFnoise = false;
634  Tm = 2;
635  kV = 100;
636  Defocus = 0;
637  Cs = Ca = espr = ispr = alpha = DeltaF = DeltaR = 0;
638  K = 1;
639  Q0 = 0;
640  envR0 = envR1 = envR2 = 0.0;
641  isLocalCTF = false;
642 }
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double espr
Definition: ctf.h:251
double envR0
Definition: ctf.h:299
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273

◆ clearPureCtf() [2/2]

void CTFDescription::clearPureCtf ( )

Clear pure CTF.

Definition at line 1384 of file ctf.cpp.

1385 {
1388 }
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
void clearPureCtf()
Clear pure CTF.
Definition: ctf.cpp:630

◆ correctPhase() [1/4]

void CTFDescription1D::correctPhase ( MultidimArray< std::complex< double > > &  FFTI,
const MultidimArray< double > &  I,
double  Ts 
)

Correct phase flip of an image.

Definition at line 832 of file ctf.cpp.

833 {
834  Matrix1D<int> idx(2);
835  Matrix1D<double> freq(2);
836  if ( ZSIZE(FFTI) > 1 )
837  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Correct phase only works on 2D images, not 3D.");
838 
839  double iTs=1.0/Ts;
841  {
842  XX(idx) = j;
843  YY(idx) = i;
844  FFT_idx2digfreq(I, idx, freq);
845  precomputeValues(XX(freq)*iTs);
846  double ctf = getValuePureAt();
847  if (ctf<0)
848  A2D_ELEM(FFTI, i, j) *= -1;
849  }
850 }
#define A2D_ELEM(v, i, j)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
#define XX(v)
Definition: matrix1d.h:85
#define ZSIZE(v)
#define j
#define YY(v)
Definition: matrix1d.h:93
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452

◆ correctPhase() [2/4]

void CTFDescription1D::correctPhase ( MultidimArray< double > &  I,
double  Ts 
)

Correct phase flip of an image.

Definition at line 852 of file ctf.cpp.

853 {
854  FourierTransformer transformer;
856  transformer.setReal(I);
857  transformer.FourierTransform();
858  correctPhase(transformer.fFourier, I, Ts);
859  transformer.inverseFourierTransform();
860 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
MultidimArray< std::complex< double > > fFourier
Definition: xmipp_fftw.h:70
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
void correctPhase(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts)
Correct phase flip of an image.
Definition: ctf.cpp:832
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166

◆ correctPhase() [3/4]

void CTFDescription::correctPhase ( MultidimArray< std::complex< double > > &  FFTI,
const MultidimArray< double > &  I,
double  Ts 
)

Correct phase flip of an image.

Definition at line 1553 of file ctf.cpp.

1554 {
1555  Matrix1D<int> idx(2);
1556  Matrix1D<double> freq(2);
1557  if ( ZSIZE(FFTI) > 1 )
1558  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Apply_CTF only works on 2D images, not 3D.");
1559 
1560  double iTs=1.0/Ts;
1562  {
1563  XX(idx) = j;
1564  YY(idx) = i;
1565  FFT_idx2digfreq(I, idx, freq);
1566  precomputeValues(XX(freq)*iTs, YY(freq)*iTs);
1567  double ctf = getValuePureAt();
1568  if (ctf<0)
1569  A2D_ELEM(FFTI, i, j) *= -1;
1570  }
1571 }
#define A2D_ELEM(v, i, j)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
#define XX(v)
Definition: matrix1d.h:85
#define ZSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
#define j
#define YY(v)
Definition: matrix1d.h:93
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452

◆ correctPhase() [4/4]

void CTFDescription::correctPhase ( MultidimArray< double > &  I,
double  Ts 
)

Correct phase flip of an image.

Definition at line 1573 of file ctf.cpp.

1574 {
1575  FourierTransformer transformer;
1576  MultidimArray<double> FFTI;
1577  transformer.setReal(I);
1578  transformer.FourierTransform();
1579  correctPhase(transformer.fFourier, I, Ts);
1580  transformer.inverseFourierTransform();
1581 }
void inverseFourierTransform()
Definition: xmipp_fftw.cpp:329
MultidimArray< std::complex< double > > fFourier
Definition: xmipp_fftw.h:70
void setReal(MultidimArray< double > &img)
Definition: xmipp_fftw.cpp:129
void FourierTransform(T &v, T1 &V, bool getCopy=true)
Definition: xmipp_fftw.h:166
void correctPhase(MultidimArray< std::complex< double > > &FFTI, const MultidimArray< double > &I, double Ts)
Correct phase flip of an image.
Definition: ctf.cpp:1553

◆ CTFDescription() [1/2]

CTFDescription::CTFDescription ( )
inline

Definition at line 899 of file ctf.h.

900  {
901  clear();
902  }
void clear()
Clear.
Definition: ctf.cpp:1366

◆ CTFDescription() [2/2]

CTFDescription::CTFDescription ( CTFDescription1D  copy)
inline

Definition at line 904 of file ctf.h.

905  {
906  DeltafU = DeltafV = copy.Defocus;
907  Ca = copy.Ca;
908  Cs = copy.Cs;
909  DeltaF = copy.DeltaF;
910  DeltaR = copy.DeltaR;
911  Q0 = copy.Q0;
912  cU = cV = copy.Gc1;
913  cU2 = cV2 = copy.Gc2;
914  base_line = copy.base_line;
915  gaussian_K = copy.gaussian_K;
916  gaussian_K2 = copy.gaussian_K2;
917  sigmaU = sigmaV = copy.sigma1;
918  sigmaU2 = sigmaV2 = copy.sigma2;
919  sqU = sqV = copy.sq;
920  kV = copy.kV;
921  bgR1 = copy.bgR1;
922  bgR2 = copy.bgR2;
923  bgR3 = copy.bgR3;
924  envR0 = copy.envR0;
925  envR1 = copy.envR1;
926  envR2 = copy.envR2;
927  espr = copy.espr;
928  ispr = copy.ispr;
929  alpha = copy.alpha;
930  sqrt_K = copy.sqrt_K;
931  K = copy.K;
932  Tm = copy.Tm;
933  azimuthal_angle = 0;
934  gaussian_angle = 0;
935  gaussian_angle2 = 0;
936  sqrt_angle = 0;
938  phase_shift = copy.phase_shift;
939  VPP_radius = copy.VPP_radius;
940  }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double bgR1
Definition: ctf.h:295
double bgR2
Definition: ctf.h:296
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double espr
Definition: ctf.h:251
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double cU
Gaussian center for U.
Definition: ctf.h:875
double phase_shift
Definition: ctf.h:305
double envR0
Definition: ctf.h:299
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sq
Sqrt width.
Definition: ctf.h:287
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double sqV
Sqrt width V.
Definition: ctf.h:885
double bgR3
Definition: ctf.h:297
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double sigmaV
Gaussian width V.
Definition: ctf.h:873
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
double VPP_radius
Definition: ctf.h:306
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877

◆ CTFDescription1D()

CTFDescription1D::CTFDescription1D ( )
inline

Empty constructor.

Definition at line 309 of file ctf.h.

310  {
311  clear();
312  }
void clear()
Clear.
Definition: ctf.cpp:610

◆ defineParams() [1/2]

void CTFDescription1D::defineParams ( XmippProgram program)
static

Define parameters in the command line.

Definition at line 496 of file ctf.cpp.

497 {
498  program->addParamsLine("== CTF1D description");
499  program->addParamsLine(" [--ctf_similar_to++ <ctfFile>] : ctfparam file");
500  program->addParamsLine(" : Parameters from this file are ");
501  program->addParamsLine(" : overriden by the parameters in the command line");
502  program->addParamsLine(" [--sampling_rate <Tm>] : Angstroms/pixel. Ex: 1.4");
503  program->addParamsLine(" : This parameter is compulsory if a CTF is needed.");
504  program->addParamsLine(" [--voltage <kV>] : Accelerating voltage (kV). Ex: 200");
505  program->addParamsLine(" : This parameter is compulsory if a CTF is needed.");
506  program->addParamsLine(" alias --kV;");
507  program->addParamsLine(" [--spherical_aberration <Cs>] : Milimiters. Ex: 5.6");
508  program->addParamsLine(" : This parameter is compulsory if a CTF is needed.");
509  program->addParamsLine(" alias --Cs;");
510  program->addParamsLine(" [--defocusU <Defocus>] : Defocus in Angstroms (Ex: 2000)");
511  program->addParamsLine(" [--chromatic_aberration++ <Ca=0>] : Milimiters. Ex: 2");
512  program->addParamsLine(" [--energy_loss++ <espr=0>] : eV. Ex: 1");
513  program->addParamsLine(" [--lens_stability++ <ispr=0>] : ppm. Ex: 1");
514  program->addParamsLine(" [--convergence_cone++ <alpha=0>] : mrad. Ex: 0.5");
515  program->addParamsLine(" [--longitudinal_displace++ <DeltaF=0>]: Angstrom. Ex: 100");
516  program->addParamsLine(" [--transversal_displace++ <DeltaR=0>] : Angstrom. Ex: 3");
517  program->addParamsLine(" [--Q0++ <Q0=0>] : Percentage of cosine (Q0>0)");
518  program->addParamsLine(" [--K++ <K=0>] : Global gain");
519  program->addParamsLine(" [--phase_shift++ <phase_shift>] : VPP phase shift");
520  program->addParamsLine(" [--VPP_radius++ <VPP_radius>] : phase plate radius");
521 }
void addParamsLine(const String &line)

◆ defineParams() [2/2]

void CTFDescription::defineParams ( XmippProgram program)
static

Define parameters in the command line.

Definition at line 1287 of file ctf.cpp.

1288 {
1290  program->addParamsLine("== CTF 2D description");
1291  program->addParamsLine(" [--defocusV++ <DeltafV>] : If astigmatic");
1292  program->addParamsLine(" [--azimuthal_angle++ <ang=0>] : Angle between X and U (degrees)");
1293 
1294 }
static void defineParams(XmippProgram *program)
Define parameters in the command line.
Definition: ctf.cpp:496
void addParamsLine(const String &line)

◆ errorBetween2CTFs()

double errorBetween2CTFs ( MetaData MD1,
MetaData MD2,
size_t  dim,
double  minFreq = 0.05,
double  maxFreq = 0.25 
)

compute error between two CTFS, return a single value

Definition at line 107 of file ctf.cpp.

112 {
113 
114  Matrix1D<double> freq(2); // Frequencies for Fourier plane
115 
116  CTFDescription CTF1;
117  CTFDescription CTF2;
118 
119  CTF1.enable_CTF=true;
120  CTF1.enable_CTFnoise=false;
121  CTF1.readFromMetadataRow(MD1,MD1.firstRowId());
122  CTF1.produceSideInfo();
123 
124  CTF2.enable_CTF=true;
125  CTF2.enable_CTFnoise=false;
126  CTF2.readFromMetadataRow(MD2,MD2.firstRowId());
127  CTF2.produceSideInfo();
128 
129  double iTm=1.0/CTF1.Tm;
130  size_t xDim;
131  size_t yDim;
132  xDim = yDim = Xdim;
133 #define DEBUG
134 #ifdef DEBUG
135 
136  Image<double> img1(xDim,yDim);
137  Image<double> img2(xDim,yDim);
138  Image<double> img3(xDim,yDim);
139 
140  MultidimArray<double> &dummy1 = img1.data;
141  MultidimArray<double> &dummy2 = img2.data;
142  MultidimArray<double> &dummy3 = img3.data;
143 #endif
144 
145  double error =0.;
146  double _freq=0.;
147  minFreq /= CTF1.Tm;
148  maxFreq /= CTF1.Tm;
149 
150  for (int i=0; i<(int)yDim; ++i)
151  {
152  FFT_IDX2DIGFREQ(i, yDim, YY(freq));
153  YY(freq) *= iTm;
154  for (int j=0; j<(int)xDim; ++j)
155  {
156  FFT_IDX2DIGFREQ(j, xDim, XX(freq));
157  XX(freq) *= iTm;
158  _freq = freq.module();
159  if (_freq < minFreq || _freq > maxFreq)
160  continue;
161  //freq *= CTF1.Tm;
162  CTF1.precomputeValues(XX(freq),YY(freq));
163  CTF2.precomputeValues(XX(freq),YY(freq));
164  error += fabs(CTF2.getValuePureWithoutDampingAt()- CTF1.getValuePureWithoutDampingAt());
165 #ifdef DEBUG
166 
167  double a = CTF1.getValuePureWithoutDampingAt();
168  double b = CTF2.getValuePureWithoutDampingAt();
169  DIRECT_A2D_ELEM(dummy1,i,j)=a;
170  DIRECT_A2D_ELEM(dummy2,i,j)=b;
171  DIRECT_A2D_ELEM(dummy3,i,j)=fabs(b-a);
172 #endif
173 
174  }
175  }
176 #ifdef DEBUG
177  img1.write("/tmp/img1.spi");
178  img2.write("/tmp/img2.spi");
179  img3.write("/tmp/img3.spi");
180 #endif
181 #undef DEBUG
182 
183  return error;
184 }
#define yDim
Definition: projection.cpp:42
#define xDim
Definition: projection.cpp:41
virtual size_t firstRowId() const =0
#define DIRECT_A2D_ELEM(v, i, j)
#define i
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
doublereal * b
#define XX(v)
Definition: matrix1d.h:85
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
double getValuePureWithoutDampingAt(bool show=false) const
Compute pure CTF without damping at (U,V). Continuous frequencies.
Definition: ctf.h:542
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
void error(char *s)
Definition: tools.cpp:107
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
doublereal * a

◆ errorMaxFreqCTFs()

double errorMaxFreqCTFs ( MetaData MD1,
double  phaseRad = HALFPI 
)

Report at which resolution an astigmatism CTF is shifted in perpendicular directions by phaseRad degrees. Returns amsgtroms

Definition at line 187 of file ctf.cpp.

189 {
190  CTFDescription CTF1;
191 
192  CTF1.enable_CTF=true;
193  CTF1.enable_CTFnoise=false;
194  CTF1.readFromMetadataRow(MD1,MD1.firstRowId());
195  CTF1.produceSideInfo();
196 
197 
198 //#define DEBUG
199 #ifdef DEBUG
200  std::cerr << "DEBUG_ROB: CTF1.DeltaU: " << CTF1.DeltafU << std::endl;
201  std::cerr << "DEBUG_ROB: CTF1.DeltaV: " << CTF1.DeltafV << std::endl;
202  std::cerr << "DEBUG_ROB: var: " << phaseRad/(CTF1.K1*abs(CTF1.DeltafU - CTF1.DeltafV)) << std::endl;
203  std::cerr << "DEBUG_ROB: var: " << sqrt(phaseRad/(CTF1.K1*abs(CTF1.DeltafU - CTF1.DeltafV))) << std::endl;
204  std::cerr << "DEBUG_ROB: var: " << 1/sqrt(phaseRad/(CTF1.K1*abs(CTF1.DeltafU - CTF1.DeltafV))) << std::endl;
205 
206 #endif
207 #undef DEBUG
208  //Armstrong ^-1
209  //K1 = PI / 2 * 2 * lambda;
210  return 1.0/sqrt(phaseRad/(CTF1.K1*abs(CTF1.DeltafU - CTF1.DeltafV)));
211 }
double K1
Definition: ctf.h:218
void sqrt(Image< double > &op)
virtual size_t firstRowId() const =0
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
void abs(Image< double > &op)
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273

◆ errorMaxFreqCTFs2D()

double errorMaxFreqCTFs2D ( MetaData MD1,
MetaData MD2,
size_t  xDim = 256,
double  phaseRad = HALFPI 
)

Report at which resolution these two CTF are shifted by phaseRad degrees returns amsgtroms

Definition at line 214 of file ctf.cpp.

218 {
219  Matrix1D<double> freq(2); // Frequencies for Fourier plane
220 
221  CTFDescription CTF1;
222  CTFDescription CTF2;
223 
224  CTF1.enable_CTF=true;
225  CTF1.enable_CTFnoise=false;
226  CTF1.readFromMetadataRow(MD1,MD1.firstRowId());
227  CTF1.produceSideInfo();
228 
229  CTF2.enable_CTF=true;
230  CTF2.enable_CTFnoise=false;
231  CTF2.readFromMetadataRow(MD2,MD2.firstRowId());
232  CTF2.produceSideInfo();
233 
234  double iTm=1.0/CTF1.Tm;
235  size_t xDim;
236  size_t yDim;
237  xDim = yDim = Xdim;
238 //#define DEBUG
239 #ifdef DEBUG
240 
241  Image<double> arg1(xDim,yDim);
242  Image<double> arg2(xDim,yDim);
243  Image<double> argDiff(xDim,yDim);
244  Image<double> ctf1(xDim,yDim);
245  Image<double> ctf2(xDim,yDim);
246  Image<double> ctfDiff(xDim,yDim);
247  Image<double> aux(xDim,yDim);
248 
249  MultidimArray<double> &arg1Mul = arg1.data;
250  MultidimArray<double> &arg2Mul = arg2.data;
251  MultidimArray<double> &argDiffMul = argDiff.data;
252  MultidimArray<double> &ctf1Mul = ctf1.data;
253  MultidimArray<double> &ctf2Mul = ctf2.data;
254  MultidimArray<double> &ctfDiffMul = ctfDiff.data;
255  MultidimArray<double> &auxMul = aux.data;
256  int counterAux = 0 ;
257 #endif
258 
259  int counter = 0 ;
260  //double _freq=0.;
261  for (int i=0; i<(int)yDim; ++i)
262  {
263  FFT_IDX2DIGFREQ(i, yDim, YY(freq));
264  YY(freq) *= iTm;
265  for (int j=0; j<(int)xDim; ++j)
266  {
267  FFT_IDX2DIGFREQ(j, xDim, XX(freq));
268  XX(freq) *= iTm;
269  //_freq = freq.module();
270  //freq *= CTF1.Tm;
271  CTF1.precomputeValues(XX(freq),YY(freq));
272  CTF2.precomputeValues(XX(freq),YY(freq));
273  double a = CTF1.getValueArgument();
274  double b = CTF2.getValueArgument();
275  if (fabs(b-a) < phaseRad)
276  counter++;
277 #ifdef DEBUG
278  counterAux++;
279  DIRECT_A2D_ELEM(argDiffMul,i,j)=fabs(b-a);
280  DIRECT_A2D_ELEM(arg1Mul,i,j)=a;
281  DIRECT_A2D_ELEM(arg2Mul,i,j)=b;
282  a = CTF1.getValuePureWithoutDampingAt();
283  b = CTF2.getValuePureWithoutDampingAt();
284  DIRECT_A2D_ELEM(ctf1Mul,i,j)=a;
285  DIRECT_A2D_ELEM(ctf2Mul,i,j)=b;
286  DIRECT_A2D_ELEM(ctfDiffMul,i,j)=fabs(b-a);
287 #endif
288 
289  }
290  }
291  double areaLessHalfPIPixels = counter;
292  double totalArePixels = PI*Xdim*Xdim/4.0;
293  double maxFreqA = 1./(2.*CTF1.Tm);
294  double resolutionA_1 = 0;
295  if (areaLessHalfPIPixels > totalArePixels)
296  resolutionA_1 = maxFreqA;
297  else
298  resolutionA_1 = areaLessHalfPIPixels * maxFreqA / totalArePixels;
299  double resolutionA = 1./ resolutionA_1;
300 #ifdef DEBUG
302  R.initIdentity(3);
303  R(2, 0) = 128.;
304  R(2, 1) = 128.;
305  applyGeometry(BSPLINE3, auxMul, arg1Mul, R.transpose(), IS_NOT_INV, true, 0.);
306  aux.write("/tmp/arg1.spi");
307  applyGeometry(BSPLINE3, auxMul, arg2Mul, R.transpose(), IS_NOT_INV, true, 0.);
308  aux.write("/tmp/arg2.spi");
309  applyGeometry(BSPLINE3, auxMul, argDiffMul, R.transpose(), IS_NOT_INV, true, 0.);
310  aux.write("/tmp/argDiff.spi");
311  applyGeometry(BSPLINE3, auxMul, ctf1Mul, R.transpose(), IS_NOT_INV, true, 0.);
312  aux.write("/tmp/ctf1.spi");
313  applyGeometry(BSPLINE3, auxMul, ctf2Mul, R.transpose(), IS_NOT_INV, true, 0.);
314  aux.write("/tmp/ctf2.spi");
315  applyGeometry(BSPLINE3, auxMul, ctfDiffMul, R.transpose(), IS_NOT_INV, true, 0.);
316  aux.write("/tmp/ctfMDiff.spi");
317 
318  std::cerr << "DEBUG_ROB: counter: " << counter << std::endl;
319  std::cerr << "DEBUG_ROB: counterAux: " << counterAux << std::endl;
320  std::cerr << "DEBUG_ROB: res in pixels: " << sqrt (counter/PI) << std::endl;
321  // area < halfpi area whole sprecta normalize to .5
322  std::cerr << "DEBUG_ROB: resolutionA_1: " << resolutionA_1 << std::endl;
323  std::cerr << "DEBUG_ROB: resolutionA: " << resolutionA << std::endl;
324 #endif
325 #undef DEBUG
326  return resolutionA;
327  //divide between area
328 }
#define yDim
Definition: projection.cpp:42
#define xDim
Definition: projection.cpp:41
void sqrt(Image< double > &op)
virtual size_t firstRowId() const =0
void applyGeometry(int SplineDegree, MultidimArray< std::complex< double > > &V2, const MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside, MultidimArray< double > *BcoeffsPtr)
#define DIRECT_A2D_ELEM(v, i, j)
Matrix2D< T > transpose() const
Definition: matrix2d.cpp:1314
#define i
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double getValueArgument(bool show=false) const
Compute pure CTF without damping at (U,V). Continuous frequencies.
Definition: ctf.h:1057
doublereal * b
#define XX(v)
Definition: matrix1d.h:85
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
double getValuePureWithoutDampingAt(bool show=false) const
Compute pure CTF without damping at (U,V). Continuous frequencies.
Definition: ctf.h:542
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
#define PI
Definition: tools.h:43
doublereal * a
void initIdentity()
Definition: matrix2d.h:673

◆ forcePhysicalMeaning() [1/2]

void CTFDescription1D::forcePhysicalMeaning ( )

Force physical meaning.

Definition at line 1055 of file ctf.cpp.

1056 {
1057  if (enable_CTF)
1058  {
1059  if (K < 0)
1060  K = 0;
1061  if (base_line < 0)
1062  base_line = 0;
1063  if (kV < 50)
1064  kV = 50;
1065  if (kV > 1000)
1066  kV = 1000;
1067  if (espr < 0)
1068  espr = 0;
1069  if (espr > 20)
1070  espr = 20;
1071  if (ispr < 0)
1072  ispr = 0;
1073  if (ispr > 20)
1074  ispr = 20;
1075  if (Cs < 0)
1076  Cs = 0;
1077  if (Cs > 20)
1078  Cs = 20;
1079  if (Ca < 0)
1080  Ca = 0;
1081  if (Ca > 3)
1082  Ca = 3;
1083  if (alpha < 0)
1084  alpha = 0;
1085  if (alpha > 5)
1086  alpha = 5;
1087  if (DeltaF < 0)
1088  DeltaF = 0;
1089  if (DeltaF > 1000)
1090  DeltaF = 1000;
1091  if (DeltaR < 0)
1092  DeltaR = 0;
1093  if (DeltaR > 1000)
1094  DeltaR = 1000;
1095  if (Q0 > 0.40)
1096  Q0 = 0.40;
1097  if (Q0 < 0)
1098  Q0 = 0;
1099  if (Defocus < 0)
1100  Defocus = 0;
1101 
1102  }
1103  if (enable_CTFnoise)
1104  {
1105  double min_sigma = XMIPP_MIN(sigma1, sigma1);
1106  double min_c = XMIPP_MIN(Gc1, Gc1);
1107  double min_sigma2 = XMIPP_MIN(sigma2, sigma2);
1108  double min_c2 = XMIPP_MIN(Gc2, Gc2);
1109  if (base_line < 0)
1110  base_line = 0;
1111  if (gaussian_K < 0)
1112  gaussian_K = 0;
1113  if (sigma1 < 0)
1114  sigma1 = 0;
1115  if (sigma1 > 100e3)
1116  sigma1 = 100e3;
1117  if (Gc1 < 0)
1118  Gc1 = 0;
1119  if (sq < 0)
1120  sq = 0;
1121  if (sqrt_K < 0)
1122  sqrt_K = 0;
1123  if (gaussian_K2 < 0)
1124  gaussian_K2 = 0;
1125  if (sigma2 < 0)
1126  sigma2 = 0;
1127  if (sigma2 > 100e3)
1128  sigma2 = 100e3;
1129  if (Gc2 < 0)
1130  Gc2 = 0;
1131  if (min_sigma > 0)
1132  if (sigma1 / min_sigma > 3)
1133  {
1134  sigma1 = 3.9 * sigma1;
1135  }
1136  if (min_c > 0)
1137  if (Gc1 / min_c > 3)
1138  {
1139  Gc1 = 3.9 * Gc1;
1140  }
1141  if (gaussian_K != 0)
1142  {
1143  if (Gc1*Tm < 0.01)
1144  Gc1 = 0.011 / Tm;
1145  }
1146  if (min_sigma2 > 0)
1147  if (sigma2 / min_sigma2 > 3)
1148  {
1149  sigma2 = 3.9 * sigma2;
1150  }
1151  if (min_c2 > 0)
1152  if (Gc2 / min_c2 > 3)
1153  {
1154  Gc2 = 3.9 * Gc2;
1155  }
1156  if (gaussian_K2 != 0)
1157  {
1158  if (Gc2*Tm < 0.01)
1159  Gc2 = 0.011 / Tm;
1160  }
1161  if (phase_shift > PI || phase_shift < -PI) //Normalize phase shift between 0-PI
1162  {
1163  phase_shift = realWRAP(phase_shift,-PI,PI);//phase_shift - floor(phase_shift/3.14)*3.14;
1164  }
1165  }
1166 }
double espr
Definition: ctf.h:251
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sq
Sqrt width.
Definition: ctf.h:287
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
#define realWRAP(x, x0, xF)
Definition: xmipp_macros.h:304
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
#define PI
Definition: tools.h:43
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285

◆ forcePhysicalMeaning() [2/2]

void CTFDescription::forcePhysicalMeaning ( )

Force physical meaning.

Definition at line 1781 of file ctf.cpp.

1782 {
1784  if (enable_CTF)
1785  {
1786  if (DeltafU < 0)
1787  DeltafU = 0;
1788  if (DeltafV < 0)
1789  DeltafV = 0;
1790  }
1791  if (enable_CTFnoise)
1792  {
1793  double min_sigma = XMIPP_MIN(sigmaU, sigmaV);
1794  double min_c = XMIPP_MIN(cU, cV);
1795  double min_sigma2 = XMIPP_MIN(sigmaU2, sigmaV2);
1796  double min_c2 = XMIPP_MIN(cU2, cV2);
1797  if (base_line < 0)
1798  base_line = 0;
1799  if (gaussian_K < 0)
1800  gaussian_K = 0;
1801  if (sigmaU < 0)
1802  sigmaU = 0;
1803  if (sigmaV < 0)
1804  sigmaV = 0;
1805  if (sigmaU > 100e3)
1806  sigmaU = 100e3;
1807  if (sigmaV > 100e3)
1808  sigmaV = 100e3;
1809  if (cU < 0)
1810  cU = 0;
1811  if (cV < 0)
1812  cV = 0;
1813  if (sqU < 0)
1814  sqU = 0;
1815  if (sqV < 0)
1816  sqV = 0;
1817  if (sqrt_K < 0)
1818  sqrt_K = 0;
1819  if (gaussian_K2 < 0)
1820  gaussian_K2 = 0;
1821  if (sigmaU2 < 0)
1822  sigmaU2 = 0;
1823  if (sigmaV2 < 0)
1824  sigmaV2 = 0;
1825  if (sigmaU2 > 100e3)
1826  sigmaU2 = 100e3;
1827  if (sigmaV2 > 100e3)
1828  sigmaV2 = 100e3;
1829  if (cU2 < 0)
1830  cU2 = 0;
1831  if (cV2 < 0)
1832  cV2 = 0;
1833  if (gaussian_angle < 0)
1834  gaussian_angle = 0;
1835  if (gaussian_angle > 90)
1836  gaussian_angle = 90;
1837  if (sqrt_angle < 0)
1838  sqrt_angle = 0;
1839  if (sqrt_angle > 90)
1840  sqrt_angle = 90;
1841  if (gaussian_angle2 < 0)
1842  gaussian_angle2 = 0;
1843  if (gaussian_angle2 > 90)
1844  gaussian_angle2 = 90;
1845  if (min_sigma > 0)
1846  if (ABS(sigmaU - sigmaV) / min_sigma > 3)
1847  {
1848  if (sigmaU < sigmaV)
1849  sigmaV = 3.9 * sigmaU;
1850  else
1851  sigmaU = 3.9 * sigmaV;
1852  }
1853  if (min_c > 0)
1854  if (ABS(cU - cV) / min_c > 3)
1855  {
1856  if (cU < cV)
1857  cV = 3.9 * cU;
1858  else
1859  cU = 3.9 * cV;
1860  }
1861  if (gaussian_K != 0)
1862  {
1863  if (cU*Tm < 0.01)
1864  cU = 0.011 / Tm;
1865  if (cV*Tm < 0.01)
1866  cV = 0.011 / Tm;
1867  }
1868  if (min_sigma2 > 0)
1869  if (ABS(sigmaU2 - sigmaV2) / min_sigma2 > 3)
1870  {
1871  if (sigmaU2 < sigmaV2)
1872  sigmaV2 = 3.9 * sigmaU2;
1873  else
1874  sigmaU2 = 3.9 * sigmaV2;
1875  }
1876  if (min_c2 > 0)
1877  if (ABS(cU2 - cV2) / min_c2 > 3)
1878  {
1879  if (cU2 < cV2)
1880  cV2 = 3.9 * cU2;
1881  else
1882  cU2 = 3.9 * cV2;
1883  }
1884  if (gaussian_K2 != 0)
1885  {
1886  if (cU2*Tm < 0.01)
1887  cU2 = 0.011 / Tm;
1888  if (cV2*Tm < 0.01)
1889  cV2 = 0.011 / Tm;
1890  }
1891  }
1892 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double cU
Gaussian center for U.
Definition: ctf.h:875
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double sqV
Sqrt width V.
Definition: ctf.h:885
#define ABS(x)
Definition: xmipp_macros.h:142
double sigmaV
Gaussian width V.
Definition: ctf.h:873
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
void forcePhysicalMeaning()
Definition: ctf.cpp:1055
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877

◆ generateCTF() [1/4]

template<class T1 , class T2 >
void CTFDescription1D::generateCTF ( const MultidimArray< T1 > &  sample_image,
MultidimArray< T2 > &  CTF,
double  Ts = -1 
)
inline

Generate CTF image. The sample image is used only to take its dimensions.

Definition at line 650 of file ctf.h.

651  {
652  if ( ZSIZE(sample_image) > 1 )
653  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Generate_CTF only works with 2D sample images, not 3D.");
654  generateCTF(YSIZE(sample_image), XSIZE(sample_image), CTF, Ts);
655  STARTINGX(CTF) = STARTINGX(sample_image);
656  STARTINGY(CTF) = STARTINGY(sample_image);
657  }
#define YSIZE(v)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define STARTINGX(v)
#define STARTINGY(v)
void generateCTF(const MultidimArray< T1 > &sample_image, MultidimArray< T2 > &CTF, double Ts=-1)
Definition: ctf.h:650
#define XSIZE(v)
#define ZSIZE(v)
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173

◆ generateCTF() [2/4]

template<class T >
void CTFDescription1D::generateCTF ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
)
inline

Generate CTF image.

Definition at line 690 of file ctf.h.

691  {
692  double iTs = initCTF(Ydim, Xdim, CTF, Ts);
693  for (int i=0; i<Ydim; ++i)
694  {
695  double wy;
696  FFT_IDX2DIGFREQ(i, YSIZE(CTF), wy);
697  double fy=wy*iTs;
698  for (int j=0; j<Xdim; ++j)
699  {
700  double wx;
701  FFT_IDX2DIGFREQ(j, XSIZE(CTF), wx);
702  double fx=wx*iTs;
703  precomputeValues(fx);
704  A2D_ELEM(CTF, i, j) = (T) getValueAt();
705  #ifdef DEBUG
706  if (i == 0)
707  std::cout << i << " " << j << " " << YY(freq) << " " << XX(freq)
708  << " " << CTF(i, j) << std::endl;
709  #endif
710  }
711  }
712  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:417
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
#define i
#define XX(v)
Definition: matrix1d.h:85
#define CTF
#define XSIZE(v)
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
double initCTF(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
Function to initialize CTF to avoid duplicated code.
Definition: ctf.h:676

◆ generateCTF() [3/4]

template<class T1 , class T2 >
void CTFDescription::generateCTF ( const MultidimArray< T1 > &  sample_image,
MultidimArray< T2 > &  CTF,
double  Ts = -1 
)
inline

Generate CTF image. The sample image is used only to take its dimensions.

Definition at line 1194 of file ctf.h.

1195  {
1196  if ( ZSIZE(sample_image) > 1 )
1197  REPORT_ERROR(ERR_MULTIDIM_DIM,"ERROR: Generate_CTF only works with 2D sample images, not 3D.");
1198  generateCTF(YSIZE(sample_image), XSIZE(sample_image), CTF, Ts);
1199  STARTINGX(CTF) = STARTINGX(sample_image);
1200  STARTINGY(CTF) = STARTINGY(sample_image);
1201  }
#define YSIZE(v)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define STARTINGX(v)
#define STARTINGY(v)
#define XSIZE(v)
#define ZSIZE(v)
void generateCTF(const MultidimArray< T1 > &sample_image, MultidimArray< T2 > &CTF, double Ts=-1)
Definition: ctf.h:1194
Incorrect MultidimArray dimensions.
Definition: xmipp_error.h:173

◆ generateCTF() [4/4]

template<class T >
void CTFDescription::generateCTF ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
)
inline

Generate CTF image.

Definition at line 1219 of file ctf.h.

1220  {
1221  double iTs = initCTF(Ydim, Xdim, CTF, Ts);
1222  for (int i=0; i<Ydim; ++i)
1223  {
1224  double wy;
1225  FFT_IDX2DIGFREQ(i, YSIZE(CTF), wy);
1226  double fy=wy*iTs;
1227  for (int j=0; j<Xdim; ++j)
1228  {
1229  double wx;
1230  FFT_IDX2DIGFREQ(j, XSIZE(CTF), wx);
1231  double fx=wx*iTs;
1232  precomputeValues(fx, fy);
1233  A2D_ELEM(CTF, i, j) = (T) getValueAt();
1234  #ifdef DEBUG
1235  if (i == 0)
1236  std::cout << i << " " << j << " " << fy << " " << fx
1237  << " " << CTF(i, j) << std::endl;
1238  #endif
1239  }
1240  }
1241  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define i
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:1050
#define CTF
#define XSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
double initCTF(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
Function to initialize CTF to avoid duplicated code.
Definition: ctf.h:676

◆ generateCTFImageWith2CTFs()

void generateCTFImageWith2CTFs ( const MetaData MD1,
const MetaData MD2,
int  Xdim,
MultidimArray< double > &  imgOut 
)

Generate CTF 2D image with two CTFs. The two CTFs are in fn1 and fn2. The output image is written to the file fnOut and has size Xdim x Xdim.

Definition at line 67 of file ctf.cpp.

68 {
69  CTFDescription CTF1;
70  CTFDescription CTF2;
71  CTF1.enable_CTF=true;
72  CTF1.enable_CTFnoise=false;
73  CTF1.readFromMetadataRow(MD1,MD1.firstRowId());
74  CTF1.produceSideInfo();
75 
76  CTF2.enable_CTF=true;
77  CTF2.enable_CTFnoise=false;
78  CTF2.readFromMetadataRow(MD2,MD2.firstRowId());
79  CTF2.produceSideInfo();
80 
81  imgOut.initZeros(Xdim,Xdim);
82  Matrix1D<int> idx(2);
83  Matrix1D<double> freq(2);
85  {
86  XX(idx) = j;
87  YY(idx) = i;
88 
89  // Digital frequency
90  FFT_idx2digfreq(imgOut, idx, freq);
91  if (XX(freq)>=0 && XX(freq)<0.5)
92  {
93  digfreq2contfreq(freq, freq, CTF1.Tm);
94  CTF1.precomputeValues(XX(freq),YY(freq));
95  A2D_ELEM(imgOut,i,j)=CTF1.getValueAt();
96  }
97  else
98  {
99  digfreq2contfreq(freq, freq, CTF2.Tm);
100  CTF2.precomputeValues(XX(freq),YY(freq));
101  A2D_ELEM(imgOut,i,j)=CTF2.getValueAt();
102  }
103  }
104  CenterFFT(imgOut,false);
105 }
#define A2D_ELEM(v, i, j)
virtual size_t firstRowId() const =0
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
#define XX(v)
Definition: matrix1d.h:85
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:1050
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
#define j
#define YY(v)
Definition: matrix1d.h:93
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
void initZeros(const MultidimArray< T1 > &op)
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
void digfreq2contfreq(const Matrix1D< double > &digfreq, Matrix1D< double > &contfreq, double pixel_size)
Definition: xmipp_fft.h:125

◆ generateCTFWithoutDamping() [1/2]

template<class T >
void CTFDescription1D::generateCTFWithoutDamping ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
)
inline

Definition at line 716 of file ctf.h.

717  {
718  double iTs = initCTF(Ydim, Xdim, CTF, Ts=-1);
719  for (int i=0; i<Ydim; ++i)
720  {
721  double wy;
722  FFT_IDX2DIGFREQ(i, YSIZE(CTF), wy);
723  double fy=wy*iTs;
724  for (int j=0; j<Xdim; ++j)
725  {
726  double wx;
727  FFT_IDX2DIGFREQ(j, XSIZE(CTF), wx);
728  double fx=wx*iTs;
729  precomputeValues(fx);
730  A2D_ELEM(CTF, i, j) = (T) getValuePureWithoutDampingAt();
731  #ifdef DEBUG
732  if (i == 0)
733  std::cout << i << " " << j << " " << YY(freq) << " " << XX(freq)
734  << " " << CTF(i, j) << std::endl;
735  #endif
736  }
737  }
738  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
#define i
#define XX(v)
Definition: matrix1d.h:85
#define CTF
#define XSIZE(v)
double getValuePureWithoutDampingAt(bool show=false) const
Compute pure CTF without damping at (U,V). Continuous frequencies.
Definition: ctf.h:542
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
double initCTF(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
Function to initialize CTF to avoid duplicated code.
Definition: ctf.h:676

◆ generateCTFWithoutDamping() [2/2]

template<class T >
void CTFDescription::generateCTFWithoutDamping ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
)
inline

Definition at line 1245 of file ctf.h.

1246  {
1247  double iTs = initCTF(Ydim, Xdim, CTF, Ts);
1248  for (int i=0; i<Ydim; ++i)
1249  {
1250  double wy;
1251  FFT_IDX2DIGFREQ(i, YSIZE(CTF), wy);
1252  double fy=wy*iTs;
1253  for (int j=0; j<Xdim; ++j)
1254  {
1255  double wx;
1256  FFT_IDX2DIGFREQ(j, XSIZE(CTF), wx);
1257  double fx=wx*iTs;
1258  precomputeValues(fx, fy);
1259  A2D_ELEM(CTF, i, j) = (T) getValuePureWithoutDampingAt();
1260  #ifdef DEBUG
1261  if (i == 0)
1262  std::cout << i << " " << j << " " << YY(freq) << " " << XX(freq)
1263  << " " << CTF(i, j) << std::endl;
1264  #endif
1265  }
1266  }
1267  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define i
#define XX(v)
Definition: matrix1d.h:85
#define CTF
#define XSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
double getValuePureWithoutDampingAt(bool show=false) const
Compute pure CTF without damping at (U,V). Continuous frequencies.
Definition: ctf.h:542
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
double initCTF(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
Function to initialize CTF to avoid duplicated code.
Definition: ctf.h:676

◆ generateEnvelope()

template<class T >
void CTFDescription::generateEnvelope ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
)
inline

Definition at line 1271 of file ctf.h.

1272  {
1273  double iTs = initCTF(Ydim, Xdim, CTF, Ts);
1274  for (int i=0; i<Ydim; ++i)
1275  {
1276  double wy;
1277  FFT_IDX2DIGFREQ(i, YSIZE(CTF), wy)
1278  double fy=wy*iTs;
1279  for (int j=0; j<Xdim; ++j)
1280  {
1281  double wx;
1282  FFT_IDX2DIGFREQ(j, XSIZE(CTF), wx)
1283  double fx=wx*iTs;
1284  precomputeValues(fx, fy);
1285  A2D_ELEM(CTF, i, j) = (T) -getValueDampingAt();
1286  #ifdef DEBUG
1287  if (i == 0)
1288  std::cout << i << " " << j << " " << YY(freq) << " " << XX(freq)
1289  << " " << CTF(i, j) << std::endl;
1290  #endif
1291  }
1292  }
1293  }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define i
#define XX(v)
Definition: matrix1d.h:85
#define CTF
#define XSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
Definition: ctf.h:424
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
#define j
#define YY(v)
Definition: matrix1d.h:93
double initCTF(int Ydim, int Xdim, MultidimArray< T > &CTF, double Ts=-1) const
Function to initialize CTF to avoid duplicated code.
Definition: ctf.h:676

◆ generatePSDCTFImage()

void generatePSDCTFImage ( MultidimArray< double > &  img,
const MetaData MD 
)

Generate an image with the PSD and the CTF Before calling the function img must have the enhanced PSD. The enhanced PSD image is modified to add the CTF.

Definition at line 330 of file ctf.cpp.

331 {
332  img.rangeAdjust(-1,1);
333  CenterFFT(img,false);
334 
336  CTF.enable_CTF=true;
337  CTF.enable_CTFnoise=false;
338  CTF.readFromMetadataRow(MD,MD.firstRowId());
339  CTF.produceSideInfo();
340 
341  Matrix1D<int> idx(2);
342  Matrix1D<double> freq(2);
344  {
345  XX(idx) = j;
346  YY(idx) = i;
347 
348  // Digital frequency
349  FFT_idx2digfreq(img, idx, freq);
350  if (XX(freq)>=0 && XX(freq)<0.5)
351  {
352  digfreq2contfreq(freq, freq, CTF.Tm);
353  CTF.precomputeValues(XX(freq),YY(freq));
354  double aux=CTF.getValueAt();
355  A2D_ELEM(img,i,j)=aux*aux;
356  }
357  }
358  CenterFFT(img,true);
359 }
#define A2D_ELEM(v, i, j)
virtual size_t firstRowId() const =0
void rangeAdjust(T minF, T maxF)
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
#define XX(v)
Definition: matrix1d.h:85
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:1050
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
#define CTF
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
#define j
#define YY(v)
Definition: matrix1d.h:93
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
void digfreq2contfreq(const Matrix1D< double > &digfreq, Matrix1D< double > &contfreq, double pixel_size)
Definition: xmipp_fft.h:125

◆ getAverageProfile() [1/2]

void CTFDescription1D::getAverageProfile ( double  fmax,
int  nsamples,
MultidimArray< double > &  profiles 
)

Get radial average profiles. It returns the radially average CTF profiles (BGNOISE, ENVELOPE, PSD, CTF). Profiles have nsamples from 0 to fmax (1/A).

Definition at line 894 of file ctf.cpp.

896 {
897  double step = fmax / nsamples;
898  profiles.initZeros(nsamples, 4);
899 
900  for (int angle=0; angle < 360; angle++) //Angulo??? En 1D no hay. Con que itero?
901  {
902  double angle2 = float(angle);
903  double cosinus = cos(angle2);
904  double f;
905  size_t i;
906  for (i = 0, f = 0; i < YSIZE(profiles); i++, f += step)
907  {
908  double fx = f * cosinus;
909 
910  // Compute current frequencies.
911  precomputeValues(fx);
912 
913  // Store values.
914  double bgNoise = getValueNoiseAt();
915  double ctf = getValuePureAt();
916  double E = getValueDampingAt();
917 
918  A2D_ELEM(profiles, i, 0) += 10*log10(bgNoise);
919  A2D_ELEM(profiles, i, 1) += 10*log10(bgNoise + E * E);
920  A2D_ELEM(profiles, i, 2) += 10*log10(bgNoise + ctf * ctf);
921  A2D_ELEM(profiles, i, 3) += getValuePureNoKAt();
922  }
923  }
924  profiles*=1.0/360;
925 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:506
#define i
double * f
void log10(Image< double > &op)
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
Definition: ctf.h:424
double getValuePureNoKAt() const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:499
void initZeros(const MultidimArray< T1 > &op)
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452
double fmax

◆ getAverageProfile() [2/2]

void CTFDescription::getAverageProfile ( double  fmax,
int  nsamples,
MultidimArray< double > &  profiles 
)

Get radial average profiles. It returns the radially average CTF profiles (BGNOISE, ENVELOPE, PSD, CTF). Profiles have nsamples from 0 to fmax (1/A).

Definition at line 1616 of file ctf.cpp.

1618 {
1619  double step = fmax / nsamples;
1620  profiles.initZeros(nsamples, 4);
1621 
1622  for(int angle=0; angle < 360; angle++)
1623  {
1624  double angle2 = float(angle);
1625  double sinus = sin(angle2);
1626  double cosinus = cos(angle2);
1627  double f;
1628  size_t i;
1629  for (i = 0, f = 0; i < YSIZE(profiles); i++, f += step)
1630  {
1631  double fx = f * cosinus;
1632  double fy = f * sinus;
1633 
1634  // Compute current frequencies.
1635  precomputeValues(fx, fy);
1636 
1637  // Store values.
1638  double bgNoise = getValueNoiseAt();
1639  double ctf = getValuePureAt();
1640  double E = getValueDampingAt();
1641 
1642  A2D_ELEM(profiles, i, 0) += 10*log10(bgNoise);
1643  A2D_ELEM(profiles, i, 1) += 10*log10(bgNoise + E * E);
1644  A2D_ELEM(profiles, i, 2) += 10*log10(bgNoise + ctf * ctf);
1645  A2D_ELEM(profiles, i, 3) += getValuePureNoKAt();
1646  }
1647  }
1648  profiles*=1.0/360;
1649 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define i
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:1121
double * f
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
void log10(Image< double > &op)
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
Definition: ctf.h:424
double getValuePureNoKAt() const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:499
void initZeros(const MultidimArray< T1 > &op)
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452
double fmax

◆ getDeltafNoPrecomputed()

double CTFDescription::getDeltafNoPrecomputed ( double  X,
double  Y 
) const
inline

Deltaf at a given direction.

Definition at line 1109 of file ctf.h.

1110  {
1111  if (fabs(X) < XMIPP_EQUAL_ACCURACY &&
1112  fabs(Y) < XMIPP_EQUAL_ACCURACY)
1113  return 0;
1114  double ellipsoid_ang = atan2(Y, X) - rad_azimuth;
1115  double cos_ellipsoid_ang_2 = cos(2*ellipsoid_ang);
1116  return(defocus_average + defocus_deviation*cos_ellipsoid_ang_2);
1117  }
double defocus_average
Definition: ctf.h:802
double defocus_deviation
Definition: ctf.h:804
double rad_azimuth
Definition: ctf.h:800
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119

◆ getPhaseAt()

double CTFDescription::getPhaseAt ( ) const
inline

Get Phase of the CTF.

Definition at line 1063 of file ctf.h.

1064  {
1066  }
double K1
Definition: ctf.h:218
double u4
Definition: ctf.h:89
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
double K2
Definition: ctf.h:219
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ getProfile() [1/2]

void CTFDescription1D::getProfile ( double  fmax,
int  nsamples,
MultidimArray< double > &  profiles 
)

Get profiles along a given direction. It returns the CTF profiles (BGNOISE, ENVELOPE, PSD, CTF) along the direction defined by angle. Profiles have nsamples from 0 to fmax (1/A).

Definition at line 863 of file ctf.cpp.

865 {
866  double step = fmax / nsamples;
867 
868  profiles.resizeNoCopy(nsamples, 4);
869  //double sinus = sin(angle);
870  //double cosinus = cos(angle);
871  double f;
872  size_t i;
873 
874  for (i = 0, f = 0; i < YSIZE(profiles); i++, f += step)
875  {
876  double fx = f;
877 
878  // Compute current frequencies.
879  precomputeValues(fx);
880 
881  // Store values.
882  double bgNoise = getValueNoiseAt();
883  double ctf = getValuePureAt();
884  double E = getValueDampingAt();
885 
886  A2D_ELEM(profiles, i, 0) = 10*log10(bgNoise);
887  A2D_ELEM(profiles, i, 1) = 10*log10(bgNoise + E * E);
888  A2D_ELEM(profiles, i, 2) = 10*log10(bgNoise + ctf * ctf);
889  A2D_ELEM(profiles, i, 3) = getValuePureNoKAt();
890  }
891 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void resizeNoCopy(const MultidimArray< T1 > &v)
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:506
#define i
double * f
void log10(Image< double > &op)
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
Definition: ctf.h:424
double getValuePureNoKAt() const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:499
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452
double fmax

◆ getProfile() [2/2]

void CTFDescription::getProfile ( double  angle,
double  fmax,
int  nsamples,
MultidimArray< double > &  profiles 
)

Get profiles along a given direction. It returns the CTF profiles (BGNOISE, ENVELOPE, PSD, CTF) along the direction defined by angle. Profiles have nsamples from 0 to fmax (1/A).

Definition at line 1584 of file ctf.cpp.

1586 {
1587  double step = fmax / nsamples;
1588 
1589  profiles.resizeNoCopy(nsamples, 4);
1590  double sinus = sin(angle);
1591  double cosinus = cos(angle);
1592  double f;
1593  size_t i;
1594 
1595  for (i = 0, f = 0; i < YSIZE(profiles); i++, f += step)
1596  {
1597  double fx = f * cosinus;
1598  double fy = f * sinus;
1599 
1600  // Compute current frequencies.
1601  precomputeValues(fx, fy);
1602 
1603  // Store values.
1604  double bgNoise = getValueNoiseAt();
1605  double ctf = getValuePureAt();
1606  double E = getValueDampingAt();
1607 
1608  A2D_ELEM(profiles, i, 0) = 10*log10(bgNoise);
1609  A2D_ELEM(profiles, i, 1) = 10*log10(bgNoise + E * E);
1610  A2D_ELEM(profiles, i, 2) = 10*log10(bgNoise + ctf * ctf);
1611  A2D_ELEM(profiles, i, 3) = getValuePureNoKAt();
1612  }
1613 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void resizeNoCopy(const MultidimArray< T1 > &v)
#define i
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:1121
double * f
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
void log10(Image< double > &op)
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
Definition: ctf.h:424
double getValuePureNoKAt() const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:499
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452
double fmax

◆ getSineAndCosineParts()

void CTFDescription1D::getSineAndCosineParts ( double &  sine_part,
double &  cosine_part,
double  E,
double  u2,
double  deltaf,
bool  show 
) const
inline

Definition at line 572 of file ctf.h.

573  {
574  double u = sqrt(u2);
575  double u4 = u2 * u2;
576  double VPP;
577  double check_VPP = round(VPP_radius*1000);
578  if(check_VPP != 0)
579  VPP = -phase_shift*(1-exp(-u2/(2*pow(VPP_radius,2.0))));
580  else
581  VPP = 0;
582  double argument = VPP + K1 * deltaf * u2 + K2 * u4;
583  //sincos(argument,&sine_part, &cosine_part); // OK
584  sine_part = sin(argument);
585  cosine_part = cos(argument);
586  double Eespr = exp(-K3 * u4); // OK
587  //CO: double Eispr=exp(-K4*u4); // OK
588  double EdeltaF = bessj0(K5 * u2); // OK
589  double EdeltaR = sinc(u * DeltaR); // OK
590  double Ealpha = exp(-K6 * (K7 * u2 * u + deltaf * u) * (K7 * u2 * u + deltaf * u)); // OK
591  // CO: double E=Eespr*Eispr*EdeltaF*EdeltaR*Ealpha;
592  E = Eespr * EdeltaF * EdeltaR * Ealpha+envR0+envR1*precomputed.u+envR2*precomputed.u2;
593  if (E < 0)
594  E = 0;
595  if (show)
596  {
597  std::cout << " Deltaf=" << deltaf << std::endl;
598  std::cout << " u,u2,u4=" << u << " " << u2 << " " << u4 << std::endl;
599  std::cout << " K1,K2,sin=" << K1 << " " << K2 << " "
600  << sine_part << std::endl;
601  std::cout << " K3,Eespr=" << K3 << " " << Eespr << std::endl;
602  //std::cout << " K4,Eispr=" << K4 << " " << /*Eispr*/ << std::endl;
603  std::cout << " K5,EdeltaF=" << K5 << " " << EdeltaF << std::endl;
604  std::cout << " EdeltaR=" << EdeltaR << std::endl;
605  std::cout << " K6,K7,Ealpha=" << K6 << " " << K7 << " " << Ealpha
606  << std::endl;
607  std::cout << " Total atenuation(E)= " << E << std::endl;
608  std::cout << " K,Q0,base_line=" << K << "," << Q0 << "," << base_line << std::endl;
609  }
610  }
double K1
Definition: ctf.h:218
double u
Definition: ctf.h:86
double envR1
Definition: ctf.h:300
double sinc(double x)
void sqrt(Image< double > &op)
double envR2
Definition: ctf.h:301
double phase_shift
Definition: ctf.h:305
double envR0
Definition: ctf.h:299
double u2
Definition: ctf.h:87
double base_line
Global base_line.
Definition: ctf.h:277
double K2
Definition: ctf.h:219
double K6
Definition: ctf.h:223
double K7
Definition: ctf.h:224
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double K
Global gain. By default, 1.
Definition: ctf.h:238
double K5
Definition: ctf.h:222
int round(double x)
Definition: ap.cpp:7245
double VPP_radius
Definition: ctf.h:306
doublereal * u
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double bessj0(double x)
PrecomputedForCTF precomputed
Definition: ctf.h:231
double K3
Definition: ctf.h:220

◆ getValueArgument()

double CTFDescription::getValueArgument ( bool  show = false) const
inline

Compute pure CTF without damping at (U,V). Continuous frequencies.

Definition at line 1057 of file ctf.h.

1058  {
1060  }
double K1
Definition: ctf.h:218
double u4
Definition: ctf.h:89
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
double K2
Definition: ctf.h:219
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ getValueAt() [1/2]

double CTFDescription1D::getValueAt ( bool  show = false) const
inline

Compute CTF at (U,V). Continuous frequencies.

Definition at line 417 of file ctf.h.

418  {
419  double pure_CTF = enable_CTF ? getValuePureAt(show) : 0;
420  return enable_CTFnoise ? sqrt(pure_CTF*pure_CTF + getValueNoiseAt(show)) : pure_CTF;
421  }
void sqrt(Image< double > &op)
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:506
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452

◆ getValueAt() [2/2]

double CTFDescription::getValueAt ( bool  show = false) const
inline

Compute CTF at (U,V). Continuous frequencies.

Definition at line 1050 of file ctf.h.

1051  {
1052  double pure_CTF = enable_CTF ? getValuePureAt(show) : 0;
1053  return enable_CTFnoise ? sqrt(pure_CTF*pure_CTF + getValueNoiseAt(show)) : pure_CTF;
1054  }
void sqrt(Image< double > &op)
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double getValueNoiseAt(bool show=false) const
Compute noise at (X,Y). Continuous frequencies, notice it is squared.
Definition: ctf.h:1121
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452

◆ getValueDampingAt()

double CTFDescription1D::getValueDampingAt ( bool  show = false) const
inline

Compute CTF damping at (U,V). Continuous frequencies.

Definition at line 424 of file ctf.h.

425  {
426  double Eespr = exp(-K3 * precomputed.u4); // OK
427  double EdeltaF = bessj0(K5 * precomputed.u2); // OK
428  double EdeltaR = SINC(precomputed.u * DeltaR); // OK
430  double Ealpha = exp(-K6 * aux * aux);
431  double E = Eespr * EdeltaF * EdeltaR * Ealpha+envR0+envR1*precomputed.u+envR2*precomputed.u2;
432  if (E < 0)
433  E = 0;
434  if (show)
435  {
436  std::cout << " Deltaf=" << precomputed.deltaf << std::endl;
437  std::cout << " u,u2,u4=" << precomputed.u << " " << precomputed.u2
438  << " " << precomputed.u4 << std::endl;
439  std::cout << " K3,Eespr=" << K3 << " " << Eespr << std::endl;
440  std::cout << " K4,Eispr=" << K4 << " " << /*Eispr <<*/ std::endl;
441  std::cout << " K5,EdeltaF=" << K5 << " " << EdeltaF << std::endl;
442  std::cout << " EdeltaR=" << EdeltaR << std::endl;
443  std::cout << " K6,K7,Ealpha=" << K6 << " " << K7 << " " << Ealpha
444  << std::endl;
445  std::cout << " Total atenuation(E)= " << E << std::endl;
446  std::cout << " CTFdamp=" << E << std::endl;
447  }
448  return -K*E;
449  }
double u
Definition: ctf.h:86
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double u4
Definition: ctf.h:89
double envR0
Definition: ctf.h:299
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
double K4
Definition: ctf.h:221
double K6
Definition: ctf.h:223
double K7
Definition: ctf.h:224
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double K
Global gain. By default, 1.
Definition: ctf.h:238
double K5
Definition: ctf.h:222
double bessj0(double x)
PrecomputedForCTF precomputed
Definition: ctf.h:231
#define SINC(x)
Definition: xmipp_macros.h:362
double K3
Definition: ctf.h:220

◆ getValueNoiseAt() [1/2]

double CTFDescription1D::getValueNoiseAt ( bool  show = false) const
inline

Compute noise at (X,Y). Continuous frequencies, notice it is squared.

Definition at line 506 of file ctf.h.

507  {
508  double c = Gc1;
509  double sigmaG1 = sigma1;
510 
511  double c2 = Gc2;
512  double sigmaG2 = sigma2;
513 
514  if(show)
515  {
516  std::cout
517  << " sq=" << sq << "\n"
518  << " c=" << c << "\n"
519  << " sigma=" << sigmaG1 << "\n"
520  << " c2=" << c2 << "\n"
521  << " sigma2=" << sigmaG2 << "\n"
522  << " gaussian_K=" << gaussian_K << "\n"
523  << " sqrt_K=" << sqrt_K << "\n"
524  << " base_line=" << base_line << "\n";
525  std::cout << " u=" << precomputed.u << "u_sqrt=" << precomputed.u_sqrt <<") CTFnoise="
526  << base_line +
527  gaussian_K*exp(-sigmaG1*(precomputed.u - c)*(precomputed.u - c)) +
528  sqrt_K*exp(-sq*sqrt(precomputed.u)) -
529  gaussian_K2*exp(-sigmaG2*(precomputed.u - c2)*(precomputed.u - c2)) << std::endl;
530  }
531 
532  double aux=precomputed.u - c;
533  double aux2=precomputed.u - c2;
534  return base_line +
535  gaussian_K*exp(-sigmaG1*aux*aux) +
536  sqrt_K*exp(-sq*precomputed.u_sqrt) -
537  gaussian_K2*exp(-sigmaG2*aux2*aux2)+
539  }
double bgR1
Definition: ctf.h:295
double u
Definition: ctf.h:86
double bgR2
Definition: ctf.h:296
doublereal * c
void sqrt(Image< double > &op)
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double u2
Definition: ctf.h:87
double sq
Sqrt width.
Definition: ctf.h:287
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double bgR3
Definition: ctf.h:297
double u_sqrt
Definition: ctf.h:85
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
PrecomputedForCTF precomputed
Definition: ctf.h:231
double u3
Definition: ctf.h:88

◆ getValueNoiseAt() [2/2]

double CTFDescription::getValueNoiseAt ( bool  show = false) const
inline

Compute noise at (X,Y). Continuous frequencies, notice it is squared.

Definition at line 1121 of file ctf.h.

1122  {
1123  double ellipsoid_ang = precomputed.ang - rad_gaussian;
1124  double ellipsoid_ang2 = precomputed.ang - rad_gaussian2;
1125  double ellipsoid_sqrt_ang = precomputed.ang - rad_sqrt;
1126  double cos_sqrt_ang = cos(ellipsoid_sqrt_ang);
1127  double cos_sqrt_ang_2 = cos_sqrt_ang*cos_sqrt_ang;
1128  double sin_sqrt_ang_2 = 1.0-cos_sqrt_ang_2;
1129  double sq = sqrt(sqU * sqU * cos_sqrt_ang_2 + sqV * sqV * sin_sqrt_ang_2);
1130 
1131  double cos_ang = cos(ellipsoid_ang);
1132  double cos_ang_2 = cos_ang*cos_ang;
1133  double sin_ang_2 = 1.0-cos_ang_2;
1134  double c = sqrt(cU * cU * cos_ang_2 + cV * cV * sin_ang_2);
1135  double sigma = sqrt(sigmaU * sigmaU * cos_ang_2 + sigmaV * sigmaV * sin_ang_2);
1136 
1137  double cos_ang2 = cos(ellipsoid_ang2);
1138  double cos_ang2_2 = cos_ang2*cos_ang2;
1139  double sin_ang2_2 = 1.0-cos_ang2_2;
1140  double c2 = sqrt(cU2 * cU2 * cos_ang2_2 + cV2 * cV2 * sin_ang2_2);
1141  double sigma2 = sqrt(sigmaU2 * sigmaU2 * cos_ang2_2 + sigmaV2 * sigmaV2 * sin_ang2_2);
1142 
1143  if(show)
1144  {
1145  std::cout << " ellipsoid_ang=" << RAD2DEG(ellipsoid_ang) << std::endl
1146  << " ellipsoid_sqrt_ang=" << RAD2DEG(ellipsoid_sqrt_ang) << std::endl
1147  << " sq=" << sq << "\n"
1148  << " c=" << c << "\n"
1149  << " sigma=" << sigma << "\n"
1150  << " ellipsoid_ang2=" << RAD2DEG(ellipsoid_ang2) << std::endl
1151  << " cU2=" << cU2 << " cV2=" << cV2 << "\n"
1152  << " cos_ang2=" << cos_ang2 << " sin_ang2_2=" << sin_ang2_2 << "\n"
1153  << " c2=" << c2 << "\n"
1154  << " sigmaU2=" << sigma2 << "\n"
1155  << " gaussian_K=" << gaussian_K << "\n"
1156  << " sqrt_K=" << sqrt_K << "\n"
1157  << " base_line=" << base_line << "\n";
1158  std::cout << " u=" << precomputed.u << "u_sqrt=" << precomputed.u_sqrt <<") CTFnoise="
1159  << base_line +
1160  gaussian_K*exp(-sigma*(precomputed.u - c)*(precomputed.u - c)) +
1161  sqrt_K*exp(-sq*sqrt(precomputed.u)) -
1162  gaussian_K2*exp(-sigma2*(precomputed.u - c2)*(precomputed.u - c2)) << std::endl;
1163  }
1164 
1165  double aux=precomputed.u - c;
1166  double aux2=precomputed.u - c2;
1167  return base_line +
1168  gaussian_K*exp(-sigma*aux*aux) +
1169  sqrt_K*exp(-sq*precomputed.u_sqrt) -
1170  gaussian_K2*exp(-sigma2*aux2*aux2)+
1172  }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double bgR1
Definition: ctf.h:295
double u
Definition: ctf.h:86
double bgR2
Definition: ctf.h:296
double rad_sqrt
Definition: ctf.h:810
doublereal * c
void sqrt(Image< double > &op)
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double rad_gaussian
Definition: ctf.h:806
double cU
Gaussian center for U.
Definition: ctf.h:875
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double u2
Definition: ctf.h:87
double sq
Sqrt width.
Definition: ctf.h:287
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double sqV
Sqrt width V.
Definition: ctf.h:885
double bgR3
Definition: ctf.h:297
double rad_gaussian2
Definition: ctf.h:808
double sigmaV
Gaussian width V.
Definition: ctf.h:873
double u_sqrt
Definition: ctf.h:85
double ang
Definition: ctf.h:90
#define RAD2DEG(r)
Definition: xmipp_macros.h:320
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
PrecomputedForCTF precomputed
Definition: ctf.h:231
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877
double u3
Definition: ctf.h:88

◆ getValuePureAt()

double CTFDescription1D::getValuePureAt ( bool  show = false) const
inline

Compute CTF pure at (U,V). Continuous frequencies.

Definition at line 452 of file ctf.h.

453  {
454  double VPP=0.0;
455  double check_VPP = round(VPP_radius*1000);
456  if(check_VPP != 0)
457  VPP = -phase_shift*(1-exp(-precomputed.u2/(2*pow(VPP_radius,2.0))));
458  else
459  VPP = 0;
460  double argument = VPP + K1 * precomputed.deltaf * precomputed.u2 + K2 *precomputed.u4;
461  double sine_part;
462  double cosine_part;
463  //sincos(argument,&sine_part, &cosine_part);
464  sine_part = sin(argument);
465  cosine_part = cos(argument);// OK
466  double Eespr = exp(-K3 * precomputed.u4); // OK
467  //CO: double Eispr=exp(-K4*u4); // OK
468  double EdeltaF = bessj0(K5 * precomputed.u2); // OK
469  double EdeltaR = SINC(precomputed.u * DeltaR); // OK
471  double Ealpha = exp(-K6 * aux * aux); // OK
472  // CO: double E=Eespr*Eispr*EdeltaF*EdeltaR*Ealpha;
473  double E = Eespr * EdeltaF * EdeltaR * Ealpha + envR0+envR1*precomputed.u+envR2*precomputed.u2;
474  if (E < 0)
475  E = 0;
476 
477  if (show)
478  {
479  std::cout << " Deltaf=" << precomputed.deltaf << std::endl;
480  std::cout << " u,u2,u4=" << precomputed.u << " " << precomputed.u2
481  << " " << precomputed.u4 << std::endl;
482  std::cout << " K1,K2,argument=" << K1 << " " << K2 << " " << argument << std::endl;
483  std::cout << " K3,Eespr=" << K3 << " " << Eespr << std::endl;
484  //std::cout << " K4,Eispr=" << K4 << " " << /*Eispr <<*/ std::endl;
485  std::cout << " K5,EdeltaF=" << K5 << " " << EdeltaF << std::endl;
486  std::cout << " EdeltaR=" << EdeltaR << std::endl;
487  std::cout << " K6,K7,Ealpha=" << K6 << " " << K7 << " " << Ealpha
488  << std::endl;
489  std::cout << " Total atenuation(E)= " << E << std::endl;
490  std::cout << " K,Q0,base_line=" << K << "," << Q0 << "," << base_line << std::endl;
491  std::cout << " VPP=" << VPP << " VPPRadius=" << VPP_radius << " phase shift=" << phase_shift << std::endl;
492  std::cout << " CTF="
493  << -K*(Ksin*sine_part - Kcos*cosine_part)*E << std::endl;
494  }
495  return -K*(Ksin*sine_part - Kcos*cosine_part)*E;
496  }
double K1
Definition: ctf.h:218
double u
Definition: ctf.h:86
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double u4
Definition: ctf.h:89
double phase_shift
Definition: ctf.h:305
double envR0
Definition: ctf.h:299
double u2
Definition: ctf.h:87
double base_line
Global base_line.
Definition: ctf.h:277
double deltaf
Definition: ctf.h:91
double K2
Definition: ctf.h:219
double K6
Definition: ctf.h:223
double K7
Definition: ctf.h:224
double Ksin
Definition: ctf.h:225
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double K
Global gain. By default, 1.
Definition: ctf.h:238
double K5
Definition: ctf.h:222
int round(double x)
Definition: ap.cpp:7245
double VPP_radius
Definition: ctf.h:306
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double bessj0(double x)
PrecomputedForCTF precomputed
Definition: ctf.h:231
double Kcos
Definition: ctf.h:226
#define SINC(x)
Definition: xmipp_macros.h:362
double K3
Definition: ctf.h:220

◆ getValuePureNoDampingNoPrecomputedAt()

double CTFDescription::getValuePureNoDampingNoPrecomputedAt ( double  X,
double  Y 
) const
inline

Compute CTF pure at (U,V). Continuous frequencies.

Definition at line 1087 of file ctf.h.

1088  {
1089  double u2 = X * X + Y * Y;
1090  //if(u2 > freq_max) return 0;
1091  double u4 = u2 * u2;
1092  double deltaf = getDeltafNoPrecomputed(X, Y);
1093  double VPP;
1094  double check_VPP = round(VPP_radius*1000);
1095  if(check_VPP != 0)
1096  VPP = -phase_shift*(1-exp(-u2/(2*pow(VPP_radius,2.0))));
1097  else
1098  VPP = 0;
1099  double argument = VPP + K1 * deltaf * u2 + K2 * u4;
1100  double sine_part;
1101  double cosine_part;
1102  //sincos(argument,&sine_part, &cosine_part); // OK
1103  sine_part = sin(argument);
1104  cosine_part = cos(argument);
1105  return -(Ksin*sine_part - Kcos*cosine_part);
1106  }
double K1
Definition: ctf.h:218
double getDeltafNoPrecomputed(double X, double Y) const
Deltaf at a given direction.
Definition: ctf.h:1109
double phase_shift
Definition: ctf.h:305
double K2
Definition: ctf.h:219
double Ksin
Definition: ctf.h:225
int round(double x)
Definition: ap.cpp:7245
double VPP_radius
Definition: ctf.h:306
double Kcos
Definition: ctf.h:226

◆ getValuePureNoKAt()

double CTFDescription1D::getValuePureNoKAt ( ) const
inline

Compute CTF pure at (U,V). Continuous frequencies.

Definition at line 499 of file ctf.h.

500  {
501  return K*getValuePureAt();
502  }
double K
Global gain. By default, 1.
Definition: ctf.h:238
double getValuePureAt(bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:452

◆ getValuePureNoPrecomputedAt()

double CTFDescription1D::getValuePureNoPrecomputedAt ( double  X,
bool  show = false 
) const
inline

Compute CTF pure at (U,V). Continuous frequencies.

Definition at line 613 of file ctf.h.

614  {
615  double u2 = X * X;
616  double deltaf = Defocus;
617  double sine_part = 0;
618  double cosine_part = 0;
619  double E = 0;
620  getSineAndCosineParts(sine_part, cosine_part, E, u2, deltaf, show);
621  if (show)
622  {
623  std::cout << " (X)=(" << X << ") CTF="
624  << -K*(Ksin*sine_part - Kcos*cosine_part)*E + base_line << std::endl;
625  }
626  return -K*(Ksin*sine_part - Kcos*cosine_part)*E;
627  }
double base_line
Global base_line.
Definition: ctf.h:277
double Ksin
Definition: ctf.h:225
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
void getSineAndCosineParts(double &sine_part, double &cosine_part, double E, double u2, double deltaf, bool show) const
Definition: ctf.h:572
double Kcos
Definition: ctf.h:226

◆ getValuePureNoPrecomputedAtxy()

double CTFDescription::getValuePureNoPrecomputedAtxy ( double  X,
double  Y,
bool  show = false 
) const
inline

Compute CTF pure at (U,V). Continuous frequencies.

Definition at line 1069 of file ctf.h.

1070  {
1071  double u2 = X * X + Y * Y;
1072  //if (u2>=ua2) return 0;
1073  double deltaf = getDeltafNoPrecomputed(X, Y);
1074  double sine_part = 0;
1075  double cosine_part = 0;
1076  double E = 0;
1077  getSineAndCosineParts(sine_part, cosine_part, E, u2, deltaf, show);
1078  if (show)
1079  {
1080  std::cout << " (X,Y)=(" << X << "," << Y << ") CTF="
1081  << -K*(Ksin*sine_part - Kcos*cosine_part)*E + base_line << std::endl;
1082  }
1083  return -K*(Ksin*sine_part - Kcos*cosine_part)*E;
1084  }
double getDeltafNoPrecomputed(double X, double Y) const
Deltaf at a given direction.
Definition: ctf.h:1109
double base_line
Global base_line.
Definition: ctf.h:277
double Ksin
Definition: ctf.h:225
double K
Global gain. By default, 1.
Definition: ctf.h:238
void getSineAndCosineParts(double &sine_part, double &cosine_part, double E, double u2, double deltaf, bool show) const
Definition: ctf.h:572
double Kcos
Definition: ctf.h:226

◆ getValuePureWithoutDampingAt()

double CTFDescription1D::getValuePureWithoutDampingAt ( bool  show = false) const
inline

Compute pure CTF without damping at (U,V). Continuous frequencies.

Definition at line 542 of file ctf.h.

543  {
544  double VPP;
545  double check_VPP = round(VPP_radius*1000);
546  if(check_VPP != 0)
547  VPP = -phase_shift*(1-exp(-precomputed.u2/(2*pow(VPP_radius,2.0))));
548  else
549  VPP = 0;
550  double argument = VPP + K1 * precomputed.deltaf * precomputed.u2 + K2 * precomputed.u4;
551  double sine_part;
552  double cosine_part;
553  //sincos(argument,&sine_part,&cosine_part);
554  sine_part = sin(argument);
555  cosine_part = cos(argument);// OK
556 
557  if (show)
558  {
559  std::cout << " Deltaf=" << precomputed.deltaf << std::endl;
560  std::cout << " u,u2,u4=" << precomputed.u << " " << precomputed.u2
561  << " " << precomputed.u4 << std::endl;
562  std::cout << " K1,K2,sin=" << K1 << " " << K2 << " "
563  << std::endl;
564  std::cout << " Q0=" << Q0 << std::endl;
565  std::cout << " VPP=" << VPP << std::endl;
566  std::cout << " CTF without damping="
567  << -(Ksin*sine_part - Kcos*cosine_part) << std::endl;
568  }
569  return -(Ksin*sine_part - Kcos*cosine_part);
570  }
double K1
Definition: ctf.h:218
double u
Definition: ctf.h:86
double u4
Definition: ctf.h:89
double phase_shift
Definition: ctf.h:305
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
double K2
Definition: ctf.h:219
double Ksin
Definition: ctf.h:225
int round(double x)
Definition: ap.cpp:7245
double VPP_radius
Definition: ctf.h:306
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
PrecomputedForCTF precomputed
Definition: ctf.h:231
double Kcos
Definition: ctf.h:226

◆ hasPhysicalMeaning() [1/2]

bool CTFDescription1D::hasPhysicalMeaning ( )

Check physical meaning. true if the CTF parameters have physical meaning. Call this function after produstd::cing side information

Definition at line 929 of file ctf.cpp.

930 {
931  bool retval;
932  if (enable_CTF)
933  {
934  precomputeValues(0);
935  retval =
936  K >= 0 && base_line >= 0 &&
937  kV >= 50 && kV <= 1000 &&
938  espr >= 0 && espr <= 20 &&
939  ispr >= 0 && ispr <= 20 &&
940  Cs >= 0 && Cs <= 20 &&
941  Ca >= 0 && Ca <= 7 &&
942  alpha >= 0 && alpha <= 5 &&
943  DeltaF >= 0 && DeltaF <= 1000 &&
944  DeltaR >= 0 && DeltaR <= 100 &&
945  Q0 >= 0 && Q0 <= 0.40 &&
946  Defocus >= 0 && getValueAt() >= 0;
947 #ifdef DEBUG
948 
949  if (retval == false)
950  {
951  std::cout << *this << std::endl;
952  std::cout << "K>=0 && base_line>=0 " << (K >= 0 && base_line >= 0) << std::endl
953  << "kV>=50 && kV<=1000 " << (kV >= 50 && kV <= 1000) << std::endl
954  << "espr>=0 && espr<=20 " << (espr >= 0 && espr <= 20) << std::endl
955  << "ispr>=0 && ispr<=20 " << (ispr >= 0 && ispr <= 20) << std::endl
956  << "Cs>=0 && Cs<=20 " << (Cs >= 0 && Cs <= 20) << std::endl
957  << "Ca>=0 && Ca<=3 " << (Ca >= 0 && Ca <= 3) << std::endl
958  << "alpha>=0 && alpha<=5 " << (alpha >= 0 && alpha <= 5) << std::endl
959  << "DeltaF>=0 && DeltaF<=1000 " << (DeltaF >= 0 && DeltaF <= 1000) << std::endl
960  << "DeltaR>=0 && DeltaR<=100 " << (DeltaR >= 0 && DeltaR <= 100) << std::endl
961  << "Q0>=0 && Q0<=0.4 " << (Q0 >= 0 && Q0 <= 0.4) << std::endl
962  << "Defocus>=0 " << (DeltafU >= 0 << std::endl
963  << "getValueAt(0,0)>=0 " << (getValueAt() >= 0) << std::endl
964  ;
965  std::cout << "getValueAt(0,0)=" << getValueAt(true) << std::endl;
966  }
967 #endif
968 
969  }
970  else
971  retval = true;
972  bool retval2;
973  if (enable_CTFnoise)
974  {
975  double min_sigma = XMIPP_MIN(sigma1, sigma1);
976  double min_c = XMIPP_MIN(Gc1, Gc1);
977  double min_sigma2 = XMIPP_MIN(sigma2, sigma2);
978  double min_c2 = XMIPP_MIN(Gc2, Gc2);
979  retval2 =
980  base_line >= 0 &&
981  gaussian_K >= 0 &&
982  sigma1 >= 0 &&
983  sigma1 <= 100e3 &&
984  Gc1 >= 0 &&
985  sq >= 0 &&
986  sqrt_K >= 0 &&
987  gaussian_K2 >= 0 &&
988  sigma2 >= 0 &&
989  sigma2 <= 100e3 &&
990  Gc2 >= 0 &&
991  phase_shift >= 0.0 && phase_shift <= 3.14
992  ;
993 
994  if (min_sigma > 0)
995  retval2 = retval2 && sigma1 / min_sigma <= 3;
996  if (min_c > 0)
997  retval2 = retval2 && Gc1 / min_c <= 3;
998  if (gaussian_K != 0)
999  retval2 = retval2 && (Gc1 * Tm >= 0.01);
1000  if (min_sigma2 > 0)
1001  retval2 = retval2 && sigma2 / min_sigma2 <= 3;
1002  if (min_c2 > 0)
1003  retval2 = retval2 && Gc2 / min_c2 <= 3;
1004  if (gaussian_K2 != 0)
1005  retval2 = retval2 && (Gc2 * Tm >= 0.01);
1006 
1007 #ifdef DEBUG
1008 
1009  if (retval2 == false)
1010  {
1011  std::cout << *this << std::endl;
1012  std::cout << "base_line>=0 && " << (base_line >= 0) << std::endl
1013  << "gaussian_K>=0 && " << (gaussian_K >= 0) << std::endl
1014  << "sigmaU>=0 && sigmaV>=0 " << (sigmaU >= 0 && sigmaV >= 0) << std::endl
1015  << "sigmaU<=100e3 && sigmaV<=100e3 " << (sigmaU <= 100e3 && sigmaV <= 100e3) << std::endl
1016  << "cU>=0 && cV>=0 " << (cU >= 0 && cV >= 0) << std::endl
1017  << "sqU>=0 && sqV>=0 " << (sqU >= 0 && sqV >= 0) << std::endl
1018  << "sqrt_K>=0 && " << (sqrt_K >= 0) << std::endl
1019  << "gaussian_K2>=0 && " << (gaussian_K2 >= 0) << std::endl
1020  << "sigmaU2>=0 && sigmaV2>=0 " << (sigmaU2 >= 0 && sigmaV2 >= 0) << std::endl
1021  << "sigmaU2<=100e3 && sigmaV2<=100e3 " << (sigmaU2 <= 100e3 && sigmaV2 <= 100e3) << std::endl
1022  << "cU2>=0 && cV2>=0 " << (cU2 >= 0 && cV2 >= 0) << std::endl
1023  << "gaussian_angle>=0 && gaussian_angle<=90 " << (gaussian_angle >= 0 && gaussian_angle <= 90) << std::endl
1024  << "sqrt_angle>=0 && sqrt_angle<=90 " << (sqrt_angle >= 0 && sqrt_angle <= 90) << std::endl
1025  << "gaussian_angle2>=0 && gaussian_angle2<=90 " << (gaussian_angle2 >= 0 && gaussian_angle2 <= 90) << std::endl
1026  ;
1027  if (min_sigma > 0)
1028  std::cout << "ABS(sigmaU-sigmaV)/min_sigma<=3 " << (ABS(sigmaU - sigmaV) / min_sigma <= 3) << std::endl;
1029  if (min_c > 0)
1030  std::cout << "ABS(cU-cV)/min_c<=3 " << (ABS(cU - cV) / min_c <= 3) << std::endl;
1031  if (gaussian_K > 0)
1032  std::cout << "(cU*Tm>=0.01) && (cV*Tm>=0.01) " << ((cU*Tm >= 0.01) && (cV*Tm >= 0.01)) << std::endl;
1033  if (min_sigma2 > 0)
1034  std::cout << "ABS(sigmaU2-sigmaV2)/min_sigma2<=3 " << (ABS(sigmaU2 - sigmaV2) / min_sigma2 <= 3) << std::endl;
1035  if (min_c2 > 0)
1036  std::cout << "ABS(cU2-cV2)/min_c2<=3 " << (ABS(cU2 - cV2) / min_c2 <= 3) << std::endl;
1037  if (gaussian_K2 > 0)
1038  std::cout << "(cU2*Tm>=0.01) && (cV2*Tm>=0.01) " << ((cU2*Tm >= 0.01) && (cV2*Tm >= 0.01)) << std::endl;
1039  std::cout << cV2*Tm << std::endl;
1040  }
1041 #endif
1042 
1043  }
1044  else
1045  retval2 = true;
1046 #ifdef DEBUG
1047 
1048 #endif
1049 
1050  return retval && retval2;
1051 }
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:417
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
double espr
Definition: ctf.h:251
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double sq
Sqrt width.
Definition: ctf.h:287
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
#define ABS(x)
Definition: xmipp_macros.h:142
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285

◆ hasPhysicalMeaning() [2/2]

bool CTFDescription::hasPhysicalMeaning ( )

Check physical meaning. true if the CTF parameters have physical meaning. Call this function after produstd::cing side information

Definition at line 1653 of file ctf.cpp.

1654 {
1655  bool retval;
1656  if (enable_CTF)
1657  {
1658  precomputeValues(0,0);
1659  retval =
1660  K >= 0 && base_line >= 0 &&
1661  kV >= 50 && kV <= 1000 &&
1662  espr >= 0 && espr <= 20 &&
1663  ispr >= 0 && ispr <= 20 &&
1664  Cs >= 0 && Cs <= 20 &&
1665  Ca >= 0 && Ca <= 7 &&
1666  alpha >= 0 && alpha <= 9 &&
1667  DeltaF >= 0 && DeltaF <= 1000 &&
1668  DeltaR >= 0 && DeltaR <= 100 &&
1669  Q0 >= 0 && Q0 <= 0.40 &&
1670  DeltafU >= 0 && DeltafV >= 0 &&
1671  getValueAt() >= 0;
1672 #ifdef DEBUG
1673 
1674  if (retval == false)
1675  {
1676  std::cout << *this << std::endl;
1677  std::cout << "K>=0 && base_line>=0 " << (K >= 0 && base_line >= 0) << std::endl
1678  << "kV>=50 && kV<=1000 " << (kV >= 50 && kV <= 1000) << std::endl
1679  << "espr>=0 && espr<=20 " << (espr >= 0 && espr <= 20) << std::endl
1680  << "ispr>=0 && ispr<=20 " << (ispr >= 0 && ispr <= 20) << std::endl
1681  << "Cs>=0 && Cs<=20 " << (Cs >= 0 && Cs <= 20) << std::endl
1682  << "Ca>=0 && Ca<=3 " << (Ca >= 0 && Ca <= 7) << std::endl
1683  << "alpha>=0 && alpha<=5 " << (alpha >= 0 && alpha <= 5) << std::endl
1684  << "DeltaF>=0 && DeltaF<=1000 " << (DeltaF >= 0 && DeltaF <= 1000) << std::endl
1685  << "DeltaR>=0 && DeltaR<=100 " << (DeltaR >= 0 && DeltaR <= 100) << std::endl
1686  << "Q0>=0 && Q0<=0.4 " << (Q0 >= 0 && Q0 <= 0.4) << std::endl
1687  << "DeltafU>=0 && DeltafV>=0 " << (DeltafU >= 0 && DeltafV >= 0) << std::endl
1688  << "getValueAt(0,0)>=0 " << (getValueAt() >= 0) << std::endl
1689  ;
1690  std::cout << "getValueAt(0,0)=" << getValueAt(true) << std::endl;
1691  }
1692 #endif
1693 
1694  }
1695  else
1696  retval = true;
1697  bool retval2;
1698  if (enable_CTFnoise)
1699  {
1700  double min_sigma = XMIPP_MIN(sigmaU, sigmaV);
1701  double min_c = XMIPP_MIN(cU, cV);
1702  double min_sigma2 = XMIPP_MIN(sigmaU2, sigmaV2);
1703  double min_c2 = XMIPP_MIN(cU2, cV2);
1704  retval2 =
1705  base_line >= 0 &&
1706  gaussian_K >= 0 &&
1707  sigmaU >= 0 && sigmaV >= 0 &&
1708  sigmaU <= 100e3 && sigmaV <= 100e3 &&
1709  cU >= 0 && cV >= 0 &&
1710  sqU >= 0 && sqV >= 0 &&
1711  sqrt_K >= 0 &&
1712  gaussian_K2 >= 0 &&
1713  sigmaU2 >= 0 && sigmaV2 >= 0 &&
1714  sigmaU2 <= 100e3 && sigmaV2 <= 100e3 &&
1715  cU2 >= 0 && cV2 >= 0 &&
1716  gaussian_angle >= 0 && gaussian_angle <= 90 &&
1717  sqrt_angle >= 0 && sqrt_angle <= 90 &&
1718  gaussian_angle2 >= 0 && gaussian_angle2 <= 90 &&
1719  phase_shift >= -PI && phase_shift <= PI
1720  ;
1721  if (min_sigma > 0)
1722  retval2 = retval2 && ABS(sigmaU - sigmaV) / min_sigma <= 3;
1723  if (min_c > 0)
1724  retval2 = retval2 && ABS(cU - cV) / min_c <= 3;
1725  if (gaussian_K != 0)
1726  retval2 = retval2 && (cU * Tm >= 0.01) && (cV * Tm >= 0.01);
1727  if (min_sigma2 > 0)
1728  retval2 = retval2 && ABS(sigmaU2 - sigmaV2) / min_sigma2 <= 3;
1729  if (min_c2 > 0)
1730  retval2 = retval2 && ABS(cU2 - cV2) / min_c2 <= 3;
1731  if (gaussian_K2 != 0)
1732  retval2 = retval2 && (cU2 * Tm >= 0.01) && (cV2 * Tm >= 0.01);
1733 #ifdef DEBUG
1734 
1735  if (retval2 == false)
1736  {
1737  std::cout << *this << std::endl;
1738  std::cout << "base_line>=0 && " << (base_line >= 0) << std::endl
1739  << "gaussian_K>=0 && " << (gaussian_K >= 0) << std::endl
1740  << "sigmaU>=0 && sigmaV>=0 " << (sigmaU >= 0 && sigmaV >= 0) << std::endl
1741  << "sigmaU<=100e3 && sigmaV<=100e3 " << (sigmaU <= 100e3 && sigmaV <= 100e3) << std::endl
1742  << "cU>=0 && cV>=0 " << (cU >= 0 && cV >= 0) << std::endl
1743  << "sqU>=0 && sqV>=0 " << (sqU >= 0 && sqV >= 0) << std::endl
1744  << "sqrt_K>=0 && " << (sqrt_K >= 0) << std::endl
1745  << "gaussian_K2>=0 && " << (gaussian_K2 >= 0) << std::endl
1746  << "sigmaU2>=0 && sigmaV2>=0 " << (sigmaU2 >= 0 && sigmaV2 >= 0) << std::endl
1747  << "sigmaU2<=100e3 && sigmaV2<=100e3 " << (sigmaU2 <= 100e3 && sigmaV2 <= 100e3) << std::endl
1748  << "cU2>=0 && cV2>=0 " << (cU2 >= 0 && cV2 >= 0) << std::endl
1749  << "gaussian_angle>=0 && gaussian_angle<=90 " << (gaussian_angle >= 0 && gaussian_angle <= 90) << std::endl
1750  << "sqrt_angle>=0 && sqrt_angle<=90 " << (sqrt_angle >= 0 && sqrt_angle <= 90) << std::endl
1751  << "gaussian_angle2>=0 && gaussian_angle2<=90 " << (gaussian_angle2 >= 0 && gaussian_angle2 <= 90) << std::endl
1752  ;
1753  if (min_sigma > 0)
1754  std::cout << "ABS(sigmaU-sigmaV)/min_sigma<=3 " << (ABS(sigmaU - sigmaV) / min_sigma <= 3) << std::endl;
1755  if (min_c > 0)
1756  std::cout << "ABS(cU-cV)/min_c<=3 " << (ABS(cU - cV) / min_c <= 3) << std::endl;
1757  if (gaussian_K > 0)
1758  std::cout << "(cU*Tm>=0.01) && (cV*Tm>=0.01) " << ((cU*Tm >= 0.01) && (cV*Tm >= 0.01)) << std::endl;
1759  if (min_sigma2 > 0)
1760  std::cout << "ABS(sigmaU2-sigmaV2)/min_sigma2<=3 " << (ABS(sigmaU2 - sigmaV2) / min_sigma2 <= 3) << std::endl;
1761  if (min_c2 > 0)
1762  std::cout << "ABS(cU2-cV2)/min_c2<=3 " << (ABS(cU2 - cV2) / min_c2 <= 3) << std::endl;
1763  if (gaussian_K2 > 0)
1764  std::cout << "(cU2*Tm>=0.01) && (cV2*Tm>=0.01) " << ((cU2*Tm >= 0.01) && (cV2*Tm >= 0.01)) << std::endl;
1765  std::cout << cV2*Tm << std::endl;
1766  }
1767 #endif
1768 
1769  }
1770  else
1771  retval2 = true;
1772 #ifdef DEBUG
1773 
1774 #endif
1775 
1776  return retval && retval2;
1777 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double espr
Definition: ctf.h:251
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double cU
Gaussian center for U.
Definition: ctf.h:875
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double getValueAt(bool show=false) const
Compute CTF at (U,V). Continuous frequencies.
Definition: ctf.h:1050
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double sqV
Sqrt width V.
Definition: ctf.h:885
#define ABS(x)
Definition: xmipp_macros.h:142
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double sigmaV
Gaussian width V.
Definition: ctf.h:873
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
double K
Global gain. By default, 1.
Definition: ctf.h:238
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
#define PI
Definition: tools.h:43
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877

◆ initCTF()

template<class T >
double CTFDescription1D::initCTF ( int  Ydim,
int  Xdim,
MultidimArray< T > &  CTF,
double  Ts = -1 
) const
inline

Function to initialize CTF to avoid duplicated code.

Definition at line 676 of file ctf.h.

677  {
678  CTF.resizeNoCopy(Ydim, Xdim);
679  if (Ts<0)
680  Ts=Tm;
681  #ifdef DEBUG
682  std::cout << "CTF:\n" << *this << std::endl;
683  #endif
684  double iTs=1.0/Ts;
685  return iTs;
686  }
void resizeNoCopy(const MultidimArray< T1 > &v)
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240

◆ lookFor() [1/2]

void CTFDescription1D::lookFor ( int  n,
const Matrix1D< double > &  u,
Matrix1D< double > &  freq,
int  iwhat = 0 
)

Returns the continuous frequency of the zero, maximum or minimum number n in the direction u. u must be a unit vector, n=1,2,... Returns (-1,-1) if it is not found 'iwhat' can be 0 (zero), 1(max), or -1 (min)

Definition at line 701 of file ctf.cpp.

702 {
703  double wmax = 1 / (2 * Tm);
704  double wstep = wmax / 300;
705  int found = 0;
706  double last_ctf = getValuePureNoPrecomputedAt(0);
707  double ctf=0.0;
708  double state=1;
709 
710  double w = 0;
711 
712  while (w <= wmax)
713  {
714  V2_BY_CT(freq, u, w);
715  ctf = getValuePureNoPrecomputedAt(XX(freq));
716 
717  switch (iwhat)
718  {
719  case 0: // Looking for zeroes
720  if (SGN(ctf) != SGN(last_ctf))
721  found++;
722  break;
723  case 1: // Looking for maxima
724  if (w>0)
725  {
726  if (state==1) // Going up
727  {
728  if (ctf<last_ctf)
729  {
730  found++;
731  state=-1;
732  }
733  }
734  else // Going down
735  {
736  if (ctf>last_ctf)
737  state=1;
738  }
739  }
740  break;
741  case -1: // Looking for minima
742  if (w>0)
743  {
744  if (state==-1) // Going down
745  {
746  if (ctf>last_ctf)
747  {
748  found++;
749  state=1;
750  }
751  }
752  else // Going up
753  {
754  if (ctf<last_ctf)
755  state=-1;
756  }
757  }
758  break;
759  }
760  if (found == n)
761  {
762  break;
763  }
764 
765  last_ctf = ctf;
766  w += wstep;
767  }
768  if (found != n)
769  {
770 
771  VECTOR_R2(freq, -1, -1);
772  }
773  else
774  {
775  // Compute more accurate zero
776 #ifdef DEBUG
777  std::cout << n << " zero: w=" << w << " (" << wmax << ") freq="
778  << (u*w).transpose()
779  << " last_ctf=" << last_ctf << " ctf=" << ctf << " ";
780 #endif
781 
782  switch (iwhat)
783  {
784  case 0:
785  w += ctf * wstep / (last_ctf - ctf);
786  break;
787  default:
788  w-=wstep;
789  }
790  V2_BY_CT(freq, u, w);
791 #ifdef DEBUG
792 
793  std::cout << " final w= " << w << " final freq=" << freq.transpose() << std::endl;
794 #endif
795  }
796 }
#define VECTOR_R2(v, x, y)
Definition: matrix1d.h:112
doublereal * w
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
#define XX(v)
Definition: matrix1d.h:85
void transpose(double *array, int size)
double getValuePureNoPrecomputedAt(double X, bool show=false) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:613
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
#define V2_BY_CT(a, b, k)
Definition: matrix1d.h:179
#define SGN(x)
Definition: xmipp_macros.h:155
int * n

◆ lookFor() [2/2]

void CTFDescription::lookFor ( int  n,
const Matrix1D< double > &  u,
Matrix1D< double > &  freq,
int  iwhat = 0 
)

Returns the continuous frequency of the zero, maximum or minimum number n in the direction u. u must be a unit vector, n=1,2,... Returns (-1,-1) if it is not found 'iwhat' can be 0 (zero), 1(max), or -1 (min)

Definition at line 1428 of file ctf.cpp.

1429 {
1430  double wmax = 1 / (2 * Tm);
1431  double wstep = wmax / 300;
1432  int found = 0;
1433  double last_ctf = getValuePureNoDampingNoPrecomputedAt(0,0);
1434  double ctf=0.0;
1435  double state=1; //getValuePureWithoutDampingAt()
1436  double w = 0;
1437  while (w <= wmax)
1438  {
1439  V2_BY_CT(freq, u, w);
1440  ctf = getValuePureNoDampingNoPrecomputedAt(XX(freq),YY(freq));
1441  switch (iwhat)
1442  {
1443  case 0: // Looking for zeroes
1444  if (SGN(ctf) != SGN(last_ctf))
1445  found++;
1446  break;
1447  case 1: // Looking for maxima
1448  if (w>0)
1449  {
1450  if (state==1) // Going up
1451  {
1452  if (ctf<last_ctf)
1453  {
1454  found++;
1455  state=-1;
1456  }
1457  }
1458  else // Going down
1459  {
1460  if (ctf>last_ctf)
1461  state=1;
1462  }
1463  }
1464  break;
1465  case -1: // Looking for minima
1466  if (w>0)
1467  {
1468  if (state==-1) // Going down
1469  {
1470  if (ctf>last_ctf)
1471  {
1472  found++;
1473  state=1;
1474  }
1475  }
1476  else // Going up
1477  {
1478  if (ctf<last_ctf)
1479  state=-1;
1480  }
1481  }
1482  break;
1483  }
1484  if (found == n)
1485  break;
1486 
1487  last_ctf = ctf;
1488  w += wstep;
1489  }
1490  if (found != n)
1491  {
1492  VECTOR_R2(freq, -1, -1);
1493  }
1494  else
1495  {
1496  // Compute more accurate zero
1497 #ifdef DEBUG
1498  std::cout << n << " zero: w=" << w << " (" << wmax << ") freq="
1499  << (u*w).transpose()
1500  << " last_ctf=" << last_ctf << " ctf=" << ctf << " ";
1501 #endif
1502 
1503  switch (iwhat)
1504  {
1505  case 0:
1506  w += ctf * wstep / (last_ctf - ctf);
1507  break;
1508  default:
1509  w-=wstep;
1510  }
1511  V2_BY_CT(freq, u, w);
1512 #ifdef DEBUG
1513 
1514  std::cout << " final w= " << w << " final freq=" << freq.transpose() << std::endl;
1515 #endif
1516  }
1517 }
#define VECTOR_R2(v, x, y)
Definition: matrix1d.h:112
doublereal * w
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
double getValuePureNoDampingNoPrecomputedAt(double X, double Y) const
Compute CTF pure at (U,V). Continuous frequencies.
Definition: ctf.h:1087
#define XX(v)
Definition: matrix1d.h:85
void transpose(double *array, int size)
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
#define YY(v)
Definition: matrix1d.h:93
#define V2_BY_CT(a, b, k)
Definition: matrix1d.h:179
#define SGN(x)
Definition: xmipp_macros.h:155
int * n

◆ precomputeValues() [1/6]

void CTFDescription1D::precomputeValues ( double  X)
inline

Precompute values for a given frequency.

Definition at line 376 of file ctf.h.

377  {
378  precomputed.ang = 0;
379  precomputed.u2 = X * X;
384 
385  if (fabs(X) < XMIPP_EQUAL_ACCURACY)
387  else
388  {
389 
390  /*
391  * For a derivation of this formulae confer
392  * Principles of Electron Optics page 1380
393  * in particular term defocus and twofold axial astigmatism
394  * take into account that a1 and a2 are the coefficient
395  * of the zernike polynomials difference of defocus at 0
396  * and at 45 degrees. In this case a2=0
397  */
398  precomputed.deltaf= Defocus;//(defocus_average + defocus_deviation*cos_ellipsoid_ang_2);
399 
400  }
401  }
double u
Definition: ctf.h:86
void sqrt(Image< double > &op)
double u4
Definition: ctf.h:89
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double u_sqrt
Definition: ctf.h:85
double ang
Definition: ctf.h:90
PrecomputedForCTF precomputed
Definition: ctf.h:231
double u3
Definition: ctf.h:88

◆ precomputeValues() [2/6]

void CTFDescription1D::precomputeValues ( const MultidimArray< double > &  cont_x_freq)

Precompute values for an image.

Definition at line 682 of file ctf.cpp.

683 {
684  precomputedImage.reserve(MULTIDIM_SIZE(cont_x_freq));
685  precomputedImageXdim=XSIZE(cont_x_freq);
686 
687  FOR_ALL_ELEMENTS_IN_ARRAY2D(cont_x_freq)
688  {
689  double X=A2D_ELEM(cont_x_freq,i,j);
690  precomputeValues(X);
691  if (fabs(X) < XMIPP_EQUAL_ACCURACY)
693  else
694  precomputed.deltaf=-1;
695  precomputedImage.push_back(precomputed);
696  }
697 }
int precomputedImageXdim
Definition: ctf.h:235
#define A2D_ELEM(v, i, j)
#define MULTIDIM_SIZE(v)
void precomputeValues(double X)
Precompute values for a given frequency.
Definition: ctf.h:376
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
double deltaf
Definition: ctf.h:91
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
#define XSIZE(v)
#define j
std::vector< PrecomputedForCTF > precomputedImage
Definition: ctf.h:233
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ precomputeValues() [3/6]

void CTFDescription1D::precomputeValues ( int  i)
inline

Precompute values for a given frequency.

Definition at line 407 of file ctf.h.

408  {
410  if (precomputed.deltaf==-1)
411  {
413  }
414  }
int precomputedImageXdim
Definition: ctf.h:235
#define i
double deltaf
Definition: ctf.h:91
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
std::vector< PrecomputedForCTF > precomputedImage
Definition: ctf.h:233
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ precomputeValues() [4/6]

void CTFDescription::precomputeValues ( double  X,
double  Y 
)
inline

Precompute values for a given frequency.

Definition at line 1002 of file ctf.h.

1003  {
1004  precomputed.ang=atan2(Y, X);
1005  precomputed.u2 = X * X + Y * Y;
1010 
1011  if (fabs(X) < XMIPP_EQUAL_ACCURACY &&
1012  fabs(Y) < XMIPP_EQUAL_ACCURACY)
1013  precomputed.deltaf=0;
1014  else
1015  {
1016  double ellipsoid_ang = precomputed.ang - rad_azimuth;
1017  /*
1018  * For a derivation of this formulae confer
1019  * Principles of Electron Optics page 1380
1020  * in particular term defocus and twofold axial astigmatism
1021  * take into account that a1 and a2 are the coefficient
1022  * of the zernike polynomials difference of defocus at 0
1023  * and at 45 degrees. In this case a2=0
1024  */
1025  double cos_ellipsoid_ang_2 = cos(2*ellipsoid_ang);
1026  precomputed.deltaf= (defocus_average + defocus_deviation*cos_ellipsoid_ang_2);
1027  }
1028  }
double u
Definition: ctf.h:86
void sqrt(Image< double > &op)
double defocus_average
Definition: ctf.h:802
double u4
Definition: ctf.h:89
double defocus_deviation
Definition: ctf.h:804
double rad_azimuth
Definition: ctf.h:800
double u2
Definition: ctf.h:87
double deltaf
Definition: ctf.h:91
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
double u_sqrt
Definition: ctf.h:85
double ang
Definition: ctf.h:90
PrecomputedForCTF precomputed
Definition: ctf.h:231
double u3
Definition: ctf.h:88

◆ precomputeValues() [5/6]

void CTFDescription::precomputeValues ( const MultidimArray< double > &  cont_x_freq,
const MultidimArray< double > &  cont_y_freq 
)

Precompute values for an image.

Definition at line 1406 of file ctf.cpp.

1408 {
1409  precomputedImage.reserve(MULTIDIM_SIZE(cont_x_freq));
1410  precomputedImageXdim=XSIZE(cont_x_freq);
1411 
1412  FOR_ALL_ELEMENTS_IN_ARRAY2D(cont_x_freq)
1413  {
1414  double X=A2D_ELEM(cont_x_freq,i,j);
1415  double Y=A2D_ELEM(cont_y_freq,i,j);
1416  precomputeValues(X, Y);
1417  if (fabs(X) < XMIPP_EQUAL_ACCURACY &&
1418  fabs(Y) < XMIPP_EQUAL_ACCURACY)
1419  precomputed.deltaf=0;
1420  else
1421  precomputed.deltaf=-1;
1422  precomputedImage.push_back(precomputed);
1423  }
1424 }
int precomputedImageXdim
Definition: ctf.h:235
#define A2D_ELEM(v, i, j)
#define MULTIDIM_SIZE(v)
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
double deltaf
Definition: ctf.h:91
#define XMIPP_EQUAL_ACCURACY
Definition: xmipp_macros.h:119
#define XSIZE(v)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
Definition: ctf.h:1002
#define j
std::vector< PrecomputedForCTF > precomputedImage
Definition: ctf.h:233
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ precomputeValues() [6/6]

void CTFDescription::precomputeValues ( int  i,
int  j 
)
inline

Precompute values for a given frequency.

Definition at line 1035 of file ctf.h.

1036  {
1037 
1039 
1040  if (precomputed.deltaf==-1)
1041  {
1042  double ellipsoid_ang = precomputed.ang - rad_azimuth;
1043  double cos_ellipsoid_ang_2 = cos(2*ellipsoid_ang);
1044  precomputed.deltaf= (defocus_average + defocus_deviation*cos_ellipsoid_ang_2);
1045 
1046  }
1047  }
int precomputedImageXdim
Definition: ctf.h:235
double defocus_average
Definition: ctf.h:802
double defocus_deviation
Definition: ctf.h:804
double rad_azimuth
Definition: ctf.h:800
#define i
double deltaf
Definition: ctf.h:91
#define j
std::vector< PrecomputedForCTF > precomputedImage
Definition: ctf.h:233
double ang
Definition: ctf.h:90
PrecomputedForCTF precomputed
Definition: ctf.h:231

◆ produceSideInfo() [1/2]

void CTFDescription1D::produceSideInfo ( )

Produce Side information.

Definition at line 645 of file ctf.cpp.

646 {
647  // Change units
648  double local_Cs = Cs * 1e7;
649  double local_Ca = Ca * 1e7;
650  double local_kV = kV * 1e3;
651  double local_ispr = ispr * 1e6;
652 
653  lambda=12.2643247/sqrt(local_kV*(1.+0.978466e-6*local_kV)); // See http://en.wikipedia.org/wiki/Electron_diffraction
654  //
655  // Phase shift for spherical aberration
656  // X(u)=-PI*deltaf(u)*lambda*u^2+PI/2*Cs*lambda^3*u^4
657  // ICE: X(u)=-PI/2*deltaf(u)*lambda*u^2+PI/2*Cs*lambda^3*u^4
658  // = K1*deltaf(u)*u^2 +K2*u^4
659  K1 = PI * lambda;
660  K2 = PI / 2 * local_Cs * lambda * lambda * lambda;
661 
662  // Envelope
663  // D(u)=Ed(u)*Ealpha(u)
664  // Ed(u)=exp(-1/2*PI^2*lambda^2*D^2*u^4)
665  // Ealpha(u)=exp(-PI^2*alpha^2*u^2*(Cs*lambda^2*u^2+Deltaf(u))^2)
666  // ICE: Eespr(u)=exp(-(1/4*PI*Ca*lambda*espr/kV)^2*u^4/log2)
667  // ICE: Eispr(u)=exp(-(1/2*PI*Ca*lambda*ispr)^2*u^4/log2)
668  // ICE: EdeltaF(u)=bessj0(PI*DeltaF*lambda*u^2)
669  // ICE: EdeltaR(u)=sinc(u*DeltaR)
670  // ICE: Ealpha(u)=exp(-PI^2*alpha^2*(Cs*lambda^2*u^3+Deltaf(u)*u)^2)
671  // CO: K3=pow(0.25*PI*Ca*lambda*(espr/kV,2)/log(2); Both combines in new K3
672  // CO: K4=pow(0.5*PI*Ca*lambda*ispr,2)/log(2);
673  K3 = pow(0.25 * PI * local_Ca * lambda * (espr / kV + 2 * local_ispr), 2) / log(2.0);
674  K5 = PI * DeltaF * lambda;
675  K6 = PI * PI * alpha * alpha;
676  K7 = local_Cs * lambda * lambda;
677  Ksin = sqrt(1-Q0*Q0);
678  Kcos = Q0;
679 }
double lambda
Definition: ctf.h:214
double K1
Definition: ctf.h:218
void sqrt(Image< double > &op)
double espr
Definition: ctf.h:251
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
double K2
Definition: ctf.h:219
double K6
Definition: ctf.h:223
void log(Image< double > &op)
double K7
Definition: ctf.h:224
double Ksin
Definition: ctf.h:225
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double K5
Definition: ctf.h:222
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
#define PI
Definition: tools.h:43
double Kcos
Definition: ctf.h:226
double K3
Definition: ctf.h:220

◆ produceSideInfo() [2/2]

void CTFDescription::produceSideInfo ( )

Produce Side information.

Definition at line 1392 of file ctf.cpp.

1393 {
1395  // Add parameters for 2D
1400  defocus_average = -(DeltafU + DeltafV) * 0.5;
1401  defocus_deviation = -(DeltafU - DeltafV) * 0.5;
1402 }
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double rad_sqrt
Definition: ctf.h:810
#define DEG2RAD(d)
Definition: xmipp_macros.h:312
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double defocus_average
Definition: ctf.h:802
double defocus_deviation
Definition: ctf.h:804
double rad_gaussian
Definition: ctf.h:806
double rad_azimuth
Definition: ctf.h:800
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double rad_gaussian2
Definition: ctf.h:808
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:645

◆ read() [1/2]

void CTFDescription1D::read ( const FileName fn,
bool  disable_if_not_K = true 
)

Read from file. An exception is thrown if the file cannot be open.

If no K or sqrt_K are given then it is assumed that the user does not want to activate that part and the noise or the CTF are removed from the model unless the disable_if_not_K is set to false

Definition at line 427 of file ctf.cpp.

428 {
429  if (fn.isMetaData())
430  {
431  MetaDataVec md;
432  md.read(fn);
433  MDRowVec row;
434  md.getRow(row, md.firstRowId());
435  readFromMdRow(row, disable_if_not_K);
436  }
437 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
std::unique_ptr< MDRow > getRow(size_t id) override
size_t firstRowId() const override
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:365
bool isMetaData(bool failIfNotExists=true) const

◆ read() [2/2]

void CTFDescription::read ( const FileName fn,
bool  disable_if_not_K = true 
)

Read from file. An exception is thrown if the file cannot be open.

If no K or sqrt_K are given then it is assumed that the user does not want to activate that part and the noise or the CTF are removed from the model unless the disable_if_not_K is set to false

Definition at line 1220 of file ctf.cpp.

1221 {
1222  if (fn.isMetaData())
1223  {
1224  MetaDataVec md;
1225  md.read(fn);
1226  MDRowVec row;
1227  md.getRow(row, md.firstRowId());
1228  readFromMdRow(row, disable_if_not_K);
1229  }
1230 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
std::unique_ptr< MDRow > getRow(size_t id) override
size_t firstRowId() const override
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:1172
bool isMetaData(bool failIfNotExists=true) const

◆ readFromMdRow() [1/2]

void CTFDescription1D::readFromMdRow ( const MDRow row,
bool  disable_if_not_K = true 
)

Same as previuous reading function but providing the MDRow

Definition at line 365 of file ctf.cpp.

366 {
368 
369  if (enable_CTF)
370  {
372  {
383  row.getValueOrDefault(MDL_CTF_K, K, 1);
387  }
388  else if (row.containsLabel(MDL_CTF_MODEL))
389  {
390  FileName fnctf;
391  row.getValue(MDL_CTF_MODEL,fnctf);
392  MetaDataVec ctfparam;
393  ctfparam.read(fnctf);
394  readFromMetadataRow(ctfparam,ctfparam.firstRowId(), disable_if_not_K);
395  }
396 
397  if (K == 0 && disable_if_not_K)
398  enable_CTF = false;
399  }
400  if (enable_CTFnoise)
401  {
414 
415  if (gaussian_K == 0 && sqrt_K == 0 && base_line == 0 && gaussian_K2 == 0 &&
416  disable_if_not_K)
417  enable_CTFnoise = false;
418  }
419 }
CTF Background parameter.
CTF gain.
double bgR1
Definition: ctf.h:295
Defocus U (Angstroms)
double bgR2
Definition: ctf.h:296
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
double envR1
Definition: ctf.h:300
CTF Background parameter.
double envR2
Definition: ctf.h:301
Convergence cone.
double espr
Definition: ctf.h:251
CTF Background parameter.
Name for the CTF Model (std::string)
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double envR0
Definition: ctf.h:299
CTF Background parameter.
CTF Background parameter.
double sq
Sqrt width.
Definition: ctf.h:287
Spherical aberration.
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
Microscope voltage (kV)
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double Gc2
Second Gaussian center.
Definition: ctf.h:293
CTF Background polynomial parameter.
double sigma2
Second Gaussian width.
Definition: ctf.h:291
CTF Envelope polynomial parameter.
double base_line
Global base_line.
Definition: ctf.h:277
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:421
T & getValue(MDLabel label)
double Gc1
Gaussian center.
Definition: ctf.h:283
CTF Envelope polynomial parameter.
CTF Envelope polynomial parameter.
Inelastic absorption.
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
CTF Background parameter.
Longitudinal displacement.
size_t firstRowId() const override
CTF Background parameter.
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
CTF Background polynomial parameter.
double bgR3
Definition: ctf.h:297
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
CTF_ CTF Background parameter.
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
const T & getValueOrDefault(MDLabel label, const T &def) const
double K
Global gain. By default, 1.
Definition: ctf.h:238
virtual bool containsLabel(MDLabel label) const =0
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
CTF Background parameter.
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
CTF Background polynomial parameter.
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
Chromatic aberration.
Transversal displacemente.
Lens stability.

◆ readFromMdRow() [2/2]

void CTFDescription::readFromMdRow ( const MDRow row,
bool  disable_if_not_K = true 
)

Same as previuous reading function but providing the MDRow

Definition at line 1172 of file ctf.cpp.

1173 {
1174  CTFDescription1D::readFromMdRow(row, disable_if_not_K);
1175  if (enable_CTF)
1176  {
1178  {
1184 
1185  }
1186  else if (row.containsLabel(MDL_CTF_MODEL))
1187  {
1188  FileName fnctf;
1189  row.getValue(MDL_CTF_MODEL,fnctf);
1190  MetaDataVec ctfparam;
1191  ctfparam.read(fnctf);
1192  readFromMetadataRow(ctfparam, ctfparam.firstRowId(), disable_if_not_K);
1193  }
1194 
1195  }
1196  if (enable_CTFnoise)
1197  {
1211  }
1212 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
CTF Background parameter.
Defocus U (Angstroms)
CTF Background parameter.
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
Defocus angle (degrees)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
CTF Background parameter.
double cU
Gaussian center for U.
Definition: ctf.h:875
Name for the CTF Model (std::string)
double phase_shift
Definition: ctf.h:305
CTF Background parameter.
CTF Background parameter.
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
CTF Background parameter.
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double sqU
Gain for the square root term.
Definition: ctf.h:883
T & getValue(MDLabel label)
void readFromMetadataRow(const MetaData &MD, size_t id, bool disable_if_not_K=true)
Definition: ctf.cpp:1214
CTF Background parameter.
size_t firstRowId() const override
CTF Background parameter.
CTF Background parameter.
double sqV
Sqrt width V.
Definition: ctf.h:885
CTF Background parameter.
double sigmaV
Gaussian width V.
Definition: ctf.h:873
CTF_ CTF Background parameter.
const T & getValueOrDefault(MDLabel label, const T &def) const
CTF Background parameter.
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:365
virtual bool containsLabel(MDLabel label) const =0
double VPP_radius
Definition: ctf.h:306
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
Defocus V (Angstroms)
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877
CTF Background parameter.

◆ readFromMetadataRow() [1/2]

void CTFDescription1D::readFromMetadataRow ( const MetaData MD,
size_t  id,
bool  disable_if_not_K = true 
)

Read from 1 row of a metadata file.

If no K or sqrt_K are given then it is assumed that the user does not want to activate that part and the noise or the CTF are removed from the model unless the disable_if_not_K is set to false This function should be used usually if you have all ctf parameters in columns format metadata or after calling fillExpand having CTF_MODEL

Definition at line 421 of file ctf.cpp.

422 {
423  std::unique_ptr<const MDRow> row = md.getRow(id);
424  readFromMdRow(*row, disable_if_not_K);
425 }
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:365

◆ readFromMetadataRow() [2/2]

void CTFDescription::readFromMetadataRow ( const MetaData MD,
size_t  id,
bool  disable_if_not_K = true 
)

Read from 1 row of a metadata file.

If no K or sqrt_K are given then it is assumed that the user does not want to activate that part and the noise or the CTF are removed from the model unless the disable_if_not_K is set to false This function should be used usually if you have all ctf parameters in columns format metadata or after calling fillExpand having CTF_MODEL

Definition at line 1214 of file ctf.cpp.

1215 {
1216  std::unique_ptr<const MDRow> row = md.getRow(id);
1217  readFromMdRow(*row, disable_if_not_K);
1218 }
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
Definition: ctf.cpp:1172

◆ readParams() [1/2]

void CTFDescription1D::readParams ( XmippProgram program)

Read parameters from the command line.

Definition at line 524 of file ctf.cpp.

525 {
526  kV=Tm=Cs=0;
527  if (program->checkParam("--ctf_similar_to"))
528  read(program->getParam("--ctf_similar_to"));
529  if (program->checkParam("--sampling_rate"))
530  Tm=program->getDoubleParam("--sampling_rate");
531  if (Tm==0)
532  REPORT_ERROR(ERR_ARG_MISSING,"--sampling_rate");
533  if (program->checkParam("--voltage"))
534  kV=program->getDoubleParam("--voltage");
535  if (kV==0)
536  REPORT_ERROR(ERR_ARG_MISSING,"--voltage");
537  if (program->checkParam("--spherical_aberration"))
538  Cs=program->getDoubleParam("--spherical_aberration");
539  if (program->checkParam("--defocusU"))
540  Defocus=program->getDoubleParam("--defocusU");
541  if (program->checkParam("--Q0"))
542  Q0=program->getDoubleParam("--Q0");
543  if (program->checkParam("--phase_shift"))
544  {
545  phase_shift=program->getDoubleParam("--phase_shift");
546  phase_shift=(phase_shift*PI)/180;
547  }
548  else
549  phase_shift = 0.0;
550  if (program->checkParam("--VPP_radius"))
551  VPP_radius=program->getDoubleParam("--VPP_radius");
552  else
553  VPP_radius = 0.0;
554  Ca=program->getDoubleParam("--chromatic_aberration");
555  espr=program->getDoubleParam("--energy_loss");
556  ispr=program->getDoubleParam("--lens_stability");
557  alpha=program->getDoubleParam("--convergence_cone");
558  DeltaF=program->getDoubleParam("--longitudinal_displace");
559  DeltaR=program->getDoubleParam("--transversal_displace");
560  K=program->getDoubleParam("--K");
561 }
Argument missing.
Definition: xmipp_error.h:114
double getDoubleParam(const char *param, int arg=0)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double espr
Definition: ctf.h:251
double phase_shift
Definition: ctf.h:305
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
const char * getParam(const char *param, int arg=0)
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
void read(const FileName &fn, bool disable_if_not_K=true)
Definition: ctf.cpp:427
double VPP_radius
Definition: ctf.h:306
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
bool checkParam(const char *param)
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
#define PI
Definition: tools.h:43

◆ readParams() [2/2]

void CTFDescription::readParams ( XmippProgram program)

Read parameters from the command line.

Definition at line 1297 of file ctf.cpp.

1298 {
1300  if (program->checkParam("--defocusU"))
1301  DeltafU=program->getDoubleParam("--defocusU");
1302  if (program->checkParam("--defocusV"))
1303  DeltafV=program->getDoubleParam("--defocusV");
1304  else
1305  DeltafV=DeltafU;
1306  azimuthal_angle=program->getDoubleParam("--azimuthal_angle");
1307 }
double getDoubleParam(const char *param, int arg=0)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
void readParams(XmippProgram *program)
Read parameters from the command line.
Definition: ctf.cpp:524
bool checkParam(const char *param)

◆ setRow() [1/2]

void CTFDescription1D::setRow ( MDRow row) const

Write current CTF model to row

Definition at line 440 of file ctf.cpp.

441 {
443  if (enable_CTF)
444  {
447  row.setValue(MDL_CTF_CS, Cs);
448  row.setValue(MDL_CTF_CA, Ca);
454  row.setValue(MDL_CTF_Q0, Q0);
455  row.setValue(MDL_CTF_K, K);
459  }
460  if (enable_CTFnoise)
461  {
474  }
475  if (isLocalCTF)
476  {
477  row.setValue(MDL_CTF_X0, x0);
478  row.setValue(MDL_CTF_XF, xF);
479  row.setValue(MDL_CTF_Y0, y0);
480  row.setValue(MDL_CTF_YF, yF);
481  }
482 }
CTF Background parameter.
CTF gain.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
double bgR1
Definition: ctf.h:295
Defocus U (Angstroms)
double bgR2
Definition: ctf.h:296
double envR1
Definition: ctf.h:300
CTF Background parameter.
double envR2
Definition: ctf.h:301
Convergence cone.
double espr
Definition: ctf.h:251
CTF Background parameter.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double envR0
Definition: ctf.h:299
CTF Background parameter.
CTF Background parameter.
double sq
Sqrt width.
Definition: ctf.h:287
Spherical aberration.
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
Microscope voltage (kV)
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double Gc2
Second Gaussian center.
Definition: ctf.h:293
CTF Background polynomial parameter.
double sigma2
Second Gaussian width.
Definition: ctf.h:291
CTF Envelope polynomial parameter.
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
CTF Envelope polynomial parameter.
CTF Envelope polynomial parameter.
Inelastic absorption.
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
CTF Background parameter.
Longitudinal displacement.
CTF Background parameter.
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
CTF Background polynomial parameter.
double bgR3
Definition: ctf.h:297
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
CTF_ CTF Background parameter.
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
void setValue(MDLabel label, const T &d, bool addLabel=true)
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double y0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:267
CTF Background parameter.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double x0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:263
CTF Background polynomial parameter.
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double xF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:265
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
Chromatic aberration.
Transversal displacemente.
double yF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:269
Lens stability.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.

◆ setRow() [2/2]

void CTFDescription::setRow ( MDRow row) const

Write current model to row

Definition at line 1233 of file ctf.cpp.

1234 {
1236  if (enable_CTF)
1237  {
1241 
1242  }
1243  if (enable_CTFnoise)
1244  {
1258  if(VPP_radius != 0.0)
1259  {
1262  }
1263 
1264 
1265  }
1266  if (isLocalCTF)
1267  {
1268  row.setValue(MDL_CTF_X0, x0);
1269  row.setValue(MDL_CTF_XF, xF);
1270  row.setValue(MDL_CTF_Y0, y0);
1271  row.setValue(MDL_CTF_YF, yF);
1272  }
1273 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
CTF Background parameter.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
Defocus U (Angstroms)
CTF Background parameter.
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
Defocus angle (degrees)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
CTF Background parameter.
double cU
Gaussian center for U.
Definition: ctf.h:875
double phase_shift
Definition: ctf.h:305
CTF Background parameter.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
CTF Background parameter.
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
CTF Background parameter.
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double sqU
Gain for the square root term.
Definition: ctf.h:883
CTF Background parameter.
CTF Background parameter.
CTF Background parameter.
double sqV
Sqrt width V.
Definition: ctf.h:885
CTF Background parameter.
double sigmaV
Gaussian width V.
Definition: ctf.h:873
CTF_ CTF Background parameter.
CTF Background parameter.
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
void setValue(MDLabel label, const T &d, bool addLabel=true)
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
double VPP_radius
Definition: ctf.h:306
double y0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:267
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
double x0
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:263
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double xF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:265
Defocus V (Angstroms)
double yF
In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined...
Definition: ctf.h:269
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
void setRow(MDRow &row) const
Definition: ctf.cpp:440
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877
CTF Background parameter.

◆ write() [1/2]

void CTFDescription1D::write ( const FileName fn)

Write to file. An exception is thrown if the file cannot be open.

Definition at line 484 of file ctf.cpp.

485 {
486  MDRowVec row;
487  setRow(row);
488 
489  MetaDataVec md;
490  md.setColumnFormat(false);
491  md.addRow(row);
492  md.write(fn);
493 }
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
size_t addRow(const MDRow &row) override
virtual void setColumnFormat(bool column)
void setRow(MDRow &row) const
Definition: ctf.cpp:440

◆ write() [2/2]

void CTFDescription::write ( const FileName fn)

Write to file. An exception is thrown if the file cannot be open.

Definition at line 1275 of file ctf.cpp.

1276 {
1277  MDRowVec row;
1278  setRow(row);
1279 
1280  MetaDataVec md;
1281  md.setColumnFormat(false);
1282  md.addRow(row);
1283  md.write(fn);
1284 }
void setRow(MDRow &row) const
Definition: ctf.cpp:1233
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
size_t addRow(const MDRow &row) override
virtual void setColumnFormat(bool column)

Variable Documentation

◆ alpha

double CTFDescription1D::alpha

Convergence cone semiangle (in mrad). Typical value 0.5.

Definition at line 255 of file ctf.h.

◆ ang

double PrecomputedForCTF::ang

Definition at line 90 of file ctf.h.

◆ azimuthal_angle

double CTFDescription::azimuthal_angle

Azimuthal angle (between X and U) in degrees.

Definition at line 832 of file ctf.h.

◆ base_line

double CTFDescription1D::base_line

Global base_line.

Definition at line 277 of file ctf.h.

◆ bgR1

double CTFDescription1D::bgR1

Definition at line 295 of file ctf.h.

◆ bgR2

double CTFDescription1D::bgR2

Definition at line 296 of file ctf.h.

◆ bgR3

double CTFDescription1D::bgR3

Definition at line 297 of file ctf.h.

◆ Ca

double CTFDescription1D::Ca

Chromatic aberration (in milimeters). Typical value 2.

Definition at line 248 of file ctf.h.

◆ Cs

double CTFDescription1D::Cs

Spherical aberration (in milimeters). Typical value 5.6.

Definition at line 246 of file ctf.h.

◆ cU

double CTFDescription::cU

Gaussian center for U.

Definition at line 875 of file ctf.h.

◆ cU2

double CTFDescription::cU2

Second Gaussian center for U.

Definition at line 893 of file ctf.h.

◆ cV

double CTFDescription::cV

Gaussian center for V.

Definition at line 877 of file ctf.h.

◆ cV2

double CTFDescription::cV2

Second Gaussian center for V.

Definition at line 895 of file ctf.h.

◆ D

double CTFDescription1D::D

Standard error of defocus Gaussian function due to chromatic aberration. in Angstroms

Definition at line 229 of file ctf.h.

◆ Defocus

double CTFDescription1D::Defocus

Defocus (in Angstroms). Negative values are underfocused.

Definition at line 244 of file ctf.h.

◆ defocus_average

double CTFDescription::defocus_average

Definition at line 802 of file ctf.h.

◆ defocus_deviation

double CTFDescription::defocus_deviation

Definition at line 804 of file ctf.h.

◆ deltaf

double PrecomputedForCTF::deltaf

Definition at line 91 of file ctf.h.

◆ DeltaF

double CTFDescription1D::DeltaF

Longitudinal mechanical displacement (ansgtrom). Typical value 100.

Definition at line 257 of file ctf.h.

◆ DeltafU

double CTFDescription::DeltafU

Global gain. By default, 1.

Standard error of defocus Gaussian function due to chromatic aberration. in AmstrongSampling rate (A/pixel) Accelerating Voltage (in KiloVolts) Defocus in U (in Angstroms). Negative values are underfocused

Definition at line 828 of file ctf.h.

◆ DeltafV

double CTFDescription::DeltafV

Defocus in V (in Angstroms). Negative values are underfocused.

Definition at line 830 of file ctf.h.

◆ DeltaR

double CTFDescription1D::DeltaR

Transversal mechanical displacement (ansgtrom). Typical value 3.

Definition at line 259 of file ctf.h.

◆ enable_CTF

bool CTFDescription1D::enable_CTF

Enable CTF part.

Definition at line 275 of file ctf.h.

◆ enable_CTFnoise

bool CTFDescription1D::enable_CTFnoise

Enable CTFnoise part.

Definition at line 273 of file ctf.h.

◆ envR0

double CTFDescription1D::envR0

Definition at line 299 of file ctf.h.

◆ envR1

double CTFDescription1D::envR1

Definition at line 300 of file ctf.h.

◆ envR2

double CTFDescription1D::envR2

Definition at line 301 of file ctf.h.

◆ espr

double CTFDescription1D::espr

Mean energy loss (eV) due to interaction with sample. Typical value 1

Definition at line 251 of file ctf.h.

◆ freq_max

double CTFDescription1D::freq_max

Definition at line 303 of file ctf.h.

◆ gaussian_angle

double CTFDescription::gaussian_angle

Gaussian angle.

Definition at line 879 of file ctf.h.

◆ gaussian_angle2

double CTFDescription::gaussian_angle2

Second Gaussian angle.

Definition at line 897 of file ctf.h.

◆ gaussian_K

double CTFDescription1D::gaussian_K

Gain for the gaussian term.

Definition at line 279 of file ctf.h.

◆ gaussian_K2

double CTFDescription1D::gaussian_K2

Gain for the second Gaussian term.

Definition at line 289 of file ctf.h.

◆ Gc1

double CTFDescription1D::Gc1

Gaussian center.

Definition at line 283 of file ctf.h.

◆ Gc2

double CTFDescription1D::Gc2

Second Gaussian center.

Definition at line 293 of file ctf.h.

◆ isLocalCTF

bool CTFDescription1D::isLocalCTF

Local CTF determination.

Definition at line 271 of file ctf.h.

◆ ispr

double CTFDescription1D::ispr

Objective lens stability (deltaI/I) (ppm). Typical value 1.

Definition at line 253 of file ctf.h.

◆ K

double CTFDescription1D::K

Global gain. By default, 1.

Definition at line 238 of file ctf.h.

◆ K1

double CTFDescription1D::K1

Definition at line 218 of file ctf.h.

◆ K2

double CTFDescription1D::K2

Definition at line 219 of file ctf.h.

◆ K3

double CTFDescription1D::K3

Definition at line 220 of file ctf.h.

◆ K4

double CTFDescription1D::K4

Definition at line 221 of file ctf.h.

◆ K5

double CTFDescription1D::K5

Definition at line 222 of file ctf.h.

◆ K6

double CTFDescription1D::K6

Definition at line 223 of file ctf.h.

◆ K7

double CTFDescription1D::K7

Definition at line 224 of file ctf.h.

◆ Kcos

double CTFDescription1D::Kcos

Definition at line 226 of file ctf.h.

◆ Ksin

double CTFDescription1D::Ksin

Definition at line 225 of file ctf.h.

◆ kV

double CTFDescription1D::kV

Accelerating Voltage (in KiloVolts)

Definition at line 242 of file ctf.h.

◆ lambda

double CTFDescription1D::lambda

Definition at line 214 of file ctf.h.

◆ phase_shift

double CTFDescription1D::phase_shift

Definition at line 305 of file ctf.h.

◆ precomputed

PrecomputedForCTF CTFDescription1D::precomputed

Definition at line 231 of file ctf.h.

◆ precomputedImage

std::vector<PrecomputedForCTF> CTFDescription1D::precomputedImage

Definition at line 233 of file ctf.h.

◆ precomputedImageXdim

int CTFDescription1D::precomputedImageXdim

Definition at line 235 of file ctf.h.

◆ Q0

double CTFDescription1D::Q0

Factor for the importance of the Amplitude contrast.

Definition at line 261 of file ctf.h.

◆ rad_azimuth

double CTFDescription::rad_azimuth

Definition at line 800 of file ctf.h.

◆ rad_gaussian

double CTFDescription::rad_gaussian

Definition at line 806 of file ctf.h.

◆ rad_gaussian2

double CTFDescription::rad_gaussian2

Definition at line 808 of file ctf.h.

◆ rad_sqrt

double CTFDescription::rad_sqrt

Definition at line 810 of file ctf.h.

◆ sigma1

double CTFDescription1D::sigma1

Gaussian width.

Definition at line 281 of file ctf.h.

◆ sigma2

double CTFDescription1D::sigma2

Second Gaussian width.

Definition at line 291 of file ctf.h.

◆ sigmaU

double CTFDescription::sigmaU

Spherical aberration (in milimeters). Typical value 5.6.

Chromatic aberration (in milimeters). Typical value 2 Mean energy loss (eV) due to interaction with sample. Typical value 1 Objective lens stability (deltaI/I) (ppm). Typical value 1 Convergence cone semiangle (in mrad). Typical value 0.5 Longitudinal mechanical displacement (ansgtrom). Typical value 100 Transversal mechanical displacement (ansgtrom). Typical value 3 Factor for the importance of the Amplitude contrast. In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined Local CTF determination Enable CTFnoise part Enable CTF part Global base_line Gain for the gaussian term Gaussian width U

Definition at line 871 of file ctf.h.

◆ sigmaU2

double CTFDescription::sigmaU2

Second Gaussian width U.

Definition at line 889 of file ctf.h.

◆ sigmaV

double CTFDescription::sigmaV

Gaussian width V.

Definition at line 873 of file ctf.h.

◆ sigmaV2

double CTFDescription::sigmaV2

Second Gaussian width V.

Definition at line 891 of file ctf.h.

◆ sq

double CTFDescription1D::sq

Sqrt width.

Definition at line 287 of file ctf.h.

◆ sqrt_angle

double CTFDescription::sqrt_angle

Sqrt angle.

Definition at line 887 of file ctf.h.

◆ sqrt_K

double CTFDescription1D::sqrt_K

Gain for the square root term.

Definition at line 285 of file ctf.h.

◆ sqU

double CTFDescription::sqU

Gain for the square root term.

Sqrt width U

Definition at line 883 of file ctf.h.

◆ sqV

double CTFDescription::sqV

Sqrt width V.

Definition at line 885 of file ctf.h.

◆ Tm

double CTFDescription1D::Tm

Sampling rate (A/pixel)

Definition at line 240 of file ctf.h.

◆ u

double PrecomputedForCTF::u

Definition at line 86 of file ctf.h.

◆ u2

double PrecomputedForCTF::u2

Definition at line 87 of file ctf.h.

◆ u3

double PrecomputedForCTF::u3

Definition at line 88 of file ctf.h.

◆ u4

double PrecomputedForCTF::u4

Definition at line 89 of file ctf.h.

◆ u_sqrt

double PrecomputedForCTF::u_sqrt

Definition at line 85 of file ctf.h.

◆ VPP_radius

double CTFDescription1D::VPP_radius

Definition at line 306 of file ctf.h.

◆ x0

double CTFDescription1D::x0

In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined.

Definition at line 263 of file ctf.h.

◆ xF

double CTFDescription1D::xF

In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined.

Definition at line 265 of file ctf.h.

◆ y0

double CTFDescription1D::y0

In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined.

Definition at line 267 of file ctf.h.

◆ yF

double CTFDescription1D::yF

In the case of local CTF determination x0,xF,y0,yF determines the region where the CTF is determined.

Definition at line 269 of file ctf.h.

Friends

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  out,
const CTFDescription1D ctf 
)
friend

Show.

Definition at line 564 of file ctf.cpp.

565 {
566  if (ctf.enable_CTF)
567  {
568  out
569  << "sampling_rate= " << ctf.Tm << std::endl
570  << "voltage= " << ctf.kV << std::endl
571  << "defocusU= " << ctf.Defocus << std::endl
572  << "spherical_aberration= " << ctf.Cs << std::endl
573  << "chromatic_aberration= " << ctf.Ca << std::endl
574  << "energy_loss= " << ctf.espr << std::endl
575  << "lens_stability= " << ctf.ispr << std::endl
576  << "convergence_cone= " << ctf.alpha << std::endl
577  << "longitudinal_displace=" << ctf.DeltaF << std::endl
578  << "transversal_displace= " << ctf.DeltaR << std::endl
579  << "envR0= " << ctf.envR0 << std::endl
580  << "envR1= " << ctf.envR1 << std::endl
581  << "envR2= " << ctf.envR2 << std::endl
582  << "Q0= " << ctf.Q0 << std::endl
583  << "K= " << ctf.K << std::endl
584  ;
585  }
586  if (ctf.enable_CTFnoise)
587  {
588  out
589  << "gaussian_K= " << ctf.gaussian_K << std::endl
590  << "sigma1= " << ctf.sigma1 << std::endl
591  << "Gc1= " << ctf.Gc1 << std::endl
592  << "sqrt_K= " << ctf.sqrt_K << std::endl
593  << "sq= " << ctf.sq << std::endl
594  << "bg1= " << ctf.bgR1 << std::endl
595  << "bg2= " << ctf.bgR2 << std::endl
596  << "bg3= " << ctf.bgR3 << std::endl
597  << "base_line= " << ctf.base_line << std::endl
598  << "gaussian_K2= " << ctf.gaussian_K2 << std::endl
599  << "sigma2= " << ctf.sigma2 << std::endl
600  << "Gc2= " << ctf.Gc2 << std::endl
601  << "phase_shift= " << ctf.phase_shift << std::endl
602  << "VPP_radius= " << ctf.VPP_radius << std::endl
603  ;
604  }
605  return out;
606 }
double bgR1
Definition: ctf.h:295
double bgR2
Definition: ctf.h:296
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double espr
Definition: ctf.h:251
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double envR0
Definition: ctf.h:299
double sq
Sqrt width.
Definition: ctf.h:287
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double Gc2
Second Gaussian center.
Definition: ctf.h:293
double sigma2
Second Gaussian width.
Definition: ctf.h:291
double base_line
Global base_line.
Definition: ctf.h:277
double Gc1
Gaussian center.
Definition: ctf.h:283
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double bgR3
Definition: ctf.h:297
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
double K
Global gain. By default, 1.
Definition: ctf.h:238
double VPP_radius
Definition: ctf.h:306
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sigma1
Gaussian width.
Definition: ctf.h:281
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  out,
const CTFDescription ctf 
)
friend

Show.

Definition at line 1310 of file ctf.cpp.

1311 {
1312  if (ctf.enable_CTF)
1313  {
1314  out
1315  << "sampling_rate= " << ctf.Tm << std::endl
1316  << "voltage= " << ctf.kV << std::endl
1317  << "defocusU= " << ctf.DeltafU << std::endl
1318  << "defocusV= " << ctf.DeltafV << std::endl
1319  << "azimuthal_angle= " << ctf.azimuthal_angle << std::endl
1320  << "spherical_aberration= " << ctf.Cs << std::endl
1321  << "chromatic_aberration= " << ctf.Ca << std::endl
1322  << "energy_loss= " << ctf.espr << std::endl
1323  << "lens_stability= " << ctf.ispr << std::endl
1324  << "convergence_cone= " << ctf.alpha << std::endl
1325  << "longitudinal_displace=" << ctf.DeltaF << std::endl
1326  << "transversal_displace= " << ctf.DeltaR << std::endl
1327  << "envR0= " << ctf.envR0 << std::endl
1328  << "envR1= " << ctf.envR1 << std::endl
1329  << "envR2= " << ctf.envR2 << std::endl
1330  << "Q0= " << ctf.Q0 << std::endl
1331  << "K= " << ctf.K << std::endl
1332  ;
1333  }
1334  if (ctf.enable_CTFnoise)
1335  {
1336  out
1337  << "gaussian_K= " << ctf.gaussian_K << std::endl
1338  << "sigmaU= " << ctf.sigmaU << std::endl
1339  << "sigmaV= " << ctf.sigmaV << std::endl
1340  << "cU= " << ctf.cU << std::endl
1341  << "cV= " << ctf.cV << std::endl
1342  << "gaussian_angle= " << ctf.gaussian_angle << std::endl
1343  << "sqrt_K= " << ctf.sqrt_K << std::endl
1344  << "sqU= " << ctf.sqU << std::endl
1345  << "sqV= " << ctf.sqV << std::endl
1346  << "sqrt_angle= " << ctf.sqrt_angle << std::endl
1347  << "bg1= " << ctf.bgR1 << std::endl
1348  << "bg2= " << ctf.bgR2 << std::endl
1349  << "bg3= " << ctf.bgR3 << std::endl
1350  << "base_line= " << ctf.base_line << std::endl
1351  << "gaussian_K2= " << ctf.gaussian_K2 << std::endl
1352  << "sigmaU2= " << ctf.sigmaU2 << std::endl
1353  << "sigmaV2= " << ctf.sigmaV2 << std::endl
1354  << "cU2= " << ctf.cU2 << std::endl
1355  << "cV2= " << ctf.cV2 << std::endl
1356  << "gaussian_angle2= " << ctf.gaussian_angle2 << std::endl
1357  << "phase_shift= " << ctf.phase_shift << std::endl
1358  << "VPP_radius= " << ctf.VPP_radius << std::endl
1359  ;
1360  }
1361  return out;
1362 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
double bgR1
Definition: ctf.h:295
double bgR2
Definition: ctf.h:296
double gaussian_angle2
Second Gaussian angle.
Definition: ctf.h:897
double envR1
Definition: ctf.h:300
double envR2
Definition: ctf.h:301
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
double espr
Definition: ctf.h:251
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
double cU
Gaussian center for U.
Definition: ctf.h:875
double phase_shift
Definition: ctf.h:305
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
double envR0
Definition: ctf.h:299
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
bool enable_CTF
Enable CTF part.
Definition: ctf.h:275
double azimuthal_angle
Azimuthal angle (between X and U) in degrees.
Definition: ctf.h:832
double base_line
Global base_line.
Definition: ctf.h:277
double sqU
Gain for the square root term.
Definition: ctf.h:883
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
double sqV
Sqrt width V.
Definition: ctf.h:885
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
double bgR3
Definition: ctf.h:297
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double sigmaV
Gaussian width V.
Definition: ctf.h:873
double K
Global gain. By default, 1.
Definition: ctf.h:238
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
double VPP_radius
Definition: ctf.h:306
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
double Q0
Factor for the importance of the Amplitude contrast.
Definition: ctf.h:261
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
double sqrt_K
Gain for the square root term.
Definition: ctf.h:285
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877