Xmipp  v3.23.11-Nereus
reconstruct_wbp.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * Authors: Sjors Scheres scheres@cnb.csic.es (2004)
4  *
5  * Unidad de Bioinformatica del 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 "reconstruct_wbp.h"
27 #include "core/geometry.h"
29 #include "core/metadata_sql.h"
30 #include "core/xmipp_fft.h"
32 #include "data/mask.h"
33 #include "directions.h"
35 
36 
37 // Read arguments ==========================================================
39 {
40  fn_sel = getParam("-i");
41  fn_out = getParam("-o");
42  fn_sym = getParam("--sym");
43  threshold = getDoubleParam("--threshold");
44  diameter = 2 * getIntParam("--radius");
45 
46  sampling = getDoubleParam("--filsam");
47  do_all_matrices = checkParam("--use_each_image");
48  do_weights = checkParam("--weight");
49 }
50 
51 // Show ====================================================================
53 {
54  if (verbose > 0)
55  {
56  // To screen
57  std::cerr
58  << " ================================================================="
59  << std::endl;
60  std::cerr << " Weighted-back projection (arbitrary geometry) "
61  << std::endl;
62  std::cerr
63  << " ================================================================="
64  << std::endl;
65  std::cerr << " Input selfile : " << fn_sel << std::endl;
66  std::cerr << " Output volume : " << fn_out << std::endl;
67  if (diameter > 0)
68  std::cerr << " Reconstruction radius : " << diameter / 2
69  << std::endl;
70  std::cerr << " Relative filter threshold : " << threshold << std::endl;
71  if (fn_sym != "")
72  std::cerr << " Symmetry file: : " << fn_sym << std::endl;
73  if (do_all_matrices)
74  std::cerr
75  << " --> Use all projection directions in arbitrary geometry filter"
76  << std::endl;
77  else
78  std::cerr << " --> Use sampled directions for filter, sampling = "
79  << sampling << std::endl;
80  if (do_weights)
81  std::cerr << " --> Use weights stored in the image headers"
82  << std::endl;
83  std::cerr
84  << " -----------------------------------------------------------------"
85  << std::endl;
86  }
87 }
88 
89 // Usage ====================================================================
91 {
92  // To screen
94  "Generate 3D reconstruction from projections using the Weighted BackProjection algorithm.");
96  "+This program allows you to generate 3D reconstructions from projections ");
98  "+using the Weighted BackProjection algorithm with arbitrary geometry as ");
100  "+described by Radermacher, M. (1992) Weighted back-projection methods. ");
101  addUsageLine("+Electron Tomography, ed. by J. Frank, Plenum Press.");
103  "angular_projection_matching, angular_discrete_assign, angular_continuous_assign");
105  " -i <input_selfile> : selection file with input images and Euler angles");
107  " [ -o <name=\"wbp.vol\"> ] : filename for output volume ");
109  " [ --doc <docfile=\"\"> ] : Ignore headers and get angles from this docfile ");
111  " [ --radius <int=-1> ] : Reconstruction radius. int=-1 means radius=dim/2 ");
113  " : The volume will be zero outside this radius");
114  addParamsLine(" [ --sym <sym=\"\"> ] : Enforce symmetry ");
116  " :+A symmetry file or point-group description.");
118  " :+Valid point-group descriptions are: C1, Ci, Cs, Cn ");
120  " :+(from here on n must be an integer number with no ");
122  " :+more than 2 digits) Cnv, Cnh, Sn, Dn, Dnv, Dnh, T, ");
124  " :+Td, Th, O, Oh I, I1, I2, I3, I4, I5, Ih. For a full ");
126  " :+description of symmetries look at http://xmipp.cnb.csic.es/twiki/bin/view/Xmipp/Symmetry");
128  " [ --threshold+ <float=0.005> ] : Lower (relative) threshold for filter values ");
130  " :+This is to avoid divisions by zero and consequent ");
132  " :+enhancement of noise. The threshold is given as a relative ");
134  " :+value with respect to the total number of images. The absolute");
136  " :+threshold will be calculated internally as the relative threshold");
138  " :+multiplied by the total number of (symmetry generated) projections.");
140  " [ --filsam+ <float=5>] : Angular sampling rate for geometry filter ");
142  " :+Instead of summing over all experimental images to calculate ");
144  " :+the arbitrary geometry filter, we bin all images in representative ");
146  " :+projection directions, which are sampled every filsam degrees.");
148  " [ --use_each_image+] : Use each image instead of sampled representatives for filter ");
150  " :+If this option is given, all experimental images will be used ");
152  " :+in the summation to calculate the arbitrary geometry filter. For ");
154  " :+large datasets this may be considerably slower than the default ");
156  " :+option of using representative projection directions");
158  " [ --weight] : Use weights stored in image headers or the input metadata");
159  addExampleLine("xmipp_reconstruct_wbp -i images.sel -o reconstruction.vol");
160 }
161 
163 {
164  show();
165  produceSideInfo();
168 }
169 
171 {
172  free(mat_g);
173  free(mat_f);
174  if (verbose > 0)
175  std::cerr << "Fourier pixels for which the threshold was not reached: "
176  << (float) (count_thr * 100.) / (SF.size() * dim * dim) << " %"
177  << std::endl;
179 }
180 
181 void ProgRecWbp::setIO(const FileName &fnIn, const FileName &fnOut)
182 {
183  fn_sel = fnIn;
184  fn_out = fnOut;
185 }
186 
188 {
189  // Read-in stuff
190  SF.read(fn_sel);
191  if (do_weights)
192  {
194  if (SF.size() == 0)
196  "there is no input file with weight!=0");
197  }
198 
199  size_t zdim, ndim;
200  getImageSize(SF, dim, dim, zdim, ndim);
201  if (fn_sym != "")
203  if (diameter <= 0)
204  diameter = dim;
205 
206  // Fill arrays of transformation matrices
207  if (do_all_matrices)
209  else
211 
212  time_bar_size = SF.size();
213  time_bar_step = CEIL((double)time_bar_size / 60.0);
214  time_bar_done = 0;
215 }
216 
217 void ProgRecWbp::getAnglesForImage(size_t id, double &rot, double &tilt,
218  double &psi, double &xoff, double &yoff, bool &flip, double &weight)
219 {
220  SF.getValue(MDL_ANGLE_ROT, rot, id);
221  SF.getValue(MDL_ANGLE_TILT, tilt, id);
222  SF.getValue(MDL_ANGLE_PSI, psi, id);
223  SF.getValue(MDL_SHIFT_X, xoff, id);
224  SF.getValue(MDL_SHIFT_Y, yoff, id);
225  flip = 0;
226  SF.getValue(MDL_FLIP, flip, id);
227  weight = 1;
228  SF.getValue(MDL_WEIGHT, weight, id);
229 }
230 
232 {
233  FileName fn_tmp;
234  Matrix2D<double> A(3, 3);
235  Matrix2D<double> L(4, 4), R(4, 4);
236  double newrot, newtilt, newpsi, rot, tilt, dum, weight, totimgs = 0.;
237  rot = 0;
238  tilt = 0;
239  bool dumB;
240  std::vector<double> count_imgs;
241 
242  if (verbose > 0)
243  std::cerr << "--> Sampling the filter ..." << std::endl;
244 
245  // Create an (asymmetric part of an) even projection direction distribution
246  std::vector<double> rotList, tiltList;
247  make_even_distribution(rotList, tiltList, sampling, SL, true);
248  size_t NN = rotList.size();
249  count_imgs.resize(NN);
250  // Each experimental image contributes to the nearest of these directions
251  FileName fn_img;
252  for (size_t objId : SF.ids())
253  {
254  SF.getValue(MDL_IMAGE, fn_img, objId);
255  getAnglesForImage(objId, rot, tilt, dum, dum, dum, dumB, weight);
256  int idx = find_nearest_direction(rot, tilt, rotList, tiltList, SL, L,
257  R);
258  if (do_weights)
259  count_imgs[idx] += weight;
260  else
261  count_imgs[idx] += 1.;
262  }
263 
264  // Now calculate transformation matrices for all representative directions
265  no_mats = 0;
266  int SL_SymsNo = SL.symsNo();
267  int SL_SymsNo_1 = SL_SymsNo + 1;
268  for (size_t i = 0; i < NN; i++)
269  if (count_imgs[i] > 0.)
270  no_mats += SL_SymsNo_1;
271  mat_g = (WBPInfo*) malloc(no_mats * sizeof(WBPInfo));
272 
273  no_mats = 0;
274  for (size_t i = 0; i < NN; i++)
275  {
276  auto count_i = (int)count_imgs[i];
277  if (count_i > 0)
278  {
279  Euler_angles2matrix(rotList[i], -tiltList[i], 0.0, A);
280  mat_g[no_mats].x = MAT_ELEM(A, 2, 0);
281  mat_g[no_mats].y = MAT_ELEM(A, 2, 1);
282  mat_g[no_mats].z = MAT_ELEM(A, 2, 2);
283  mat_g[no_mats].count = count_i;
284  totimgs += count_i;
285  no_mats++;
286 
287  // Expand symmetric directions
288  for (int j = 0; j < SL_SymsNo; j++)
289  {
290  SL.getMatrices(j, L, R, false);
291  Euler_apply_transf(L, R, rot, tilt, 0., newrot, newtilt, newpsi);
292  Euler_angles2matrix(newrot, -newtilt, newpsi, A);
293  mat_g[no_mats].x = MAT_ELEM(A, 2, 0);
294  mat_g[no_mats].y = MAT_ELEM(A, 2, 1);
295  mat_g[no_mats].z = MAT_ELEM(A, 2, 2);
296  mat_g[no_mats].count = count_i;
297  totimgs += count_i;
298  no_mats++;
299  }
300  }
301  }
302 
303  // Adjust relative threshold
304  threshold *= totimgs;
305 }
306 
307 // Fill array with transformation matrices needed for arbitrary geometry filter
309 {
310  Matrix2D<double> A(3, 3);
311  Matrix2D<double> L(4, 4), R(4, 4);
312  double rot, tilt, psi, weight, dum, newrot, newtilt, newpsi, totimgs = 0.;
313  bool dumB;
314  int NN;
315 
316  no_mats = 0;
317 
318  NN = SF.size();
319  NN *= (SL.symsNo() + 1);
320  mat_g = (WBPInfo*) malloc(NN * sizeof(WBPInfo));
321  FileName fn_img;
322 
323  for (size_t objId : SF.ids())
324  {
325  SF.getValue(MDL_IMAGE, fn_img, objId);
326  getAnglesForImage(objId, rot, tilt, psi, dum, dum, dumB, weight);
327  Euler_angles2matrix(rot, -tilt, psi, A);
328  mat_g[no_mats].x = MAT_ELEM(A, 2, 0);
329  mat_g[no_mats].y = MAT_ELEM(A, 2, 1);
330  mat_g[no_mats].z = MAT_ELEM(A, 2, 2);
331  if (do_weights)
332  mat_g[no_mats].count = weight;
333  else
334  mat_g[no_mats].count = 1.;
335  totimgs += mat_g[no_mats].count;
336  no_mats++;
337  // Also add symmetry-related projection directions
338  for (int i = 0; i < SL.symsNo(); i++)
339  {
340  SL.getMatrices(i, L, R);
341  L.resize(3, 3);
342  R.resize(3, 3);
343  Euler_apply_transf(L, R, rot, -tilt, psi, newrot, newtilt, newpsi);
344  Euler_angles2matrix(newrot, newtilt, newpsi, A);
345  mat_g[no_mats].x = MAT_ELEM(A, 2, 0);
346  mat_g[no_mats].y = MAT_ELEM(A, 2, 1);
347  mat_g[no_mats].z = MAT_ELEM(A, 2, 2);
348  if (do_weights)
349  mat_g[no_mats].count = weight;
350  else
351  mat_g[no_mats].count = 1.;
352  totimgs += mat_g[no_mats].count;
353  no_mats++;
354  }
355  }
356 
357  // Adjust relative threshold
358  threshold *= totimgs;
359 }
360 
361 // Simple backprojection of a single image
364 {
365  //this should be int not size_t ROB
366  int i, j, k, l, m;
367  Matrix2D<double> A(3, 3);
368  double dim2, x, y, z, xp, yp;
369  double value1, value2, scalex, scaley, value;
370  double radius2, x2, y2, z2, z2_plus_y2;
371 
372  // Use minus-tilt, because code copied from OldXmipp
373  Euler_angles2matrix(img.rot(), -img.tilt(), img.psi(), A);
374  A = A.inv();
375 
376  radius2 = diameter / 2.;
377  radius2 = radius2 * radius2;
378  dim2 = dim / 2;
379  double a00 = MAT_ELEM(A,0,0);
380  double a01 = MAT_ELEM(A,0,1);
381  double a10 = MAT_ELEM(A,1,0);
382  double a11 = MAT_ELEM(A,1,1);
383  double a20 = MAT_ELEM(A,2,0);
384  double a21 = MAT_ELEM(A,2,1);
385 
386  double dim1 = dim - 1;
387  const MultidimArray<double> mImg = img();
388  int idim;
389  idim = dim;//cast to int from size_t
390  for (i = 0; i < idim; i++)
391  {
392  z = -i + dim2; /*** Z points upwards ***/
393  z2 = z * z;
394  if (z2 > radius2)
395  continue;
396  double xpz = z * a20 + dim2;
397  double ypz = z * a21 + dim2;
398  for (j = 0; j < idim; j++)
399  {
400  y = j - dim2;
401  y2 = y * y;
402  z2_plus_y2 = z2 + y2;
403  if (z2_plus_y2 > radius2)
404  continue;
405  x = 0 - dim2; /***** X for k == 0 *****/
406  xp = x * a00 + y * a10 + xpz;
407  yp = x * a01 + y * a11 + ypz;
408  if (yp >= dim1 || yp < 0.0)
409  continue;
410  l = (int) yp;
411  scaley = yp - l;
412  double scale1y = 1. - scaley;
413  for (k = 0; k < idim; k++, xp += a00, yp += a01, x++)
414  {
415  x2 = x * x;
416  if (x2 + z2_plus_y2 > radius2)
417  continue;
418  if (xp >= dim1 || xp < 0.0)
419  continue;
420 
421  /**** interpolation ****/
422  m = (int) xp;
423  scalex = xp - m;
424  double scale1x = 1. - scalex;
425  value1 = scalex * dAij(mImg, l, m + 1)
426  + scale1x * dAij(mImg, l, m);
427  value2 = scalex * dAij(mImg, l + 1, m + 1)
428  + scale1x * dAij(mImg, l + 1, m);
429  value = scaley * value2 + scale1y * value1;
430  dAkij(vol, i, j, k) += value;
431  }
432  }
433  }
434 }
435 
436 // Calculate the filter in 2D and apply ======================================
438 {
440  Matrix2D<double> A(3, 3);
441  double factor, argum, weight, x, y;
442 
443  factor = diameter;
444 
445  //Euler_angles2matrix(proj.rot(), -proj.tilt(), proj.psi(), A);
446  //A = A.inv();
447  Euler_angles2matrix(-proj.rot(), proj.tilt(), -proj.psi(), A);
448  FourierTransform(proj(), IMG);
449  CenterFFT(IMG, true);
450 
451  // loop over all transformation matrices
452  double a00 = MAT_ELEM(A,0,0);
453  double a01 = MAT_ELEM(A,0,1);
454  double a10 = MAT_ELEM(A,1,0);
455  double a11 = MAT_ELEM(A,1,1);
456  double a20 = MAT_ELEM(A,2,0);
457  double a21 = MAT_ELEM(A,2,1);
458  for (int k = 0; k < no_mats; k++)
459  {
460  mat_f[k].x = a00 * mat_g[k].x + a10 * mat_g[k].y + a20 * mat_g[k].z;
461  mat_f[k].y = a01 * mat_g[k].x + a11 * mat_g[k].y + a21 * mat_g[k].z;
462  }
463 
464  double K = ((double) diameter) / dim;
466  {
467  y = K * i;
468  x = K * j;
469  weight = 0.;
470  for (int k = 0; k < no_mats; k++)
471  {
472  argum = x * mat_f[k].x + y * mat_f[k].y;
473  double daux;
474  TSINCVALUE(TSINC, argum, daux);
475  weight += mat_g[k].count * daux;
476  }
477 
478  if (fabs(weight) < threshold)
479  {
480  count_thr++;
481  A2D_ELEM(IMG, i, j) /= SGN(weight) * (threshold * factor);
482  }
483  else
484  {
485  A2D_ELEM(IMG, i, j) /= (weight * factor);
486  }
487  }
488 
489  // Calculate back-projection with the filtered projection
490  CenterFFT(IMG, false);
491  InverseFourierTransform(IMG, proj());
492 }
493 
494 bool ProgRecWbp::getImageToProcess(size_t &objId)
495 {
496  if (time_bar_done == 0) {
497  iter = std::unique_ptr<MetaDataVec::id_iterator>(new MetaDataVec::id_iterator(SF.ids().begin()));
498  } else {
499  ++(*iter);
500  }
501 
502  bool isValid = *iter != SF.ids().end();
503  if (isValid) {
504  ++time_bar_done;
505  objId = **iter;
506  }
507  return isValid;
508 }
509 
511 {
512  if (verbose > 0 && time_bar_done % time_bar_step == 0)
514 }
515 
516 // Calculate the filter in 2D and apply ======================================
518 {
519  double rot, tilt, psi, xoff, yoff, weight;
520  bool flip;
521  Projection proj;
522  Matrix2D<double> L(4, 4), R(4, 4), A;
523  FileName fn_img;
524 
525  MultidimArray<double> &mReconstructedVolume = reconstructedVolume();
526  mReconstructedVolume.initZeros(dim, dim, dim);
527  mReconstructedVolume.setXmippOrigin();
528  count_thr = 0;
529 
530  // Initialize time bar
531  if (verbose > 0)
532  {
533  std::cerr << "--> Back-projecting ..." << std::endl;
535  }
536 
537  mat_f = (WBPInfo*) malloc(no_mats * sizeof(WBPInfo));
538  Tabsinc TSINC(0.0001, dim);
539 
540  size_t objId;
541  while (getImageToProcess(objId))
542  {
543  SF.getValue(MDL_IMAGE, fn_img, objId);
544  proj.read(fn_img, false);
545  getAnglesForImage(objId, rot, tilt, psi, xoff, yoff, flip, weight);
546  proj.setRot(rot);
547  proj.setTilt(tilt);
548  proj.setPsi(psi);
549  proj.setShifts(xoff, yoff);
550  proj.setFlip(flip);
551  proj.setWeight(weight);
552  proj.getTransformationMatrix(A, true);
553  if (!A.isIdentity())
554  selfApplyGeometry(xmipp_transformation::BSPLINE3, proj(), A, xmipp_transformation::IS_INV, xmipp_transformation::WRAP);
555  if (do_weights)
556  proj() *= proj.weight();
557  proj().setXmippOrigin();
558  filterOneImage(proj, TSINC);
559  simpleBackprojection(proj, mReconstructedVolume, diameter);
560 
561  showProgress();
562  }
563  if (verbose > 0)
565 
566  // Symmetrize if necessary
567  if (fn_sym != "")
568  {
570  Vaux.resize(mReconstructedVolume);
571  symmetrizeVolume(SL, mReconstructedVolume, Vaux);
572  mReconstructedVolume = Vaux;
573  Mask mask_prm;
574  mask_prm.mode = INNER_MASK;
575  mask_prm.R1 = diameter / 2.;
576  mask_prm.type = BINARY_CIRCULAR_MASK;
577  mask_prm.generate_mask(mReconstructedVolume);
578  mask_prm.apply_mask(mReconstructedVolume, mReconstructedVolume, 0.);
579  }
580 }
581 
void filterOneImage(Projection &proj, Tabsinc &TSINC)
void selfApplyGeometry(int Splinedegree, MultidimArray< std::complex< double > > &V1, const Matrix2D< double > &A, bool inv, bool wrap, std::complex< double > outside)
Image< double > reconstructedVolume
Reconstructed volume.
void removeObjects(const std::vector< size_t > &toRemove) override
void init_progress_bar(long total)
virtual void produceSideInfo()
Fill arrays with relevant transformation matrices.
bool isIdentity() const
Definition: matrix2d.cpp:1323
void setRot(double rot, const size_t n=0)
Rotation angle of an image (double,degrees)
#define A2D_ELEM(v, i, j)
virtual void showProgress()
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
double getDoubleParam(const char *param, int arg=0)
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
Definition: symmetries.cpp:348
void read(const FileName &inFile, const std::vector< MDLabel > *desiredLabels=nullptr, bool decomposeStack=true) override
double threshold
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double psi(const size_t n=0) const
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
Definition: geometry.cpp:624
void make_even_distribution(std::vector< double > &rotList, std::vector< double > &tiltList, double sampling, SymList &SL, bool include_mirror)
Make even distribution, taking symmetry into account.
Definition: directions.cpp:133
#define dAij(M, i, j)
void symmetrizeVolume(const SymList &SL, const MultidimArray< double > &V_in, MultidimArray< double > &V_out, int spline, bool wrap, bool do_outside_avg, bool sum, bool helical, bool dihedral, bool helicalDihedral, double rotHelical, double rotPhaseHelical, double zHelical, double heightFraction, const MultidimArray< double > *mask, int Cn)
Definition: symmetrize.cpp:117
Definition: mask.h:360
Tilting angle of an image (double,degrees)
static double * y
size_t time_bar_size
double count
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
Definition: symmetries.cpp:33
Shift for the image in the X axis (double)
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)
void simpleBackprojection(Projection &img, MultidimArray< double > &vol, int diameter)
void getImageSize(const MetaData &md, size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim, MDLabel image_label)
void show()
Show.
void inv(Matrix2D< T > &result) const
Definition: matrix2d.cpp:663
Special label to be used when gathering MDs in MpiMetadataPrograms.
FileName fn_sel
void getSampledMatrices(MetaData &SF)
size_t time_bar_step
Time bar variables.
FileName fn_sym
void InverseFourierTransform(const MultidimArray< std::complex< double > > &in, MultidimArray< double > &out)
Definition: xmipp_fft.cpp:155
double rot(const size_t n=0) const
int symsNo() const
Definition: symmetries.h:268
virtual IdIteratorProxy< false > ids()
void setPsi(double psi, const size_t n=0)
double weight(const size_t n=0) const
void getAnglesForImage(size_t id, double &rot, double &tilt, double &psi, double &xoff, double &yoff, bool &flip, double &weight)
Get angles (either from reading the header or from a docfile)
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
virtual bool getValue(MDObject &mdValueOut, size_t id) const =0
doublereal * x
size_t size() const override
#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
Incorrect number of objects in Metadata.
Definition: xmipp_error.h:160
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void addSeeAlsoLine(const char *seeAlso)
double tilt(const size_t n=0) const
double z
void readParams()
Read arguments from command line.
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
void CenterFFT(MultidimArray< T > &v, bool forward)
Definition: xmipp_fft.h:291
void defineParams()
Define parameters.
void setShifts(double xoff, double yoff, double zoff=0., const size_t n=0)
void apply_mask(const MultidimArray< T > &I, MultidimArray< T > &result, T subs_val=0, bool apply_geo=false)
Definition: mask.h:635
std::unique_ptr< MetaDataVec::id_iterator > iter
Iterator over input metadata.
void apply2DFilterArbitraryGeometry()
const char * getParam(const char *param, int arg=0)
int find_nearest_direction(double rot1, double tilt1, std::vector< double > &rotList, std::vector< double > &tiltList, SymList &SL, Matrix2D< double > &Laux, Matrix2D< double > &Raux)
Determine which of the entries in DFlib is closest to [rot1,tilt1].
Definition: directions.cpp:194
void getAllMatrices(MetaData &SF)
Fill array with transformation matrices needed for arbitrary geometry filter.
WBPInfo * mat_f
#define CEIL(x)
Definition: xmipp_macros.h:225
FileName fnOut
WBPInfo * mat_g
void setFlip(bool flip, const size_t n=0)
double R1
Definition: mask.h:413
Flip the image? (bool)
virtual bool getImageToProcess(size_t &objId)
Get 1 image to process.
void setIO(const FileName &fn_in, const FileName &fn_out)
void progress_bar(long rlen)
#define TSINCVALUE(Tsinc, x, y)
Definition: xmipp_funcs.h:94
#define dAkij(V, k, i, j)
int type
Definition: mask.h:402
FileName fn_out
free((char *) ob)
double z
void addExampleLine(const char *example, bool verbatim=true)
int verbose
Verbosity level.
virtual size_t size() const =0
void FourierTransform(const MultidimArray< double > &in, MultidimArray< std::complex< double > > &out)
Definition: xmipp_fft.cpp:124
#define j
int m
size_t time_bar_done
bool getValue(MDObject &mdValueOut, size_t id) const override
MetaDataVec SF
void generate_mask(bool apply_geo=false)
Definition: mask.cpp:1577
void setTilt(double tilt, const size_t n=0)
#define BINARY_CIRCULAR_MASK
Definition: mask.h:365
double psi(const double x)
double sampling
bool checkParam(const char *param)
void read(const FileName &fn, const bool only_apply_shifts=false, DataMode datamode=DATA, MDRow *row=nullptr)
void getTransformationMatrix(Matrix2D< double > &A, bool only_apply_shifts=false, const size_t n=0)
constexpr int K
idIterator< false > id_iterator
Shift for the image in the Y axis (double)
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
void setWeight(double weight, const size_t n=0)
int getIntParam(const char *param, int arg=0)
virtual void finishProcessing()
double y
#define SGN(x)
Definition: xmipp_macros.h:155
Name of an image (std::string)
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
Definition: matrix2d.cpp:1022
void addParamsLine(const String &line)
int mode
Definition: mask.h:407
< Score 4 for volumes
bool do_all_matrices
constexpr int INNER_MASK
Definition: mask.h:47
double x