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

#include <angular_neighbourhood.h>

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

Public Member Functions

void readParams ()
 Read argument from command line. More...
 
void show ()
 Show. More...
 
void defineParams ()
 Usage. More...
 
double check_symmetries (double rot1, double tilt1, double &rot2, double &tilt2)
 
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_ref
 
FileName fn_sel
 
double maxdist
 
FileName fn_sym
 
FileName fn_out
 
bool check_mirrors
 
MetaDataVec DF1
 
MetaDataVec DF2
 
SymList SL
 
- 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

Projection Neighbourhood parameters.

Definition at line 38 of file angular_neighbourhood.h.

Member Function Documentation

◆ check_symmetries()

double ProgAngularNeighbourhood::check_symmetries ( double  rot1,
double  tilt1,
double &  rot2,
double &  tilt2 
)

Check symmetries. Given two sets of angles, this function modifies set 2 so that the difference with set 1 are minimized searching in the symmetry list and the second set. Return the angle distance.

◆ defineParams()

void ProgAngularNeighbourhood::defineParams ( )
virtual

Usage.

Reimplemented from XmippProgram.

Definition at line 60 of file angular_neighbourhood.cpp.

61 {
62  addUsageLine("Computes the images in Metadata1 that are within the neighbourhood of");
63  addUsageLine("images in Metadata2. ");
64  addParamsLine(" --i1 <metadata> : Metadata1 with images and their angles");
65  addParamsLine(" --i2 <metadata> : Metadata2 with images and their angles");
66  addParamsLine(" -o <metadata> : Output metadata ");
67  addParamsLine(" :+For each image in Metadata2, there is a block ");
68  addParamsLine(" :+in the output metadata corresponding to all ");
69  addParamsLine(" :+images in Metadata1 within its neighbourhood.");
70  addParamsLine(" [--dist <d=10> ] : Maximum neighbourhood distance ");
71  addParamsLine(" [--sym <symmetry=\"\"> ] : Symmetry description if any");
72  addParamsLine(" :+The definition of the symmetry is described at [[transform_symmetrize_v3][transform_symmetrize]]");
73  addParamsLine(" [--check_mirrors] : Check mirrors");
74  addSeeAlsoLine("angular_distance");
75 }
void addSeeAlsoLine(const char *seeAlso)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgAngularNeighbourhood::readParams ( )
virtual

Read argument from command line.

Reimplemented from XmippProgram.

Definition at line 33 of file angular_neighbourhood.cpp.

34 {
35  fn_sel = getParam("--i1");
36  fn_ref = getParam("--i2");
37  fn_out = getParam("-o");
38  maxdist = getDoubleParam("--dist");
39  fn_sym = getParam("--sym");
40  if (fn_sym != "")
42  check_mirrors=checkParam("--check_mirrors");
43  DF2.read(fn_ref);
44  DF1.read(fn_sel);
45 }
double getDoubleParam(const char *param, int arg=0)
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:33
const char * getParam(const char *param, int arg=0)
bool checkParam(const char *param)

◆ run()

void ProgAngularNeighbourhood::run ( )
virtual

Compute distance. Compute the distance between the two document files loaded. The average distance is returned.

Reimplemented from XmippProgram.

Definition at line 78 of file angular_neighbourhood.cpp.

79 {
80  show();
82  MetaDataVec SF_out;
83  FileName fn2, fn1, fnAux;
84 
85  std::cerr << "Calculating ...\n";
86  for (size_t objId : DF2.ids())
87  {
88  // Read reference projection direction
89  double rot2, tilt2;
90  DF2.getValue(MDL_IMAGE,fn2,objId);
91  DF2.getValue(MDL_ANGLE_ROT,rot2,objId);
92  DF2.getValue(MDL_ANGLE_TILT,tilt2,objId);
93  for (size_t objId2 : DF1.ids())
94  {
95  // Read assigned angles from document file
96  double rot1, tilt1, psi1;
97  DF1.getValue(MDL_ANGLE_ROT,rot1,objId2);
98  DF1.getValue(MDL_ANGLE_TILT,tilt1,objId2);
99  DF1.getValue(MDL_ANGLE_PSI,psi1,objId2);
100  double dist = SL.computeDistance(rot2, tilt2, 0., rot1, tilt1, psi1,
101  true, check_mirrors, false, false);
102  if (dist <= maxdist)
103  {
104  MDRowVec row;
105  DF1.getRow(row, objId2);
106 
107  // Use the symmetry closest to the projection angle
108  // which is provided by computeDistance
109  row.setValue(MDL_ANGLE_ROT, rot1);
110  row.setValue(MDL_ANGLE_TILT, tilt1);
111  row.setValue(MDL_ANGLE_PSI, psi1);
112 
113  SF_out.addRow(row);
114  }
115  }
116 
117  // finished reading all particles for this neighbourhood
118  fnAux=fn2.replaceCharacter('/','_');
119  fnAux=fnAux.replaceCharacter('@','_');
120  fnAux=fnAux.replaceCharacter('.','_');
121  SF_out.write((String)"neighbourhoodOf_"+fnAux.c_str()+"@"+fn_out,MD_APPEND);
122  SF_out.clear();
123  }
124 }
Rotation angle of an image (double,degrees)
Tilting angle of an image (double,degrees)
void setValue(const MDObject &object) override
Special label to be used when gathering MDs in MpiMetadataPrograms.
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
virtual IdIteratorProxy< false > ids()
std::unique_ptr< MDRow > getRow(size_t id) override
size_t addRow(const MDRow &row) override
void clear() override
double computeDistance(double rot1, double tilt1, double psi1, double &rot2, double &tilt2, double &psi2, bool projdir_mode, bool check_mirrors, bool object_rotation=false, bool write_mirrors=true)
FileName replaceCharacter(char oldChar, char newChar) const
void deleteFile() const
bool getValue(MDObject &mdValueOut, size_t id) const override
std::string String
Definition: xmipp_strings.h:34
Name of an image (std::string)

◆ show()

void ProgAngularNeighbourhood::show ( )

Show.

Definition at line 48 of file angular_neighbourhood.cpp.

49 {
50  std::cerr
51  << "Selfile : " << fn_sel << std::endl
52  << "Neighbourhoods docfile : " << fn_ref << std::endl
53  << "Output root : " << fn_out << std::endl
54  << "Max. neighbour distance : " << maxdist << std::endl
55  << "Symmetry file : " << fn_sym << std::endl
56  ;
57 }

Member Data Documentation

◆ check_mirrors

bool ProgAngularNeighbourhood::check_mirrors

Check mirrors

Definition at line 52 of file angular_neighbourhood.h.

◆ DF1

MetaDataVec ProgAngularNeighbourhood::DF1

Definition at line 55 of file angular_neighbourhood.h.

◆ DF2

MetaDataVec ProgAngularNeighbourhood::DF2

Definition at line 57 of file angular_neighbourhood.h.

◆ fn_out

FileName ProgAngularNeighbourhood::fn_out

Filename of output file

Definition at line 50 of file angular_neighbourhood.h.

◆ fn_ref

FileName ProgAngularNeighbourhood::fn_ref

Filename reference projection directions document file

Definition at line 42 of file angular_neighbourhood.h.

◆ fn_sel

FileName ProgAngularNeighbourhood::fn_sel

Filename selection file containing the images

Definition at line 44 of file angular_neighbourhood.h.

◆ fn_sym

FileName ProgAngularNeighbourhood::fn_sym

Filename symmetry file

Definition at line 48 of file angular_neighbourhood.h.

◆ maxdist

double ProgAngularNeighbourhood::maxdist

Double maximum neighbour distance

Definition at line 46 of file angular_neighbourhood.h.

◆ SL

SymList ProgAngularNeighbourhood::SL

Definition at line 59 of file angular_neighbourhood.h.


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