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

#include <evaluate_coordinates.h>

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

Public Member Functions

void readParams ()
 Read argument. More...
 
void show ()
 Show. More...
 
void defineParams ()
 Define parameters. More...
 
void run ()
 Main routine. 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 ()
 

Public Attributes

MetaDataVec GT
 
MetaDataVec Eval
 
FileName fnGt
 
FileName fnEval
 
FileName rootName
 
int numMic
 
int errMargin
 
- 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 34 of file evaluate_coordinates.h.

Member Function Documentation

◆ defineParams()

void ProgEvaluateCoordinates::defineParams ( )
virtual

Define parameters.

Reimplemented from XmippProgram.

Definition at line 53 of file evaluate_coordinates.cpp.

54 {
55  addUsageLine("Evaluates the set of coordinates against the ground truth");
56  addParamsLine(" -g <selfile> : Selfile containing ground truth coordinates");
57  addParamsLine(" -e <selfile> : Selfile containing coordinates to evaluate");
58  addParamsLine(" -n <int> : Number of micrographs");
59  addParamsLine(" [-t <int=10>] : Tolerance of center misplacement");
60  addParamsLine(" --root <rootName> : Root name of the micrographs");
61 }
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgEvaluateCoordinates::readParams ( )
virtual

Read argument.

Reimplemented from XmippProgram.

Definition at line 29 of file evaluate_coordinates.cpp.

30 {
31  fnGt = getParam("-g");
32  fnEval = getParam("-e");
33  numMic = getIntParam("-n");
34  errMargin = getIntParam("-t");
35  rootName = getParam("--root");
36 }
const char * getParam(const char *param, int arg=0)
int getIntParam(const char *param, int arg=0)

◆ run()

void ProgEvaluateCoordinates::run ( )
virtual

Main routine.

Reimplemented from XmippProgram.

Definition at line 63 of file evaluate_coordinates.cpp.

64 {
65  int evalXCoor, evalYCoor, gtXCoor, gtYCoor;
66  int truePosivites = 0, totalEval = 0, totalGT = 0;
67 
68  for (int m = 1; m <= numMic; m++)
69  {
70  // Here you need to change the identifiers based on datasets
71  // TODO: loading names and counts of mics automatically?
72  FileName micGT = formatString("%s_%04d@%s", rootName.c_str(), m, fnGt.c_str());
73  FileName micEval = formatString("%s_%04d@%s", rootName.c_str(), m, fnEval.c_str());
74 
75  GT.read(micGT);
76  Eval.read(micEval);
77 
78  int iterE = 1;
79  for (size_t objIdEval : Eval.ids())
80  {
81  MDRowVec row;
82  Eval.getRow(row, iterE);
83  row.getValue(MDL_XCOOR, evalXCoor);
84  row.getValue(MDL_YCOOR, evalYCoor);
85 
86  int iterG = 1;
87  for (size_t objIdGT : GT.ids())
88  {
89  GT.getRow(row, iterG);
90  row.getValue(MDL_XCOOR, gtXCoor);
91  row.getValue(MDL_YCOOR, gtYCoor);
92 
93  if ((evalXCoor > (gtXCoor-errMargin-1)) &&
94  (evalXCoor < (gtXCoor+errMargin+1)) &&
95  (evalYCoor > (gtYCoor-errMargin-1)) &&
96  (evalYCoor < (gtYCoor+errMargin+1)))
97  truePosivites++;
98 
99  iterG++;
100  }
101  iterE++;
102  }
103  totalEval += Eval.size();
104  totalGT += GT.size();
105  }
106 
107  std::cout << std::endl;
108  std::cout << "True positives (correctly picked particles): ";
109  std::cout << truePosivites << std::endl;
110  std::cout << "False positives (incorrectly picked particles): ";
111  std::cout << totalEval - truePosivites << std::endl;
112  std::cout << "False negatives (missed particles): ";
113  std::cout << totalGT - truePosivites << std::endl << std::endl;
114 
115  std::cout << "How many relevant particles are picked:" << std::endl;
116  std::cout << "True positive rate: ";
117  double truePositiveRate = (0 == totalGT) ? 0 : (double) truePosivites / totalGT;
118  std::cout << truePositiveRate << std::endl << std::endl;
119 
120  std::cout << "Ratio of wrongly picked particles and all picked particles:";
121  std::cout << std::endl;
122  std::cout << "False positive rate: ";
123  std::cout << (double) (totalEval - truePosivites) / totalEval;
124  std::cout << std::endl << std::endl;
125 }
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
virtual IdIteratorProxy< false > ids()
std::unique_ptr< MDRow > getRow(size_t id) override
size_t size() const override
T & getValue(MDLabel label)
X component (int)
int m
String formatString(const char *format,...)
Y component (int)

◆ show()

void ProgEvaluateCoordinates::show ( )

Show.

Definition at line 39 of file evaluate_coordinates.cpp.

40 {
41  if (verbose==0)
42  return;
43  std::cerr
44  << "Ground truth coordinates: " << fnGt << std::endl
45  << "Coordinates to evaluate: " << fnEval << std::endl
46  << "Number of micrographs: " << numMic << std::endl
47  << "Tolerance of center misplacement: " << errMargin << std::endl
48  << "Root name: " << rootName << std::endl
49  ;
50 }
int verbose
Verbosity level.

Member Data Documentation

◆ errMargin

int ProgEvaluateCoordinates::errMargin

Error margin (toleration of misplacement of object center)

Definition at line 56 of file evaluate_coordinates.h.

◆ Eval

MetaDataVec ProgEvaluateCoordinates::Eval

Definition at line 41 of file evaluate_coordinates.h.

◆ fnEval

FileName ProgEvaluateCoordinates::fnEval

Filename of evaluated file with coordinates

Definition at line 47 of file evaluate_coordinates.h.

◆ fnGt

FileName ProgEvaluateCoordinates::fnGt

Filename of ground truth coordinates

Definition at line 44 of file evaluate_coordinates.h.

◆ GT

MetaDataVec ProgEvaluateCoordinates::GT

Definition at line 38 of file evaluate_coordinates.h.

◆ numMic

int ProgEvaluateCoordinates::numMic

Number of micrographs

Definition at line 53 of file evaluate_coordinates.h.

◆ rootName

FileName ProgEvaluateCoordinates::rootName

Rootname

Definition at line 50 of file evaluate_coordinates.h.


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