Xmipp  v3.23.11-Nereus
sampling.h
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Roberto Marabini
4  *
5  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
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 /* This file contains functions related to the SAMPLING Transform */
26 
27 #ifndef _SAMPLING1_HH
28 #define _SAMPLING1_HH
29 #include <vector>
30 #include "core/matrix1d.h"
31 #include "core/symmetries.h"
32 
33 class MetaData;
34 
35 #define cte_w 1.107149
36 
46 class Sampling
47 {
48 public:
50  struct Vertex
51  {
52  double rot;
53  double tilt;
54  double psi;
55  };
56 
58  typedef std::vector<Vertex> Vect_angles;
59 
62  Vect_angles vertices_angles;
63 
66  std::vector <Matrix1D<double> > vertices_vectors;
67 
70 
73 
76 
79 
82 
85 
87  std::vector<std::vector<size_t> > my_neighbors;
88 
90  std::vector<std::vector<size_t> > my_exp_img_per_sampling_point;
91 
92 #ifdef MYPSI
93 
94  std::vector<std::vector<double> > my_neighbors_psi;
95 #endif
96 
98  std::vector<std::vector<double> > my_cross_correlation;
99 
101  std::vector <Matrix1D<double> > sampling_points_vector;
103  std::vector <Matrix1D<double> > sampling_points_angles;
105  std::vector <Matrix2D<double> > R_repository;
106  std::vector <Matrix2D<double> > L_repository;
108  std::vector <Matrix1D<double> > exp_data_projection_direction_by_L_R;
110  std::vector <FileName > exp_data_fileNames;
111 #ifdef MYPSI
112 
113  std::vector <double > exp_data_projection_direction_by_L_R_psi;
114 #endif
115 
118  std::vector <Matrix1D<double> > no_redundant_sampling_points_vector;
121  std::vector <Matrix1D<double> > no_redundant_sampling_points_angles;
124 
126  int verbose;
127 
129  Sampling();
130 
132  bool operator==(const Sampling& op) const;
133 
136 
139 
143  void computeSamplingPoints(bool only_half_sphere = true,
144  double max_tilt= 180,
145  double min_tilt= 0);
147  void fillEdge(const Matrix1D<double> &starting_point,
148  const Matrix1D<double> &ending_point,
149  std::vector <Matrix1D<double> > &edge_vector,
150  bool FLAG_END
151  );
153  void fillDistance(const Matrix1D<double> &starting_point,
154  const Matrix1D<double> &ending_point,
155  std::vector <Matrix1D<double> > &edge_vector,
156  int number,
157  bool only_half_spheree,
158  double min_z= -10.,
159  double max_z= +10.
160  );
162  void fillLRRepository(void);
163 
165  void setSampling(double sampling);
166 
169  void setNoise(double deviation, int my_seed=-1);
170 
172  void setNeighborhoodRadius(double neighborhood);
173 
174  /* eliminate redundant points,
175  symmetry group, symmetry order */
176  void removeRedundantPoints(const int symmetry, int sym_order);
177 
178  /* eliminate redundant points,
179  symmetry group, symmetry order
180  This function first calls removeRedundantPoints,
181  and then checks each point versus all others to calculate an angular distance
182  If this distance is less than 0.8 times the angular sampling, the point is deleted
183  */
184  void removeRedundantPointsExhaustive(const int symmetry,
185  int sym_order,
186  bool only_half_sphere,
187  double max_ang);
188 
189  /* sorting criteria for euler angles */
190  int sortFunc(const Matrix1D<double> & a, const Matrix1D<double> & b);
191 
194  void createSymFile(const FileName &simFp,int symmetry, int sym_order);
195 
197  void createAsymUnitFile(const FileName& docfilename);
198 
203  void computeNeighbors(bool only_winner=false);
204 
210  void saveSamplingFile(const FileName &fn_base, bool write_vectors = true, bool write_sampling_sphere = false);
211 
214  void readSamplingFile(const FileName &infilename,bool read_vectors=true, bool read_sampling_sphere = false);
215 
219 
221  void findClosestSamplingPoint(const MetaData &DFi,
222  const FileName &output_file_root);
223 
225  void findClosestSamplingPoint(const FileName &FnexperimentalImages,
226  const FileName &output_file_root);
227 
231 
234 
236  void fillExpDataProjectionDirectionByLR(const FileName &FnexperimentalImages);
237 };
239 #endif
std::vector< std::vector< size_t > > my_exp_img_per_sampling_point
Definition: sampling.h:90
void setSampling(double sampling)
Definition: sampling.cpp:121
void removeRedundantPoints(const int symmetry, int sym_order)
Definition: sampling.cpp:691
void setNoise(double deviation, int my_seed=-1)
Definition: sampling.cpp:134
std::vector< Matrix1D< double > > vertices_vectors
Definition: sampling.h:66
FileName symmetry_file
Definition: sampling.h:135
void createAsymUnitFile(const FileName &docfilename)
Definition: sampling.cpp:1440
std::vector< Matrix1D< double > > sampling_points_angles
Definition: sampling.h:103
void setNeighborhoodRadius(double neighborhood)
Definition: sampling.cpp:140
std::vector< Matrix2D< double > > R_repository
Definition: sampling.h:105
double neighborhood_radius_rad
Definition: sampling.h:81
void findClosestSamplingPoint(const MetaData &DFi, const FileName &output_file_root)
Definition: sampling.cpp:1991
int verbose
Definition: sampling.h:126
size_t number_of_samples
Definition: sampling.h:75
void findClosestExperimentalPoint()
Definition: sampling.cpp:2100
std::vector< Matrix1D< double > > no_redundant_sampling_points_vector
Definition: sampling.h:118
void computeNeighbors(bool only_winner=false)
Definition: sampling.cpp:1715
void removeRedundantPointsExhaustive(const int symmetry, int sym_order, bool only_half_sphere, double max_ang)
Definition: sampling.cpp:1253
void saveSamplingFile(const FileName &fn_base, bool write_vectors=true, bool write_sampling_sphere=false)
Definition: sampling.cpp:1495
double sampling_rate_rad
Definition: sampling.h:69
std::vector< Matrix1D< double > > exp_data_projection_direction_by_L_R
Definition: sampling.h:108
bool operator==(const Sampling &op) const
Definition: sampling.cpp:107
std::vector< size_t > no_redundant_sampling_points_index
Definition: sampling.h:123
doublereal * b
void computeSamplingPoints(bool only_half_sphere=true, double max_tilt=180, double min_tilt=0)
Definition: sampling.cpp:155
size_t numberSamplesAsymmetricUnit
Definition: sampling.h:78
Vect_angles vertices_angles
Definition: sampling.h:62
#define sampling
double cos_neighborhood_radius
Definition: sampling.h:84
Sampling()
Definition: sampling.cpp:32
void fillLRRepository(void)
Definition: sampling.cpp:2216
void fillDistance(const Matrix1D< double > &starting_point, const Matrix1D< double > &ending_point, std::vector< Matrix1D< double > > &edge_vector, int number, bool only_half_spheree, double min_z=-10., double max_z=+10.)
Definition: sampling.cpp:631
std::vector< std::vector< size_t > > my_neighbors
Definition: sampling.h:87
void readSamplingFile(const FileName &infilename, bool read_vectors=true, bool read_sampling_sphere=false)
Definition: sampling.cpp:1592
void fillEdge(const Matrix1D< double > &starting_point, const Matrix1D< double > &ending_point, std::vector< Matrix1D< double > > &edge_vector, bool FLAG_END)
Definition: sampling.cpp:606
std::vector< Matrix1D< double > > no_redundant_sampling_points_angles
Definition: sampling.h:121
std::vector< Matrix2D< double > > L_repository
Definition: sampling.h:106
std::vector< Vertex > Vect_angles
Definition: sampling.h:58
int sortFunc(const Matrix1D< double > &a, const Matrix1D< double > &b)
Definition: sampling.cpp:586
std::vector< Matrix1D< double > > sampling_points_vector
Definition: sampling.h:101
std::vector< std::vector< double > > my_cross_correlation
Definition: sampling.h:98
std::vector< FileName > exp_data_fileNames
Definition: sampling.h:110
void fillExpDataProjectionDirectionByLR(const MetaData &DFi)
Definition: sampling.cpp:2256
void removePointsFarAwayFromExperimentalData()
Definition: sampling.cpp:1928
double sampling_noise
Definition: sampling.h:72
void createSymFile(const FileName &simFp, int symmetry, int sym_order)
Definition: sampling.cpp:1319
doublereal * a
SymList SL
Definition: sampling.h:138