Xmipp  v3.23.11-Nereus
base_art_recons.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Authors: Carlos Oscar S. Sorzano (coss@cnb.csic.es)
3  * Joaquin Oton (joton@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 <fstream>
27 #include "base_art_recons.h"
28 #include "core/xmipp_threads.h"
29 #include "core/metadata_vec.h"
30 #include "data/fourier_filter.h"
31 #include "data/wavelet.h"
32 #include "data/projection.h"
33 #include "recons_misc.h"
34 
36 {
37  artPrm.readParams(program);
38 }
39 
40 void ARTReconsBase::preProcess(GridVolume &vol_basis0, int level, int rank)
41 {
42  artPrm.produceSideInfo(vol_basis0, level, rank);
43 }
44 
45 void ARTReconsBase::iterations(GridVolume &vol_basis, int rank)
46 {
47  // Some variables .......................................................
48  int ART_numIMG; // Normalizing factor
49  GridVolume *ptr_vol_out; // Pointer to output volume
50  GridVolume vol_basis_out; // Output volume (only useful in SIRT)
51  Image<double> vol_voxels; // This one is useful only in the
52  // case of saving intermediate volumes
53  int Xoutput_volume_size, Youtput_volume_size, Zoutput_volume_size;
54  double aux_tilt;
55 
56  // Projection related ...................................................
57  Projection read_proj; // Projection read from file
58  Projection theo_proj; // Projection from the
59  // reconstruction
60  Projection alig_proj; // Projection with the correlation
61  // maps needed for translation alignment
62  Projection corr_proj; // Image with the correction
63  // factors for unitary basis
64  Projection diff_proj; // Difference between the
65  // theoretical and real image
66 
67  // preIterations(vol_basis);
68 
69  // Reconstruction results ...............................................
70  double mean_error = 0.0;
71  double global_mean_error,global_mean_error_1stblock;
72 
73  // Initialize residual image vector for wlsART ..........................
74  if (artPrm.WLS)
75  {
76  artPrm.residual_imgs.clear();
77  for (int iact_proj = 0; iact_proj < artPrm.numIMG ; iact_proj++)
78  {
79  read_proj.read(artPrm.IMG_Inf[iact_proj].fn_proj);
80  read_proj().setXmippOrigin();
81  read_proj().initZeros();
82  artPrm.residual_imgs.push_back(read_proj);
83  }
84  }
85 
86  // Some initialization ..................................................
87  Xoutput_volume_size = (artPrm.Xoutput_volume_size==0) ?
89  Youtput_volume_size = (artPrm.Youtput_volume_size==0) ?
91  Zoutput_volume_size = (artPrm.Zoutput_volume_size==0) ?
93 
94  // POCS constraints .....................................................
95  POCSClass POCS(&artPrm, Zoutput_volume_size, Youtput_volume_size,
96  Xoutput_volume_size);
97 
98  // Variability analysis .................................................
99  VariabilityClass VC(&artPrm, Zoutput_volume_size, Youtput_volume_size,
100  Xoutput_volume_size);
101 
102  // Noisy reconstruction .................................................
103  GridVolume vol_basis_noisy; // Output volume (only for ART)
104  Projection noisy_projection;
105  MetaDataVec SF_noise, SF_signal;
107  {
108  vol_basis_noisy = vol_basis;
109  vol_basis_noisy.initZeros();
110  }
111 
112  // If SIRT set normalizing factor and create output volume ..............
114  {
115  ART_numIMG = artPrm.numIMG;
116  vol_basis_out = vol_basis; // Copy the structure of vol_basis
117  ptr_vol_out = &vol_basis_out; // Pointer to output volume
119  ptr_vol_out->initZeros();
120  }
125  {
126  // In those cases, normalization must be done at the top level program once we
127  // have the reconstruction values. Have a look ar /Applications/Src/MPIArt/mpi_art.cc for
128  // an example
129  ART_numIMG = 1;
130  ptr_vol_out = &vol_basis_out; // Pointer to output volume
131  vol_basis_out = vol_basis; // Copy the structure of vol_basis
132  // and possible initial values
133  }
134  else if (artPrm.eq_mode == CAV)
135  {
136  ART_numIMG = 1; // Normalizing factor = Total no. images
137  ptr_vol_out = &vol_basis_out; // Pointer to output volume
138  vol_basis_out = vol_basis; // Copy the structure of vol_basis
139  // and possible initial values
140  }
141  else
142  {
143  ART_numIMG = 1; // No normalizing factor
144  ptr_vol_out = &vol_basis; // Output volume is the same as
145  // input one
146  }
147  // Now iterate ..........................................................
148  ProcessorTimeStamp time0; // For measuring the elapsed time
149  annotate_processor_time(&time0);
150  int images=0;
151  double mean_error_2ndblock,pow_residual_imgs;
152  bool iv_launched=false;
153  for (int it = 0; it < artPrm.no_it; it++)
154  {
155  // Initialization of some variables
156  global_mean_error = 0;
157  global_mean_error_1stblock = 0;
158  POCS.newIteration();
159  VC.newIteration();
160  if (rank==-1)
161  {
162  std::cout << "Running iteration " << it << " with lambda= " << artPrm.lambda(it)<< "\n" << std::endl;
163  if (!(artPrm.tell&TELL_SHOW_ERROR))
165  }
166 
167  // For each projection -----------------------------------------------
168  for (int act_proj = 0; act_proj < artPrm.numIMG ; act_proj++)
169  {
170  POCS.newProjection();
171 
172  // Select next projection ........................................
173  int iact_proj; // Index inside the sorting information for act_proj
175  {
176  int proj_number;
177  std::cout << "Introduce next projection to study: ";
178  std::cin >> proj_number;
179  int sym_number=-1;
180  if (artPrm.SL.symsNo()!=0)
181  {
182  std::cout << "Introduce symmetry to study: ";
183  std::cin >> sym_number;
184  }
185  iact_proj=0;
186  while (iact_proj<artPrm.numIMG)
187  {
188  if (artPrm.IMG_Inf[iact_proj].fn_proj.getNumber()==proj_number &&
189  artPrm.IMG_Inf[iact_proj].sym==sym_number)
190  break;
191  iact_proj++;
192  }
193  }
194  else
195  {
196  iact_proj = artPrm.ordered_list(act_proj);
197  }
198 
199  ReconsInfo &imgInfo = artPrm.IMG_Inf[iact_proj];
200 
201  read_proj.read(imgInfo.fn_proj, artPrm.apply_shifts, DATA, &imgInfo.row);
202  read_proj().setXmippOrigin();
203  read_proj.setEulerAngles(imgInfo.rot, imgInfo.tilt, imgInfo.psi);
204 
205  // If noisy reconstruction
207  {
208  init_random_generator(imgInfo.seed);
209  noisy_projection().resize(read_proj());
210  noisy_projection().initRandom(0, 1, RND_GAUSSIAN);
211  noisy_projection().setXmippOrigin();
212  noisy_projection.setEulerAngles(imgInfo.rot,
213  imgInfo.tilt,
214  imgInfo.psi);
215  if ( it == 0 && imgInfo.sym==-1 )
216  {
217  FileName fn_noise;
218  MDRowVec row;
219  fn_noise.compose(read_proj.name().getPrefixNumber(),artPrm.fn_root+"_noise_proj.stk");
220 
221  noisy_projection.write(fn_noise);
222  row.setValue(MDL_IMAGE, fn_noise);
223  row.setValue(MDL_ENABLED, 1);
224  row.setValue(MDL_ANGLE_PSI, read_proj.psi());
225  row.setValue(MDL_ANGLE_ROT, read_proj.rot());
226  row.setValue(MDL_ANGLE_TILT, read_proj.tilt());
227  SF_noise.addRow(row);
228 
229  row.setValue(MDL_IMAGE, read_proj.name());
230  SF_signal.addRow(row);
231  }
232  }
233 
234  //skipping if tilt greater than max_tilt
235  //tilt is in between 0 and 360
236  aux_tilt=read_proj.tilt();
237  if((aux_tilt > artPrm.max_tilt && aux_tilt < 180.-artPrm.max_tilt) ||
238  (aux_tilt > artPrm.max_tilt + 180 && aux_tilt < 360.-artPrm.max_tilt))
239  {
240  std::cout << "Skipping Proj no: " << iact_proj
241  << "tilt=" << read_proj.tilt() << std::endl;
242  continue;
243  }
244 
245  // Projection extension? .........................................
246  if (artPrm.proj_ext!=0)
247  {
248  read_proj().selfWindow(
249  STARTINGY (read_proj())-artPrm.proj_ext,
250  STARTINGX (read_proj())-artPrm.proj_ext,
251  FINISHINGY(read_proj())+artPrm.proj_ext,
252  FINISHINGX(read_proj())+artPrm.proj_ext);
253  noisy_projection().resize(read_proj());
254  }
255 
256  //Skip if desired
258  {
259  if( imgInfo.sym != -1)
260  {
261  std::cout << "Skipping Proj no: " << iact_proj
262  << " with symmetry no: " << imgInfo.sym
263  << std::endl;
264  continue;
265  }
266  else
267  std::cout << "NO Skipping Proj no: " << iact_proj
268  << " with symmetry no: " << imgInfo.sym
269  << std::endl;
270  }
271 
272  // For wlsART: use alig_proj for residual image!!
273  if (artPrm.WLS)
274  alig_proj=artPrm.residual_imgs[iact_proj];
275 
276  // Is there a mask ...............................................
277  MultidimArray<int> mask;
278  const MultidimArray<int> *maskPtr=nullptr;
280  {
281  mask.resize(read_proj());
282  FOR_ALL_ELEMENTS_IN_ARRAY2D(read_proj())
283  {
284  mask(i,j)=1;
285  if ((read_proj(i,j)<artPrm.goldmask && artPrm.goldmask<1e6) ||
286  (ABS(read_proj(i,j))<1e-5 && artPrm.shiftedTomograms))
287  mask(i,j)=0;
288  }
289  maskPtr=&mask;
290  }
291 
292  // Apply the reconstruction algorithm ............................
293  // Notice that the following function is specific for each art type
294  singleStep(vol_basis, ptr_vol_out,
295  theo_proj, read_proj, imgInfo.sym , diff_proj,
296  corr_proj, alig_proj,
297  mean_error, ART_numIMG, artPrm.lambda(it),
298  images, imgInfo.fn_ctf, maskPtr,
299  artPrm.refine);
300 
301  if (artPrm.WLS)
302  {
303  artPrm.residual_imgs[iact_proj]=alig_proj;
304  global_mean_error_1stblock += diff_proj().sum2()/(XSIZE(diff_proj())*YSIZE(diff_proj()));
305  }
306 
307  global_mean_error += mean_error;
309  {
310  double noise_mean_error;
311  singleStep(vol_basis_noisy, &vol_basis_noisy,
312  theo_proj, noisy_projection, imgInfo.sym,
313  diff_proj, corr_proj, alig_proj,
314  noise_mean_error, ART_numIMG, artPrm.lambda(it),
315  images, imgInfo.fn_ctf,maskPtr,
316  false);
317  }
318 
319  // Force symmetry in the volume ..................................
320  // so far only crystallographic
321  if (artPrm.sym_each &&
322  act_proj%artPrm.sym_each==0 &&
323  (act_proj!=0 || artPrm.sym_each==1))
324  {
325  // apply_symmetry(vol_basis,ptr_vol_out, artPrm.grid_type);
327  // apply_symmetry(vol_basis_noisy,&vol_basis_noisy, artPrm.grid_type);
328  ;
329  }
330 
331  // Apply POCS ....................................................
332  POCS.apply(vol_basis,it,images);
334  POCS.apply(vol_basis_noisy,it,images);
335 
336  // Variability analysis ..........................................
338  VC.newUpdateVolume(ptr_vol_out,read_proj);
339 
340  // Apply anisotropic diffusion ...................................
341  if (it>=1 && artPrm.diffusionWeight>-1)
342  {
343  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
344  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
345  Matrix1D<double> alpha;
346  alpha=vectorR3(1.0,1.0,artPrm.diffusionWeight);
347  double regError=tomographicDiffusion(vol_voxels(),alpha,
348  artPrm.lambda(it)/100);
350  std::cout << "Regularization error = " << regError << std::endl;
351  *artPrm.fh_hist << "Regularization error = " << regError << std::endl;
352  artPrm.basis.changeFromVoxels(vol_voxels(),vol_basis,artPrm.grid_type,
353  artPrm.grid_relative_size, nullptr, nullptr, artPrm.R, artPrm.threads);
354  }
355 
356  // Apply sparsity constraint .....................................
357  if (it>=1 && artPrm.sparseEps>0 &&
361  {
362  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
363  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
364  forceDWTSparsity(vol_voxels(),artPrm.sparseEps);
365  artPrm.basis.changeFromVoxels(vol_voxels(),vol_basis,artPrm.grid_type,
366  artPrm.grid_relative_size, nullptr, nullptr, artPrm.R, artPrm.threads);
367  }
368 
369  // Show results ..................................................
370  *artPrm.fh_hist << imgInfo.fn_proj << ", sym="
371  << imgInfo.sym << "\t\t" << mean_error;
372  if (POCS.apply_POCS)
373  *artPrm.fh_hist << "\tPOCS:" << POCS.POCS_mean_error;
374  *artPrm.fh_hist << std::endl;
376  {
377  std::cout << imgInfo.fn_proj << ", sym="
378  << imgInfo.sym << "\t\t" << mean_error;
379  if (POCS.apply_POCS)
380  std::cout << "\tPOCS:" << POCS.POCS_mean_error;
381  std::cout << std::endl;
382  }
383  else if (act_proj%XMIPP_MAX(1,artPrm.numIMG/60)==0)
384  progress_bar(act_proj);
385 
386  if (artPrm.tell&TELL_STATS)
387  {
388  std::cout << " read ";
389  read_proj().printStats();
390  std::cout << "\n theo ";
391  theo_proj().printStats();
392  std::cout << "\n corr ";
393  corr_proj().printStats();
394  std::cout << "\n alig ";
395  alig_proj().printStats();
396  std::cout << "\n diff ";
397  diff_proj().printStats();
398  std::cout << "\n subvol(0) ";
399  (*ptr_vol_out)(0)().printStats();
400  std::cout << "\n";
401  }
402 
404  {
405  std::cout << "Stats PPPdiff.xmp: ";
406  diff_proj().printStats();
407  std::cout << std::endl;
408  std::cout << "Stats PPPtheo.xmp: ";
409  theo_proj().printStats();
410  std::cout << std::endl;
411  std::cout << "Stats PPPread.xmp: ";
412  read_proj().printStats();
413  std::cout << std::endl;
414  std::cout << "Stats PPPcorr.xmp: ";
415  corr_proj().printStats();
416  std::cout << std::endl;
417  diff_proj.write("PPPdiff.xmp");
418  theo_proj.write("PPPtheo.xmp");
419  read_proj.write("PPPread.xmp");
420  corr_proj.write("PPPcorr.xmp");
421  if(act_proj!=0)
422  alig_proj.write("PPPalign.xmp");
423  vol_basis.write("PPPbasis.basis");
424  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
425  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
426  std::cout << "Stats PPPvol.vol : ";
427  vol_voxels().printStats();
428  std::cout << std::endl;
429  vol_voxels.write("PPPvol.vol");
430 
431  if (!iv_launched)
432  {
433  if (system("xmipp_show -img PPPdiff.xmp PPPtheo.xmp PPPread.xmp PPPcorr.xmp -dont_apply_geo -poll &")==-1)
434  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
435  if (system("xmipp_show -vol PPPvol.vol -poll &")==-1)
436  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
437  iv_launched=true;
438  }
439  std::cout << "\nHit any key and enter\n";
440  char c;
441  std::cin >> c;
442  }
443 
444  // Save intermediate
447  act_proj%artPrm.save_intermidiate_every==0)
448  {
450  std::cout << "\nSaving intermediate ...\n"
451  << "Converting basis volume to voxels ...\n";
452  // Save reconstructed volume
453  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
454  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
456  vol_voxels.write(artPrm.fn_root+"it"+integerToString(it)+"proj"+
457  integerToString(act_proj,5)+".vol");
458  else
459  vol_voxels.write("PPPvol.vol");
460 
461  // Launch viewer
462  if (!iv_launched)
463  {
464  if (system("xmipp_show -i PPPvol.vol --poll &")==-1)
465  REPORT_ERROR(ERR_UNCLASSIFIED,"Cannot open shell");
466  iv_launched=true;
467  }
468  }
469 
470  // Check if algorithm must stop via stop_at
471  if (++images==artPrm.stop_at)
472  break;
473  }
474 
475  if (!(artPrm.tell&TELL_SHOW_ERROR))
477 
478  // Update residual images for WLS
479  if (artPrm.WLS)
480  {
481  double kappa=artPrm.kappa(it);
482  updateResidualVector( artPrm, vol_basis, kappa,
483  mean_error_2ndblock, pow_residual_imgs);
484  }
485 
486  // Prepare for next global iteration ---------------------------------
487  // Calculate norm and print
488  if (rank==-1)
489  {
490  *artPrm.fh_hist << "Finished - Iteration " << it << std::endl;
491  if (artPrm.WLS)
492  std::cout << " Weighted error: " << global_mean_error
493  << " 1st block: " << global_mean_error_1stblock
494  << " 2nd block: " << mean_error_2ndblock
495  << " residual: " << pow_residual_imgs << std::endl;
496  else
497  std::cout << " Global mean squared error: "
498  << global_mean_error/artPrm.numIMG << std::endl;
499 
500  if (artPrm.WLS)
501  *artPrm.fh_hist << " Weighted error: " << global_mean_error
502  << " 1st block: " << global_mean_error_1stblock
503  << " 2nd block: " << mean_error_2ndblock
504  << " residual: " << pow_residual_imgs << std::endl;
505  else
506  *artPrm.fh_hist << " Global mean squared error: "
507  << global_mean_error/artPrm.numIMG << std::endl;
508 
509  if (POCS.apply_POCS)
510  {
511  std::cout << " POCS Global mean squared error: "
512  << POCS.POCS_global_mean_error/POCS.POCS_N << std::endl;
513  *artPrm.fh_hist << " POCS Global mean squared error: "
514  << POCS.POCS_global_mean_error/POCS.POCS_N << std::endl;
515  }
516  }
517 
518  // Convert volume and write if not last iteration
519  // If in SIRT mode move the volume to the reference one
526  artPrm.eq_mode==CAV )
527  {
528  vol_basis=vol_basis_out;
529  if (artPrm.sparseEps>0)
530  {
531  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
532  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
534  (size_t)NEXT_POWER_OF_2(XSIZE(vol_voxels())),
535  (size_t)NEXT_POWER_OF_2(YSIZE(vol_voxels())),
536  (size_t)NEXT_POWER_OF_2(ZSIZE(vol_voxels())));
537  Image<double> vol_wavelets, vol_wavelets_abs;
539  DWT(vol_voxels(),vol_wavelets());
540  vol_wavelets_abs()=vol_wavelets();
541  vol_wavelets_abs().selfABS();
542  double *begin=MULTIDIM_ARRAY(vol_wavelets_abs());
543  double *end=MULTIDIM_ARRAY(vol_wavelets_abs())+
544  MULTIDIM_SIZE(vol_wavelets_abs());
545  std::sort(begin,end);
546  double threshold1=DIRECT_MULTIDIM_ELEM(vol_wavelets_abs(),
547  (long int)((1-artPrm.sparseEps)*MULTIDIM_SIZE(vol_wavelets_abs())));
548  std::cout << "Threshold=" << threshold1 << std::endl;
549  vol_wavelets().threshold("abs_below", threshold1, 0.0);
550  IDWT(vol_wavelets(),vol_voxels());
552  Xoutput_volume_size,
553  Youtput_volume_size,
554  Zoutput_volume_size);
555  artPrm.basis.changeFromVoxels(vol_voxels(),vol_basis,artPrm.grid_type,
556  artPrm.grid_relative_size, nullptr, nullptr, artPrm.R, artPrm.threads);
557  }
558  }
559 
560  if ( (artPrm.tell & TELL_SAVE_INTERMIDIATE) && it != artPrm.no_it-1)
561  {
562  if (rank==-1)
563  std::cout << "Converting basis volume to voxels ...\n";
564  artPrm.basis.changeToVoxels(vol_basis, &(vol_voxels()),
565  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
566  FileName fn_tmp = artPrm.fn_out.insertBeforeExtension(formatString("_it%06d", it));
567  vol_voxels.write(fn_tmp);
568 
570  vol_basis.write(fn_tmp.removeLastExtension().addExtension("basis"));
571  }
572 
573  // Check if algorithm must stop via stop_at
574  if (images==artPrm.stop_at)
575  break;
576  }
577 
578  // Times on screen
579  if (rank==-1)
580  {
581  std::cout << "\nTime of " << artPrm.no_it << " iterations: \n";
582  print_elapsed_time(time0);
583  }
584 
585  // Finish variability analysis
586  VC.finishAnalysis();
587 
588  // Save the noisy reconstruction
590  {
591  Image<double> vol_voxels_noisy;
592  artPrm.basis.changeToVoxels(vol_basis_noisy, &(vol_voxels_noisy()),
593  Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
594  vol_voxels_noisy.write(artPrm.fn_out.insertBeforeExtension("_noise"));
595  SF_noise.write(artPrm.fn_root+"_noise_proj.xmd");
596  SF_signal.write(artPrm.fn_root+"_signal_proj.xmd");
597  }
598 
599 }
600 
601 void ARTReconsBase::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)
602 {}
603 
605 {}
606 
607 void ARTReconsBase::initHistory(const GridVolume &vol_basis0)
608 {
609  // Show general information ................................................
610  *artPrm.fh_hist << " ============================================================\n";
611  *artPrm.fh_hist << " ART RECONSTRUCTION HISTORY: \n";
612  *artPrm.fh_hist << " ============================================================\n\n";
613  *artPrm.fh_hist << " Parameters -------------------------------------------------\n";
614  *artPrm.fh_hist << " Projections file : " << artPrm.fn_sel << std::endl;
615  *artPrm.fh_hist << " CTF file : " << artPrm.fn_ctf << std::endl;
616  *artPrm.fh_hist << " Goldmask : " << artPrm.goldmask << std::endl;
617  *artPrm.fh_hist << " Unmatched projectors : " << artPrm.unmatched << std::endl;
618  *artPrm.fh_hist << " Sampling : " << artPrm.sampling << std::endl;
619  *artPrm.fh_hist << artPrm.basis << std::endl;
620  switch (artPrm.grid_type)
621  {
622  case FCC:
623  *artPrm.fh_hist << " Grid Type: FCC ";
624  break;
625  case BCC:
626  *artPrm.fh_hist << " Grid Type: BCC ";
627  break;
628  case CC:
629  *artPrm.fh_hist << " Grid Type: CC ";
630  break;
631  }
632  *artPrm.fh_hist << " Shifted tomograms:" << artPrm.shiftedTomograms << std::endl;
633  *artPrm.fh_hist << " Ray length: " << artPrm.ray_length << std::endl;
634  *artPrm.fh_hist << "\n Radius of the interest sphere= " << artPrm.R
635  << " pixels" << std::endl;
636  *artPrm.fh_hist << " Grid unit=" << artPrm.grid_relative_size
637  << " pixels" << std::endl;
638  if (artPrm.proj_ext==0)
639  *artPrm.fh_hist << " No Projection extension\n";
640  else
641  *artPrm.fh_hist << " Projection extension frame: " << artPrm.proj_ext
642  << " pixels\n";
644  *artPrm.fh_hist << " Output volume size as input images\n";
645  else
646  *artPrm.fh_hist << " Output volume size (ZxYxX): "
648  << "x" << artPrm.Xoutput_volume_size << std::endl;
649  *artPrm.fh_hist << " Iterations: lambda=" << artPrm.lambda_list << std::endl
650  << " No. Iter=" << artPrm.no_it << std::endl;
651  if (artPrm.WLS)
652  {
653  *artPrm.fh_hist << " Perform weighted least-squares ART "<< std::endl;
654  *artPrm.fh_hist << " Iterations: kappa=" << artPrm.kappa_list << std::endl
655  << " No. Iter=" << artPrm.no_it << std::endl;
656  }
657  *artPrm.fh_hist << " Parallel mode: ";
658  switch (artPrm.parallel_mode)
659  {
661  *artPrm.fh_hist << "ART\n";
662  break;
664  *artPrm.fh_hist << "SIRT\n";
665  break;
667  *artPrm.fh_hist << "Parallel SIRT\n";
668  break;
670  *artPrm.fh_hist << "Parallel False SIRT\n";
671  break;
673  *artPrm.fh_hist << "SART, block size=" << artPrm.block_size << std::endl;
674  break;
676  *artPrm.fh_hist << "AVSP\n";
677  break;
679  *artPrm.fh_hist << "BiCAV, block size=" << artPrm.block_size << std::endl;
680  break;
682  *artPrm.fh_hist << "CAV (global algorithm)\n";
683  break;
684  }
685  *artPrm.fh_hist << " Equation mode: ";
686  if (artPrm.eq_mode==CAV)
687  *artPrm.fh_hist << "CAV (Projection update)\n";
688  else if (artPrm.eq_mode==CAVK)
689  *artPrm.fh_hist << "CAVK\n";
690  else if (artPrm.eq_mode==CAVARTK)
691  *artPrm.fh_hist << "CAVARTK\n";
692  else
693  *artPrm.fh_hist << "ARTK\n";
694  *artPrm.fh_hist << " Projections: Ydim x Xdim = " << artPrm.projYdim
695  << " x " << artPrm.projXdim << std::endl;
696  *artPrm.fh_hist << " Surface mask: " << artPrm.fn_surface_mask << std::endl;
697  *artPrm.fh_hist << " POCS freq: " << artPrm.POCS_freq << std::endl;
698  *artPrm.fh_hist << " Known volume: " << artPrm.known_volume << std::endl;
699  *artPrm.fh_hist << " Positivity: " <<artPrm.positivity << std::endl;
700  *artPrm.fh_hist << " Apply shifts in images headers: " << artPrm.apply_shifts << std::endl;
701  *artPrm.fh_hist << " Symmetry file: " << artPrm.fn_sym << std::endl;
702  *artPrm.fh_hist << " Force Symmetry each: " << artPrm.sym_each << " projections"
703  <<std::endl;
704  *artPrm.fh_hist << " Maximun absolute tilt angle: " << artPrm.max_tilt << " degrees"
705  <<std::endl;
706  *artPrm.fh_hist << " Generating symmetry group: " << !artPrm.do_not_generate_subgroup << std::endl;
707  *artPrm.fh_hist << " Do not use symmetrized projections: "
708  << !artPrm.do_not_use_symproj << std::endl;
709  *artPrm.fh_hist << " Number of total projections (including symmetrized): "
710  << artPrm.numIMG << std::endl;
711  *artPrm.fh_hist << " Number of different projections: " << artPrm.trueIMG << std::endl;
712  *artPrm.fh_hist << " Forcing symmetry: " << artPrm.force_sym << std::endl;
713  *artPrm.fh_hist << " Stop at: " << artPrm.stop_at << std::endl;
714  if (artPrm.random_sort)
715  *artPrm.fh_hist << " Random sort" << std::endl;
716  else
717  *artPrm.fh_hist << " Sort with last " << artPrm.sort_last_N << " images\n";
718  *artPrm.fh_hist << " Variability analysis: " << artPrm.variability_analysis << std::endl;
719  *artPrm.fh_hist << " Refine projections: " << artPrm.refine << std::endl;
720  *artPrm.fh_hist << " Sparsity epsilon: " << artPrm.sparseEps << std::endl;
721  *artPrm.fh_hist << " Diffusion weight: " << artPrm.diffusionWeight << std::endl;
722  if (artPrm.SL.symsNo()!=0)
723  {
724  Matrix2D<double> L(4,4),R(4,4); // A matrix from the list
725  *artPrm.fh_hist << " Symmetry matrices -------\n";
726  for (int j=0; j<artPrm.SL.symsNo(); j++)
727  {
728  artPrm.SL.getMatrices(j,L,R);
729  *artPrm.fh_hist << " Left Symmetry matrix " << j << std::endl << L;
730  *artPrm.fh_hist << " Right Symmetry matrix " << j << std::endl << R << std::endl;
731  }
732  }
733  *artPrm.fh_hist << " Saving intermidiate at every "
734  << artPrm.save_intermidiate_every << " projections\n";
735  if(artPrm.ref_trans_step > 0.)
736  {
737  *artPrm.fh_hist << " Refine translational alignement after "
738  << artPrm.ref_trans_after << " projection presentations\n"
739  << " Maximun allowed shift is: " << artPrm.ref_trans_step << "\n\n";
740  }
741 
742  // Show angles .............................................................
743  // Prepare info structure for showing
744  MetaDataVec MD;
745  double dfrot, dftilt, dfpsi;
746  size_t id;
747  for (int i=0; i<artPrm.numIMG; i++)
748  {
749  id=MD.addObject();
754  }
755 
756  // Now show
757  *artPrm.fh_hist << " Projection angles -----------------------------------------\n";
758  for (size_t objId : MD.ids())
759  {
760  MD.getValue(MDL_ANGLE_ROT, dfrot, objId);
761  MD.getValue(MDL_ANGLE_TILT, dftilt, objId);
762  MD.getValue(MDL_ANGLE_PSI, dfpsi, objId);
763 
764  *artPrm.fh_hist << "rot= "<<dfrot<<" tilt= "<<dftilt<<" psi= "<<dfpsi<<std::endl;
765  }
766  *artPrm.fh_hist << " -----------------------------------------------------------\n";
767 
768  // Show Initial volume and volume structure ................................
769  if (artPrm.fn_start != "")
770  *artPrm.fh_hist << " Starting from file: " << artPrm.fn_start << std::endl;
771  else
772  *artPrm.fh_hist << " Starting from a zero volume\n";
773 
774  *artPrm.fh_hist << " Grid structure ------\n" << vol_basis0.grid();
775 
776  // Show extra information ..................................................
777  if (typeid(*this) != typeid(ARTReconsBase))
778  *artPrm.fh_hist << " Extra: ";
779  print(*artPrm.fh_hist);
780 }
781 
782 void ARTReconsBase::print(std::ostream &o) const
783 {}
784 std::ostream & operator<< (std::ostream &o, const ARTReconsBase& artRecons)
785 {
786  artRecons.print(o);
787  return o;
788 }
789 
790 void ARTReconsBase::applySymmetry(GridVolume &vol_in, GridVolume *vol_out,int grid_type)
791 {
792  REPORT_ERROR(ERR_NOT_IMPLEMENTED, "ARTReconsBase::applySymmetry: Function not implemented for single particles");
793 }
794 
795 
796 void SinPartARTRecons::preProcess(GridVolume & vol_basis0, int level, int rank)
797 {
798  ARTReconsBase::preProcess(vol_basis0, level, rank);
799 
800  // As this is a threaded implementation, create structures for threads, and
801  // create threads
802  if( artPrm.threads > 1 )
803  {
804  th_ids = (pthread_t *)malloc( artPrm.threads * sizeof( pthread_t));
805 
806  // Initialize the structures which will contain the parameters passed to different
807  // threads
809 
810  // Initialize barrier to wait for working threads and the master thread.
812 
813  // Threads are created in a waiting state. They can only run when master thread unlocks them by calling
814  // barrier_wait()
815 
816  for( int c = 0 ; c < artPrm.threads ; c++ )
817  {
820  project_threads[c].destroy = false;
821 
822  pthread_create( (th_ids+c), nullptr, project_SimpleGridThread<double>, (void *)(project_threads+c) );
823  }
824  }
825 }
826 
827 
829  Projection &theo_proj, Projection &read_proj,
830  int sym_no,
831  Projection &diff_proj, Projection &corr_proj, Projection &alig_proj,
832  double &mean_error, int numIMG, double lambda, int act_proj,
833  const FileName &fn_ctf, const MultidimArray<int> *maskPtr,
834  bool refine)
835 {
836  // Prepare to work with CTF ................................................
837  FourierFilter ctf;
838  auto *footprint = (ImageOver *) & artPrm.basis.blobprint;
839  auto *footprint2 = (ImageOver *) & artPrm.basis.blobprint2;
840  bool remove_footprints = false;
841  double weight, sqrtweight;
842 
843  if (fn_ctf != "" && !artPrm.unmatched)
844  {
845  if (artPrm.basis.type != Basis::blobs)
846  REPORT_ERROR(ERR_VALUE_INCORRECT, "ART_single_step: This way of correcting for the CTF "
847  "only works with blobs");
848  // It is a description of the CTF
849  ctf.FilterShape = ctf.FilterBand = CTF;
850  ctf.ctf.enable_CTFnoise = false;
851  ctf.ctf.read(fn_ctf);
852  ctf.ctf.Tm /= BLOB_SUBSAMPLING;
853  ctf.ctf.produceSideInfo();
854 
855  // Create new footprints
856  footprint = new ImageOver;
857  footprint2 = new ImageOver;
858  remove_footprints = true;
859 
860  // Enlarge footprint, bigger than necessary to avoid
861  // aliasing
862  *footprint = artPrm.basis.blobprint;
863  (*footprint)().setXmippOrigin();
864  double blob_radius = artPrm.basis.blob.radius;
865  int finalsize = 2 * CEIL(30 + blob_radius) + 1;
866  footprint->window(
867  FIRST_XMIPP_INDEX(finalsize), FIRST_XMIPP_INDEX(finalsize),
868  LAST_XMIPP_INDEX(finalsize), LAST_XMIPP_INDEX(finalsize));
869 
870  // Generate mask to the size of the footprint, correct phase
871  // and apply CTF
872  ctf.generateMask((*footprint)());
873  ctf.correctPhase();
874  ctf.applyMaskSpace((*footprint)());
875 
876  // Remove unnecessary regions
877  finalsize = 2 * CEIL(15 + blob_radius) + 1;
878  footprint->window(
879  FIRST_XMIPP_INDEX(finalsize), FIRST_XMIPP_INDEX(finalsize),
880  LAST_XMIPP_INDEX(finalsize), LAST_XMIPP_INDEX(finalsize));
881 #ifdef DEBUG
882 
883  Image<double> save;
884  save() = (*footprint)();
885  save.write("PPPfootprint.xmp");
886 #endif
887 
888  // Create footprint2
889  *footprint2 = *footprint;
890  (*footprint2)() *= (*footprint2)();
891  }
892 
893  // Project structure .......................................................
894  // The correction image is reused in this call to store the normalising
895  // projection, ie, the projection of an all-1 volume
896  Matrix2D<double> *A = nullptr;
898  A = new Matrix2D<double>;
899  corr_proj().initZeros();
900 
901  project_GridVolume(vol_in, artPrm.basis, theo_proj,
902  corr_proj, YSIZE(read_proj()), XSIZE(read_proj()),
903  read_proj.rot(), read_proj.tilt(), read_proj.psi(), FORWARD, artPrm.eq_mode,
904  artPrm.GVNeq, A, maskPtr, artPrm.ray_length, artPrm.threads);
905 
906  if (fn_ctf != "" && artPrm.unmatched)
907  {
908  ctf.generateMask(theo_proj());
909  ctf.applyMaskSpace(theo_proj());
910  }
911 
912  // Print system matrix
914  {
915  std::cout << "Equation system (Ax=b) ----------------------\n";
916  std::cout << "Size: "<< (*A).mdimx <<"x"<<(*A).mdimy<< std::endl;
917  for (size_t i = 0; i < MAT_YSIZE(*A); i++)
918  {
919  bool null_row = true;
920  for (size_t j = 0; j < MAT_XSIZE(*A); j++)
921  if (MAT_ELEM(*A, i, j) != 0)
922  {
923  null_row = false;
924  break;
925  }
926  if (!null_row)
927  {
928  std::cout << "pixel=" << integerToString(i, 3) << " --> "
929  << DIRECT_MULTIDIM_ELEM(read_proj(), i) << " = ";
930  for (size_t j = 0; j < MAT_XSIZE(*A); j++)
931  std::cout << MAT_ELEM(*A, i, j) << " ";
932  std::cout << std::endl;
933  }
934  }
935  std::cout << "---------------------------------------------\n";
936  delete A;
937  }
938 
939  // Refine ..............................................................
940  if (refine)
941  {
943  /*
944  Image<double> save;
945  save()=theo_proj(); save.write("PPPtheo.xmp");
946  save()=read_proj(); save.write("PPPread.xmp");
947  */
948  alignImages(theo_proj(),read_proj(),M);
949  //save()=read_proj(); save.write("PPPread_aligned.xmp");
950  std::cout << M << std::endl;
951  read_proj().rangeAdjust(theo_proj());
952  //save()=read_proj(); save.write("PPPread_aligned_grey.xmp");
953  //std::cout << "Press any key\n";
954  //char c; std::cin >> c;
955  }
956 
957  // Now compute differences .................................................
958  double applied_lambda = lambda / numIMG; // In ART mode, numIMG=1
959 
960  mean_error = 0;
961  diff_proj().resize(read_proj());
962 
963  // Weighted least-squares ART for Maximum-Likelihood refinement
964  if (artPrm.WLS)
965  {
966  weight = read_proj.weight() / artPrm.sum_weight;
967  sqrtweight = sqrt(weight);
968 
970  {
971  // Compute difference image and error
972  IMGPIXEL(diff_proj, i, j) = IMGPIXEL(read_proj, i, j) - IMGPIXEL(theo_proj, i, j);
973  mean_error += IMGPIXEL(diff_proj, i, j) * IMGPIXEL(diff_proj, i, j);
974 
975  // Subtract the residual image (stored in alig_proj!)
976  IMGPIXEL(diff_proj, i, j) = sqrtweight * IMGPIXEL(diff_proj, i, j) - IMGPIXEL(alig_proj, i, j);
977 
978  // Calculate the correction and the updated residual images
979  IMGPIXEL(corr_proj, i, j) =
980  applied_lambda * IMGPIXEL(diff_proj, i, j) / (weight * IMGPIXEL(corr_proj, i, j) + 1.);
981  IMGPIXEL(alig_proj, i, j) += IMGPIXEL(corr_proj, i, j);
982  IMGPIXEL(corr_proj, i, j) *= sqrtweight;
983 
984  }
985  mean_error /= XSIZE(diff_proj()) * YSIZE(diff_proj());
986  mean_error *= weight;
987 
988  }
989  else
990  {
991  long int Nmean=0;
993  {
994  if (maskPtr!=nullptr)
995  if ((*maskPtr)(i,j)<0.5)
996  continue;
997  // Compute difference image and error
998  IMGPIXEL(diff_proj, i, j) = IMGPIXEL(read_proj, i, j) - IMGPIXEL(theo_proj, i, j);
999  mean_error += IMGPIXEL(diff_proj, i, j) * IMGPIXEL(diff_proj, i, j);
1000  Nmean++;
1001 
1002  // Compute the correction image
1003  IMGPIXEL(corr_proj, i, j) = XMIPP_MAX(IMGPIXEL(corr_proj, i, j), 1);
1004  IMGPIXEL(corr_proj, i, j) =
1005  applied_lambda * IMGPIXEL(diff_proj, i, j) / IMGPIXEL(corr_proj, i, j);
1006  }
1007  mean_error /= Nmean;
1008  }
1009 
1010  // Backprojection of correction plane ......................................
1011  project_GridVolume(*vol_out, artPrm.basis, theo_proj,
1012  corr_proj, YSIZE(read_proj()), XSIZE(read_proj()),
1013  read_proj.rot(), read_proj.tilt(), read_proj.psi(), BACKWARD, artPrm.eq_mode,
1014  artPrm.GVNeq, nullptr, maskPtr, artPrm.ray_length, artPrm.threads);
1015 
1016  // Remove footprints if necessary
1017  if (remove_footprints)
1018  {
1019  delete footprint;
1020  delete footprint2;
1021  }
1022 }
1023 
1024 
1026 {
1027  // Destroy created threads. This is done in a tricky way. At this point, threads
1028  // are "slept" waiting for a barrier to be reached by the master thread to continue
1029  // projecting/backprojecting a new projection. Here we set the flag destroy=true so
1030  // the threads won't process a projections but will return.
1031  if( artPrm.threads > 1 )
1032  {
1033  for( int c = 0 ; c < artPrm.threads ; c++ )
1034  {
1035  project_threads[c].destroy = true;
1036  }
1037 
1038  // Trigger threads "self-destruction"
1040 
1041  // Wait for effective threads death
1042  for( int c = 0 ; c < artPrm.threads ; c++ )
1043  {
1044  pthread_join(*(th_ids+c),nullptr);
1045  }
1046 
1047  // Destroy barrier and mutex, as they are no longer needed.
1048  // Sjors, 27march2009
1049  // NO, don't do this, because running a second threaded-ART
1050  // in a single program will not have mutexes anymore...
1051  //pthread_mutex_destroy( &project_mutex );
1052  //barrier_destroy( &project_barrier );
1053  }
1054 }
1055 
1056 
1057 
#define TELL_IV
Definition: basic_art.h:269
Just to locate unclassified errors.
Definition: xmipp_error.h:192
int barrier_init(barrier_t *barrier, int needed)
#define MAT_YSIZE(m)
Definition: matrix2d.h:124
void init_progress_bar(long total)
MDRowVec row
Header information of projection.
Definition: basic_art.h:63
template void * project_SimpleGridThread< double >(void *)
bool positivity
Apply positivity constraint.
Definition: basic_art.h:246
int numIMG
Total number of images to process (taking symmetries into account)
Definition: basic_art.h:348
Rotation angle of an image (double,degrees)
#define YSIZE(v)
void set_DWT_type(int DWT_type)
Definition: wavelet.cpp:154
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
#define XMIPP_MAX(x, y)
Definition: xmipp_macros.h:193
Case or algorithm not implemented yet.
Definition: xmipp_error.h:177
size_t projXdim
Projection X dimension.
Definition: basic_art.h:333
Symmetry number for a projection (used in ART)
double psi
Psi angle.
Definition: basic_art.h:71
bool refine
Refine experimental projection before backprojecting.
Definition: basic_art.h:258
#define TELL_SHOW_ERROR
Definition: basic_art.h:272
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
Definition: symmetries.cpp:348
CTFDescription ctf
Basis basis
Basis function. By default, blobs.
Definition: basic_art.h:97
FileName removeLastExtension() const
#define FINISHINGX(v)
double alignImages(const MultidimArray< double > &Iref, const AlignmentTransforms &IrefTransforms, MultidimArray< double > &I, Matrix2D< double > &M, bool wrap, AlignmentAux &aux, CorrelationAux &aux2, RotationalCorrelationAux &aux3)
Definition: filters.cpp:2047
#define REPORT_ERROR(nerr, ErrormMsg)
Definition: xmipp_error.h:211
double psi(const size_t n=0) const
void updateResidualVector(BasicARTParameters &prm, GridVolume &vol_basis, double &kappa, double &pow_residual_vol, double &pow_residual_imgs)
FileName fn_start
Grid volume as initial guess.
Definition: basic_art.h:220
void initHistory(const GridVolume &vol_basis0)
doublereal * c
#define MULTIDIM_SIZE(v)
void sqrt(Image< double > &op)
void annotate_processor_time(ProcessorTimeStamp *time)
#define TELL_MANUAL_ORDER
Definition: basic_art.h:273
Tilting angle of an image (double,degrees)
FileName addExtension(const String &ext) const
void setValue(const MDObject &object) override
FileName insertBeforeExtension(const String &str) const
Matrix1D< double > vectorR3(double x, double y, double z)
Definition: matrix1d.cpp:892
virtual void print(std::ostream &o) const
#define TELL_STATS
Definition: basic_art.h:277
void changeFromVoxels(const MultidimArray< double > &vol_voxels, GridVolume &vol_basis, int grid_type, double grid_relative_size, const MultidimArray< double > *vol_mask, const Matrix2D< double > *D, double R, int threads=1) const
Definition: basis.cpp:292
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)
bool do_not_use_symproj
Do not use symmetrized projections.
Definition: basic_art.h:202
#define MULTIDIM_ARRAY(v)
#define TELL_SAVE_BASIS
Definition: basic_art.h:276
virtual void applySymmetry(GridVolume &vol_in, GridVolume *vol_out, int grid_type)
double grid_relative_size
Relative size for the grid.
Definition: basic_art.h:141
void compose(const String &str, const size_t no, const String &ext="")
Special label to be used when gathering MDs in MpiMetadataPrograms.
struct blobtype blob
Blob parameters.
Definition: basis.h:61
#define BACKWARD
Definition: blobs.cpp:1092
const FileName & name() const
void write(const FileName &outFile, WriteModeMetaData mode=MD_OVERWRITE) const
FileName fn_sym
File containing symmetries.
Definition: basic_art.h:173
String integerToString(int I, int _width, char fill_with)
bool shiftedTomograms
Shifted tomograms.
Definition: basic_art.h:214
tBasisFunction type
Basis function to use.
Definition: basis.h:52
double rot(const size_t n=0) const
ImageOver blobprint2
Square of the footprint.
Definition: basis.h:74
double kappa(int n)
Definition: basic_art.h:453
int symsNo() const
Definition: symmetries.h:268
#define CC
CC identifier.
Definition: grids.h:585
virtual IdIteratorProxy< false > ids()
FileName fn_sel
Selection file with all images to process.
Definition: basic_art.h:208
std::ofstream * fh_hist
File handler for the history file.
Definition: basic_art.h:339
bool variability_analysis
Variability analysis.
Definition: basic_art.h:255
int save_intermidiate_every
Frequency for saving intermidiate.
Definition: basic_art.h:314
#define IMGMATRIX(I)
double weight(const size_t n=0) const
size_t projYdim
Projection Y dimension.
Definition: basic_art.h:336
#define STARTINGX(v)
void changeToVoxels(GridVolume &vol_basis, MultidimArray< double > *vol_voxels, int Zdim, int Ydim, int Xdim, int threads=1) const
Definition: basis.cpp:261
double sampling
Sampling rate.
Definition: basic_art.h:170
virtual void readParams(XmippProgram *program)
#define i
void init_random_generator(int seed)
Is this image enabled? (int [-1 or 1])
void selfScaleToSize(int SplineDegree, MultidimArrayGeneric &V1, int Xdim, int Ydim, int Zdim)
size_t addRow(const MDRow &row) override
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void read(const FileName &fn, bool disable_if_not_K=true)
Definition: ctf.cpp:1220
int block_size
Number of projections for each parallel block.
Definition: basic_art.h:112
bool random_sort
True if random sort of projections.
Definition: basic_art.h:120
int grid_type
CC, BCC or FCC (in grids.hh)
Definition: basic_art.h:144
double tilt(const size_t n=0) const
#define STARTINGY(v)
#define BCC
BCC identifier.
Definition: grids.h:589
int trueIMG
Number of different images (without symmetries)
Definition: basic_art.h:351
#define MAT_ELEM(m, i, j)
Definition: matrix2d.h:116
FileName fn_surface_mask
File containing surface mask.
Definition: basic_art.h:205
double known_volume
Known volume. If -1, not applied.
Definition: basic_art.h:226
Matrix1D< double > kappa_list
Definition: basic_art.h:132
#define TELL_ONLY_SYM
Definition: basic_art.h:270
double sparseEps
Sparse reconstruction.
Definition: basic_art.h:190
bool print_system_matrix
Print system matrix.
Definition: basic_art.h:249
double tilt
Tilting angle.
Definition: basic_art.h:69
bool apply_shifts
Apply shifts stored in the headers of the 2D-images.
Definition: basic_art.h:243
#define DAUB12
Definition: wavelet.h:39
double * lambda
GridVolumeT< int > * GVNeq
Definition: basic_art.h:381
double goldmask
Goldmask.
Definition: basic_art.h:211
bool setValue(const MDObject &mdValueIn, size_t id)
#define CEIL(x)
Definition: xmipp_macros.h:225
virtual void postProcess(GridVolume &vol_basis)
size_t addObject() override
#define FCC
FCC identifier.
Definition: grids.h:587
#define CTF
void DWT(const MultidimArray< T > &v, MultidimArray< double > &result, int isign=1)
Definition: wavelet.h:83
void project_GridVolume(GridVolumeT< T > &vol, const Basis &basis, Projection &proj, Projection &norm_proj, int Ydim, int Xdim, double rot, double tilt, double psi, int FORW, int eq_mode, GridVolumeT< int > *GVNeq, Matrix2D< double > *M, const MultidimArray< int > *mask, double ray_length, int threads)
size_t getPrefixNumber(size_t pos=0) const
int stop_at
Stop after this number of images, if 0 then don&#39;t use.
Definition: basic_art.h:223
void postProcess(GridVolume &vol_basis)
struct tms ProcessorTimeStamp
Definition: xmipp_funcs.h:822
ReconsInfo * IMG_Inf
Array with all the sorting information for each projection.
Definition: basic_art.h:342
int seed
Definition: basic_art.h:81
virtual void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Produce Plain side information from the Class parameters.
void initZeros()
Definition: grids.h:936
friend std::ostream & operator<<(std::ostream &o, const ARTReconsBase &artRecons)
#define XSIZE(v)
void progress_bar(long rlen)
void newUpdateVolume(GridVolume *ptr_vol_out, Projection &read_proj)
double Tm
Sampling rate (A/pixel)
Definition: ctf.h:240
#define ABS(x)
Definition: xmipp_macros.h:142
#define TELL_SAVE_INTERMIDIATE
Definition: basic_art.h:275
FileName fn_ctf
CTF filename.
Definition: basic_art.h:65
#define ZSIZE(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
ARTParallelMode parallel_mode
Definition: basic_art.h:109
void print_elapsed_time(ProcessorTimeStamp &time, bool _IN_SECS)
void produceSideInfo(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Definition: basic_art.cpp:468
virtual 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)
FileName fn_root
Definition: basic_art.h:217
FileName fn_proj
Projection filename.
Definition: basic_art.h:61
void sort(struct DCEL_T *dcel)
Definition: sorting.cpp:18
double ref_trans_step
Refine the translation alignement after n projection presentations.
Definition: basic_art.h:187
#define NEXT_POWER_OF_2(x)
Definition: xmipp_macros.h:374
#define j
#define FORWARD
Definition: blobs.cpp:1091
bool noisy_reconstruction
Noisy reconstruction.
Definition: basic_art.h:261
int force_sym
Force the reconstruction to be symmetric this number of times.
Definition: basic_art.h:196
bool getValue(MDObject &mdValueOut, size_t id) const override
#define proj_number(base, irot, itilt, ipsi)
Definition: project.cpp:559
void setEulerAngles(double rot, double tilt, double psi, const size_t n=0)
constexpr int CAV
Definition: projection.h:180
bool unmatched
Apply unmatched projectors to correct for the CTF.
Definition: basic_art.h:232
int no_it
Number of iterations.
Definition: basic_art.h:100
barrier_t project_barrier
Definition: projection.cpp:46
#define FINISHINGY(v)
constexpr int CAVARTK
Definition: projection.h:181
void write(const FileName &fn) const
Definition: grids.h:1196
MultidimArray< int > ordered_list
Order in which projections will be presented to algorithm.
Definition: basic_art.h:345
double rot
Rotational angle.
Definition: basic_art.h:67
#define TELL_SAVE_AT_EACH_STEP
Definition: basic_art.h:274
#define MAT_XSIZE(m)
Definition: matrix2d.h:120
constexpr int CAVK
Definition: projection.h:178
#define FIRST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:439
const SimpleGrid & grid(size_t n) const
Definition: grids.h:978
void produceSideInfo()
Produce Side information.
Definition: ctf.cpp:1392
project_thread_params * project_threads
Definition: projection.cpp:48
void iterations(GridVolume &vol_basis, int rank=-1)
String formatString(const char *format,...)
int ref_trans_after
Refine the translation alignement after n projection presentations.
Definition: basic_art.h:184
double tomographicDiffusion(MultidimArray< double > &V, const Matrix1D< double > &alpha, double lambda)
Definition: filters.cpp:2764
void IDWT(const MultidimArray< double > &v, MultidimArray< double > &result)
Definition: wavelet.cpp:159
int getNumber() const
void preProcess(GridVolume &vol_basis0, int level=FULL, int rank=-1)
Produce Plain side information from the Class parameters.
void read(const FileName &fn, const bool only_apply_shifts=false, DataMode datamode=DATA, MDRow *row=nullptr)
void forceDWTSparsity(MultidimArray< double > &V, double eps)
Definition: filters.cpp:3539
const int BLOB_SUBSAMPLING
Definition: basis.h:34
int sort_last_N
Sort perpendicular with the last N projections. If -1 with all previous.
Definition: basic_art.h:126
BasicARTParameters artPrm
FileName fn_ctf
Selection file with all images to process.
Definition: basic_art.h:229
bool enable_CTFnoise
Enable CTFnoise part.
Definition: ctf.h:273
#define LAST_XMIPP_INDEX(size)
Definition: xmipp_macros.h:448
int barrier_wait(barrier_t *barrier)
double lambda(int n)
Definition: basic_art.h:438
double diffusionWeight
Tomographic diffussion.
Definition: basic_art.h:193
void readParams(XmippProgram *program)
Definition: basic_art.cpp:269
Incorrect value received.
Definition: xmipp_error.h:195
void generateMask(MultidimArray< double > &v)
int threads
Number of threads to use. Can not be different than 1 when using MPI.
Definition: basic_art.h:267
double radius
Spatial radius in Universal System units.
Definition: blobs.h:115
Name of an image (std::string)
FileName fn_out
Name of the output volume, also used to set the root of rest output files.
Definition: basic_art.h:217
SymList SL
A list with the symmetry matrices.
Definition: basic_art.h:330
void applyMaskSpace(MultidimArray< double > &v)
#define IMGPIXEL(I, i, j)
std::vector< Projection > residual_imgs
Definition: basic_art.h:135
virtual 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)
Matrix1D< double > lambda_list
Relaxation parameter.
Definition: basic_art.h:103
bool do_not_generate_subgroup
Do not generate symmetry subgroup.
Definition: basic_art.h:199
ImageOver blobprint
Blob footprint.
Definition: basis.h:71