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

#include <ctf_correct_idr.h>

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

Public Member Functions

void readParams ()
 Read params. More...
 
void preProcess ()
 Preprocess. More...
 
void show ()
 Show parameters. More...
 
void defineParams ()
 Define parameters. More...
 
void processImage (const FileName &fnImg, const FileName &fnImgOut, const MDRow &rowIn, MDRow &rowOut)
 Process one image. More...
 
- Public Member Functions inherited from XmippMetadataProgram
MetaDatagetInputMd ()
 
MetaDataVecgetOutputMd ()
 
 XmippMetadataProgram ()
 Empty constructor. More...
 
virtual int tryRead (int argc, const char **argv, bool reportErrors=true)
 
virtual void init ()
 
virtual void setup (MetaData *md, const FileName &o="", const FileName &oroot="", bool applyGeo=false, MDLabel label=MDL_IMAGE)
 
virtual ~XmippMetadataProgram ()
 
void setMode (WriteModeMetaData _mode)
 
void setupRowOut (const FileName &fnImgIn, const MDRow &rowIn, const FileName &fnImgOut, MDRow &rowOut) const
 Prepare rowout. More...
 
virtual void wait ()
 Wait for the distributor to finish. More...
 
virtual void checkPoint ()
 For very long programs, it may be needed to write checkpoints. More...
 
virtual void run ()
 Run over all images. 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)
 
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 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 ()
 

Public Attributes

FileName fn_vol
 Reference volume. More...
 
double mu
 Relaxation factor. More...
 
FileName fnRoot
 Output filename root. More...
 
Image< double > V
 
Projection Ireal
 
Projection Itheo
 
MultidimArray< double > Inorm
 
MultidimArray< double > Itheo_CTF
 
FourierFilter ctf
 
FileName last_fn_ctf
 
- Public Attributes inherited from XmippMetadataProgram
FileName fn_in
 Filenames of input and output Metadata. More...
 
FileName fn_out
 
FileName baseName
 
FileName pathBaseName
 
FileName oextBaseName
 
bool apply_geo
 Apply geo. More...
 
size_t ndimOut
 Output dimensions. More...
 
size_t zdimOut
 
size_t ydimOut
 
size_t xdimOut
 
DataType datatypeOut
 
size_t mdInSize
 Number of input elements. 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 XmippMetadataProgram
virtual void initComments ()
 
virtual void postProcess ()
 
virtual bool getImageToProcess (size_t &objId, size_t &objIndex)
 
void show () const override
 
virtual void startProcessing ()
 
virtual void finishProcessing ()
 
virtual void writeOutput ()
 
virtual void showProgress ()
 
virtual void defineLabelParam ()
 
- Protected Member Functions inherited from XmippProgram
void defineCommons ()
 
- Protected Attributes inherited from XmippMetadataProgram
WriteModeMetaData mode
 Metadata writing mode: OVERWRITE, APPEND. More...
 
FileName oext
 Output extension and root. More...
 
FileName oroot
 
MDLabel image_label
 MDLabel to be used to read/write images, usually will be MDL_IMAGE. More...
 
bool produces_an_output
 Indicate that a unique final output is produced. More...
 
bool produces_a_metadata
 Indicate that the unique final output file is a Metadata. More...
 
bool each_image_produces_an_output
 Indicate that an output is produced for each image in the input. More...
 
bool allow_apply_geo
 
bool decompose_stacks
 Input Metadata will treat a stack file as a set of images instead of a unique file. More...
 
bool delete_output_stack
 Delete previous output stack file prior to process images. More...
 
bool get_image_info
 Get the input image file dimensions to further operations. More...
 
bool save_metadata_stack
 Save the associated output metadata when output file is a stack. More...
 
bool track_origin
 Include the original input image filename in the output stack. More...
 
bool keep_input_columns
 Keep input metadata columns. More...
 
bool remove_disabled
 Remove disabled images from the input selfile. More...
 
bool allow_time_bar
 Show process time bar. More...
 
bool input_is_metadata
 Input is a metadata. More...
 
bool single_image
 Input is a single image. More...
 
bool input_is_stack
 Input is a stack. More...
 
bool output_is_stack
 Output is a stack. More...
 
bool create_empty_stackfile
 
bool delete_mdIn
 
size_t time_bar_step
 Some time bar related counters. More...
 
size_t time_bar_size
 
size_t time_bar_done
 
- 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

IDR Parameters.

Definition at line 38 of file ctf_correct_idr.h.

Member Function Documentation

◆ defineParams()

void ProgCtfCorrectIdr::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgCtfCorrectIdr >.

Definition at line 51 of file ctf_correct_idr.cpp.

52 {
54  addUsageLine("Correct CTF by using IDR");
55  addUsageLine("+This utility allows you to make reconstructions removing the effect ");
56  addUsageLine("+of the CTF. The projection images are modified according to a current ");
57  addUsageLine("+guess of the reconstruction and the CTF definition. The modified images ");
58  addUsageLine("+should be used for reconstruction which now serves as a new current guess ");
59  addUsageLine("+for a new IDR iteration.");
60  addUsageLine("+The method is fully described at http://www.ncbi.nlm.nih.gov/pubmed/15005161");
61  addUsageLine("+");
62  addUsageLine("+The program will assume that the image phase have already been corrected");
63  addUsageLine("+(otherwise the initial solution is too far from the true solution and the ");
64  addUsageLine("+algorithm does not converge).");
65  addSeeAlsoLine("ctf_phase_flip");
66  defaultComments["-i"].clear();
67  defaultComments["-i"].addComment("Metadata with images and corresponding CTFs (ctfdat)");
69  addParamsLine(" --vol <volume> : Volume with the current reconstruction");
70  addParamsLine(" [--mu <s=1.8>] : Relaxation factor");
71  addExampleLine("xmipp_ctf_correct_idr -i images.sel --vol currentGuess.vol -o idrCorrectedImages.stk");
72 }
void addSeeAlsoLine(const char *seeAlso)
void addExampleLine(const char *example, bool verbatim=true)
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)
void addParamsLine(const String &line)
std::map< String, CommentList > defaultComments
Definition: xmipp_program.h:83

◆ preProcess()

void ProgCtfCorrectIdr::preProcess ( )
virtual

Preprocess.

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgCtfCorrectIdr >.

Definition at line 36 of file ctf_correct_idr.cpp.

37 {
38  V.read(fn_vol);
39  V().setXmippOrigin();
40 }
FileName fn_vol
Reference volume.
Image< double > V
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)

◆ processImage()

void ProgCtfCorrectIdr::processImage ( const FileName fnImg,
const FileName fnImgOut,
const MDRow rowIn,
MDRow rowOut 
)
virtual

Process one image.

Implements XmippMetadataProgram.

Definition at line 76 of file ctf_correct_idr.cpp.

77 {
78  FileName fn_ctf;
79  rowIn.getValue(MDL_CTF_MODEL,fn_ctf);
80 
81  // Read current input image
82  Ireal.readApplyGeo(fnImg, rowIn);
83  int Ydim = YSIZE(Ireal());
84  int Xdim = XSIZE(Ireal());
85 
86  // Project the volume in the same direction
87  projectVolume(V(), Itheo, Ydim, Xdim, Ireal.rot(), Ireal.tilt(), Ireal.psi());
88 
89  // Copy to theo_CTF and resize
90  Itheo_CTF = Itheo();
91  Itheo_CTF.setXmippOrigin();
92  Itheo_CTF.selfWindow(FIRST_XMIPP_INDEX(2*Ydim), FIRST_XMIPP_INDEX(2*Xdim),
93  LAST_XMIPP_INDEX(2*Ydim), LAST_XMIPP_INDEX(2*Xdim));
94 
95  // Read CTF file
96  if (last_fn_ctf!=fn_ctf)
97  {
98  ctf.FilterBand = CTF;
99  ctf.ctf.read(fn_ctf);
100  ctf.ctf.enable_CTFnoise = false;
102  ctf.generateMask(Itheo_CTF);
103  ctf.correctPhase();
104  last_fn_ctf=fn_ctf;
105  }
106 
107  // Apply CTF
108  ctf.applyMaskSpace(Itheo_CTF);
109  Itheo_CTF.selfWindow(FIRST_XMIPP_INDEX(Ydim), FIRST_XMIPP_INDEX(Xdim),
110  LAST_XMIPP_INDEX(Ydim), LAST_XMIPP_INDEX(Xdim));
111 
112 #ifdef DEBUG
113 
114  Itheo.write("PPPtheo.xmp");
115  Ireal.write("PPPreal.xmp");
116 #endif
117 
118  // Apply IDR process
119  MultidimArray<double> &mItheo=Itheo();
120  const MultidimArray<double> &mIreal=Ireal();
122  DIRECT_MULTIDIM_ELEM(mItheo, n) = mu * DIRECT_MULTIDIM_ELEM(mIreal, n) +
123  (DIRECT_MULTIDIM_ELEM(mItheo, n) -
124  mu * DIRECT_MULTIDIM_ELEM(Itheo_CTF, n));
125 
126  // Save output image
127  Itheo.write(fnImgOut);
128 
129 #ifdef DEBUG
130 
131  Image<double> save;
132  save()=Itheo_CTF;
133  save.write("PPPtheo_CTF.xmp");
134  save() = Itheo() - mu * Itheo_CTF;
135  save.write("PPPdiff.xmp");
136  Itheo.write("PPPidr.xmp");
137  std::cout << "Press any key to continue\n";
138  char c;
139  std::cin >> c;
140 #endif
141 }
#define YSIZE(v)
CTFDescription ctf
double psi(const size_t n=0) const
doublereal * c
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)
Name for the CTF Model (std::string)
double rot(const size_t n=0) const
int readApplyGeo(const FileName &name, const MDRow &row, const ApplyGeoParams &params=DefaultApplyGeoParams)
FourierFilter ctf
void read(const FileName &fn, bool disable_if_not_K=true)
Definition: ctf.cpp:1220
double tilt(const size_t n=0) const
T & getValue(MDLabel label)
double mu
Relaxation factor.
#define CTF
#define XSIZE(v)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
MultidimArray< double > Itheo_CTF
Image< double > V
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
void generateMask(MultidimArray< double > &v)
int * n
void applyMaskSpace(MultidimArray< double > &v)

◆ readParams()

void ProgCtfCorrectIdr::readParams ( )
virtual

Read params.

Reimplemented from XmippMetadataProgram.

Reimplemented in BasicMpiMetadataProgram< ProgCtfCorrectIdr >.

Definition at line 29 of file ctf_correct_idr.cpp.

30 {
32  fn_vol = getParam("--vol");
33  mu = getDoubleParam("--mu");
34 }
double getDoubleParam(const char *param, int arg=0)
FileName fn_vol
Reference volume.
double mu
Relaxation factor.
const char * getParam(const char *param, int arg=0)

◆ show()

void ProgCtfCorrectIdr::show ( )

Show parameters.

Definition at line 42 of file ctf_correct_idr.cpp.

43 {
44  if (!verbose)
45  return;
47  std::cout << "Input volume: " << fn_vol << std::endl
48  << "Relaxation factor: " << mu << std::endl;
49 }
FileName fn_vol
Reference volume.
double mu
Relaxation factor.
int verbose
Verbosity level.
void show() const override

Member Data Documentation

◆ ctf

FourierFilter ProgCtfCorrectIdr::ctf

Definition at line 58 of file ctf_correct_idr.h.

◆ fn_vol

FileName ProgCtfCorrectIdr::fn_vol

Reference volume.

Definition at line 42 of file ctf_correct_idr.h.

◆ fnRoot

FileName ProgCtfCorrectIdr::fnRoot

Output filename root.

Definition at line 48 of file ctf_correct_idr.h.

◆ Inorm

MultidimArray<double> ProgCtfCorrectIdr::Inorm

Definition at line 55 of file ctf_correct_idr.h.

◆ Ireal

Projection ProgCtfCorrectIdr::Ireal

Definition at line 54 of file ctf_correct_idr.h.

◆ Itheo

Projection ProgCtfCorrectIdr::Itheo

Definition at line 54 of file ctf_correct_idr.h.

◆ Itheo_CTF

MultidimArray<double> ProgCtfCorrectIdr::Itheo_CTF

Definition at line 55 of file ctf_correct_idr.h.

◆ last_fn_ctf

FileName ProgCtfCorrectIdr::last_fn_ctf

Definition at line 61 of file ctf_correct_idr.h.

◆ mu

double ProgCtfCorrectIdr::mu

Relaxation factor.

Definition at line 45 of file ctf_correct_idr.h.

◆ V

Image<double> ProgCtfCorrectIdr::V

Definition at line 51 of file ctf_correct_idr.h.


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