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

#include <compare_views.h>

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

Public Member Functions

void defineParams ()
 Define params. More...
 
void readParams ()
 Read arguments from command line. More...
 
void show ()
 Show. More...
 
void run ()
 Run. More...
 
void computeCorrImage (int i)
 Compute corr image. 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

FileName fnVol1
 Volumes to compare. More...
 
FileName fnVol2
 
FileName fnImgOut
 Output corelation image. More...
 
double degstep
 Degree step. More...
 
Image< double > V1
 Images. More...
 
Image< double > V2
 
Image< double > CorrImg
 
std::vector< double > tilt_v
 Rot and tilt vectors. More...
 
std::vector< double > rot_v
 
- 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

Sph Alignment Parameters.

Definition at line 38 of file compare_views.h.

Member Function Documentation

◆ computeCorrImage()

void ProgCompareViews::computeCorrImage ( int  i)

Compute corr image.

Definition at line 95 of file compare_views.cpp.

96 {
97  Projection P1, P2;
98  auto &mCorrImg = CorrImg();
99  auto &mV1 = V1();
100  auto &mV2 = V2();
101  auto &mP1 = P1();
102  auto &mP2 = P2();
103  int size_x = XSIZE(mV1);
104  int size_y = YSIZE(mV1);
105  auto rot = rot_v[i];
106  for (int j = 0; j < tilt_v.size(); j++)
107  {
108  projectVolume(mV1, P1, size_y, size_x, rot, tilt_v[j], 0.);
109  projectVolume(mV2, P2, size_y, size_x, rot, tilt_v[j], 0.);
110  DIRECT_A2D_ELEM(mCorrImg, i, j) = correlationIndex(mP1, mP2);
111  }
112 }
#define YSIZE(v)
Image< double > V1
Images.
Definition: compare_views.h:53
#define DIRECT_A2D_ELEM(v, i, j)
double correlationIndex(const MultidimArray< T > &x, const MultidimArray< T > &y, const MultidimArray< int > *mask=NULL, MultidimArray< double > *Contributions=NULL)
#define i
Image< double > CorrImg
Definition: compare_views.h:53
std::vector< double > rot_v
Definition: compare_views.h:56
Image< double > V2
Definition: compare_views.h:53
#define XSIZE(v)
void projectVolume(FourierProjector &projector, Projection &P, int Ydim, int Xdim, double rot, double tilt, double psi, const MultidimArray< double > *ctf)
std::vector< double > tilt_v
Rot and tilt vectors.
Definition: compare_views.h:56
#define j

◆ defineParams()

void ProgCompareViews::defineParams ( )
virtual

Define params.

Reimplemented from XmippProgram.

Definition at line 36 of file compare_views.cpp.

36  {
37  addUsageLine("Compute the deformation that properly fits two volumes using spherical harmonics");
38  addParamsLine(" -v1 <volume> : First volume to compare");
39  addParamsLine(" -v2 <volume> : Second volume to compare");
40  addParamsLine(" [-o <image=\"\">] : Output correlation image");
41  addParamsLine(" [--degstep <d=5.0>] : Degrees step size for rot and tilt angles");
42  addParamsLine(" [--thr <N=-1>] : Maximal number of the processing CPU threads");
43  addExampleLine("xmipp_compare_views -v1 vol1.vol -v2 vol2.vol -o corr_img.xmp");
44 }
void addExampleLine(const char *example, bool verbatim=true)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)

◆ readParams()

void ProgCompareViews::readParams ( )
virtual

Read arguments from command line.

Reimplemented from XmippProgram.

Definition at line 47 of file compare_views.cpp.

47  {
48  std::string aux;
49  fnVol1 = getParam("-v1");
50  fnVol2 = getParam("-v2");
51  fnImgOut = getParam("-o");
52  degstep = getDoubleParam("--degstep");
53 
54  if (fnImgOut=="")
55  fnImgOut="Rot_tilt_corr_map.xmp";
56 
57  V1.read(fnVol1);
58  V1().setXmippOrigin();
59  V2.read(fnVol2);
60  V2().setXmippOrigin();
61 
62  // Update degstep to have evenly spaced points in the interval [0,180]
63  degstep = 360. / ROUND(360./degstep);
64 
65  int size_rot = 360./degstep;
66  int size_tlt = 180./degstep;
67  tilt_v.resize(size_tlt + 1);
68  rot_v.resize(size_rot + 1);
69  CorrImg().initZeros(size_rot + 1, size_tlt + 1);
70  CorrImg().setXmippOrigin();
71 
72  std::generate(tilt_v.begin(), tilt_v.end(), [&, n = -degstep] () mutable { return n+=degstep; });
73  std::generate(rot_v.begin(), rot_v.end(), [&, n = -degstep] () mutable { return n+=degstep; });
74 
75  int threads = getIntParam("--thr");
76  if (0 >= threads) {
77  threads = CPU::findCores();
78  }
79  m_threadPool.resize(threads);
80 }
double getDoubleParam(const char *param, int arg=0)
Image< double > V1
Images.
Definition: compare_views.h:53
FileName fnImgOut
Output corelation image.
Definition: compare_views.h:46
static unsigned findCores()
Definition: cpu.h:41
void resize(int nThreads)
Definition: ctpl.h:70
Image< double > CorrImg
Definition: compare_views.h:53
const char * getParam(const char *param, int arg=0)
std::vector< double > rot_v
Definition: compare_views.h:56
Image< double > V2
Definition: compare_views.h:53
#define ROUND(x)
Definition: xmipp_macros.h:210
FileName fnVol1
Volumes to compare.
Definition: compare_views.h:42
std::vector< double > tilt_v
Rot and tilt vectors.
Definition: compare_views.h:56
double degstep
Degree step.
Definition: compare_views.h:49
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
int getIntParam(const char *param, int arg=0)
int * n

◆ run()

void ProgCompareViews::run ( )
virtual

Run.

Reimplemented from XmippProgram.

Definition at line 115 of file compare_views.cpp.

115  {
116  auto futures = std::vector<std::future<void>>();
117  futures.reserve(V1().zdim);
118 
119  auto routine = [this](int thrId, int i) {
121  };
122 
123  for (int i=0; i<rot_v.size(); i++)
124  {
125  futures.emplace_back(m_threadPool.push(routine, i));
126  }
127 
128  for (auto &f : futures) {
129  f.get();
130  }
131 
133 }
Image< double > V1
Images.
Definition: compare_views.h:53
auto push(F &&f, Rest &&... rest) -> std::future< decltype(f(0, rest...))>
Definition: ctpl.h:152
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)
FileName fnImgOut
Output corelation image.
Definition: compare_views.h:46
void computeCorrImage(int i)
Compute corr image.
#define i
Image< double > CorrImg
Definition: compare_views.h:53
std::vector< double > rot_v
Definition: compare_views.h:56
double * f

◆ show()

void ProgCompareViews::show ( )

Show.

Definition at line 83 of file compare_views.cpp.

83  {
84  if (verbose==0)
85  return;
86  std::cout
87  << "First volume: " << fnVol1 << std::endl
88  << "Second volume: " << fnVol2 << std::endl
89  << "Output image: " << fnImgOut << std::endl
90  << "Degree step: " << degstep << std::endl
91  ;
92 
93 }
FileName fnImgOut
Output corelation image.
Definition: compare_views.h:46
FileName fnVol1
Volumes to compare.
Definition: compare_views.h:42
int verbose
Verbosity level.
double degstep
Degree step.
Definition: compare_views.h:49

Member Data Documentation

◆ CorrImg

Image<double> ProgCompareViews::CorrImg

Definition at line 53 of file compare_views.h.

◆ degstep

double ProgCompareViews::degstep

Degree step.

Definition at line 49 of file compare_views.h.

◆ fnImgOut

FileName ProgCompareViews::fnImgOut

Output corelation image.

Definition at line 46 of file compare_views.h.

◆ fnVol1

FileName ProgCompareViews::fnVol1

Volumes to compare.

Definition at line 42 of file compare_views.h.

◆ fnVol2

FileName ProgCompareViews::fnVol2

Definition at line 43 of file compare_views.h.

◆ rot_v

std::vector<double> ProgCompareViews::rot_v

Definition at line 56 of file compare_views.h.

◆ tilt_v

std::vector<double> ProgCompareViews::tilt_v

Rot and tilt vectors.

Definition at line 56 of file compare_views.h.

◆ V1

Image<double> ProgCompareViews::V1

Images.

Definition at line 53 of file compare_views.h.

◆ V2

Image<double> ProgCompareViews::V2

Definition at line 53 of file compare_views.h.


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