Xmipp  v3.23.11-Nereus
ctf_correct_wiener2d.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: AUTHOR_NAME (jvargas@cnb.csic.es)
3  *
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #include "ctf_correct_wiener2d.h"
27 
28 
29 // Read arguments ==========================================================
31 {
33  phase_flipped = checkParam("--phase_flipped");
34  pad = XMIPP_MAX(1.,getDoubleParam("--pad"));
35  isIsotropic = checkParam("--isIsotropic");
37  correct_envelope = checkParam("--correct_envelope");
38  sampling_rate = getDoubleParam("--sampling_rate");
39 }
40 
41 // Define parameters ==========================================================
43 {
44  addUsageLine("Perform CTF correction to 2D projection images with estimated ctfs using a Wiener filter.");
47  addKeywords("correct CTF by Wiener filtering");
48  addParamsLine(" [--phase_flipped] : Is the data already phase-flipped?");
49  addParamsLine(" [--isIsotropic] : Must be considered the defocus isotropic?");
50  addParamsLine(" [--sampling_rate <float=1.0>] : Sampling rate of the input particles");
51  addParamsLine(" [--wc <float=-1>] : Wiener-filter constant (if < 0: use FREALIGN default)");
52  addParamsLine(" [--pad <factor=2.> ] : Padding factor for Wiener correction");
53  addParamsLine(" [--correct_envelope] : Correct the CTF envelope");
54 }
55 
56 // Define parameters ==========================================================
58 {
59  MetaData &ptrMdOut = getOutputMd();
60 
61  ptrMdOut.removeLabel(MDL_CTF_DEFOCUSA);
62  ptrMdOut.removeLabel(MDL_CTF_DEFOCUSU);
64  ptrMdOut.removeLabel(MDL_CTF_DEFOCUSV);
82  ptrMdOut.removeLabel(MDL_CTF_CA);
85  ptrMdOut.removeLabel(MDL_CTF_ENVELOPE);
89  ptrMdOut.removeLabel(MDL_CTF_K);
90 
91  ptrMdOut.write(fn_out.replaceExtension("xmd"));
92 
93 }
94 
95 
96 void ProgCorrectWiener2D::processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
97 {
98  WF.pad = pad;
104  WF.applyWienerFilter(fnImg, fnImgOut, rowIn, rowOut);
105 
106 }
107 
void applyWienerFilter(MultidimArray< double > &ptrImg, CTFDescription &ctf)
Definition: wiener2d.cpp:101
CTF Background parameter.
CTF gain.
Defocus U (Angstroms)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
double getDoubleParam(const char *param, int arg=0)
CTF Background parameter.
virtual bool removeLabel(const MDLabel label)=0
FileName replaceExtension(const String &newExt) const
Defocus angle (degrees)
CTF Background parameter.
virtual void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const =0
bool isIsotropic
Definition: wiener2d.h:44
Convergence cone.
CTF Background parameter.
CTF Background parameter.
CTF Background parameter.
double sampling_rate
Sampling rate.
CTF Background parameter.
CTF Background parameter.
CTF Background parameter.
double wiener_constant
Wiener filter constant.
void addKeywords(const char *keywords)
double pad
Definition: wiener2d.h:42
CTF Background parameter.
Longitudinal displacement.
average defocus (Angtroms)
CTF Background parameter.
CTF Background parameter.
CTF Background parameter.
CTF_ CTF Background parameter.
CTF Background parameter.
double wiener_constant
Wiener filter constant.
Definition: wiener2d.h:49
bool phase_flipped
Definition: wiener2d.h:39
void processImage(const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
CTF Background parameter.
bool checkParam(const char *param)
bool each_image_produces_an_output
Indicate that an output is produced for each image in the input.
void addUsageLine(const char *line, bool verbatim=false)
double sampling_rate
Sampling rate.
Definition: wiener2d.h:52
Defocus V (Angstroms)
Chromatic aberration.
Transversal displacemente.
bool correct_envelope
Definition: wiener2d.h:46
Lens stability.
void addParamsLine(const String &line)
CTF Background parameter.