Xmipp  v3.23.11-Nereus
Public Member Functions | Public Attributes | List of all members
ProgCtfCreateCtfdat Class Reference
Inheritance diagram for ProgCtfCreateCtfdat:
Inheritance graph
[legend]
Collaboration diagram for ProgCtfCreateCtfdat:
Collaboration graph
[legend]

Public Member Functions

void readParams ()
 
void defineParams ()
 
void run ()
 
- 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 ()
 

Public Attributes

FileName fn_sel
 
FileName fn_doc
 
FileName fn_ctf
 
FileName fn_param
 
FileName oroot
 
bool do_mode2
 
- 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

Definition at line 31 of file ctf_create_ctfdat.cpp.

Member Function Documentation

◆ defineParams()

void ProgCtfCreateCtfdat::defineParams ( )
inlinevirtual

Function in which the param of each Program are defined.

Reimplemented from XmippProgram.

Definition at line 57 of file ctf_create_ctfdat.cpp.

58  {
59  addUsageLine("Create CTFdat files from a selfile that contains image selfiles for each micrograph.");
60  addUsageLine("+This program is useful when interacting with other packages outputs. There are two ");
61  addUsageLine("+main usage modes. In the first mode you should provide a ctfparam file with common");
62  addUsageLine("+options of each micrograph and a metadata with defocus values for each one. ");
63  addUsageLine("+In the second mode you should provide a metadata with filenames of the ctfparams for");
64  addUsageLine("+each micrograph.");
65 
66  addParamsLine(" -i <selfile> : Input selfile of selfiles for each micrograph");
67  addParamsLine(" --oroot <rootname=out> : Root name for output files ");
68  addParamsLine(" --defocus <metadata> <common_ctf> : CTFparam file with common parameters ");
69  addParamsLine(" : Metadata with defocus values for each micrograph ");
70  addParamsLine(" : this file may have either a single column (defocus)");
71  addParamsLine(" : or three columns (defocusU, defocusV, azimuth_angle)");
72  addParamsLine(" or --ctfs <selfile> : Selfile of CTF param files for each micrograph ");
73 
74  addExampleLine("Example of use: Sample at MODE 1", false);
75  addExampleLine(" ctf_create_ctfdat -i input.sel --defocus defocus.doc input.ctfparam");
76  addExampleLine("Example of use: Sample at MODE 2", false);
77  addExampleLine(" ctf_create_ctfdat -i input.sel --ctfs ctfparams.sel");
78  }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgCtfCreateCtfdat::readParams ( )
inlinevirtual

Function in which each program will read parameters that it need. If some error occurs the usage will be printed out.

Reimplemented from XmippProgram.

Definition at line 41 of file ctf_create_ctfdat.cpp.

42  {
43  fn_sel = getParam("-i");
44  oroot = getParam("--oroot");
45 
46  if ((do_mode2 = checkParam("--ctfs")))
47  {
48  fn_ctf = getParam("--ctfs");
49  }
50  else
51  {
52  fn_doc = getParam("--defocus", 0);
53  fn_param = getParam("--defocus", 1);
54  }
55  }
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)

◆ run()

void ProgCtfCreateCtfdat::run ( )
inlinevirtual

This function will be start running the program. it also should be implemented by derived classes.

Reimplemented from XmippProgram.

Definition at line 81 of file ctf_create_ctfdat.cpp.

82  {
83  MetaDataVec mdIn, SFind, mdCtf, ctfdat;
84  FileName fnsel, fnimg, fnctf;
85 
86  mdIn.read(fn_sel);
87 
88  if (do_mode2)//Mode 2: read directly the ctf file
89  {
90  mdCtf.read(fn_ctf);
91  }
92  else //Mode 1: create ctf file from defocus file and a common ctfparam file
93  {
94  // Write param files for each micrograph to disc and make an internal SFctf
95  CTFDescription ctf;
96  MetaDataVec DFdef;
97  double defU, defV, azi;
98  int ii = 0;
99  DFdef.read(fn_doc);
100  ctf.read(fn_param);
101  ctf.enable_CTF = true;
102  ctf.enable_CTFnoise = false;
103 
104  if (mdIn.size() != DFdef.size())
105  REPORT_ERROR(ERR_IO_SIZE, "Sizes between input images (-i) and docfile(-doc) should be the same!!! ");
106 
107  for (size_t objId : DFdef.ids())
108  {
109  ii++;
110  DFdef.getValue(MDL_CTF_DEFOCUSU, defU, objId);
111  if (!DFdef.getValue(MDL_CTF_DEFOCUSU, defV, objId))
112  defV=defU;
113  if (!DFdef.getValue(MDL_CTF_DEFOCUS_ANGLE, azi, objId))
114  azi=0;
115 
116  ctf.DeltafU = defU;
117  ctf.DeltafV = defV;
118  ctf.azimuthal_angle = azi;
119  fnctf.compose(oroot, ii, "ctfparam");
120  ctf.write(fnctf);
121  mdCtf.setValue(MDL_CTF_MODEL, fnctf, mdCtf.addObject());
122  if (verbose)
123  std::cout << formatString(" Saved CTF parameter file %s for micrograph number %d", fnctf.c_str(), ii) << std::endl;
124  }
125  }
126 
127  // For both modes
128  if (mdIn.size() != mdCtf.size())
129  REPORT_ERROR(ERR_MD_OBJECTNUMBER, "Selfiles of options -i and -ctfs have unequal number of entries! ");
130 
131  size_t id;
132 
133  auto itIdIn = mdIn.ids().begin();
134  auto itIdCtf = mdCtf.ids().begin();
135  const auto totalSize = mdIn.ids().end();
136  for (; itIdIn != totalSize; ++itIdIn, ++itIdCtf)
137  {
138  mdIn.getValue(MDL_SELFILE,fnsel, *itIdIn);
139  mdCtf.getValue(MDL_CTF_MODEL,fnctf, *itIdCtf);
140  SFind.read(fnsel);
141  for (size_t objId : SFind.ids())
142  {
143  SFind.getValue(MDL_IMAGE,fnimg, objId);
144  id = ctfdat.addObject();
145  ctfdat.setValue(MDL_IMAGE,fnimg, id);
146  ctfdat.setValue(MDL_CTF_MODEL,fnctf, id);
147  }
148  }
149 
150  FileName fn = oroot + ".ctfdat";
151  ctfdat.write(fn);
152  if (verbose)
153  std::cout << " Saved CTFdat file as " << fn << std::endl << " Done! "<< std::endl;
154  }
Defocus U (Angstroms)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
Defocus angle (degrees)
double DeltafV
Defocus in V (in Angstroms). Negative values are underfocused.
Definition: ctf.h:830
void write(const FileName &fn)
Definition: ctf.cpp:1275
void compose(const String &str, const size_t no, const String &ext="")
Name for the CTF Model (std::string)
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
virtual IdIteratorProxy< false > ids()
size_t size() const override
Incorrect number of objects in Metadata.
Definition: xmipp_error.h:160
void read(const FileName &fn, bool disable_if_not_K=true)
Definition: ctf.cpp:1220
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
Name of an image (std::string)
bool setValue(const MDObject &mdValueIn, size_t id)
size_t addObject() override
int verbose
Verbosity level.
bool getValue(MDObject &mdValueOut, size_t id) const override
String formatString(const char *format,...)
Incorrect file size.
Definition: xmipp_error.h:145
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
Name of an image (std::string)

Member Data Documentation

◆ do_mode2

bool ProgCtfCreateCtfdat::do_mode2

Definition at line 37 of file ctf_create_ctfdat.cpp.

◆ fn_ctf

FileName ProgCtfCreateCtfdat::fn_ctf

Definition at line 36 of file ctf_create_ctfdat.cpp.

◆ fn_doc

FileName ProgCtfCreateCtfdat::fn_doc

Definition at line 36 of file ctf_create_ctfdat.cpp.

◆ fn_param

FileName ProgCtfCreateCtfdat::fn_param

Definition at line 36 of file ctf_create_ctfdat.cpp.

◆ fn_sel

FileName ProgCtfCreateCtfdat::fn_sel

Definition at line 36 of file ctf_create_ctfdat.cpp.

◆ oroot

FileName ProgCtfCreateCtfdat::oroot

Definition at line 36 of file ctf_create_ctfdat.cpp.


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