43 addParamsLine(
" [--label+ <image_label=micrograph>] : Label to be used to read/write images.");
62 addUsageLine(
"Evaluate the CTFs and PSDs of a set of micrographs.");
63 addUsageLine(
"This process is strongly coupled to the output produced by the preprocessing micrographs step of the Xmipp protocols. ");
64 addUsageLine(
"For each input PSD, the program writes its enhanced version since it is used in the computation of some of the criteria.");
65 addUsageLine(
"+The different criteria for evaluating the PSDs are:");
67 addUsageLine(
"+$ *Damping*: this is the envelope value at the border of the PSD. Micrographs ");
68 addUsageLine(
"+with a high envelope value at border are either wrongly estimated strongly undersampled.");
70 addUsageLine(
"+$ *First zero average*: this is average in Angstroms of the first zero. ");
71 addUsageLine(
"+Normally, this value should be between 4x and 10x the sampling rate in Angstroms.");
73 addUsageLine(
"+$ *Maximum frequency*: this is the resolution (in Angstroms) at which the envelope drops below 1% of the maximum envelope");
75 addUsageLine(
"+$ *First zero disagreement*: if the CTF has been estimated by two different methods ");
76 addUsageLine(
"+(normally Xmipp and Ctffind), then this criterion measures the average disagreement ");
77 addUsageLine(
"+in Angstroms between the first zero in the two estimates. Low disagreements are ");
80 addUsageLine(
"+$ *First zero ratio*: this measures the astigmatism of the CTF by computing the ratio ");
81 addUsageLine(
"+between the largest and smallest axes of the first zero ellipse. Ratios close to 1 ");
84 addUsageLine(
"+$ *Ratio between the standard deviation at 1st zero and 1st minimum*: the variance in the experimental PSD along the");
85 addUsageLine(
"+first zero and the first CTF minimum should be approximately equal (ratio=1).");
87 addUsageLine(
"+$ *CTF margin*: ratio between the average difference in the experimental PSD between the 1st Thon");
88 addUsageLine(
"+ring and its previous zero, and the variance of the experimental PSD along the first zero");
89 addUsageLine(
"+first zero and the first CTF minimum should be approximately equal (ratio=1).");
91 addUsageLine(
"+$ *Fitting score*: the CTF is computed by fitting a theoretical model to the experimentally observed PSD. ");
92 addUsageLine(
"+This criterion is the fitting score. Smaller scores correspond to better fits.");
94 addUsageLine(
"+$ *Fitting correlation between zeros 1 and 3*: the region between the first and third zeroes ");
95 addUsageLine(
"+is particularly important since it is where the Thon rings are most visible. ");
96 addUsageLine(
"+This criterion reports the correlation between the experimental and theoretical PSDs ");
97 addUsageLine(
"+within this region. High correlations indicate good fits.");
99 addUsageLine(
"+$ *Non-astigmatic validity*: if we consider the CTF cosine part in the direction U and V ");
100 addUsageLine(
"+and add both as if they were waves, this criterion shows the frequency (in Angstroms) at which ");
101 addUsageLine(
"+both waves would interfere completely destructively. Beyond this frequency, it cannot be assumed that ");
102 addUsageLine(
"+a non-astigmatic CTF correction can manage an astigmatic CTF");
104 addUsageLine(
"+$ *PSD correlation at 90 degrees*: The PSD of non-astigmatic micrographs correlate well ");
105 addUsageLine(
"+with itself after rotating the micrograph 90 degrees. This is so because non-astigmatic ");
106 addUsageLine(
"+PSDs are circularly symmetrical, while astigmatic micrographs are elliptically symmetrical.");
107 addUsageLine(
"+High correlation when rotating 90 degrees is an indicator of non-astigmatism.");
108 addUsageLine(
"+This criterion is computed on the enhanced PSD. See [[ctf_enhance_psd_v3][ctf_enhance_psd]].");
110 addUsageLine(
"+$ *PSD radial integral*: this criterion reports the integral of the radially symmetrized PSD.");
111 addUsageLine(
"+This criterion can highlight differences among the background noises of micrographs. ");
112 addUsageLine(
"+This criterion is computed on the enhanced PSD. See [[ctf_enhance_psd_v3][ctf_enhance_psd]].");
114 addUsageLine(
"+$ *PSD variance*: the PSD is estimated by averaging different PSD local estimates in small regions of the micrograph. ");
115 addUsageLine(
"+This criterion measures the variance of the different PSD local estimates. Untilted micrographs ");
116 addUsageLine(
"+have equal defoci all over the micrograph, and therefore, the variance is due only to noise. ");
117 addUsageLine(
"+However, tilted micrographs have an increased PSD variance since different regions of the micrograph ");
118 addUsageLine(
"+have different defoci. Low variance of the PSD are indicative of non-tilted micrographs");
120 addUsageLine(
"+$ *PSD Principal Component 1 Variance*: when considering the local PSDs previously defined as vectors ");
121 addUsageLine(
"+in a multidimensional space, we can compute the variance of their projection onto the first principal component axis. ");
122 addUsageLine(
"+Low variance of this projection is indicative of a uniformity of local PSDs, i.e., this is another measure ");
123 addUsageLine(
"+of the presence of tilt in the micrograph.");
125 addUsageLine(
"+$ *PSD !PCA Runs test*: when computing the projections onto the first principal component, as discussed in the previous criterion, ");
126 addUsageLine(
"+one might expect that the sign of the projection is random for untilted micrographs. Micrographs with a marked ");
127 addUsageLine(
"+non-random pattern of projections are indicative of tilted micrographs. The larger the value of this criterion, the less random the pattern is.");
129 addParamsLine(
" [-f1 <freq_low=0.02>] : Low freq. for band pass filtration, max 0.5");
130 addParamsLine(
" [-f2 <freq_high=0.2>] : High freq. for band pass filtration, max 0.5");
131 addParamsLine(
" [-decay <freq_decay=0.02>] : Decay for the transition bands");
132 addParamsLine(
" [-m1 <mfreq_low=0.01>] : Low freq. for mask, max 0.5");
133 addParamsLine(
" [-m2 <mfreq_high=0.45>] : High freq. for mask, max 0.5");
144 <<
"Filter w1: " <<
filter_w1 << std::endl
145 <<
"Filter w2: " <<
filter_w2 << std::endl
147 <<
"Mask w1: " <<
mask_w1 << std::endl
148 <<
"Mask w2: " <<
mask_w2 << std::endl ;
157 FileName fnMicrograph, fnPSD, fnCTF, fnCTF2;
165 if (enabled==-1 || fnPSD ==
"NA")
194 if (!fnCTF2.empty() && fnCTF2 !=
"NA")
236 PSD().setXmippOrigin();
255 #define GET_CTF_CRITERION(labelll,xxx) \ 256 if (rowIn.containsLabel(labelll)) \ 257 rowIn.getValue(labelll,xxx); \ 258 else if (MDctf1.containsLabel(labelll)) \ 259 MDctf1.getValue(labelll,xxx,objId1); \ 269 Matrix1D<double> u(2), freqZero1(2), freqZero2(2), freqMin1(2), pixelZero1(2), pixelMin1(2);
270 double wmax=0.5/CTF1.
Tm;
271 double maxModuleZero=0, minModuleZero=1e38;
276 double firstZeroAvgPSD=0;
277 double firstZeroStddevPSD=0;
278 double firstMinAvgPSD=0;
279 double firstMinStddevPSD=0;
280 double firstZeroMinAvgPSD=0;
281 double firstZeroMinStddevPSD=0;
286 double f2pixel=CTF1.
Tm*
XSIZE(PSD());
299 for (
double alpha=0; alpha<=
PI; alpha+=
PI/Nalpha, N++)
305 double moduleZero=1.0/freqZero1.module();
306 maxModuleZero=
XMIPP_MAX(maxModuleZero,moduleZero);
307 minModuleZero=
XMIPP_MIN(minModuleZero,moduleZero);
312 pixelZero1=freqZero1*f2pixel;
313 pixelMin1=freqMin1*f2pixel;
314 double psdZero=PSD().interpolatedElement2D(
XX(pixelZero1),
YY(pixelZero1),0.0);
315 double psdMin=PSD().interpolatedElement2D(
XX(pixelMin1),
YY(pixelMin1),0.0);
316 firstMinAvgPSD+=psdMin;
317 firstMinStddevPSD+=psdMin*psdMin;
318 firstZeroAvgPSD+=psdZero;
319 firstZeroStddevPSD+=psdZero*psdZero;
320 double zeroMinDiff=psdMin-psdZero;
321 firstZeroMinAvgPSD+=zeroMinDiff;
322 firstZeroMinStddevPSD+=zeroMinDiff*zeroMinDiff;
325 double wx=wmax*
XX(
u);
326 double wy=wmax*
YY(
u);
329 damping=damping*damping;
333 for (
double w=0;
w<wmax;
w+=wmax/99.0)
339 if (normalizedDamping>0.1)
348 double module2=1.0/freqZero2.module();
349 double diff=
ABS(moduleZero-module2);
355 for (
double w=0;
w<wmax;
w+=wmax/99.0)
365 firstZeroStddevPSD=
sqrt(fabs(firstZeroStddevPSD/N-firstZeroAvgPSD*firstZeroAvgPSD));
367 firstMinStddevPSD=
sqrt(fabs(firstMinStddevPSD/N-firstMinAvgPSD*firstMinAvgPSD));
368 firstZeroMinAvgPSD/=N;
369 firstZeroMinStddevPSD=
sqrt(fabs(firstZeroMinStddevPSD/N-firstZeroMinAvgPSD*firstZeroMinAvgPSD));
373 if (firstZeroStddevPSD>1e-6)
382 double avg, stddev, minval, maxval;
383 M().computeStats(avg, stddev, minval, maxval);
#define VECTOR_R2(v, x, y)
void min(Image< double > &op1, const Image< double > &op2)
double decay_width
Decay width (raised cosine)
double filter_w2
Bandpass filter high frequency (in Fourier space, max 0.5)
double getDoubleParam(const char *param, int arg=0)
double KLDistance(const Histogram1D &h1, const Histogram1D &h2)
double filter_w2
Bandpass filter high frequency (in Fourier space, max 0.5)
double histogramNormality
void sqrt(Image< double > &op)
double mask_w1
Lower frequency for the mask (in Fourier space, max 0.5)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
void abs(Image< double > &op)
FileName ctf_envelope_ssnr
#define rotate(a, i, j, k, l)
void read(const FileName &fn, bool disable_if_not_K=true)
double mask_w2
Higher frequency for the mask (in Fourier space, max 0.5)
double DeltafU
Global gain. By default, 1.
void index2val(double i, double &v) const
#define GET_CTF_CRITERION(labelll, xxx)
T & getValue(MDLabel label)
void compute_hist(const MultidimArrayGeneric &array, Histogram1D &hist, int no_steps)
double maxDampingAtBorder
ProgPSDSort()
Downsampling factor used for the PSDs.
double Tm
Sampling rate (A/pixel)
void radialAverage(const MultidimArray< double > &VolFourierMag, const MultidimArray< double > &V, MultidimArray< double > &radial_mean)
double decay_width
Decay width (raised cosine)
void readFromMdRow(const MDRow &row, bool disable_if_not_K=true)
void precomputeValues(double X, double Y)
Precompute values for a given frequency.
int verbose
Verbosity level.
double getValueDampingAt(bool show=false) const
Compute CTF damping at (U,V). Continuous frequencies.
double filter_w1
Bandpass filter low frequency (in Fourier space, max 0.5)
double firstMinimumDiffStddev_ZeroStddev
double mask_w1
Lower frequency for the mask (in Fourier space, max 0.5)
void setValue(MDLabel label, const T &d, bool addLabel=true)
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
virtual bool containsLabel(MDLabel label) const =0
FileName withoutExtension() const
double filter_w1
Bandpass filter low frequency (in Fourier space, max 0.5)
void lookFor(int n, const Matrix1D< double > &u, Matrix1D< double > &freq, int iwhat=0)
void applyFilter(MultidimArray< double > &PSD)
void produceSideInfo()
Produce Side information.
double firstMinimumStddev_ZeroStddev
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
double mask_w2
Higher frequency for the mask (in Fourier space, max 0.5)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
int readMapped(const FileName &name, size_t select_img=ALL_IMAGES, int mode=WRITE_READONLY)
void addParamsLine(const String &line)
double firstZeroDisagreement
double gaussian1D(double x, double sigma, double mu)