Xmipp  v3.23.11-Nereus
art_crystal.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
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 
26 #include <data/projection.h>
27 #include <data/symmetries.h>
28 #include "art_crystal.h"
29 #include "project_crystal.h"
30 #include "refinement.h"
31 
32 /* ------------------------------------------------------------------------- */
33 /* Crystal ART Parameters */
34 /* ------------------------------------------------------------------------- */
35 /* Define parameters ===================================================== */
36 void CrystalARTRecons::defineParams(XmippProgram *program, const char* prefix, const char* comment)
37 {
38  std::string line = " [--crystal ] : Crystal mode activation";
39 
40  if(nullptr != prefix)
41  line = prefix + line;
42  if (nullptr != comment)
43  line = line + " : " + comment;
44 
45  program->addParamsLine(line);
46  program->addParamsLine(" [--mag_a <mag>] : Magnitude of the first lattice vector");
47  program->addParamsLine(" [--mag_b <mag>] : Magnitude of the second lattice vector");
48  program->addParamsLine(" [--ang_a2b_deg <angle>] : Angle from vector a to vector b");
49  program->addParamsLine(" [--ang_x2a_deg <angle=0>] : Angle from vector x to vector a");
50  program->addParamsLine(" [--fill_space] : Repeat unit cell all over the space (pixels)");
51 
52 }
53 /* Read ART parameters ===================================================== */
55 {
57  artPrm.is_crystal = true;
58  a_mag = program->getDoubleParam("--mag_a");
60  b_mag = program->getDoubleParam("--mag_b");
62  ang_a2b_deg = program->getDoubleParam("--ang_a2b_deg");
63  ang_x2a_deg = program->getDoubleParam("--ang_x2a_deg");
64  fill_space = program->checkParam("--fill_space");
65  avox.resize(2);
66  bvox.resize(2);
67  //DISCLAMER: I know this 0 and 90 degrees cases are rather silly but
68  //when debugging is so good that 90 is 90 and not 90.000001
69  //NOTE:ang_x2a_deg is applied ONLY in the final volume
70  //when moving from basis to voxels
71 
72  XX(avox) = a_mag;
73  YY(avox) = 0.;
74 
75  if (ang_a2b_deg == 90.)
76  {
77  XX(bvox) = 0;
78  YY(bvox) = b_mag;
79  }
80  else
81  {
84  }
85 
86 }
87 
88 /* Show parameters ========================================================= */
89 void CrystalARTRecons::print(std::ostream &o) const
90 {
91  o << "Crystal information ------------------------------------------" << std::endl;
92  o << "Lattice vector a: " << a.transpose() << std::endl;
93  o << "Lattice vector b: " << b.transpose() << std::endl;
94  o << "mag_a: " << a_mag << std::endl;
95  o << "mag_b: " << b_mag << std::endl;
96  o << "ang_a2b_deg: " << ang_a2b_deg << std::endl;
97  o << "ang_x2a_deg: " << ang_x2a_deg << std::endl;
98  o << "Fill space: " << fill_space << std::endl;
99  o << "Symmetry group: " << space_group << std::endl;
100 }
101 
102 /* Special vector product ================================================== */
103 /* To see if a point is inside a polygon the vector product of cir
104  (the vector which goes from the point (r) to the corner i (ci)
105  position) and each polygon side is computed. This vector product
106  assume that both vectors are in the same plane (XY), so its z component
107  is 0, and we are only interested on the sign of z in the resulting
108  vector. */
109 #define SGN0_VEC_PRODUCT(cir,a) SGN0(XX(cir)*YY(a)-YY(cir)*XX(a))
110 
111 /* Side information ======================================================== */
112 //#define DEBUG
113 //#define DEBUG_A_LOT
114 void CrystalARTRecons::preProcess(GridVolume &vol_basis0, int level, int rank)
115 {
116  // Lattice vectors in BCC units
119 
120  // Compute space_group
121  if (artPrm.fn_sym != "")
123  ang_a2b_deg);
124  else
126 
127  // Integer lattice vectors ----------------------------------------------
131  ang_a2b_deg, aint, bint, D,
132  space_group);
133  // Define two more useful lattice vectors
134  ai = aint / 2;
135  bi = bint / 2;
136 
137  // Set general deformation pointer to this matrix
138  artPrm.D = new Matrix2D<double>;
139  *(artPrm.D) = D;
140  artPrm.D->resize(3, 3);
141  MAT_ELEM(*(artPrm.D), 2, 2) = 1;
143  *(artPrm.Dinv) = artPrm.D->inv();
145 
146  // Unit cell mask within volume -----------------------------------------
147  // Compute the 4 parallelogram corners
148  Matrix1D<double> c1 = ai + bi;
149  Matrix1D<double> c2 = -ai + bi;
150  Matrix1D<double> c3 = -c1;
151  Matrix1D<double> c4 = -c2;
152  Matrix1D<double> c1c3 = c1 - c3; // These extra variables are needed because
153  Matrix1D<double> c2c4 = c2 - c4; // the compiler messes up
154 
155  // Resize unit cell mask
156  // The unit mask is a little bigger to avoid the possibility of losing
157  // any basis due to a too tight mask.
158  int mask_xdim = CEIL(XMIPP_MAX(ABS(XX(c1c3)), ABS(XX(c2c4)))) + 3;
159  int mask_ydim = CEIL(XMIPP_MAX(ABS(YY(c1c3)), ABS(YY(c2c4)))) + 3;
160  unit_cell_mask.initZeros(mask_ydim, mask_xdim);
162 
163  // Resize the reconstructed volume
164  Matrix1D<double> r1(3), r2(3);
165  for (size_t n = 0; n < vol_basis0.VolumesNo(); n++)
166  {
167  Image<double> &V = vol_basis0(n);
168  ZZ(r1) = XMIPP_MIN(ZZ(r1), STARTINGZ(V()));
169  ZZ(r2) = XMIPP_MAX(ZZ(r2), FINISHINGZ(V()));
170  }
177  vol_basis0.resize(r1, r2);
178 
179  // Fill the unit cell mask
180  Matrix1D<double> r(2);
182  {
183  // Position vector of actual BCC element been considered
184  YY(r) = i;
185  XX(r) = j;
186 
187  // Vectors from r to each corner
188  Matrix1D<double> c1r = c1 - r;
189  Matrix1D<double> c2r = c2 - r;
190  Matrix1D<double> c3r = c3 - r;
191  Matrix1D<double> c4r = c4 - r;
192 
193  // Product of each of these vectors with tha parallelogram borders
194  int sgn[4];
195  sgn[0] = SGN0_VEC_PRODUCT(c1r, -ai);
196  sgn[1] = SGN0_VEC_PRODUCT(c2r, -bi);
197  sgn[2] = SGN0_VEC_PRODUCT(c3r, ai);
198  sgn[3] = SGN0_VEC_PRODUCT(c4r, bi);
199 
200 #ifdef DEBUG_A_LOT
201 
202  std::cout << "(x,y)=(" << XX(r) << "," << YY(r) << ") " << sgn[0] << sgn[1]
203  << sgn[2] << sgn[3] << std::endl;
204 #endif
205 
206  // Now check if point is inside
207  int inside_table[4][4] = {
208  {1, 1, 1, 1},
209  {0, 1, 1, 1},
210  {1, 0, 1, 1},
211  // 1,1,0,1, Take this side out
212  // 1,1,1,0, Take this side out
213  {0, 0, 1, 1}
214  // 1,0,0,1, and their three Vertex
215  // 1,1,0,0,
216  // 0,1,1,0
217  };
218 #define INSIDE_ACCORDING_TO(n) \
219  sgn[0]==inside_table[n][0] && sgn[1]==inside_table[n][1] && \
220  sgn[2]==inside_table[n][2] && sgn[3]==inside_table[n][3]
221 
222  for (int n = 0; n < 4; n++)
223  if (INSIDE_ACCORDING_TO(n))
224  {
225  unit_cell_mask(i, j) = 1;
226 #ifdef DEBUG_A_LOT
227 
228  std::cout << " Inside\n";
229 #endif
230 
231  break;
232  }
233  }
234 
235  // Now calculate side info of basel class
236  ARTReconsBase::preProcess(vol_basis0);
237 
238  // Show all parameters --------------------------------------------------
239 #ifdef DEBUG
240  std::cout << "avox= " << avox.transpose() << std::endl;
241  std::cout << "bvox= " << bvox.transpose() << std::endl;
242  std::cout << "grid_relative_size= " << artPrm.grid_relative_size << std::endl;
243  std::cout << "a= " << a.transpose() << std::endl;
244  std::cout << "b= " << b.transpose() << std::endl;
245  std::cout << "aint= " << aint.transpose() << std::endl;
246  std::cout << "bint= " << bint.transpose() << std::endl;
247  std::cout << "ai= " << ai.transpose() << std::endl;
248  std::cout << "bi= " << bi.transpose() << std::endl;
249  std::cout << "D= " << D;
250  std::cout << "Check that a=D*aint " << (D*aint).transpose() << std::endl;
251  std::cout << "Check that b=D*bint " << (D*bint).transpose() << std::endl;
252  std::cout << "Symmetry group: " << space_group;
253  ImageXmipp I;
254  I = unit_cell_mask;
255  I.write("unit_cell_mask.xmp");
256  std::cout << "unit_cell_mask shape=";
258  std::cout << std::endl;
259 #endif
260 }
261 #undef DEBUG
262 #undef DEBUG_A_LOT
263 
264 /* ------------------------------------------------------------------------- */
265 /* ART Single step */
266 /* ------------------------------------------------------------------------- */
268  GridVolume &vol_in, // Input Reconstructed volume
269  GridVolume *vol_out, // Output Reconstructed volume
270  Projection &theo_proj, // Projection of the reconstruction
271  // It is outside to make it visible
272  // just if it needed for any
273  // other purpose
274  Projection &read_proj, // Real projection
275  int sym_no, // Symmetry matrix index
276  Projection &diff_proj, // Difference between read and
277  // theoretical projection
278  Projection &corr_proj, // Correcting projection
279  Projection &alig_proj, // Translation alignement aux proj
280  double &mean_error, // Mean error over the pixels
281  int numIMG, // number of images in the set
282  // in SIRT the correction must
283  // be divided by this number
284  double lambda, // Lambda to be used
285  int imagen_no, // Projection number
286  const FileName &fn_ctf, // CTF to apply
287  const MultidimArray<int> *maskPtr, // Mask to apply
288  bool refine)
289 {
290  // Only works for blob volumes .............................................
291  if (artPrm.basis.type != Basis::blobs)
293  "This function only works with blob volumes");
294 
295  // Compute lattice vectors to be used ......................................
296  Matrix1D<double> aint, bint, shift;
297  aint.resize(2);
298  bint.resize(2);
299  shift.resize(3);
300  shift.initZeros();
301 
302  symmetrizeCrystalVectors(aint, bint, shift, this->space_group, sym_no,
303  this->aint, this->bint);
304  // Project structure .......................................................
305  // The correction image is reused in this call to store the normalizing
306  // projection, ie, the projection of an all-1 volume
307 
308  project_Crystal_Volume(vol_in, artPrm.basis, theo_proj,
309  corr_proj, YSIZE(read_proj()), XSIZE(read_proj()),
310  read_proj.rot(), read_proj.tilt(), read_proj.psi(), shift,
311  aint, bint, *(artPrm.D), *(artPrm.Dinv), this->unit_cell_mask,
313  double shift_X, shift_Y;
314 
315  // #define DEBUG_SHIFT
316 #ifdef DEBUG_SHIFT
317 
318  Matrix2D<double> A(3, 3);
319  A.initIdentity();
320  dMij(A, 0, 2) = 8;
321  dMij(A, 1, 2) = -5;
322  std::cout << "A" << A;
323  //move read_proj
324  FOR_ALL_DIRECT_ELEMENTS_IN_MATRIX2D(theo_proj())
325  dMij(theo_proj(), i, j) = dMij(read_proj(), i, j);
326  applyGeometry(IMGMATRIX(read_proj), A, IMGMATRIX(theo_proj), IS_NOT_INV, WRAP);
327 #endif
328 #undef DEBUG_SHIFT
329 
330  if (artPrm.ref_trans_after != -1 &&
331  imagen_no > artPrm.ref_trans_after && imagen_no != 0)
332  {
333  CorrelationAux aux;
334  calculate_and_find_correlation_max_proj(read_proj, theo_proj,
335  alig_proj,
336  shift_X, shift_Y,
339  imagen_no, aux);
340 
341  // Apply correction
342  Matrix2D<double> Correction(3, 3);
343  alig_proj().resize(read_proj());
344  Correction.initIdentity();
345 
346  dMij(Correction, 0, 2) = - shift_X;
347  dMij(Correction, 1, 2) = - shift_Y;
348  //copy theo_proj to a temporal matrix
350  dAij(alig_proj(), i, j) = dAij(read_proj(), i, j);
351  applyGeometry(xmipp_transformation::LINEAR, IMGMATRIX(alig_proj), IMGMATRIX(read_proj), Correction,
352  xmipp_transformation::IS_NOT_INV, xmipp_transformation::WRAP);
353  }
354  // Now compute differences .................................................
355  double applied_lambda = lambda / numIMG; // In ART mode, numIMG=1
356  mean_error = 0;
357  diff_proj().resize(read_proj());
358 
360  {
361  // Compute difference image and error
362  IMGPIXEL(diff_proj, i, j) = IMGPIXEL(read_proj, i, j) - IMGPIXEL(theo_proj, i, j);
363  mean_error += IMGPIXEL(diff_proj, i, j) * IMGPIXEL(diff_proj, i, j);
364 
365  // Compute the correction image
366  if (ABS(IMGPIXEL(corr_proj, i, j)) < 1)
367  IMGPIXEL(corr_proj, i, j) = SGN(IMGPIXEL(corr_proj, i, j));
368  IMGPIXEL(corr_proj, i, j) =
369  applied_lambda * IMGPIXEL(diff_proj, i, j) / IMGPIXEL(corr_proj, i, j);
370  }
371  mean_error /= XSIZE(diff_proj()) * YSIZE(diff_proj());
372 
373  // Backprojection of correction plane ......................................
374  project_Crystal_Volume(*vol_out, artPrm.basis, theo_proj,
375  corr_proj, YSIZE(read_proj()), XSIZE(read_proj()),
376  read_proj.rot(), read_proj.tilt(), read_proj.psi(), shift,
377  aint, bint, *(artPrm.D), *(artPrm.Dinv), this->unit_cell_mask,
379 }
380 
381 
383 {
384  if (fill_space)
385  expandToFillSpace(artPrm, *this, vol_basis);
386 }
387 
388 void CrystalARTRecons::applySymmetry(GridVolume &vol_in, GridVolume *vol_out, int grid_type)
389 {
391 }
392 
393 /* Compute integer lattice ================================================= */
395  const Matrix1D<double> &b,
396  double a_mag_grid, double b_mag_grid,
397  double ang_a2b_deg,
400  Matrix2D<double> &D,
401  int space_group)
402 {
403 
404  // Integer lattice
405  // If we force it to be orthogonal the symmetrization is easier
406  //a_mag=original a_mag/sampling/grid_relatice_size
407  aint.resize(2);
408  bint.resize(2);
409  XX(aint) = ROUND(a_mag_grid);
410  YY(aint) = 0.;
411  XX(bint) = 0.0;
412  YY(bint) = ROUND(b_mag_grid);
413 
414  //different crystalline grids impose different restrictions
415  //on the grid, we will check them here but only if the user
416  //has provided a symmetry file
417 
418  if (space_group != sym_undefined)
419  {
420 
421  switch (space_group)
422  {
423 
424  case sym_P1:
425  break;// no check needed
426  case sym_P2_122://XX(aint) and YY(aint) should be even
427  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
428  YY(bint) != 2*(int)(YY(bint) / 2))
429  {
430  std::cout << "\nLattice connstrains for P2_122 are not satisficed"
431  << "\nRound[mag_a/(sampling*grid_size)] must be even"
432  << "\nPlease modify the parmeters and try again" << std::endl;
433  exit(0);
434  }
435  break;
436  case sym_P22_12://XX(aint) and YY(aint) should be even
437  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
438  YY(bint) != 2*(int)(YY(bint) / 2))
439  {
440  std::cout << "\nLattice connstrains for P22_12 are not satisficed"
441  << "\nRound[mag_a/(sampling*grid_size)] must be even"
442  << "\nPlease modify the parmeters and try again" << std::endl;
443  exit(0);
444  }
445  break;
446  case sym_P42_12://XX(aint) and YY(aint) should be even
447  if (XX(aint) != 2*(int)(XX(aint) / 2) ||
448  YY(bint) != 2*(int)(YY(bint) / 2))
449  {
450  std::cout << "\nLattice connstrains for P4212 are not satisficed"
451  << "\nRound[mag_a/(sampling*grid_size)] must be even"
452  << "\nPlease modify the parmeters and try again" << std::endl;
453  exit(0);
454  }
455  break;
456  case sym_P4:
457  case sym_P6:
458  break;// no check needed
459  default:
460  std::cerr << "\n Congratulations: you have found a bug in the\n"
461  << "routine compute_integer_lattice or\n"
462  << "you are using a non implemented symmetry group\n"
463  << std::endl;
464  exit(0);
465  break;
466  }//switch(space_group) end
467 
468  }//if (prm.fn_sym!="")
469 
470 
471  // Converting matrix
472  // a=D*aint
473  // b=D*bint
474  Matrix2D<double> L(2, 2), LI(2, 2);
475 
476  L .setCol(0, a);
477  L .setCol(1, b);
478  LI.setCol(0, aint);
479  LI.setCol(1, bint);
480  D = L * LI.inv();
481 }
482 
483 /* Expansion to fill space ------------------------------------------------- */
484 //#define DEBUG
485 //#define DEBUG2
487  const CrystalARTRecons &eprm, GridVolume &vol)
488 {
489  std::cout << "Replicating unit cell ...\n";
490 #ifdef DEBUG
491 
492  Image<double> save;
493  vol(0)().getSlice(0, save());
494  save.write("inter_before_filling.xmp");
495 #endif
496 
497  // Resize volume ........................................................
498  Matrix1D<double> corner1(2), corner2(2);
499  VECTOR_R2(corner1,
502  VECTOR_R2(corner2,
505 
507  VECTOR_R2(zero, 0, 0);
508  int a0, aF, b0, bF;
509  // How many lattice units fit inside the output volume
510  find_crystal_limits(corner1, corner2, zero, zero,
511  eprm.a, eprm.b, a0, aF, b0, bF);
512 #ifdef DEBUG
513  std::cerr << "DEBUG_JM: eprm.a: " << eprm.a << std::endl;
514  std::cerr << "DEBUG_JM: eprm.b: " << eprm.b << std::endl;
515  std::cout << "Output Volume size (ZxYxX)=" << prm.Zoutput_volume_size
516  << " " << prm.Youtput_volume_size << " "
517  << prm.Xoutput_volume_size << std::endl;
518  std::cout << "corners:\n" << corner1.transpose() << std::endl
519  << corner2.transpose() << std::endl;
520  std::cout << "a0=" << a0 << "..." << aF << std::endl
521  << "b0=" << b0 << "..." << bF << std::endl;
522 #endif
523 
524  // Expand the volume to the required space
525  corner1 = (double)(a0 - 1) * eprm.a + (double)(b0 - 1) * eprm.b; // CO: I'm not very satisfied with
526  corner2 = (double)(aF + 1) * eprm.a + (double)(bF + 1) * eprm.b; // the +1 and -1 but it works
527  corner1.resize(3);
528  ZZ(corner1) = FIRST_XMIPP_INDEX(prm.Zoutput_volume_size);
529  corner2.resize(3);
530  ZZ(corner2) = LAST_XMIPP_INDEX(prm.Zoutput_volume_size);
531  vol.resize(corner1, corner2);
532 
533  // Copy values ..........................................................
534  Matrix1D<double> r(3);
535  for (size_t n = 0; n < vol.VolumesNo(); n++)
536  {
537  Image<double> &V = vol(n);
539  {
540  if (A2D_ELEM(eprm.unit_cell_mask, i, j))
541  {
542 #ifdef DEBUG2
543  std::cout << "(y,x)=(" << i << "," << j << ") is inside\n";
544 #endif
545 
546  for (int ii = b0; ii <= bF; ii++)
547  for (int jj = a0; jj <= aF; jj++)
548  {
549  if (jj == 0 && ii == 0)
550  continue;
551  XX(r) = j + ii * XX(eprm.bint) + jj * XX(eprm.aint);
552  YY(r) = i + ii * YY(eprm.bint) + jj * YY(eprm.aint);
553  ZZ(r) = STARTINGZ(VOLMATRIX(V));
554  if (!VOLMATRIX(V).outside(r))
555  {
556 #ifdef DEBUG2
557  std::cout << " Is copied to (" << (int)YY(r) << ","
558  << (int)XX(r) << ")\n";
559 #endif
560  // copy values if inside volume
561  for (int k = STARTINGZ(VOLMATRIX(V));
562  k <= FINISHINGZ(VOLMATRIX(V)); k++)
563  VOLVOXEL(V, k, (int)YY(r), (int)XX(r)) =
564  VOLVOXEL(V, k, i, j);
565  }
566  }
567  }
568  }
569  }
570 #ifdef DEBUG
571  vol(0)().getSlice(0, save());
572  save.write("inter_after_filling.xmp");
573 #endif
574 }
575 #undef DEBUG2
576 #undef DEBUG
bool is_crystal
Is this a crystal 0 means NO 1 YES.
Definition: basic_art.h:252
#define VECTOR_R2(v, x, y)
Definition: matrix1d.h:112
#define INSIDE_ACCORDING_TO(n)
#define YSIZE(v)
Matrix1D< double > avox
First lattice vector (voxel units)
Definition: art_crystal.h:58
#define A2D_ELEM(v, i, j)
#define VOLVOXEL(V, k, i, j)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
double getDoubleParam(const char *param, int arg=0)
#define sym_P22_12
Definition: symmetries.h:60
Basis basis
Basis function. By default, blobs.
Definition: basic_art.h:97
void calculate_and_find_correlation_max_proj(Projection const &proj1, Projection const &proj2, Projection &proj_temp, double &shift_X, double &shift_Y, double const max_step, int ref_trans_after, int imagen_no, CorrelationAux &aux)
Definition: refinement.cpp:151
#define FINISHINGX(v)
void printShape(std::ostream &out=std::cout) const
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
void resize(const Matrix1D< double > &corner1, const Matrix1D< double > &corner2)
Definition: grids.h:873
double psi(const size_t n=0) const
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
#define dAij(M, i, j)
#define VOLMATRIX(V)
Matrix2D< double > * D
Definition: basic_art.h:365
void applyGeometry(int SplineDegree, MultidimArray< std::complex< double > > &V2, const MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside, MultidimArray< double > *BcoeffsPtr)
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)
#define sym_P4
Definition: symmetries.h:63
#define sym_P6
Definition: symmetries.h:68
double grid_relative_size
Relative size for the grid.
Definition: basic_art.h:141
void inv(Matrix2D< T > &result) const
Definition: matrix2d.cpp:663
#define BACKWARD
Definition: blobs.cpp:1092
Matrix1D< double > bint
Second lattice vector approximated to integer numbers (BCC units)
Definition: art_crystal.h:72
FileName fn_sym
File containing symmetries.
Definition: basic_art.h:173
Matrix1D< double > a
First lattice vector (BCC units)
Definition: art_crystal.h:66
void computeIntegerLattice(const Matrix1D< double > &a, const Matrix1D< double > &b, double a_mag_grid, double b_mag_grid, double ang_a2b_deg, Matrix1D< double > &aint, Matrix1D< double > &bint, Matrix2D< double > &D, int space_group)
tBasisFunction type
Basis function to use.
Definition: basis.h:52
double rot(const size_t n=0) const
#define FINISHINGZ(v)
#define SIND(x)
Definition: xmipp_macros.h:347
#define IMGMATRIX(I)
#define STARTINGX(v)
double sampling
Sampling rate.
Definition: basic_art.h:170
virtual void readParams(XmippProgram *program)
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
#define SGN0_VEC_PRODUCT(cir, a)
void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
Matrix1D< T > transpose() const
Definition: matrix1d.cpp:644
double tilt(const size_t n=0) const
#define STARTINGY(v)
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
void find_crystal_limits(const Matrix1D< double > &proj_corner1, const Matrix1D< double > &proj_corner2, const Matrix1D< double > &cell_corner1, const Matrix1D< double > &cell_corner2, const Matrix1D< double > &a, const Matrix1D< double > &b, int &iamin, int &iamax, int &ibmin, int &ibmax)
#define sym_P2_122
Definition: symmetries.h:59
int crystallographicSpaceGroup(double mag_a, double mag_b, double ang_a2b_deg) const
Definition: symmetries.cpp:541
size_t VolumesNo() const
Definition: grids.h:1003
double ang_x2a_deg
angle from x axis to a (degrees)
Definition: art_crystal.h:56
Matrix1D< double > b
Second lattice vector (BCC units)
Definition: art_crystal.h:68
Matrix1D< double > ai
ai=aint/2 as double numbers
Definition: art_crystal.h:74
double * lambda
MultidimArray< int > unit_cell_mask
Definition: art_crystal.h:85
#define XX(v)
Definition: matrix1d.h:85
void transpose(double *array, int size)
#define CEIL(x)
Definition: xmipp_macros.h:225
#define dMij(m, i, j)
Definition: matrix2d.h:139
void readParams(XmippProgram *program)
Definition: art_crystal.cpp:54
void setCol(size_t j, const Matrix1D< T > &v)
Definition: matrix2d.cpp:929
virtual void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Produce Plain side information from the Class parameters.
void resize(size_t Xdim, bool copy=true)
Definition: matrix1d.h:410
#define XSIZE(v)
void write(const FileName &fn) const
#define ABS(x)
Definition: xmipp_macros.h:142
void postProcess(GridVolume &vol_basis)
#define ROUND(x)
Definition: xmipp_macros.h:210
Matrix1D< double > bvox
Second lattice vector (voxel units)
Definition: art_crystal.h:60
void print(std::ostream &o) const
std::cout << crystal_prm;
Definition: art_crystal.cpp:89
Matrix1D< double > bi
bi=aint/2 as double numbers
Definition: art_crystal.h:76
void project_Crystal_Volume(GridVolume &vol, const Basis &basis, Projection &proj, Projection &norm_proj, int Ydim, int Xdim, double rot, double tilt, double psi, const Matrix1D< double > &shift, const Matrix1D< double > &aint, const Matrix1D< double > &bint, const Matrix2D< double > &D, const Matrix2D< double > &Dinv, const MultidimArray< int > &mask, int FORW, int eq_mode)
double ang_a2b_deg
angle from a to b (degrees)
Definition: art_crystal.h:54
void initZeros()
Definition: matrix1d.h:592
#define sym_P42_12
Definition: symmetries.h:65
#define XMIPP_MIN(x, y)
Definition: xmipp_macros.h:181
double ref_trans_step
Refine the translation alignement after n projection presentations.
Definition: basic_art.h:187
#define j
#define FORWARD
Definition: blobs.cpp:1091
#define YY(v)
Definition: matrix1d.h:93
void applySymmetry(GridVolume &vol_in, GridVolume *vol_out, int grid_type)
void symmetrizeCrystalVectors(Matrix1D< double > &aint, Matrix1D< double > &bint, Matrix1D< double > &shift, int space_group, int sym_no, const Matrix1D< double > &eprm_aint, const Matrix1D< double > &eprm_bint)
Definition: symmetries.cpp:44
#define FINISHINGY(v)
void setD(Matrix2D< double > *_D)
Definition: basis.h:123
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
#define sym_P1
Definition: symmetries.h:54
bool fill_space
Fill space, repeat unit cell all over the space.
Definition: art_crystal.h:62
void expandToFillSpace(const BasicARTParameters &prm, const CrystalARTRecons &eprm, GridVolume &vol)
int ref_trans_after
Refine the translation alignement after n projection presentations.
Definition: basic_art.h:184
static void defineParams(XmippProgram *program, const char *prefix=nullptr, const char *comment=nullptr)
Definition: art_crystal.cpp:36
bool checkParam(const char *param)
float r2
ProgClassifyCL2D * prm
BasicARTParameters artPrm
void initZeros(const MultidimArray< T1 > &op)
#define COSD(x)
Definition: xmipp_macros.h:329
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
int space_group
space_group
Definition: art_crystal.h:78
void singleStep(GridVolume &vol_in, GridVolume *vol_out, Projection &theo_proj, Projection &read_proj, int sym_no, Projection &diff_proj, Projection &corr_proj, Projection &alig_proj, double &mean_error, int numIMG, double lambda, int act_proj, const FileName &fn_ctf, const MultidimArray< int > *maskPtr, bool refine)
Incorrect value received.
Definition: xmipp_error.h:195
#define SGN(x)
Definition: xmipp_macros.h:155
#define STARTINGZ(v)
int * n
#define sym_undefined
Definition: symmetries.h:53
void symmetrizeCrystalVolume(GridVolume &vol_in, const Matrix1D< double > &eprm_aint, const Matrix1D< double > &eprm_bint, int eprm_space_group, const MultidimArray< int > &mask, int grid_type)
Definition: symmetries.cpp:301
Matrix1D< double > aint
First lattice vector approximated to integer numbers (BCC units)
Definition: art_crystal.h:70
#define ZZ(v)
Definition: matrix1d.h:101
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
Definition: matrix2d.cpp:1022
void getSlice(Image< double > &op)
void addParamsLine(const String &line)
ql0001_ & zero(ctemp+1),(cvec+1),(a+1),(b+1),(bl+1),(bu+1),(x+1),(w+1), &iout, ifail, &zero,(w+3), &lwar2,(iw+1), &leniw, &glob_grd.epsmac
SymList SL
A list with the symmetry matrices.
Definition: basic_art.h:330
void initIdentity()
Definition: matrix2d.h:673
Matrix2D< double > * Dinv
Just the inverse of D.
Definition: basic_art.h:367
#define IMGPIXEL(I, i, j)
float r1