Perform all ART iterations. This function performs the iterations according to the ART parameters, it needs the side information to be fully computed. It throws a lot of information to the screen and to the history file (side.fh_hist), specially this one must exist.
The GridVolume must have as input an initial guess for the solution, and when this function finishes, it contains the final solution volume in basis.
The rank is the identification number of the process running this function. If it is -1, the function is run in sequential mode. If it is 0, then it is the root process.
This method is not virtual as it should be common for all ARTRecons classes.
53 int Xoutput_volume_size, Youtput_volume_size, Zoutput_volume_size;
70 double mean_error = 0.0;
71 double global_mean_error,global_mean_error_1stblock;
77 for (
int iact_proj = 0; iact_proj <
artPrm.
numIMG ; iact_proj++)
80 read_proj().setXmippOrigin();
81 read_proj().initZeros();
100 Xoutput_volume_size);
108 vol_basis_noisy = vol_basis;
116 vol_basis_out = vol_basis;
117 ptr_vol_out = &vol_basis_out;
130 ptr_vol_out = &vol_basis_out;
131 vol_basis_out = vol_basis;
137 ptr_vol_out = &vol_basis_out;
138 vol_basis_out = vol_basis;
144 ptr_vol_out = &vol_basis;
151 double mean_error_2ndblock,pow_residual_imgs;
152 bool iv_launched=
false;
156 global_mean_error = 0;
157 global_mean_error_1stblock = 0;
162 std::cout <<
"Running iteration " << it <<
" with lambda= " <<
artPrm.
lambda(it)<<
"\n" << std::endl;
168 for (
int act_proj = 0; act_proj <
artPrm.
numIMG ; act_proj++)
170 POCS.newProjection();
177 std::cout <<
"Introduce next projection to study: ";
182 std::cout <<
"Introduce symmetry to study: ";
183 std::cin >> sym_number;
202 read_proj().setXmippOrigin();
209 noisy_projection().resize(read_proj());
211 noisy_projection().setXmippOrigin();
215 if ( it == 0 && imgInfo.
sym==-1 )
221 noisy_projection.
write(fn_noise);
236 aux_tilt=read_proj.
tilt();
240 std::cout <<
"Skipping Proj no: " << iact_proj
241 <<
"tilt=" << read_proj.
tilt() << std::endl;
248 read_proj().selfWindow(
253 noisy_projection().resize(read_proj());
259 if( imgInfo.
sym != -1)
261 std::cout <<
"Skipping Proj no: " << iact_proj
262 <<
" with symmetry no: " << imgInfo.
sym 267 std::cout <<
"NO Skipping Proj no: " << iact_proj
268 <<
" with symmetry no: " << imgInfo.
sym 295 theo_proj, read_proj, imgInfo.
sym , diff_proj,
296 corr_proj, alig_proj,
298 images, imgInfo.
fn_ctf, maskPtr,
304 global_mean_error_1stblock += diff_proj().sum2()/(
XSIZE(diff_proj())*
YSIZE(diff_proj()));
307 global_mean_error += mean_error;
310 double noise_mean_error;
312 theo_proj, noisy_projection, imgInfo.
sym,
313 diff_proj, corr_proj, alig_proj,
315 images, imgInfo.
fn_ctf,maskPtr,
332 POCS.apply(vol_basis,it,images);
334 POCS.apply(vol_basis_noisy,it,images);
338 VC.newUpdateVolume(ptr_vol_out,read_proj);
344 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
350 std::cout <<
"Regularization error = " << regError << std::endl;
351 *
artPrm.
fh_hist <<
"Regularization error = " << regError << std::endl;
363 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
371 << imgInfo.
sym <<
"\t\t" << mean_error;
377 std::cout << imgInfo.
fn_proj <<
", sym=" 378 << imgInfo.
sym <<
"\t\t" << mean_error;
380 std::cout <<
"\tPOCS:" << POCS.POCS_mean_error;
381 std::cout << std::endl;
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();
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");
422 alig_proj.
write(
"PPPalign.xmp");
423 vol_basis.
write(
"PPPbasis.basis");
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");
433 if (system(
"xmipp_show -img PPPdiff.xmp PPPtheo.xmp PPPread.xmp PPPcorr.xmp -dont_apply_geo -poll &")==-1)
435 if (system(
"xmipp_show -vol PPPvol.vol -poll &")==-1)
439 std::cout <<
"\nHit any key and enter\n";
450 std::cout <<
"\nSaving intermediate ...\n" 451 <<
"Converting basis volume to voxels ...\n";
454 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
459 vol_voxels.
write(
"PPPvol.vol");
464 if (system(
"xmipp_show -i PPPvol.vol --poll &")==-1)
483 mean_error_2ndblock, pow_residual_imgs);
490 *
artPrm.
fh_hist <<
"Finished - Iteration " << it << std::endl;
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;
497 std::cout <<
" Global mean squared error: " 502 <<
" 1st block: " << global_mean_error_1stblock
503 <<
" 2nd block: " << mean_error_2ndblock
504 <<
" residual: " << pow_residual_imgs << std::endl;
511 std::cout <<
" POCS Global mean squared error: " 512 << POCS.POCS_global_mean_error/POCS.POCS_N << std::endl;
514 << POCS.POCS_global_mean_error/POCS.POCS_N << std::endl;
528 vol_basis=vol_basis_out;
532 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
539 DWT(vol_voxels(),vol_wavelets());
540 vol_wavelets_abs()=vol_wavelets();
541 vol_wavelets_abs().selfABS();
548 std::cout <<
"Threshold=" << threshold1 << std::endl;
549 vol_wavelets().threshold(
"abs_below", threshold1, 0.0);
550 IDWT(vol_wavelets(),vol_voxels());
554 Zoutput_volume_size);
563 std::cout <<
"Converting basis volume to voxels ...\n";
565 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
567 vol_voxels.
write(fn_tmp);
581 std::cout <<
"\nTime of " <<
artPrm.
no_it <<
" iterations: \n";
593 Zoutput_volume_size, Youtput_volume_size, Xoutput_volume_size);
Just to locate unclassified errors.
void init_progress_bar(long total)
MDRowVec row
Header information of projection.
int numIMG
Total number of images to process (taking symmetries into account)
void set_DWT_type(int DWT_type)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
size_t projXdim
Projection X dimension.
bool refine
Refine experimental projection before backprojecting.
Basis basis
Basis function. By default, blobs.
FileName removeLastExtension() const
#define REPORT_ERROR(nerr, ErrormMsg)
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)
void annotate_processor_time(ProcessorTimeStamp *time)
#define TELL_MANUAL_ORDER
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)
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
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 MULTIDIM_ARRAY(v)
double grid_relative_size
Relative size for the grid.
void compose(const String &str, const size_t no, const String &ext="")
const FileName & name() const
String integerToString(int I, int _width, char fill_with)
bool shiftedTomograms
Shifted tomograms.
double rot(const size_t n=0) const
std::ofstream * fh_hist
File handler for the history file.
bool variability_analysis
Variability analysis.
int save_intermidiate_every
Frequency for saving intermidiate.
size_t projYdim
Projection Y dimension.
void changeToVoxels(GridVolume &vol_basis, MultidimArray< double > *vol_voxels, int Zdim, int Ydim, int Xdim, int threads=1) const
void init_random_generator(int seed)
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
int grid_type
CC, BCC or FCC (in grids.hh)
double tilt(const size_t n=0) const
double sparseEps
Sparse reconstruction.
double tilt
Tilting angle.
bool apply_shifts
Apply shifts stored in the headers of the 2D-images.
void DWT(const MultidimArray< T > &v, MultidimArray< double > &result, int isign=1)
size_t getPrefixNumber(size_t pos=0) const
int stop_at
Stop after this number of images, if 0 then don't use.
struct tms ProcessorTimeStamp
ReconsInfo * IMG_Inf
Array with all the sorting information for each projection.
void progress_bar(long rlen)
#define TELL_SAVE_INTERMIDIATE
FileName fn_ctf
CTF filename.
#define DIRECT_MULTIDIM_ELEM(v, n)
ARTParallelMode parallel_mode
void print_elapsed_time(ProcessorTimeStamp &time, bool _IN_SECS)
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_proj
Projection filename.
void sort(struct DCEL_T *dcel)
#define NEXT_POWER_OF_2(x)
bool noisy_reconstruction
Noisy reconstruction.
#define proj_number(base, irot, itilt, ipsi)
void setEulerAngles(double rot, double tilt, double psi, const size_t n=0)
int no_it
Number of iterations.
void write(const FileName &fn) const
MultidimArray< int > ordered_list
Order in which projections will be presented to algorithm.
double rot
Rotational angle.
#define TELL_SAVE_AT_EACH_STEP
String formatString(const char *format,...)
double tomographicDiffusion(MultidimArray< double > &V, const Matrix1D< double > &alpha, double lambda)
void IDWT(const MultidimArray< double > &v, MultidimArray< double > &result)
void read(const FileName &fn, const bool only_apply_shifts=false, DataMode datamode=DATA, MDRow *row=nullptr)
void forceDWTSparsity(MultidimArray< double > &V, double eps)
BasicARTParameters artPrm
double diffusionWeight
Tomographic diffussion.
int threads
Number of threads to use. Can not be different than 1 when using MPI.
FileName fn_out
Name of the output volume, also used to set the root of rest output files.
SymList SL
A list with the symmetry matrices.
std::vector< Projection > residual_imgs