Xmipp  v3.23.11-Nereus
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members

#include <ctf_estimate_from_micrograph.h>

Inheritance diagram for ProgCTFEstimateFromMicrograph:
Inheritance graph
[legend]
Collaboration diagram for ProgCTFEstimateFromMicrograph:
Collaboration graph
[legend]

Public Types

enum  TPSDEstimator_mode { ARMA, Periodogram }
 
enum  TPSD_mode { OnePerMicrograph, OnePerRegion, OnePerParticle }
 

Public Member Functions

 ProgCTFEstimateFromMicrograph ()
 
void readParams ()
 
void defineParams ()
 
void PSD_piece_by_averaging (MultidimArray< double > &piece, MultidimArray< double > &psd)
 
void run ()
 Process the whole thing. More...
 
- Public Member Functions inherited from XmippProgram
const char * getParam (const char *param, int arg=0)
 
const char * getParam (const char *param, const char *subparam, int arg=0)
 
int getIntParam (const char *param, int arg=0)
 
int getIntParam (const char *param, const char *subparam, int arg=0)
 
double getDoubleParam (const char *param, int arg=0)
 
double getDoubleParam (const char *param, const char *subparam, int arg=0)
 
float getFloatParam (const char *param, int arg=0)
 
float getFloatParam (const char *param, const char *subparam, int arg=0)
 
void getListParam (const char *param, StringVector &list)
 
int getCountParam (const char *param)
 
bool checkParam (const char *param)
 
bool existsParam (const char *param)
 
void addParamsLine (const String &line)
 
void addParamsLine (const char *line)
 
ParamDefgetParamDef (const char *param) const
 
virtual void quit (int exit_code=0) const
 
virtual int tryRun ()
 
void initProgress (size_t total, size_t stepBin=60)
 
void setProgress (size_t value=0)
 
void endProgress ()
 
void processDefaultComment (const char *param, const char *left)
 
void setDefaultComment (const char *param, const char *comment)
 
virtual void initComments ()
 
void setProgramName (const char *name)
 
void addUsageLine (const char *line, bool verbatim=false)
 
void clearUsage ()
 
void addExampleLine (const char *example, bool verbatim=true)
 
void addSeeAlsoLine (const char *seeAlso)
 
void addKeywords (const char *keywords)
 
const char * name () const
 
virtual void usage (int verb=0) const
 
virtual void usage (const String &param, int verb=2)
 
int version () const
 
virtual void show () const
 
virtual void read (int argc, const char **argv, bool reportErrors=true)
 
virtual void read (int argc, char **argv, bool reportErrors=true)
 
void read (const String &argumentsLine)
 
 XmippProgram ()
 
 XmippProgram (int argc, const char **argv)
 
virtual ~XmippProgram ()
 

Static Public Member Functions

template<typename T >
static void constructPieceSmoother (const MultidimArray< T > &piece, MultidimArray< T > &pieceSmoother)
 

Public Attributes

ProgCTFEstimateFromPSD prmEstimateCTFFromPSD
 Parameters for adjust_CTF program. More...
 
ProgCTFEstimateFromPSDFast prmEstimateCTFFromPSDFast
 Parameters for adjust_CTF program. More...
 
ARMA_parameters ARMA_prm
 Parameters for ARMA. More...
 
FileName fn_pos
 Position file. More...
 
FileName fn_micrograph
 Micrograph filename. More...
 
FileName fn_root
 Output rootname. More...
 
TPSD_mode psd_mode
 Partition mode. More...
 
int pieceDim
 Dimension of micrograph pieces. More...
 
double overlap
 
int skipBorders
 
int Nsubpiece
 
TPSDEstimator_mode PSDEstimator_mode
 
int bootstrapN
 
bool estimate_ctf
 Estimate a CTF for each PSD. More...
 
bool acceleration1D
 Accelerate PSD estimation. More...
 
- Public Attributes inherited from XmippProgram
bool doRun
 
bool runWithoutArgs
 
int verbose
 Verbosity level. More...
 
int debug
 

Additional Inherited Members

- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippProgram
int errorCode
 
ProgramDefprogDef
 Program definition and arguments parser. More...
 
std::map< String, CommentListdefaultComments
 
int argc
 Original command line arguments. More...
 
const char ** argv
 

Detailed Description

Assign CTF parameters.

Definition at line 41 of file ctf_estimate_from_micrograph.h.

Member Enumeration Documentation

◆ TPSD_mode

◆ TPSDEstimator_mode

Constructor & Destructor Documentation

◆ ProgCTFEstimateFromMicrograph()

ProgCTFEstimateFromMicrograph::ProgCTFEstimateFromMicrograph ( )

Member Function Documentation

◆ constructPieceSmoother()

template<typename T >
template void ProgCTFEstimateFromMicrograph::constructPieceSmoother< double > ( const MultidimArray< T > &  piece,
MultidimArray< T > &  pieceSmoother 
)
static

Definition at line 145 of file ctf_estimate_from_micrograph.cpp.

148 {
149  // Attenuate borders to avoid discontinuities
150  pieceSmoother.resizeNoCopy(piece);
151  pieceSmoother.initConstant(1);
152  pieceSmoother.setXmippOrigin();
153  T iHalfsize = (T)2 / YSIZE(pieceSmoother);
154  const T alpha = 0.025;
155  const T alpha1 = 1 - alpha;
156  const T ialpha = 1.0 / alpha;
157 
158  auto computeMaskValue = [&] (T fraction) {
159  return 0.5 * (1 + cos(PI * ((fraction - 1) * ialpha + 1)));
160  };
161 
162  for (int i = STARTINGY(pieceSmoother);
163  i <= FINISHINGY(pieceSmoother);
164  i++) {
165  T iFraction = fabs(i * iHalfsize);
166  if (iFraction > alpha1)
167  {
168  T maskValue = computeMaskValue(iFraction);
169  for (int j = STARTINGX(pieceSmoother);
170  j <= FINISHINGX(pieceSmoother); j++) {
171  A2D_ELEM(pieceSmoother,i,j) *= maskValue;
172  }
173  }
174  }
175 
176  for (int j = STARTINGX(pieceSmoother);
177  j <= FINISHINGX(pieceSmoother);
178  j++) {
179  T jFraction = fabs(j * iHalfsize);
180  if (jFraction > alpha1)
181  {
182  T maskValue = computeMaskValue(jFraction);
183  for (int i = STARTINGY(pieceSmoother);
184  i <= FINISHINGY(pieceSmoother); i++) {
185  A2D_ELEM(pieceSmoother,i,j) *= maskValue;
186  }
187  }
188  }
189 }
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
#define FINISHINGX(v)
void resizeNoCopy(const MultidimArray< T1 > &v)
void initConstant(T val)
#define STARTINGX(v)
#define i
#define STARTINGY(v)
#define j
#define FINISHINGY(v)
#define PI
Definition: tools.h:43

◆ defineParams()

void ProgCTFEstimateFromMicrograph::defineParams ( )
virtual

Define parameters

Reimplemented from XmippProgram.

Definition at line 91 of file ctf_estimate_from_micrograph.cpp.

92 {
93  addUsageLine("Estimate the CTF from a micrograph.");
94  addUsageLine("The PSD of the micrograph is first estimated using periodogram averaging or ");
95  addUsageLine("ARMA models ([[http://www.ncbi.nlm.nih.gov/pubmed/12623169][See article]]). ");
96  addUsageLine("Then, the PSD is enhanced ([[http://www.ncbi.nlm.nih.gov/pubmed/16987671][See article]]). ");
97  addUsageLine("And finally, the CTF is fitted to the PSD, being guided by the enhanced PSD ");
98  addUsageLine("([[http://www.ncbi.nlm.nih.gov/pubmed/17911028][See article]]).");
99  addParamsLine(" --micrograph <file> : File with the micrograph");
100  addParamsLine(" [--oroot <rootname=\"\">] : Rootname for output");
101  addParamsLine(" : If not given, the micrograph without extensions is taken");
102  addParamsLine(" :++ rootname.psd or .psdstk contains the PSD or PSDs");
103  addParamsLine("==+ PSD estimation");
104  addParamsLine(" [--psd_estimator <method=periodogram>] : Method for estimating the PSD");
105  addParamsLine(" where <method>");
106  addParamsLine(" periodogram");
107  addParamsLine(" ARMA");
108  addParamsLine(" [--pieceDim <d=512>] : Size of the piece");
109  addParamsLine(" [--overlap <o=0.5>] : Overlap (0=no overlap, 1=full overlap)");
110  addParamsLine(" [--skipBorders <s=2>] : Number of pieces around the border to skip");
111  addParamsLine(" [--Nsubpiece <N=1>] : Each piece is further subdivided into NxN subpieces.");
112  addParamsLine(" : This option is useful for small micrographs in which ");
113  addParamsLine(" : not many pieces of size pieceDim x pieceDim can be defined. ");
114  addParamsLine(" :++ Note that this is not the same as defining a smaller pieceDim. ");
115  addParamsLine(" :++ Defining a smaller pieceDim, would result in a small PSD, while ");
116  addParamsLine(" :++ subdividing the piece results in a large PSD, although smoother.");
117  addParamsLine(" [--mode <mode=micrograph>] : How many PSDs are to be estimated");
118  addParamsLine(" where <mode>");
119  addParamsLine(" micrograph : Single PSD for the whole micrograph");
120  addParamsLine(" regions <file=\"\"> : The micrograph is divided into a region grid ");
121  addParamsLine(" : and a PSD is computed for each one.");
122  addParamsLine(" : The file is metadata with the position of each particle within the micrograph");
123  addParamsLine(" particles <file> : One PSD per particle.");
124  addParamsLine(" : The file is metadata with the position of each particle within the micrograph");
125  addParamsLine("==+ CTF fit");
126  addParamsLine(" [--dont_estimate_ctf] : Do not fit a CTF to PSDs");
127  addParamsLine(" [--acceleration1D] : Accelerate PSD estimation");
131  addExampleLine("Estimate PSD", false);
132  addExampleLine("xmipp_ctf_estimate_from_micrograph --micrograph micrograph.mrc --dont_estimate_ctf");
133  addExampleLine("Estimate a single CTF for the whole micrograph", false);
134  addExampleLine("xmipp_ctf_estimate_from_micrograph --micrograph micrograph.mrc --sampling_rate 1.4 --voltage 200 --spherical_aberration 2.5");
135  addExampleLine("Estimate a single CTF for the whole micrograph providing a starting point for the defocus",false);
136  addExampleLine("xmipp_ctf_estimate_from_micrograph --micrograph micrograph.mrc --sampling_rate 1.4 --voltage 200 --spherical_aberration 2.5 --defocusU -15000");
137  addExampleLine("Estimate a CTF per region", false);
138  addExampleLine("xmipp_ctf_estimate_from_micrograph --micrograph micrograph.mrc --mode regions micrograph.pos --sampling_rate 1.4 --voltage 200 --spherical_aberration 2.5 --defocusU -15000");
139  addExampleLine("Estimate a CTF per particle", false);
140  addExampleLine("xmipp_ctf_estimate_from_micrograph --micrograph micrograph.mrc --mode particles micrograph.pos --sampling_rate 1.4 --voltage 200 --spherical_aberration 2.5 --defocusU -15000");
141 }
void addExampleLine(const char *example, bool verbatim=true)
static void defineBasicParams(XmippProgram *program)
Define basic parameters.
static void defineParams(XmippProgram *program)
Define parameters.
void addUsageLine(const char *line, bool verbatim=false)
static void defineBasicParams(XmippProgram *program)
Define basic parameters.
void addParamsLine(const String &line)

◆ PSD_piece_by_averaging()

void ProgCTFEstimateFromMicrograph::PSD_piece_by_averaging ( MultidimArray< double > &  piece,
MultidimArray< double > &  psd 
)

PSD averaging within a piece. Compute the PSD of a piece by subdividing it in smaller pieces and averaging their PSDs. The piece will be cut into 3x3 overlapping pieces of size N/2 x N/2.

Definition at line 193 of file ctf_estimate_from_micrograph.cpp.

195 {
196  int small_Ydim = 2 * YSIZE(piece) / Nsubpiece;
197  int small_Xdim = 2 * XSIZE(piece) / Nsubpiece;
198  MultidimArray<double> small_piece(small_Ydim, small_Xdim);
199 
200  int Xstep = (XSIZE(piece) - small_Xdim) / (Nsubpiece - 1);
201  int Ystep = (YSIZE(piece) - small_Ydim) / (Nsubpiece - 1);
202  psd.initZeros(small_piece);
203 #ifdef DEBUG
204 
205  Image<double> save;
206  save()=piece;
207  save.write("PPPpiece.xmp");
208 #endif
209 
211  MultidimArray<double> small_psd;
212 
213  // Attenuate borders to avoid discontinuities
214  MultidimArray<double> pieceSmoother;
215  constructPieceSmoother(piece, pieceSmoother);
216 
217  for (int ii = 0; ii < Nsubpiece; ii++)
218  for (int jj = 0; jj < Nsubpiece; jj++)
219  {
220  // Take the corresponding small piece from the piece
221  int i0 = ii * Xstep;
222  int j0 = jj * Ystep;
223 
224  int i, j, ib, jb;
225  for (i = 0, ib = i0; i < small_Ydim; i++, ib++)
226  for (j = 0, jb = j0; j < small_Xdim; j++, jb++)
227  DIRECT_A2D_ELEM(small_piece, i, j)=
228  DIRECT_A2D_ELEM(piece, ib, jb);
229  normalize_ramp(piece);
230  piece *= pieceSmoother;
231 
232 #ifdef DEBUG
233 
234  save()=small_piece;
235  save.write("PPPsmall_piece.xmp");
236 #endif
237 
238  // Compute the PSD of the small piece
239  small_psd.initZeros(small_piece);
240  if (PSDEstimator_mode == ARMA)
241  {
242  CausalARMA(small_piece, ARMA_prm);
243  ARMAFilter(small_piece, small_psd, ARMA_prm);
244  }
245  else
246  {
247  FourierTransform(small_piece, Periodogram);
248  FFT_magnitude(Periodogram, small_psd);
249  small_psd *= small_psd;
250  small_psd *= small_Ydim * small_Xdim;
251  }
252 
253 #ifdef DEBUG
254  save()=small_psd;
255  save.write("PPPsmall_psd.xmp");
256 #endif
257 
258  // Add to the average
259  psd += small_psd;
260  }
261 
262  // Compute the average of all the small pieces and enlarge
263  psd *= 1.0 / (Nsubpiece * Nsubpiece);
264 
265 #ifdef DEBUG
266 
267  save()=psd;
268  save.write("PPPpsd1.xmp");
269 #endif
270 
271  CenterFFT(psd, true);
273  CenterFFT(psd, false);
274  psd.threshold("below", 0, 0);
275 
276 #ifdef DEBUG
277 
278  save()=psd;
279  save.write("PPPpsd2.xmp");
280  std::cout << "Press any key\n";
281  char c;
282  std::cin >> c;
283 #endif
284 }
#define YSIZE(v)
void threshold(const String &type, T a, T b=0, MultidimArray< int > *mask=NULL)
doublereal * c
static void constructPieceSmoother(const MultidimArray< T > &piece, MultidimArray< T > &pieceSmoother)
#define DIRECT_A2D_ELEM(v, i, j)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define i
void selfScaleToSize(int SplineDegree, MultidimArrayGeneric &V1, int Xdim, int Ydim, int Zdim)
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
void CausalARMA(MultidimArray< double > &Img, ARMA_parameters &prm)
void normalize_ramp(MultidimArray< double > &I, MultidimArray< int > *bg_mask)
Definition: normalize.cpp:333
#define XSIZE(v)
void FourierTransform(const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out)
Definition: xmipp_fft.cpp:124
#define j
void ARMAFilter(MultidimArray< double > &Img, MultidimArray< double > &Filter, ARMA_parameters &prm)
ARMA_parameters ARMA_prm
Parameters for ARMA.
void initZeros(const MultidimArray< T1 > &op)
void FFT_magnitude(const MultidimArray< std::complex< double > > &v, MultidimArray< double > &mag)
Definition: xmipp_fftw.cpp:393

◆ readParams()

void ProgCTFEstimateFromMicrograph::readParams ( )
virtual

Read parameters

Reimplemented from XmippProgram.

Definition at line 45 of file ctf_estimate_from_micrograph.cpp.

46 {
47  fn_micrograph = getParam("--micrograph");
48  fn_root = getParam("--oroot");
49  if (fn_root == "")
51  pieceDim = getIntParam("--pieceDim");
52  skipBorders = getIntParam("--skipBorders");
53  overlap = getDoubleParam("--overlap");
54  String aux = getParam("--psd_estimator");
55  if (aux == "periodogram")
57  else
58  {
60  ARMA_prm.readParams(this);
61  }
62  Nsubpiece = getIntParam("--Nsubpiece");
63 
64  String mode = getParam("--mode");
65  if (mode == "micrograph")
67  else if (mode == "regions")
68  {
70  fn_pos = getParam("--mode", 1);
71  }
72  else if (mode == "particles")
73  {
75  fn_pos = getParam("--mode", 1);
76  }
77  estimate_ctf = !checkParam("--dont_estimate_ctf");
78  acceleration1D = checkParam("--acceleration1D");
79 
80  if (estimate_ctf)
81  {
82  if (!acceleration1D)
84  else
86  }
87 
88  bootstrapN = getIntParam("--bootstrapFit");
89 }
double getDoubleParam(const char *param, int arg=0)
void readBasicParams(XmippProgram *program)
Read parameters.
void readBasicParams(XmippProgram *program)
Read parameters.
bool estimate_ctf
Estimate a CTF for each PSD.
const char * getParam(const char *param, int arg=0)
bool acceleration1D
Accelerate PSD estimation.
ProgCTFEstimateFromPSDFast prmEstimateCTFFromPSDFast
Parameters for adjust_CTF program.
void mode
int pieceDim
Dimension of micrograph pieces.
ProgCTFEstimateFromPSD prmEstimateCTFFromPSD
Parameters for adjust_CTF program.
ARMA_parameters ARMA_prm
Parameters for ARMA.
FileName withoutExtension() const
std::string String
Definition: xmipp_strings.h:34
void readParams(XmippProgram *program)
Read parameters from command line.
bool checkParam(const char *param)
FileName fn_micrograph
Micrograph filename.
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgCTFEstimateFromMicrograph::run ( )
virtual

Process the whole thing.

Reimplemented from XmippProgram.

Definition at line 289 of file ctf_estimate_from_micrograph.cpp.

290 {
291  // Open input files -----------------------------------------------------
292  // Open coordinates
293  MetaDataVec posFile;
294  if (fn_pos != "")
295  posFile.read(fn_pos);
296  auto iterPosFile = posFile.ids().begin();
297 
298  // Open the micrograph --------------------------------------------------
299  Image<double> M_in;
300  size_t Ndim, Zdim, Ydim , Xdim; // Micrograph dimensions
301 
302  //ImageInfo imgInfo;
303  //getImageInfo(fn_micrograph, imgInfo);
304  //imgInfo.adim.ndim
305 
306  M_in.read(fn_micrograph,HEADER);
307  M_in.getDimensions(Xdim, Ydim, Zdim, Ndim);
308 
309  // Compute the number of divisions --------------------------------------
310  int div_Number = 0;
311  int div_NumberX=1, div_NumberY=1;
312  if (psd_mode == OnePerParticle)
313  div_Number = posFile.size();
314  else if (psd_mode == OnePerMicrograph)
315  {
316  div_NumberX = CEIL((double)Xdim / (pieceDim *(1-overlap))) - 1;
317  div_NumberY = CEIL((double)Ydim / (pieceDim *(1-overlap))) - 1;
318  div_Number = div_NumberX * div_NumberY;
319  }
320  else if (psd_mode == OnePerRegion)
321  {
322  div_NumberX = CEIL((double)Xdim / pieceDim);
323  div_NumberY = CEIL((double)Ydim / pieceDim);
324  if (div_NumberX<=2*skipBorders || div_NumberY<=2*skipBorders)
325  REPORT_ERROR(ERR_ARG_INCORRECT,formatString("The micrograph is not big enough to skip %d pieces on each side",skipBorders));
326  div_Number = div_NumberX * div_NumberY;
327  }
328 
329  // Process each piece ---------------------------------------------------
330  Image<double> psd_avg, psd_std, psd, psd2;
333  psd().resizeNoCopy(piece);
334  MultidimArray<double> &mpsd = psd();
335  MultidimArray<double> &mpsd2 = psd2();
336  PCAMahalanobisAnalyzer pcaAnalyzer;
337  MultidimArray<int> PCAmask;
339  double pieceDim2 = pieceDim * pieceDim;
340 
341  //Multidimensional data variables to store the defocus obtained locally for plane fitting
342  MultidimArray<double> defocusPlanefittingU(div_NumberX-2*skipBorders, div_NumberY-2*skipBorders);
343  MultidimArray<double> defocusPlanefittingV(defocusPlanefittingU);
344  MultidimArray<double> Xm(defocusPlanefittingU);
345  MultidimArray<double> Ym(defocusPlanefittingU);
346 
347  // Attenuate borders to avoid discontinuities
348  MultidimArray<double> pieceSmoother;
349  constructPieceSmoother(piece, pieceSmoother);
350  if (verbose)
351  std::cerr << "Computing models of each piece ...\n";
352 
353  // Prepare these filenames in case they are needed
354  FileName fn_psd;
355  if (psd_mode == OnePerMicrograph)
356  fn_psd = fn_root + ".psd";
357  else
358  fn_psd = fn_root + ".psdstk";
359  if (fileExists(fn_psd))
360  fn_psd.deleteFile();
361  if (fileExists(fn_root+".ctfparam"))
362  FileName(fn_root+".ctfparam").deleteFile();
363 
364  if (verbose)
365  init_progress_bar(div_Number);
366  int N = 1; // Index of current piece
367  size_t piecei = 0, piecej = 0; // top-left corner of the current piece
368  FourierTransformer transformer;
369  int actualDiv_Number = 0;
370 
371  for (size_t nIm = 1; nIm <= Ndim; nIm++)
372  {
373  M_in.read(fn_micrograph,DATA,nIm);
374  std::cout << "Micrograph number: " << nIm << std::endl;
375 
376  while (N <= div_Number)
377  {
378  bool skip = false;
379  int blocki=0, blockj=0;
380  // Compute the top-left corner of the piece ..........................
381  if (psd_mode == OnePerParticle)
382  {
383  // Read position of the particle
384  posFile.getValue(MDL_X, piecej, *iterPosFile);
385  posFile.getValue(MDL_Y, piecei, *iterPosFile);
386 
387  // j,i are the selfWindow center, we need the top-left corner
388  piecej -= (int) (pieceDim / 2);
389  piecei -= (int) (pieceDim / 2);
390  if (piecei < 0)
391  piecei = 0;
392  if (piecej < 0)
393  piecej = 0;
394  }
395  else
396  {
397  int step = pieceDim;
398  if (psd_mode == OnePerMicrograph)
399  step = (int) ((1 - overlap) * step);
400  blocki = (N - 1) / div_NumberX;
401  blockj = (N - 1) % div_NumberX;
402  if (blocki < skipBorders || blockj < skipBorders
403  || blocki > (div_NumberY - skipBorders - 1)
404  || blockj > (div_NumberX - skipBorders - 1))
405  skip = true;
406  piecei = blocki * step;
407  piecej = blockj * step;
408  }
409 
410  // test if the full piece is inside the micrograph
411  if (piecei + pieceDim > Ydim)
412  piecei = Ydim - pieceDim;
413  if (piecej + pieceDim > Xdim)
414  piecej = Xdim - pieceDim;
415 
416  if (!skip)
417  {
418  // Extract micrograph piece ..........................................
419 // M_in().window(piece, 0, 0, piecei, piecej, 0, 0, piecei + YSIZE(piece) - 1,
420 // piecej + XSIZE(piece) - 1);
421  window2D( M_in(), piece, piecei, piecej, piecei + YSIZE(piece) - 1, piecej + XSIZE(piece) - 1);
422  piece.statisticsAdjust(0., 1.);
423  normalize_ramp(piece);
424  piece *= pieceSmoother;
425 
426  // Estimate the power spectrum .......................................
427  if (Nsubpiece == 1)
428  if (PSDEstimator_mode == ARMA)
429  {
430  CausalARMA(piece, ARMA_prm);
431  ARMAFilter(piece, mpsd, ARMA_prm);
432  }
433  else
434  {
435  transformer.completeFourierTransform(piece, Periodogram);
436  FFT_magnitude(Periodogram, mpsd);
438  DIRECT_MULTIDIM_ELEM(mpsd,n)*=DIRECT_MULTIDIM_ELEM(mpsd,n)*pieceDim2;
439  }
440  else
441  PSD_piece_by_averaging(piece, mpsd);
442  mpsd2.resizeNoCopy(mpsd);
444  {
445  double psdval = DIRECT_MULTIDIM_ELEM(mpsd,n);
446  DIRECT_MULTIDIM_ELEM(mpsd2,n)=psdval*psdval;
447  }
448 
449  // Perform averaging if applicable ...................................
450  if (psd_mode == OnePerMicrograph)
451  {
452  actualDiv_Number += 1;
453  // Compute average and standard deviation
454  if (XSIZE(psd_avg()) != XSIZE(mpsd))
455  {
456  psd_avg() = mpsd;
457  psd_std() = psd2();
458  }
459  else
460  {
461  psd_avg() += mpsd;
462  psd_std() += psd2();
463  }
464 
465  // Keep psd for the PCA
466  if (estimate_ctf)
467  {
468  if (XSIZE(PCAmask) == 0)
469  {
470  PCAmask.initZeros(mpsd);
471  Matrix1D<int> idx(2); // Indexes for Fourier plane
472  Matrix1D<double> freq(2); // Frequencies for Fourier plane
473  size_t PCAdim = 0;
475  {
476  VECTOR_R2(idx, j, i);
477  FFT_idx2digfreq(mpsd, idx, freq);
478  double w = freq.module();
479  if (w > 0.05 && w < 0.4)
480  {
481  A2D_ELEM(PCAmask,i,j)=1;
482  ++PCAdim;
483  }
484  }
485  PCAv.initZeros(PCAdim);
486  }
487 
488  size_t ii = -1;
490  if (DIRECT_MULTIDIM_ELEM(PCAmask,n))
491  A1D_ELEM(PCAv,++ii)=(float)DIRECT_MULTIDIM_ELEM(mpsd,n);
492  pcaAnalyzer.addVector(PCAv);
493  }
494  }
495 
496  // Compute the theoretical model if not averaging ....................
497  if (psd_mode != OnePerMicrograph)
498  {
499 
500  if (bootstrapN != -1)
502  "Bootstrapping is only available for micrograph averages");
503 
504  FileName fn_psd_piece;
505  fn_psd_piece.compose(N, fn_psd);
506  psd.write(fn_psd_piece);
507  if (psd_mode == OnePerParticle)
508  posFile.setValue(MDL_PSD, fn_psd_piece, *iterPosFile);
509  if (estimate_ctf)
510  {
511  // Estimate the CTF parameters of this piece
512  prmEstimateCTFFromPSD.fn_psd = fn_psd_piece;
513  CTFDescription ctfmodel;
514 
515  ctfmodel.isLocalCTF = true;
516  ctfmodel.x0 = piecej;
517  ctfmodel.xF = (piecej + pieceDim-1);
518  ctfmodel.y0 = piecei;
519  ctfmodel.yF = (piecei + pieceDim-1);
520  ROUT_Adjust_CTF(prmEstimateCTFFromPSD, ctfmodel, false);
521 
522  int idxi=blocki-skipBorders;
523  int idxj=blockj-skipBorders;
524  A2D_ELEM(defocusPlanefittingU,idxi,idxj)=ctfmodel.DeltafU;
525  A2D_ELEM(defocusPlanefittingV,idxi,idxj)=ctfmodel.DeltafV;
526 
527  A2D_ELEM(Xm,idxi,idxj)=(piecei+pieceDim/2)*ctfmodel.Tm;
528  A2D_ELEM(Ym,idxi,idxj)=(piecej+pieceDim/2)*ctfmodel.Tm;
529 
530  //1D//
531  prmEstimateCTFFromPSDFast.fn_psd = fn_psd_piece; //Nuevo
532  CTFDescription1D ctf1Dmodel; //Nuevo
533  ctf1Dmodel.isLocalCTF = true;
534  ctf1Dmodel.x0 = piecej;
535  ctf1Dmodel.xF = (piecej + pieceDim-1);
536  ctf1Dmodel.y0 = piecei;
537  ctf1Dmodel.yF = (piecei + pieceDim-1);
538  ROUT_Adjust_CTFFast(prmEstimateCTFFromPSDFast, ctf1Dmodel, false); //Nuevo
539 
540  A2D_ELEM(defocusPlanefittingU,idxi,idxj)=ctf1Dmodel.Defocus;
541 
542  A2D_ELEM(Xm,idxi,idxj)=(piecei+pieceDim/2)*ctf1Dmodel.Tm;
543  A2D_ELEM(Ym,idxi,idxj)=(piecej+pieceDim/2)*ctf1Dmodel.Tm;
544 
546  posFile.setValue(MDL_CTF_MODEL,
547  fn_psd_piece.withoutExtension() + ".ctfparam",
548  *iterPosFile);
549  }
550  }
551  }
552  // Increment the division counter
553  ++N;
554  if (verbose)
555  progress_bar(N);
556  if (psd_mode == OnePerParticle)
557  ++iterPosFile;
558  }
559 
560  init_progress_bar(div_Number);
561  N = 1;
562  }
563  if (verbose)
564  progress_bar(div_Number);
565 
566  // If averaging, compute the CTF model ---------------------------------- //Program execution
567  if (psd_mode == OnePerMicrograph)
568  {
569  // Compute the avg and stddev of the local PSDs
570  const MultidimArray<double> &mpsd_std = psd_std();
571  const MultidimArray<double> &mpsd_avg = psd_avg();
572  double idiv_Number = 1.0 / actualDiv_Number;
574  {
575  DIRECT_MULTIDIM_ELEM(mpsd_avg,n)*=idiv_Number;
576  DIRECT_MULTIDIM_ELEM(mpsd_std,n)*=idiv_Number;
577  DIRECT_MULTIDIM_ELEM(mpsd_std,n)-=DIRECT_MULTIDIM_ELEM(mpsd_avg,n)*
578  DIRECT_MULTIDIM_ELEM(mpsd_avg,n);
579  if (DIRECT_MULTIDIM_ELEM(mpsd_std,n)<0)
580  DIRECT_MULTIDIM_ELEM(mpsd_std,n)=0;
581  else
582  DIRECT_MULTIDIM_ELEM(mpsd_std,n)=sqrt(DIRECT_MULTIDIM_ELEM(mpsd_std,n));
583  }
584  psd_avg.write(fn_psd);
585 
586  if (estimate_ctf)
587  {
588  // Estimate the CTF parameters
589  std::cerr << "Adjusting CTF model to the PSD ...\n";
590  prmEstimateCTFFromPSD.fn_psd = fn_psd;
592  CTFDescription ctfmodel;
593  CTFDescription1D ctf1Dmodel;
594 
595  if (bootstrapN == -1)
596  {
597  try {
598  // No bootstrapping
599  // Compute the PCA of the local PSDs
600  pcaAnalyzer.standardarizeVariables();
601  // pcaAnalyzer.subtractAvg();
602  pcaAnalyzer.learnPCABasis(1, 10);
603  } catch (XmippError &xe)
604  {
605  if (xe.__errno==ERR_NUMERICAL)
606  REPORT_ERROR(ERR_NUMERICAL,"There is no variance in the PSD, check that the micrograph is not constant");
607  else
608  throw xe;
609  }
610 
611 #ifdef DEBUG
612 
613  Image<double> save;
614  save().initZeros(psd());
615  int ii=-1;
617  if (PCAmask(i,j))
618  save(i,j)=pcaAnalyzer.PCAbasis[0](++ii);
619  save.write("PPPbasis.xmp");
620 #endif
621 
622  Matrix2D<double> CtY;
623  pcaAnalyzer.projectOnPCABasis(CtY);
625  CtY.toVector(p);
626  double pavg = p.sum(true);
627  double pstd = p.sum2() / VEC_XSIZE(p) - pavg * pavg;
628  pstd = (pstd < 0) ? 0 : sqrt(pstd);
629 
630  std::string psign;
632  if (p(i) < 0)
633  psign += "-";
634  else
635  psign += "+";
636  double zrandomness = checkRandomness(psign);
637 
638  if (!acceleration1D)
639  {
640  ctfmodel.isLocalCTF = false;
641  ctfmodel.x0 = 0;
642  ctfmodel.xF = (Xdim-1);
643  ctfmodel.y0 = 0;
644  ctfmodel.yF = (Ydim-1);
645  ROUT_Adjust_CTF(prmEstimateCTFFromPSD,ctfmodel, false);
646  }
647  else
648  {
649  ctf1Dmodel.isLocalCTF = false;
650  ctf1Dmodel.x0 = 0;
651  ctf1Dmodel.xF = (Xdim-1);
652  ctf1Dmodel.y0 = 0;
653  ctf1Dmodel.yF = (Ydim-1);
655  }
656  // Evaluate PSD variance and write into the CTF
657  double stdQ = 0;
659  stdQ += A2D_ELEM(mpsd_std,i,j)/A2D_ELEM(mpsd_avg,i,j);
660  stdQ /= MULTIDIM_SIZE(psd_std());
661 
662  MetaDataVec MD;
663  MD.read(fn_psd.withoutExtension() + ".ctfparam");
664  size_t id = MD.firstRowId();
665  MD.setValue(MDL_CTF_CRIT_PSDVARIANCE, stdQ, id);
667  MD.setValue(MDL_CTF_CRIT_PSDPCARUNSTEST, zrandomness, id);
668  MD.write((String)"fullMicrograph@"+fn_psd.withoutExtension() + ".ctfparam");
669  }
670  else
671  {
672  // If bootstrapping
675  if (!acceleration1D)
676  {
678  FileName fnBase = fn_psd.withoutExtension();
679  std::cerr << "Computing bootstrap ...\n";
681  for (int n = 0; n < bootstrapN; n++)
682  {
684  ctfmodel, false);
685 
686  CTFs(n, 0) = ctfmodel.Tm;
687  CTFs(n, 1) = ctfmodel.kV;
688  CTFs(n, 2) = ctfmodel.DeltafU;
689  CTFs(n, 3) = ctfmodel.DeltafV;
690  CTFs(n, 4) = ctfmodel.azimuthal_angle;
691  CTFs(n, 5) = ctfmodel.Cs;
692  CTFs(n, 6) = ctfmodel.Ca;
693  CTFs(n, 7) = ctfmodel.espr;
694  CTFs(n, 8) = ctfmodel.ispr;
695  CTFs(n, 9) = ctfmodel.alpha;
696  CTFs(n, 10) = ctfmodel.DeltaF;
697  CTFs(n, 11) = ctfmodel.DeltaR;
698  CTFs(n, 12) = ctfmodel.Q0;
699  CTFs(n, 13) = ctfmodel.K;
700  CTFs(n, 14) = ctfmodel.gaussian_K;
701  CTFs(n, 15) = ctfmodel.sigmaU;
702  CTFs(n, 16) = ctfmodel.sigmaV;
703  CTFs(n, 17) = ctfmodel.cU;
704  CTFs(n, 18) = ctfmodel.cV;
705  CTFs(n, 19) = ctfmodel.gaussian_angle;
706  CTFs(n, 20) = ctfmodel.sqrt_K;
707  CTFs(n, 21) = ctfmodel.sqU;
708  CTFs(n, 22) = ctfmodel.sqV;
709  CTFs(n, 23) = ctfmodel.sqrt_angle;
710  CTFs(n, 24) = ctfmodel.base_line;
711  CTFs(n, 25) = ctfmodel.gaussian_K2;
712  CTFs(n, 26) = ctfmodel.sigmaU2;
713  CTFs(n, 27) = ctfmodel.sigmaV2;
714  CTFs(n, 28) = ctfmodel.cU2;
715  CTFs(n, 29) = ctfmodel.cV2;
716  CTFs(n, 30) = ctfmodel.gaussian_angle2;
717 
718 
719  std::string command = (std::string) "mv -i " + fnBase
720  + ".ctfparam " + fnBase + "_bootstrap_"
721  + integerToString(n, 4) + ".ctfparam";
722  if (system(command.c_str())==-1)
723  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
724  command = (std::string) "mv -i " + fnBase
725  + ".ctfmodel_quadrant " + fnBase + "_bootstrap_"
726  + integerToString(n, 4) + ".ctfmodel_quadrant";
727  if (system(command.c_str())==-1)
728  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
729  command = (std::string) "mv -i " + fnBase
730  + ".ctfmodel_halfplane " + fnBase + "_bootstrap_"
731  + integerToString(n, 4) + ".ctfmodel_halfplane";
732  if (system(command.c_str())==-1)
733  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
734 
735  progress_bar(n);
736  }
737  progress_bar(bootstrapN);
738 
739  }
741  else
742  {
743  MultidimArray<double> CTFs(bootstrapN, 21);
746  FileName fnBase = fn_psd.withoutExtension();
747  std::cerr << "Computing bootstrap ...\n";
748  init_progress_bar(bootstrapN);
749  for (int n = 0; n < bootstrapN; n++)
750  {
751  CTFs(n, 21) = ROUT_Adjust_CTFFast(prmEstimateCTFFromPSDFast,ctf1Dmodel, false);
752 
753  CTFs(n, 0) = ctf1Dmodel.Tm;
754  CTFs(n, 1) = ctf1Dmodel.kV;
755  CTFs(n, 2) = ctf1Dmodel.Defocus;
756  CTFs(n, 3) = ctf1Dmodel.Cs;
757  CTFs(n, 4) = ctf1Dmodel.Ca;
758  CTFs(n, 5) = ctf1Dmodel.espr;
759  CTFs(n, 6) = ctf1Dmodel.ispr;
760  CTFs(n, 7) = ctf1Dmodel.alpha;
761  CTFs(n, 8) = ctf1Dmodel.DeltaF;
762  CTFs(n, 9) = ctf1Dmodel.DeltaR;
763  CTFs(n, 10) = ctf1Dmodel.Q0;
764  CTFs(n, 11) = ctf1Dmodel.K;
765  CTFs(n, 12) = ctf1Dmodel.gaussian_K;
766  CTFs(n, 13) = ctf1Dmodel.sigma1;
767  CTFs(n, 14) = ctf1Dmodel.Gc1;
768  CTFs(n, 15) = ctf1Dmodel.sqrt_K;
769  CTFs(n, 16) = ctf1Dmodel.sq;
770  CTFs(n, 17) = ctf1Dmodel.base_line;
771  CTFs(n, 18) = ctf1Dmodel.gaussian_K2;
772  CTFs(n, 19) = ctf1Dmodel.sigma2;
773  CTFs(n, 20) = ctf1Dmodel.Gc2;
774 
775 
776  std::string command = (std::string) "mv -i " + fnBase
777  + ".ctfparam " + fnBase + "_bootstrap_"
778  + integerToString(n, 4) + ".ctfparam";
779  if (system(command.c_str())==-1)
780  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
781  command = (std::string) "mv -i " + fnBase
782  + ".ctf1Dmodel_quadrant " + fnBase + "_bootstrap_"
783  + integerToString(n, 4) + ".ctf1Dmodel_quadrant";
784  if (system(command.c_str())==-1)
785  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
786  command = (std::string) "mv -i " + fnBase
787  + ".ctf1Dmodel_halfplane " + fnBase + "_bootstrap_"
788  + integerToString(n, 4) + ".ctf1Dmodel_halfplane";
789  if (system(command.c_str())==-1)
790  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
791 
792  progress_bar(n);
793  }
794  progress_bar(bootstrapN);
795  }
796  }
797 
798 
799  }
800  }
801 
802  // Assign a CTF to each particle ----------------------------------------
804  {
805  double pU0 = 0, pU1 = 0, pU2 = 0;
806  planeFit(defocusPlanefittingU, Xm, Ym, pU0, pU1, pU2);
807  double pV0 = 0, pV1 = 0, pV2 = 0;
808  planeFit(defocusPlanefittingV, Xm, Ym, pV0, pV1, pV2);
809 
810  MetaDataVec MDctf;
811  MDctf.read(fn_root+".ctfparam");
812  double Tm, downsampling;
813  size_t id=MDctf.firstRowId();
814  MDctf.getValue(MDL_CTF_SAMPLING_RATE,Tm,id);
815  MDctf.getValue(MDL_CTF_DOWNSAMPLE_PERFORMED,downsampling,id);
816 
817  MetaDataVec MD;
818  MD.setColumnFormat(false);
819  id = MD.addObject();
820  MD.setValue(MDL_CTF_DEFOCUS_PLANEUA, pU1, id);
821  MD.setValue(MDL_CTF_DEFOCUS_PLANEUB, pU2, id);
822  MD.setValue(MDL_CTF_DEFOCUS_PLANEUC, pU0, id);
823  MD.setValue(MDL_CTF_DEFOCUS_PLANEVA, pV1, id);
824  MD.setValue(MDL_CTF_DEFOCUS_PLANEVB, pV2, id);
825  MD.setValue(MDL_CTF_DEFOCUS_PLANEVC, pV0, id);
826  MD.setValue(MDL_CTF_X0, 0., id);
827  MD.setValue(MDL_CTF_Y0, 0., id);
828  MD.setValue(MDL_CTF_XF, (Xdim-1)*Tm*downsampling, id);
829  MD.setValue(MDL_CTF_YF, (Ydim-1)*Tm*downsampling, id);
830  MD.write((String)"fullMicrograph@"+fn_root+".ctfparam", MD_APPEND);
831 
832  if (fn_pos != "")
833  {
834  FileName fn_img, fn_psd_piece, fn_ctfparam_piece;
835  int Y, X;
836  for (size_t objId : posFile.ids())
837  {
838  posFile.getValue(MDL_IMAGE, fn_img, objId);
839  posFile.getValue(MDL_X, X, objId);
840  posFile.getValue(MDL_Y, Y, objId);
841  auto idx_X = (int)floor((double) X / pieceDim);
842  auto idx_Y = (int)floor((double) Y / pieceDim);
843  int N = idx_Y * div_NumberX + idx_X + 1;
844 
845  fn_psd_piece.compose(N, fn_psd);
846  fn_ctfparam_piece = fn_psd_piece.withoutExtension()
847  + ".ctfparam";
848  posFile.setValue(MDL_PSD, fn_psd_piece, objId);
849  posFile.setValue(MDL_CTF_MODEL, fn_ctfparam_piece, objId);
850  }
851  }
852  }
853  posFile.write(fn_pos);
854 }
double sigmaU
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:871
Just to locate unclassified errors.
Definition: xmipp_error.h:192
#define VECTOR_R2(v, x, y)
Definition: matrix1d.h:112
void planeFit(const MultidimArray< double > &z, const MultidimArray< double > &x, const MultidimArray< double > &y, double &p0, double &p1, double &p2)
void init_progress_bar(long total)
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
#define YSIZE(v)
#define A2D_ELEM(v, i, j)
void addVector(const MultidimArray< float > &_v)
Add vector.
Definition: basic_pca.h:100
__host__ __device__ float2 floor(const float2 v)
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
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
#define VEC_XSIZE(m)
Definition: matrix1d.h:77
#define MULTIDIM_SIZE(v)
void projectOnPCABasis(Matrix2D< double > &CtY)
Project on basis.
Definition: basic_pca.cpp:119
void resizeNoCopy(const MultidimArray< T1 > &v)
Defocus = A*x+B*y+C.
Defocus = A*x+B*y+C.
void sqrt(Image< double > &op)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
static void constructPieceSmoother(const MultidimArray< T > &piece, MultidimArray< T > &pieceSmoother)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
#define A1D_ELEM(v, i)
void toVector(Matrix1D< T > &op1) const
Definition: matrix2d.cpp:832
double espr
Definition: ctf.h:251
double cU2
Second Gaussian center for U.
Definition: ctf.h:893
void compose(const String &str, const size_t no, const String &ext="")
double cU
Gaussian center for U.
Definition: ctf.h:875
doublereal * w
Name for the CTF Model (std::string)
void PSD_piece_by_averaging(MultidimArray< double > &piece, MultidimArray< double > &psd)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
bool estimate_ctf
Estimate a CTF for each PSD.
String integerToString(int I, int _width, char fill_with)
Defocus = A*x+B*y+C.
Defocus = A*x+B*y+C.
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
virtual IdIteratorProxy< false > ids()
double gaussian_K
Gain for the gaussian term.
Definition: ctf.h:279
void FFT_idx2digfreq(T &v, const Matrix1D< int > &idx, Matrix1D< double > &freq)
Definition: xmipp_fft.h:80
A Power Spectrum Density file name (std::string)
double sq
Sqrt width.
Definition: ctf.h:287
FileName fn_psd
CTF filename.
double DeltaF
Longitudinal mechanical displacement (ansgtrom). Typical value 100.
Definition: ctf.h:257
double sqrt_angle
Sqrt angle.
Definition: ctf.h:887
size_t size() const override
#define i
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
Defocus = A*x+B*y+C.
double DeltafU
Global gain. By default, 1.
Definition: ctf.h:828
void standardarizeVariables()
Standardarize variables.
Definition: basic_pca.cpp:61
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
bool bootstrap
Bootstrap estimation.
double sum2() const
Definition: matrix1d.cpp:673
#define FOR_ALL_ELEMENTS_IN_MATRIX1D(v)
Definition: matrix1d.h:72
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
if(fabs(c[*nmax+ *nmax *c_dim1])==0.e0)
bool acceleration1D
Accelerate PSD estimation.
void CausalARMA(MultidimArray< double > &Img, ARMA_parameters &prm)
double gaussian_K2
Gain for the second Gaussian term.
Definition: ctf.h:289
bool setValue(const MDObject &mdValueIn, size_t id)
#define CEIL(x)
Definition: xmipp_macros.h:225
size_t addObject() override
double ROUT_Adjust_CTFFast(ProgCTFEstimateFromPSDFast &prm, CTFDescription1D &output_ctfmodel, bool standalone)
void normalize_ramp(MultidimArray< double > &I, MultidimArray< int > *bg_mask)
Definition: normalize.cpp:333
Incorrect argument received.
Definition: xmipp_error.h:113
size_t firstRowId() const override
#define XSIZE(v)
void progress_bar(long rlen)
ProgCTFEstimateFromPSDFast prmEstimateCTFFromPSDFast
Parameters for adjust_CTF program.
double ispr
Objective lens stability (deltaI/I) (ppm). Typical value 1.
Definition: ctf.h:253
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
double sqV
Sqrt width V.
Definition: ctf.h:885
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
Error related to numerical calculation.
Definition: xmipp_error.h:179
#define DIRECT_MULTIDIM_ELEM(v, n)
double sum(bool average=false) const
Definition: matrix1d.cpp:652
std::vector< MultidimArray< double > > PCAbasis
Definition: basic_pca.h:69
void window2D(const MultidimArray< T > &Ibig, MultidimArray< T > &Ismall, size_t y0, size_t x0, size_t yF, size_t xF)
int verbose
Verbosity level.
double Cs
Spherical aberration (in milimeters). Typical value 5.6.
Definition: ctf.h:246
int pieceDim
Dimension of micrograph pieces.
ProgCTFEstimateFromPSD prmEstimateCTFFromPSD
Parameters for adjust_CTF program.
Defocus = A*x+B*y+C.
double DeltaR
Transversal mechanical displacement (ansgtrom). Typical value 3.
Definition: ctf.h:259
double sigmaV
Gaussian width V.
Definition: ctf.h:873
bool show_optimization
Show convergence values.
Runs test on the projection of the PSD on the first principal component.
#define j
double Defocus
Defocus (in Angstroms). Negative values are underfocused.
Definition: ctf.h:244
void deleteFile() const
double checkRandomness(const std::string &sequence)
Downsampling performed to estimate the CTF.
bool getValue(MDObject &mdValueOut, size_t id) const override
double K
Global gain. By default, 1.
Definition: ctf.h:238
void ARMAFilter(MultidimArray< double > &Img, MultidimArray< double > &Filter, ARMA_parameters &prm)
double gaussian_angle
Gaussian angle.
Definition: ctf.h:879
Variance in the first principal component of the PSDs.
virtual void setColumnFormat(bool column)
bool isLocalCTF
Local CTF determination.
Definition: ctf.h:271
ARMA_parameters ARMA_prm
Parameters for ARMA.
FileName withoutExtension() const
Y component (double)
double Ca
Chromatic aberration (in milimeters). Typical value 2.
Definition: ctf.h:248
std::string String
Definition: xmipp_strings.h:34
double alpha
Convergence cone semiangle (in mrad). Typical value 0.5.
Definition: ctf.h:255
bool fileExists(const char *filename)
String formatString(const char *format,...)
void completeFourierTransform(T &v, T1 &V)
Definition: xmipp_fftw.h:315
X component (double)
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
void learnPCABasis(size_t NPCA, size_t Niter)
Learn basis.
Definition: basic_pca.cpp:170
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
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
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
ErrorType __errno
Definition: xmipp_error.h:227
double kV
Accelerating Voltage (in KiloVolts)
Definition: ctf.h:242
void initZeros(const MultidimArray< T1 > &op)
double cV2
Second Gaussian center for V.
Definition: ctf.h:895
FileName fn_micrograph
Micrograph filename.
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
void FFT_magnitude(const MultidimArray< std::complex< double > > &v, MultidimArray< double > &mag)
Definition: xmipp_fftw.cpp:393
Incorrect value received.
Definition: xmipp_error.h:195
double ROUT_Adjust_CTF(ProgCTFEstimateFromPSD &prm, CTFDescription &output_ctfmodel, bool standalone)
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
int * n
Name of an image (std::string)
double sigmaU2
Second Gaussian width U.
Definition: ctf.h:889
The CTF is valid within (x0,y0) to (xF,yF) in the micrograph coordinates.
double sigmaV2
Second Gaussian width V.
Definition: ctf.h:891
double cV
Gaussian center for V.
Definition: ctf.h:877
void getDimensions(size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const

Member Data Documentation

◆ acceleration1D

bool ProgCTFEstimateFromMicrograph::acceleration1D

Accelerate PSD estimation.

Definition at line 79 of file ctf_estimate_from_micrograph.h.

◆ ARMA_prm

ARMA_parameters ProgCTFEstimateFromMicrograph::ARMA_prm

Parameters for ARMA.

Definition at line 54 of file ctf_estimate_from_micrograph.h.

◆ bootstrapN

int ProgCTFEstimateFromMicrograph::bootstrapN

Bootstrap N

Definition at line 75 of file ctf_estimate_from_micrograph.h.

◆ estimate_ctf

bool ProgCTFEstimateFromMicrograph::estimate_ctf

Estimate a CTF for each PSD.

Definition at line 77 of file ctf_estimate_from_micrograph.h.

◆ fn_micrograph

FileName ProgCTFEstimateFromMicrograph::fn_micrograph

Micrograph filename.

Definition at line 58 of file ctf_estimate_from_micrograph.h.

◆ fn_pos

FileName ProgCTFEstimateFromMicrograph::fn_pos

Position file.

Definition at line 56 of file ctf_estimate_from_micrograph.h.

◆ fn_root

FileName ProgCTFEstimateFromMicrograph::fn_root

Output rootname.

Definition at line 60 of file ctf_estimate_from_micrograph.h.

◆ Nsubpiece

int ProgCTFEstimateFromMicrograph::Nsubpiece

Number of pieces (Nsubpiece x Nsubpiece) for the piece averaging

Definition at line 71 of file ctf_estimate_from_micrograph.h.

◆ overlap

double ProgCTFEstimateFromMicrograph::overlap

Overlap among pieces (0=No overlap, 1=Full overlap

Definition at line 66 of file ctf_estimate_from_micrograph.h.

◆ pieceDim

int ProgCTFEstimateFromMicrograph::pieceDim

Dimension of micrograph pieces.

Definition at line 64 of file ctf_estimate_from_micrograph.h.

◆ prmEstimateCTFFromPSD

ProgCTFEstimateFromPSD ProgCTFEstimateFromMicrograph::prmEstimateCTFFromPSD

Parameters for adjust_CTF program.

Definition at line 50 of file ctf_estimate_from_micrograph.h.

◆ prmEstimateCTFFromPSDFast

ProgCTFEstimateFromPSDFast ProgCTFEstimateFromMicrograph::prmEstimateCTFFromPSDFast

Parameters for adjust_CTF program.

Definition at line 52 of file ctf_estimate_from_micrograph.h.

◆ psd_mode

TPSD_mode ProgCTFEstimateFromMicrograph::psd_mode

Partition mode.

Definition at line 62 of file ctf_estimate_from_micrograph.h.

◆ PSDEstimator_mode

TPSDEstimator_mode ProgCTFEstimateFromMicrograph::PSDEstimator_mode

PSDEstimator_mode

Definition at line 73 of file ctf_estimate_from_micrograph.h.

◆ skipBorders

int ProgCTFEstimateFromMicrograph::skipBorders

Skip borders. The number of pieces around the border that must be skipped.

Definition at line 69 of file ctf_estimate_from_micrograph.h.


The documentation for this class was generated from the following files: