Xmipp  v3.23.11-Nereus
Macros | Functions
ctf.cpp File Reference
#include "ctf.h"
#include "core/multidim_array.h"
#include "core/xmipp_fftw.h"
#include "core/xmipp_image.h"
#include "core/xmipp_program.h"
#include "core/metadata_vec.h"
Include dependency graph for ctf.cpp:

Go to the source code of this file.

Macros

#define DEBUG
 

Functions

bool containsCTFBasicLabels (const MetaData &md)
 
void groupCTFMetaData (const MetaDataDb &imgMd, MetaDataDb &ctfMd, std::vector< MDLabel > &groupbyLabels)
 
void generateCTFImageWith2CTFs (const MetaData &MD1, const MetaData &MD2, int Xdim, MultidimArray< double > &imgOut)
 
double errorBetween2CTFs (MetaData &MD1, MetaData &MD2, size_t Xdim, double minFreq, double maxFreq)
 
double errorMaxFreqCTFs (MetaData &MD1, double phaseRad)
 
double errorMaxFreqCTFs2D (MetaData &MD1, MetaData &MD2, size_t Xdim, double phaseRad)
 
void generatePSDCTFImage (MultidimArray< double > &img, const MetaData &MD)
 
std::ostream & operator<< (std::ostream &out, const CTFDescription1D &ctf)
 
std::ostream & operator<< (std::ostream &out, const CTFDescription &ctf)
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG

Function Documentation

◆ containsCTFBasicLabels()

bool containsCTFBasicLabels ( const MetaData md)

Check that a metadata contains ALL CTF_BASIC_LABELS labels

Definition at line 33 of file ctf.cpp.

34 {
35  for(int i=0; i < CTF_BASIC_LABELS_SIZE; i++)
37  return false;
38  return true;
39 }
virtual bool containsLabel(const MDLabel label) const =0
const MDLabel CTF_BASIC_LABELS[]
Definition: ctf.h:42
#define i
const int CTF_BASIC_LABELS_SIZE
Definition: ctf.h:41

◆ groupCTFMetaData()

void groupCTFMetaData ( const MetaDataDb imgMd,
MetaDataDb ctfMd,
std::vector< MDLabel > &  groupbyLabels 
)

From a give images metadata, group by CTF_BASIC_LABELS and fill a ctfs metadata. Params: imgMd: input images metadata. ctfMd: the ctfs metadata that will be filled.

Raise error if neither CTF_MODEL or ALL CTF_BASIC_LABELS are found in input images metadata.

Definition at line 41 of file ctf.cpp.

42 {
43  //number of different CTFs
44  if (imgMd.containsLabel(MDL_CTF_MODEL))
45  {
48  }
49  else if (containsCTFBasicLabels(imgMd))
50  {
51  groupbyLabels.clear();
52  for(int i=0; i < CTF_ALL_LABELS_SIZE; i++)
53  if (imgMd.containsLabel(CTF_ALL_LABELS[i]))
54  groupbyLabels.push_back(CTF_ALL_LABELS[i]);
56  groupbyLabels.push_back(MDL_MICROGRAPH_ID);
57  else
58  REPORT_ERROR(ERR_MD_MISSINGLABEL,"ERROR: Input metadata does not have micrographId");
59  ctfMd.aggregateGroupBy(imgMd, AGGR_COUNT, groupbyLabels, MDL_CTF_DEFOCUSU, MDL_COUNT);
60  }
61  else
62  REPORT_ERROR(ERR_MD_MISSINGLABEL,"Expecting CTF_MODEL or (MDL_CTF_DEFOCUSU, MDL_CTF_DEFOCUSV, MDL_CTF_DEFOCUS_ANGLE) labels");
63 
64 }
const MDLabel CTF_ALL_LABELS[]
Definition: ctf.h:48
Defocus U (Angstroms)
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void fillExpand(MDLabel label)
bool containsCTFBasicLabels(const MetaData &md)
Definition: ctf.cpp:33
Name for the CTF Model (std::string)
void aggregateGroupBy(const MetaDataDb &mdIn, AggregateOperation op, const std::vector< MDLabel > &groupByLabels, MDLabel operateLabel, MDLabel resultLabel)
#define i
void aggregate(const MetaDataDb &mdIn, AggregateOperation op, MDLabel aggregateLabel, MDLabel operateLabel, MDLabel resultLabel)
Number of elements of a type (int) [this is a genereic type do not use to transfer information to ano...
const int CTF_ALL_LABELS_SIZE
Definition: ctf.h:47
Missing expected label.
Definition: xmipp_error.h:158
Micrograph unique id for reference (MDL_ITEM_ID should be used for Micrographs list) ...
bool containsLabel(const MDLabel label) const override
Definition: metadata_db.h:305

◆ operator<<() [1/2]

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

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 
)

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