Xmipp  v3.23.11-Nereus
angular_commonline.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar Sanchez Sorzano (coss@cnb.csic.es)
4  *
5  * Universidad San Pablo C.E.U.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20  * 02111-1307 USA
21  *
22  * All comments concerning this program package may be sent to the
23  * e-mail address 'xmipp@cnb.csic.es'
24  ***************************************************************************/
25 
26 #ifndef _PROG_ANGULAR_COMMON_LINES
27 #define _PROG_ANGULAR_COMMON_LINES
28 
29 #include <core/xmipp_funcs.h>
30 #include <core/metadata_vec.h>
31 #include <data/numerical_tools.h>
32 #include <core/matrix2d.h>
33 #include <vector>
34 #include <core/symmetries.h>
35 
40 
41 // Forward declaration
43 
44 // Class for solving the optimization problem
45 class EulerSolver: public DESolver {
46 public:
47  bool show;
49  double roti, tilti, psii;
50  double rotj, tiltj, psij;
56 
60 public:
61  // Constructor
62  EulerSolver(int dim, int pop,
63  const Matrix1D<int> &newAlreadyOptimized,
64  const Matrix1D<double> &newCurrentSolution,
65  const MultidimArray<int> &newImgIdx,
66  const Prog_Angular_CommonLine *newParent);
67 
68  // Energy function for the solver
69  double EnergyFunction(double trial[],bool &bAtSolution);
70 
71  // Distance between two common lines
72  double similarityBetweenTwoLines(int imgi, int imgj);
73 
74  // Set Debug
75  void setShow(bool newShow);
76 };
77 
80 public:
83 
86 
89 
91  int NGen;
92 
94  int NGroup;
95 
97  bool tryInitial;
98 
100  void read(int argc, const char **argv);
101 
103  void show() const;
104 
106  void usage() const;
107 
109  void produceSideInfo();
110 
112  double optimizeGroup(const Matrix1D<int> &imgIdx,
113  Matrix1D<double> &solution, bool show=false);
114 
116  void optimize(Matrix1D<double> &solution);
117 
119  double realignCurrentSolution();
120 
122  double trySolution(const Matrix1D<double> &solution);
123 
125  double computeClusters(const MultidimArray<double> &correlationMatrix,
126  std::vector< std::vector<int> > &clusters,
127  MultidimArray<double> &worseCorrelationMatrix,
128  MultidimArray<double> &bestCorrelationMatrix, bool show=false) const;
129 
131  std::vector<int> removeViaClusters(
133 
135  void run();
136 public:
137  // Selfile with images
139 
140  // Optimizer
142 
143  // Input images
144  std::vector< MultidimArray<double> > img;
145 
146  // Initial solution
148 
149  // Already optimized images
151 
152  // Current optimized solution, angles of the already
153  // optimized images
155 
156  // Correlation of the images individually
158 
159  // Worse Correlation of the images individually
161 
162  // Correlation between any pair of images
164 
165  // Best line in image i matching with image j
167 
168  // Best correlation of a line in image i matching with image j
170 
171  // Symmetry list
173 
174  // Radon transform of the images
175  std::vector< std::vector< MultidimArray<double> > > radon;
176 
177  // Left matrices for the symmetry transformations
178  std::vector< Matrix2D<double> > L;
179 
180  // Right matrices for the symmetry transformations
181  std::vector< Matrix2D<double> > R;
182 };
183 
185 #endif
std::vector< Matrix2D< double > > R
const Prog_Angular_CommonLine * parent
Matrix1D< double > imgAvgCorrelation
Matrix1D< double > currentImgMinCorrelation
std::vector< MultidimArray< double > > img
MultidimArray< double > currentCorrelationMatrix
std::vector< Matrix2D< double > > L
const MultidimArray< int > * imgIdx
Matrix1D< double > commonlinei
Matrix1D< double > normali
double similarityBetweenTwoLines(int imgi, int imgj)
double EnergyFunction(double trial[], bool &bAtSolution)
Matrix1D< double > normalj
Matrix1D< double > currentSolution
const Matrix1D< double > * currentSolution
void setShow(bool newShow)
Matrix2D< double > bestLineCorrelation
std::vector< std::vector< MultidimArray< double > > > radon
Matrix1D< double > initialSolution
Matrix1D< double > commonline
Matrix1D< int > alreadyOptimized
Matrix1D< double > imgMinCorrelation
const Matrix1D< int > * alreadyOptimized
EulerSolver(int dim, int pop, const Matrix1D< int > &newAlreadyOptimized, const Matrix1D< double > &newCurrentSolution, const MultidimArray< int > &newImgIdx, const Prog_Angular_CommonLine *newParent)
Matrix1D< double > commonlinej
file read(std::istream &is)
Definition: pdb2cif.cpp:6200
MultidimArray< double > correlationMatrix
Matrix1D< double > currentImgAvgCorrelation
void pop(struct stack_T *stack)
Definition: stack.cpp:59