Xmipp  v3.23.11-Nereus
precompute_sampling.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors:
4  *
5  * Roberto Marabini
6  * Unidad de Bioinformatica of Centro Nacional de Biotecnologia , CSIC
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21  * 02111-1307 USA
22  *
23  * All comments concerning this program package may be sent to the
24  * e-mail address 'xmipp@cnb.csic.es'
25  ***************************************************************************/
26 
27 #include "precompute_sampling.h"
28 
29 /* Empty constructor ------------------------------------------------------- */
31 {
34 }
35 
36 
37 /* Read parameters --------------------------------------------------------- */
38 void Prog_Sampling_Parameters::read(int argc, const char **argv)
39 {
40  sampling_file_root = getParameter(argc, argv, "-o");
41  fn_sym = getParameter(argc, argv, "-sym");
42  //symmetry = getParameter(argc, argv, "-symmetry", "cn");
43  //sym_order = textToInteger(getParameter(argc, argv, "-sym_order", "1"));
44  sampling = textToFloat(getParameter(argc, argv, "-sampling_rate", "5"));
45  neighborhood = textToFloat(getParameter(argc, argv, "-neighborhood", "1"));
46  max_tilt_angle = textToFloat(getParameter(argc, argv, "-max_tilt_angle","0"));
47  min_tilt_angle = textToFloat(getParameter(argc, argv, "-min_tilt_angle","180"));
48 }
49 
50 /* Usage ------------------------------------------------------------------- */
52 {
53  std::cerr << "precompute_sampling\n"
54  << " -o root_file_name : Root for output files\n"
55  << " [-sym cn] :One of the 17 possible symmetries in\n"
56  << " single particle electronmicroscopy\n"
57  << " i.e. ci, cs, cn, cnv, cnh, sn, dn, dnv, dnh, t, td, th, o, oh, i, ih\n"
58  << " : where n may change from 1 to 99\n"
59  << " [-sampling_rate 5] : Distance in degrees between sampling points\n"
60  << " [-neighborhood 1] : A sampling point is neighbor if closer than this value in degrees\n"
61  << " [-max_tilt_angle <t=0>] : maximum tilt angle in degrees\n"
62  << " [-min_tilt_angle <t=-180>] : minimum tilt angle in degrees\n"
63  << "\n"
64  << "Example of use: Sample at 2degres and compute neighboor at "
65  << " 5 degrees for c6 symmetry\n"
66  << " xmipp_precompute_sampling -o out -sym c6 "
67  << " -sampling_rate 2 -neighborhood 5 -max_tilt_angle 70 "
68  << " -min_tilt_angle 50 \n"
69  ;
70 }
71 
72 /* Show -------------------------------------------------------------------- */
74 {
75  std::cout
76  << "Sampling rate: " << sampling << std::endl
77  << "output files root: " << sampling_file_root << std::endl
78  << "symmetry group: " << fn_sym << std::endl
79  //<< "symmetry order: " << sym_order << std::endl
80  << "neighborhood: " << neighborhood << std::endl
81  << "max_tilt_angle: " << max_tilt_angle << std::endl
82  << "min_tilt_angle: " << min_tilt_angle << std::endl
83  ;
84 }
85 
86 
87 
88 /* Run --------------------------------------------------------------------- */
90 {
91  show();
95  //mysampling.computeSamplingPoints(false);
99  //mysampling.computeNeighbors();
100  //#define DEBUG6
101 #ifdef DEBUG6
102  for (int i = 0; i < mysampling.no_redundant_sampling_points_vector.size(); i++)
103  {
104  std::cout << mysampling.no_redundant_sampling_points_vector[i].transpose() << " 1.1 2.2222 " << std::endl;
105  //std::cout << mysampling.no_redundant_sampling_points_angles[i].transpose() << " 1.21 1 " << std::endl;
106  }
107 #endif
108 #undef DEBUG6
109  //#define DEBUG6
110 #ifdef DEBUG6
111  { /* for sphere coverage only R is important.
112  for psi L and R are important
113  */
114  double rot, tilt, psi;
115  double rotp, tiltp, psip;
116  Matrix1D<double> row(3);
117  Matrix2D<double> L(4, 4), R(4, 4);
118  //std::cerr << "mysampling.SL.SymsNo():" << mysampling.SL.SymsNo() << std::endl;
119  for (int i = 0; i < mysampling.no_redundant_sampling_points_vector.size(); i++)
120  {
121  if (i == 50)
122  {
126  std::cerr << 1 << " " << 3 << " " << rot << " " << tilt << " " << psi << std::endl;
127  //std::cerr << mysampling.no_redundant_sampling_points_vector[i].transpose() << " 1 1" << std::endl;
128  }
129  for (int isym = 0; isym < mysampling.SL.SymsNo(); isym++)
130  {
131  //std::cerr << L << R << std::endl;
132  mysampling.SL.get_matrices(isym, L, R);
133  R.resize(3, 3); // as only the relative orientation
135  std::cout << row.transpose() << " 1 " << isym + 2 << std::endl;
136  if (i == 50)
137  {
138  //std::cerr << row.transpose() << " 1 " << isym +2 << std::endl;
139  L.resize(3, 3); // Erase last row and column
140  //std::cerr << L << R << std::endl;
141  Euler_apply_transf(L, R, rot, tilt, psi, rotp, tiltp, psip);
142  Euler_direction(rotp, tiltp, psip, row);
143  std::cerr << isym + 2 << " " << 3 << " " << rotp << " " << tiltp << " " << psip << std::endl;
144  }
145  }
146  }
147  }
148 #endif
149 #undef DEBUG6
150  //#define DEBUG6
151 #ifdef DEBUG6
152  for (int i = 0;
154  i++)
155  std::cout << mysampling.sampling_points_vector[i].transpose() << " 1 1 " << std::endl;
156 #endif
157 #undef DEBUG6
158  //#define DEBUG6
159 #ifdef DEBUG6
160  for (int i = 0; i < mysampling.no_redundant_sampling_points_vector.size();i++)
161  {
162  std::cout << mysampling.no_redundant_sampling_points_vector[i].transpose() << " 1.2 3 " << std::endl;
163  for (int j = 0; j < mysampling.my_neighbors[i].size();j++)
164  std::cout <<
166  << " 1.1 2 " << std::endl;
167  }
168 #endif
169 #undef DEBUG6
170 }
171 
void setSampling(double sampling)
Definition: sampling.cpp:121
void removeRedundantPoints(const int symmetry, int sym_order)
Definition: sampling.cpp:691
void Euler_direction(double alpha, double beta, double gamma, Matrix1D< double > &v)
Definition: geometry.cpp:721
void createAsymUnitFile(const FileName &docfilename)
Definition: sampling.cpp:1440
void setNeighborhoodRadius(double neighborhood)
Definition: sampling.cpp:140
bool isSymmetryGroup(FileName fn_sym, int &pgGroup, int &pgOrder)
Definition: symmetries.cpp:601
std::vector< Matrix1D< double > > no_redundant_sampling_points_vector
Definition: sampling.h:118
void Euler_apply_transf(const Matrix2D< double > &L, const Matrix2D< double > &R, double rot, double tilt, double psi, double &newrot, double &newtilt, double &newpsi)
Definition: geometry.cpp:1038
#define i
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
void computeSamplingPoints(bool only_half_sphere=true, double max_tilt=180, double min_tilt=0)
Definition: sampling.cpp:155
const char * getParameter(int argc, const char **argv, const char *param, const char *option)
Definition: args.cpp:30
#define XX(v)
Definition: matrix1d.h:85
float textToFloat(const char *str)
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
std::vector< std::vector< size_t > > my_neighbors
Definition: sampling.h:87
#define j
#define YY(v)
Definition: matrix1d.h:93
void read(int argc, const char **argv)
std::vector< Matrix1D< double > > no_redundant_sampling_points_angles
Definition: sampling.h:121
double psi(const double x)
std::vector< Matrix1D< double > > sampling_points_vector
Definition: sampling.h:101
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
Definition: matrix2d.cpp:1022
#define ZZ(v)
Definition: matrix1d.h:101
SymList SL
Definition: sampling.h:138