40 "Align and classify 3D images with missing data regions in Fourier space,");
42 "e.g. subtomograms or RCT reconstructions, by a 3D multi-reference refinement");
43 addUsageLine(
"based on a maximum-likelihood (ML) target function.");
45 "+++For several cases, this method has been shown to be able to both align and " 46 "classify in a completely *reference-free* manner, by starting from random assignments of " 47 "the orientations and classes. The mathematical details behind this approach are explained " 49 addUsageLine(
"+++Scheres et al. (2009) Structure, 17, 1563-1572",
true);
51 "+++*Please cite this paper if this program is of use to you!* %BR% " 52 "There also exists a standardized python script [[http://newxmipp.svn.sourceforge.net/viewvc/" 53 "newxmipp/trunk/xmipp/applications/scripts/protocols/protocol__mltomo.py]" 54 "[xmipp_protocol__mltomo.py]] for this program. " 55 "Thereby, rather than executing the command line options explained below, the user" 56 " can submit his jobs through a convenient GUI in the [[GettingStartedWithProtocols][Xmipp_protocols]], " 57 "although we still recommend reading this page carefully in order " 58 "to fully understand the options given in the protocol. Note that this protocol is available " 59 "from the main xmipp_protocols setup window by pressing the _Additional protocols_ button.)");
61 addUsageLine(
"See http://xmipp.cnb.csic.es/twiki/bin/view/Xmipp/Ml_tomo_v3 for further documentation");
63 " -i <metadata> : Metadata file with input images (and angles) ");
65 " --nref <int=0> : Number of references to generate automatically (recommended)");
67 " OR --ref <file=\"\"> : or metadata file with initial references/single reference image ");
68 addParamsLine(
" [ --oroot <rootname=mltomo> ] : Output rootname ");
74 " [ --missing <metadata=\"\"> ] : Metadata file with missing data region definitions");
78 " [ --ang <float=10.> ] : Angular sampling rate (in degrees)");
80 " [ --ang_search <float=-1.> ] : Angular search range around orientations from Metadata ");
82 " : (by default, exhaustive searches are performed)");
84 " [ --dont_limit_psirange ] : Exhaustive psi searches when using -ang_search (only for c1 symmetry)");
86 " [ --limit_trans <float=-1.> ] : Maximum allowed shifts (negative value means no restriction)");
88 " [ --tilt0+ <float=0> ] : Limit tilt angle search from tilt0 to tiltF (in degrees) ");
90 " [ --tiltF+ <float=180> ] : Limit tilt angle search from tilt0 to tiltF (in degrees) ");
92 " [ --psi_sampling+ <float=-1.> ] : Angular sampling rate for the in-plane rotations(in degrees)");
96 " [ --reg0 <float=0.> ] : Initial regularization parameters (in N/K^2) ");
98 " [ --regF <float=0.> ] : Final regularization parameters (in N/K^2) ");
100 " [ --reg_steps <int=5> ] : Number of iterations in which the regularization is changed from reg0 to regF");
104 " [ --dont_rotate ] : Keep orientations from Metadata fixed, only translate and classify ");
106 " [ --dont_align ] : Keep orientations and tran Metadata (otherwise start from random)");
108 " [ --only_average ] : Keep orientations and classes from docfile, only output weighted averages ");
110 " [ --perturb ] : Apply random perturbations to angular sampling in each iteration");
112 " [ --dim <int=-1> ] : Use downscaled (in fourier space) images of this size ");
114 " [ --maxres <float=0.5> ] : Maximum resolution (in pixel^-1) to use ");
116 " [ --thr <int=1> ] : Number of shared-memory threads to use in parallel ");
120 " [ --impute_iter <int=1> ] : Number of iterations for inner imputation loop ");
122 " [ --iter <int=25> ] : Maximum number of iterations to perform ");
124 " [ --istart <int=1> ] : number of initial iteration ");
126 " [ --noise <float=1.> ] : Expected standard deviation for pixel noise ");
128 " [ --offset <float=3.> ] : Expected standard deviation for origin offset [pix]");
130 " [ --frac <metadata=\"\"> ] : Metadata with expected model fractions (default: even distr.)");
132 " [ --restart <logfile> ] : restart a run with all parameters as in the logfile ");
134 " [ --fix_sigma_noise] : Do not re-estimate the standard deviation in the pixel noise ");
136 " [ --fix_sigma_offset] : Do not re-estimate the standard deviation in the origin offsets ");
138 " [ --fix_fractions] : Do not re-estimate the model fractions ");
139 addParamsLine(
" [ --eps <float=5e-5> ] : Stopping criterium ");
141 " [ --pixel_size <float=1> ] : Pixel size (in Anstrom) for resolution in FSC plots ");
144 " [ --mask <maskfile=\"\"> ] : Mask particles; only valid in combination with -dont_align ");
146 " [ --maxCC ] : Use constrained cross-correlation and weighted averaging instead of ML ");
148 " [ --dont_impute ] : Use weighted averaging, rather than imputation ");
150 " [ --noimp_threshold <float=1.>] : Threshold to avoid division by zero for weighted averaging ");
161 "+++ The input metadata should contain the =image= column = and =missingRegionNumber=, " 162 "indicating the subtomogran filename and the missing region number, respectively. It can" 163 "also contains columns with angles and shift information. The output will be a metadata" 164 "with the same format. Follow is an example:",
false);
180 "+++ 32_000001.scl 0.00 0.000000 0.000 0.000 0.000000 0.000000 0 0.000000 1",
183 "+++ 32_000002.scl 0.00 0.000000 0.000 0.000 0.000000 0.000000 0 0.000000 1",
206 "+++ The first column =missingRegionNumber= (starting at 1) is required for each type " 207 "of missing region, this number should appears in the input images metadata %BR% ",
210 "+++ Here =missingRegionType= can be one of the following: %BR% ",
false);
212 "+++ * =wedge_y= for a missing wedge where the tilt axis is along Y,",
215 "+++ colums =missingRegionThetaY0= and =missingRegionThetaYF= are used",
218 "+++ * =wedge_x= for a missing wedge where the tilt axis is along X,",
221 "+++ colums =missingRegionThetaX0= and =missingRegionThetaXF= are used",
224 "+++ * =pyramid= for a missing pyramid where the tilt axes are along Y and X,",
226 addExampleLine(
"+++ same columns as =wedge_y= and =wedge_x= are used",
229 "+++ * =cone= for a missing cone (pointing along Z) ",
231 addExampleLine(
"+++ column =missingRegionThetaY0= is used",
false);
242 char ** argv2 =
nullptr;
247 "restart procedure temporarily de-activated.... sorry!");
312 argv2 = (
char **)
argv;
313 for (
int i = 1;
i < argc2;
i++)
392 double LL, sumw_allrefs, sumcorr;
394 std::vector<double> conv;
395 double wsum_sigma_noise, wsum_sigma_offset;
396 std::vector<MultidimArray<double> > wsumimgs;
397 std::vector<MultidimArray<double> > wsumweds;
398 std::vector<MultidimArray<double> > fsc;
415 std::cout <<
" Multi-reference refinement: iteration " <<
iter <<
" of " 416 <<
Niter << std::endl;
418 for (
int refno = 0; refno <
nr_ref; refno++)
436 wsum_sigma_noise, wsum_sigma_offset, sumw);
451 maximization(wsumimgs, wsumweds, wsum_sigma_noise, wsum_sigma_offset, sumw,
452 sumcorr, sumw_allrefs, fsc,
iter);
500 std::cout <<
" Optimization converged!" << std::endl;
519 <<
" -----------------------------------------------------------------" 522 <<
" | Read more about this program in the following publication: |" 525 <<
" | Scheres et al. (2009) Structure, 17, 1563-1572 |" 531 <<
" | *** Please cite it if this program is of use to you! *** |" 534 <<
" -----------------------------------------------------------------" 536 std::cout <<
"--> Maximum-likelihood multi-reference refinement " 538 std::cout <<
" Input images : " <<
fn_sel <<
" (" 541 std::cout <<
" Reference image(s) : " <<
fn_ref << std::endl;
543 std::cout <<
" Number of references: : " <<
nr_ref << std::endl;
544 std::cout <<
" Output rootname : " <<
fn_root << std::endl;
548 <<
" degrees" << std::endl;
551 std::cout <<
" Local angular searches : " <<
ang_search <<
" degrees" 555 <<
" : but with complete psi searches" 560 std::cout <<
" Maximum allowed shifts : " <<
limit_trans <<
" pixels" 562 std::cout <<
" Symmetry group : " <<
fn_sym << std::endl;
563 std::cout <<
" Stopping criterium : " <<
eps << std::endl;
564 std::cout <<
" initial sigma noise : " <<
sigma_noise << std::endl;
565 std::cout <<
" initial sigma offset : " <<
sigma_offset << std::endl;
566 std::cout <<
" Maximum resolution : " <<
maxres <<
" pix^-1" 568 std::cout <<
" Use images of size : " <<
dim << std::endl;
571 std::cout <<
" Regularization from : " <<
reg0 <<
" to " <<
regF 572 <<
" in " <<
reg_steps <<
" steps" << std::endl;
576 std::cout <<
" Missing data info : " <<
fn_missing << std::endl;
578 std::cout <<
" Missing data treatment : imputation " << std::endl;
580 std::cout <<
" Missing data treatment : conventional division " 584 std::cout <<
" Initial model fractions : " <<
fn_frac << std::endl;
588 std::cout <<
" -> Skip rotational searches, only translate and classify " 593 std::cout <<
" -> Skip alignment, only classify " << std::endl;
595 std::cout <<
" -> Classify within mask " <<
fn_mask << std::endl;
600 <<
" -> Skip alignment and classification, only calculate weighted average " 606 <<
" -> Use constrained correlation coefficient instead of ML-imputation approach." 611 std::cout <<
" -> Perturb angular sampling." << std::endl;
615 std::cout <<
" -> Do not update estimates of model fractions." 620 std::cout <<
" -> Do not update sigma-estimate of origin offsets." 625 std::cout <<
" -> Do not update sigma-estimate of noise." << std::endl;
629 std::cout <<
" -> Using " <<
threads <<
" parallel threads" << std::endl;
633 <<
" -----------------------------------------------------------------" 647 FileName fn_img, fn_tmp, fn_base, fn_tmp2;
654 size_t xdim, ydim, zdim;
659 std::cerr<<
"Start produceSideInfo"<<std::endl;
679 String labelStr =
"WARNING: Labels ";
681 for (
int i = 0;
i < 6; ++
i)
688 std::cerr <<
"missing label: " << labels[
i] <<
" " << labelStr<<std::endl;
692 std::cerr << labelStr +
"are missing in input metadata and are filled with value 0.0" <<std::endl;
698 "and your missing region metadata contains more than one missing region");
702 std::cerr <<
"WARNING: missingRegionNumber is missing from input images metadata," 703 "column filled with unique missing region provided" <<std::endl;
711 if (xdim != ydim || xdim != zdim)
720 "dim should be smaller than the size of the images");
756 "option -mask is only valid in combination with -dont_align");
758 if (
Imask().computeMin() < 0. ||
Imask().computeMax() > 1.)
760 "mask should have values within the range [0,1]");
761 Imask().setXmippOrigin();
780 int dimb = (dim - 1) / 2;
781 for (
int z = 0, ii = 0;
z <
dim;
z++)
787 for (
int y = 0;
y <
dim;
y++)
793 for (
int xx = 0; xx <
hdim + 1; xx++, ii++)
798 if (
A3D_ELEM(cosine_mask,xx,yy,zz) > 0.)
817 "Options --dont_align, --dont_rotate and --only_average require that angle information is present in input images metadata");
825 (std::string)
"Invalid symmetry " +
fn_sym);
833 std::cout <<
" --> Using symmetry version of the code: " << std::endl;
835 <<
" [-psi, -tilt, -rot] is applied to the references, thereby " 837 std::cout <<
" tilt and psi are sampled on an hexagonal lattice, " 839 std::cout <<
" and rot is sampled linearly " << std::endl;
841 <<
" Note that --dont_limit_psirange option is not allowed.... " 846 "exhaustive psi-angle search only allowed for C1 symmetry");
902 std::vector<MultidimArray<double> > fsc;
908 std::vector<MetaDataVec> MDtmp(
nr_ref);
910 double my_rot, my_tilt, my_psi, resolution;
916 std::cerr<<
"Start generateInitialReferences"<<std::endl;
920 std::cerr <<
"DEBUG_JM: entering ProgMLTomo::generateInitialReferences" <<std::endl;
926 <<
" Generating initial references by averaging over random subsets" 934 Iave1().setXmippOrigin();
936 Iave2().setXmippOrigin();
945 for (
int refno = 0; refno <
nr_ref; ++refno)
953 for (
size_t objId : md.
ids())
957 Itmp().setXmippOrigin();
1007 calculateFsc(Iave1(), Iave2(), Msumwedge1, Msumwedge2, fsc[0],
1008 fsc[refno + 1], resolution);
1010 Msumwedge1 += Msumwedge2;
1031 Iave1() /= (double) Nsub;
1047 Iout() = Msumwedge1;
1058 std::cerr<<
"Finished generateInitialReferences"<<std::endl;
1082 std::cerr<<
"Start produceSideInfo2"<<std::endl;
1088 std::vector<Matrix1D<double> > Vdm;
1102 "Expecting missing region label 'missingRegionNumber' on input metadata");
1110 size_t count = 0, imgno;
1114 double rot, tilt,
psi;
1146 std::cerr <<
"r t p " << rot <<
" " << tilt <<
" " << psi <<std::endl;
1166 std::cerr <<
"myLastImg" <<
myLastImg <<std::endl;
1167 std::cerr <<
"ang_search " <<
ang_search << std::endl;
1169 std::cerr <<
"MDsub.size " << MDsub.
size() << std::endl;
1172 std::cerr <<
"exp_data_projection_direction_by_L_R " 1176 std::cerr <<
"no_redundant_sampling_points_vector" 1200 for (
const auto& row : MDsub)
1208 myinfo.
rot = -myinfo.
psi;
1229 for (
int ipsi = 0; ipsi < nr_psi; ipsi++)
1231 psi = (double) (ipsi * 360. / nr_psi);
1239 myinfo.
tilt = -tilt;
1263 for (
int angno = 0; angno <
nr_ang; angno++)
1275 for (
int angno = 0; angno <
nr_ang; angno++)
1289 fnt =
fn_root +
"_angles1.doc";
1298 img().setXmippOrigin();
1299 for (
int refno = 0; refno <
nr_ref; refno++)
1301 Iref.push_back(img);
1302 Iold.push_back(img);
1315 img().setXmippOrigin();
1333 Iref.push_back(img);
1334 Iold.push_back(img);
1345 double sumfrac = 0.;
1361 if (
ABS(sumfrac - 1.) > 1e-3)
1363 std::cerr <<
" ->WARNING: Sum of all expected model fractions (" 1364 << sumfrac <<
") is not one!" << std::endl;
1365 for (
int refno = 0; refno <
nr_ref; refno++)
1387 std::cerr<<
"nr_ref= "<<
nr_ref<<std::endl;
1388 std::cerr<<
"nr_miss= "<<
nr_miss<<std::endl;
1389 std::cerr<<
"dim= "<<
dim<<std::endl;
1390 std::cerr<<
"Finished produceSideInfo"<<std::endl;
1391 std::cerr<<
"nr_ang= "<<nr_ang<<std::endl;
1397 std::cerr<<
"Finished produceSideInfo2"<<std::endl;
1407 double ran1, ran2, ran3;
1418 #ifdef DEBUG_PERTURB 1420 std::cerr<<
" random perturbation= "<<ran1<<
" "<<ran2<<
" "<<ran3<<std::endl;
1423 for (
int angno = 0; angno <
nr_ang; angno++)
1455 emptyMissingInfo.
do_cone =
false;
1456 emptyMissingInfo.
thx0 = emptyMissingInfo.
thxF = emptyMissingInfo.
thy0 =
1457 emptyMissingInfo.
thyF = 0.;
1458 emptyMissingInfo.
tg0_x = emptyMissingInfo.
tgF_x = emptyMissingInfo.
tg0_y =
1459 emptyMissingInfo.
tgF_y = 0.;
1473 if (missingType ==
"wedge_y")
1475 else if (missingType ==
"wedge_x")
1477 else if (missingType ==
"pyramid")
1479 else if (missingType ==
"cone")
1484 formatString(
"Unrecognized type of missing region: '%s'", missingType.c_str()));
1491 myinfo.
tg0_y = -tan(
PI * (-90. - myinfo.
thyF) / 180.);
1492 myinfo.
tgF_y = -tan(
PI * (90. - myinfo.
thy0) / 180.);
1499 myinfo.
tg0_x = -tan(
PI * (-90. - myinfo.
thxF) / 180.);
1500 myinfo.
tgF_x = -tan(
PI * (90. - myinfo.
thx0) / 180.);
1506 myinfo.
tg0_y = -tan(
PI * (-90. - myinfo.
thy0) / 180.);
1531 std::cerr <<
" DEBUG_JM: entering ProgMLTomo::getMissingRegion" <<std::endl;
1532 std::cerr <<
" DEBUG_JM: missno: " << missno << std::endl;
1535 if (missno < 0 || missno >=
nr_miss)
1538 "ProgMLTomo::getMissingRegion: missno should be between 0 and nr_miss - 1");
1542 double limx0 = 0., limxF = 0., limy0 = 0., limyF = 0., lim = 0.;
1551 std::cerr<<
"do_limit_x= "<<do_limit_x<<std::endl;
1552 std::cerr<<
"do_limit_y= "<<do_limit_y<<std::endl;
1553 std::cerr<<
"do_cone= "<<do_cone<<std::endl;
1554 std::cerr<<
"tg0_y= "<<tg0_y<<std::endl;
1555 std::cerr<<
"tgF_y= "<<tgF_y<<std::endl;
1556 std::cerr<<
"tg0_x= "<<tg0_x<<std::endl;
1557 std::cerr<<
"tgF_x= "<<tgF_x<<std::endl;
1559 std::cerr<<
"Ainv= "<<Ainv<<
" A= "<<A<<std::endl;
1563 int dimb = (
dim - 1) / 2;
1564 double Ainv_zz_x, Ainv_zz_y, Ainv_zz_z;
1565 double Ainv_yy_x, Ainv_yy_y, Ainv_yy_z;
1567 for (
int z = 0, ii = 0;
z <
dim; ++
z)
1569 zz = (
z > dimb ) ?
z - dim :
z;
1570 Ainv_zz_x =
dMij(Ainv, 0, 2) * zz;
1571 Ainv_zz_y =
dMij(Ainv, 1, 2) * zz;
1572 Ainv_zz_z =
dMij(Ainv, 2, 2) * zz;
1574 for (
int y = 0;
y <
dim; ++
y)
1576 yy = (
y > dimb ) ?
y - dim :
y;
1577 Ainv_yy_x = Ainv_zz_x +
dMij(Ainv, 0, 1) * yy;
1578 Ainv_yy_y = Ainv_zz_y +
dMij(Ainv, 1, 1) * yy;
1579 Ainv_yy_z = Ainv_zz_z +
dMij(Ainv, 2, 1) * yy;
1581 for (
int xx = 0; xx <
hdim + 1; ++xx, ++ii)
1592 xp =
dMij(Ainv, 0, 0) * xx + Ainv_yy_x;
1593 yp =
dMij(Ainv, 1, 0) * xx + Ainv_yy_y;
1594 zp =
dMij(Ainv, 2, 0) * xx + Ainv_yy_z;
1599 lim = myinfo.
tg0_y * zp;
1601 is_observed = (xp * xp + yp * yp >= lim);
1605 is_observed =
false;
1608 limx0 = myinfo.
tg0_y * zp;
1609 limxF = myinfo.
tgF_y * zp;
1611 is_observed = (xp <= limx0 || xp >= limxF);
1613 is_observed = (xp <= limxF || xp >= limx0);
1617 limy0 = myinfo.
tg0_x * zp;
1618 limyF = myinfo.
tgF_x * zp;
1620 is_observed = (yp <= limy0 || yp >= limyF);
1622 is_observed = (yp <= limyF || yp >= limy0);
1638 ori.
write(
"oriwedge.fft");
1650 test.write(
"wedge.ftt");
1652 test.write(
"Fwedge.vol");
1653 test().setXmippOrigin();
1659 test.write(
"Mwedge.vol");
1663 std::cerr <<
" DEBUG_JM: leaving ProgMLTomo::getMissingRegion" <<std::endl;
1673 std::cerr<<
"start calculatePdfTranslations"<<std::endl;
1684 r2 = (double) (
j *
j +
i *
i +
k *
k);
1693 pdfpix *= pow(2. *
PI * sigma_offset * sigma_offset, -3. / 2.);
1697 if (k == 0 &&
i == 0 &&
j == 0)
1715 #ifdef DEBUG_PDF_SHIFT 1716 std::cerr<<
" Sum of translation pdfs (should be one) = "<<
P_phi.
sum()<<std::endl;
1719 Vt.
write(
"pdf.vol");
1724 std::cerr<<
"finished calculatePdfTranslations"<<std::endl;
1732 double outside_density = 0., sumdd = 0.;
1739 outside_density /= sumdd;
1761 local_transformer_in.
setReal(Min);
1764 Mout.
resize(newdim, newdim, newdim);
1766 local_transformer_out.
setReal(Mout);
1777 #ifdef DEBUG_RESCALE_VOLUME 1781 Vt.
write(
"Min.vol");
1783 Vt.
write(
"Mout.vol");
1797 std::cerr<<
"start postProcessVolume"<<std::endl;
1810 if (resolution > 0.)
1813 double raised_w = 0.02;
1814 double w1 = resolution;
1815 double w2 = w1 + raised_w;
1822 double absw = w.
module();
1825 else if (absw > w1 && absw < w2)
1844 <<
" WARNING: Symmetrization and dont_impute together are not implemented correctly...\n Proceed at your own risk" 1851 Vaux().setXmippOrigin();
1856 R(3, 0) = sh(0) *
dim;
1857 R(3, 1) = sh(1) *
dim;
1858 R(3, 2) = sh(2) *
dim;
1868 std::cerr<<
"finished postProcessVolume"<<std::endl;
1879 std::cerr<<
"start precalculateA2"<<std::endl;
1886 std::cerr <<
"DEBUG_JM: entering ProgMLTomo::precalculateA2" <<std::endl;
1889 double AA, stdAA, corr;
1899 for (
int refno = 0; refno <
nr_ref; refno++)
1903 for (
int angno = 0; angno <
nr_ang; angno++)
1911 #ifdef DEBUG_PRECALC_A2_ROTATE 1915 Vt.
write(
"rot.vol");
1917 Vt.
write(
"ref.vol");
1919 std::cerr<<
" Written volume rot.vol and ref.vol, press any key to continue ..."<<std::endl;
1929 corr =
sqrt(stdAA / AA);
1941 for (
int missno = 0; missno <
nr_miss; ++missno)
1949 A2.push_back(Maux.
sum2());
1951 #ifdef DEBUG_PRECALC_A2 1954 std::cerr<<
"refno= "<<refno<<
" angno= "<<angno<<
" missno= "<<missno<<
" A2= "<<Maux.
sum2()<<
" corrA2= "<<corr<<std::endl;
1956 #ifdef DEBUG_PRECALC_A2_b 1960 tt.
write(
"refrotwedge.vol");
1961 std::cerr<<
"press any key"<<std::endl;
1971 A2.push_back(Maux.
sum2());
1972 #ifdef DEBUG_PRECALC_A2 1974 std::cerr<<
"refno= "<<refno<<
" angno= "<<angno<<
" A2= "<<Maux.
sum2()<<std::endl;
1982 std::cerr<<
"finished precalculateA2"<<std::endl;
1995 double &dLL,
double &fracweight,
double &sumfracweight,
double &trymindiff,
2000 std::cerr<<
"start expectationSingleImage"<<std::endl;
2010 std::cerr <<
"DEBUG_JM: entering ProgMLTomo::expectationSingleImage" <<std::endl;
2011 std::cerr <<
" DEBUG_JM: imgno: " << imgno << std::endl;
2012 std::cerr <<
"DEBUG_JM: missno: " << missno << std::endl;
2020 std::complex<double> complex_zero=0;
2021 std::vector<MultidimArray<double> > mysumimgs;
2022 std::vector<MultidimArray<double> > mysumweds;
2024 double sigma_noise2, aux, pdf, fracpdf, myA2, mycorrAA, myXi2, A2_plus_Xi2,
2026 double diff, mindiff, my_mindiff;
2027 double my_sumweight, weight;
2028 double wsum_sc, wsum_sc2, wsum_offset;
2029 double wsum_corr, sum_refw, maxweight, my_maxweight;
2031 int ioptx = 0, iopty = 0, ioptz = 0;
2032 bool is_ok_trymindiff =
false;
2033 int my_nr_ang, old_optangno = opt_angno, old_optrefno = opt_refno;
2034 std::vector<double> all_Xi2;
2036 bool is_a_neighbor, is_within_psirange =
true;
2055 Mweight.
initZeros(sigdim, sigdim, sigdim);
2069 "BUG: !dont_align and do_mask cannot coincide at this stage...");
2072 A_rot_inv = A_rot.
inv();
2091 myXi2 = Maux.
sum2();
2103 if (trymindiff < 0.)
2106 int redo_counter = 0;
2107 while (!is_ok_trymindiff)
2111 wsum_corr = wsum_offset = wsum_sc = wsum_sc2 = 0.;
2112 maxweight = sum_refw = 0.;
2113 mysumimgs.assign(
nr_ref, Mzero2);
2115 mysumweds.assign(
nr_ref, Mzero);
2122 for (
int aa = old_optangno; aa < old_optangno + my_nr_ang; aa++)
2131 is_a_neighbor =
false;
2141 is_within_psirange =
true;
2148 is_within_psirange =
true;
2150 is_within_psirange =
false;
2160 is_a_neighbor =
true;
2168 is_a_neighbor =
true;
2175 A_rot_inv = A_rot.
inv();
2181 for (
int rr = old_optrefno; rr < old_optrefno +
nr_ref; rr++)
2184 if (refno >= nr_ref)
2193 Maux = Maux2 * mycorrAA;
2199 A2_plus_Xi2 = 0.5 * (myA2 + myXi2);
2209 my_sumweight = my_maxweight = 0.;
2219 diff = A2_plus_Xi2 - myXA;
2222 #ifdef DEBUG_MINDIFF 2226 std::cerr<<
"k= "<<
k<<
" j= "<<
j<<
" i= "<<
i<<std::endl;
2230 std::cerr<<
"diff= "<<diff<<
" A2_plus_Xi"<<std::endl;
2231 std::cerr<<
" mycorrAA= "<<mycorrAA<<
" "<<std::endl;
2232 std::cerr<<
"debug mindiff= " <<mindiff<<
" trymindiff= "<<trymindiff<< std::endl;
2233 std::cerr<<
"A2_plus_Xi2= "<<A2_plus_Xi2<<
" myA2= "<<myA2<<
" myXi2= "<<myXi2<<std::endl;
2237 tt.
write(
"Maux.vol");
2239 tt.
write(
"Mweight.vol");
2240 std::cerr<<
"Ainv= "<<A_rot_inv<<std::endl;
2241 std::cerr<<
"A= "<<A_rot_inv.
inv()<<std::endl;
2246 aux = (diff - trymindiff) / sigma_noise2;
2251 weight = exp(-aux) * pdf;
2254 my_sumweight += weight;
2256 wsum_corr += weight * diff;
2260 my_maxweight =
XMIPP_MAX(my_maxweight, weight);
2261 if (weight > maxweight)
2279 std::cout<<
" imgno= "<<imgno<<
" refno= "<<refno<<
" angno= "<<angno<<
" A2= "<<myA2<<
" <<Xi2= "<<myXi2<<
" my_maxweight= "<<my_maxweight<<std::endl;
2282 sum_refw += my_sumweight;
2283 refw(refno) += my_sumweight;
2319 mysumimgs[refno] += Maux *
ddim3;
2329 if (
ABS((mindiff - trymindiff) / sigma_noise2) > 500.)
2333 #ifdef DEBUG_REDOCOUNTER 2334 std::cerr<<
"repeating mindiff "<<redo_counter<<
"th time"<<std::endl;
2335 std::cerr<<
"trymindiff= "<<trymindiff<<
" mindiff= "<<mindiff<<std::endl;
2336 std::cerr<<
"diff= "<<
ABS((mindiff - trymindiff) / sigma_noise2)<<std::endl;
2339 trymindiff = mindiff;
2342 if (redo_counter > 1)
2347 is_ok_trymindiff =
true;
2348 my_mindiff = trymindiff;
2349 trymindiff = mindiff;
2353 fracweight = maxweight / sum_refw;
2354 wsum_sc /= sum_refw;
2355 wsum_sc2 /= sum_refw;
2359 XX(opt_offsets) = -(double) ioptx;
2360 YY(opt_offsets) = -(double) iopty;
2361 ZZ(opt_offsets) = -(double) ioptz;
2367 wsum_sigma_noise += (2 * wsum_corr / sum_refw);
2368 wsum_sigma_offset += (wsum_offset / sum_refw);
2369 sumfracweight += fracweight;
2372 for (
int refno = 0; refno <
nr_ref; refno++)
2374 sumw(refno) += refw(refno) / sum_refw;
2376 wsumimgs[iran_fsc * nr_ref + refno] += (mysumimgs[refno]) / sum_refw;
2379 wsumweds[iran_fsc * nr_ref + refno] += mysumweds[refno] / sum_refw;
2390 log(sum_refw) - my_mindiff / sigma_noise2
2394 dLL =
log(sum_refw) - my_mindiff / sigma_noise2
2402 std::cerr <<
" DEBUG_JM: my_mindiff: " << my_mindiff << std::endl;
2403 std::cerr <<
" DEBUG_JM: sigma_noise2: " << sigma_noise2 << std::endl;
2406 std::cerr <<
" DEBUG_JM: sum_refw: " << sum_refw << std::endl;
2407 std::cerr <<
" DEBUG_JM: wsum_sigma_noise: " << wsum_sigma_noise << std::endl;
2408 std::cerr <<
" DEBUG_JM: wsum_sigma_offset: " << wsum_sigma_offset << std::endl;
2409 std::cerr <<
" DEBUG_JM: sumfracweight: " << sumfracweight << std::endl;
2410 std::cerr <<
" DEBUG_JM: dLL: " << dLL << std::endl;
2411 std::cerr <<
" DEBUG_JM: LL: " << LL << std::endl;
2412 std::cerr <<
"DEBUG_JM: leaving ProgMLTomo::expectationSingleImage" <<std::endl;
2418 std::cerr<<
"finished expectationSingleImage"<<std::endl;
2428 double &maxCC,
double &sumCC,
int &opt_refno,
int &opt_angno,
2433 std::cerr<<
"start maxConstrainedCorrSingleImage"<<std::endl;
2441 std::cerr <<
"DEBUG_JM: entering ProgMLTomo::maxConstrainedCorrSingleImage" <<std::endl;
2449 std::complex<double> complex_zero=0;
2451 double img_stddev, ref_stddev, corr, maxcorr = -9999.;
2452 int ioptx=0, iopty=0, ioptz=0;
2453 int my_nr_ang, old_optangno = opt_angno, old_optrefno = opt_refno;
2454 bool is_within_psirange =
true;
2467 "BUG: !dont_align and do_mask cannot coincide at this stage...");
2470 A_rot_inv = A_rot.
inv();
2498 opt_angno = old_optangno;
2499 opt_refno = old_optrefno;
2506 for (
int aa = old_optangno; aa < old_optangno + my_nr_ang; aa++)
2515 is_a_neighbor =
false;
2525 is_within_psirange =
true;
2532 is_within_psirange =
true;
2534 is_within_psirange =
false;
2544 is_a_neighbor =
true;
2552 is_a_neighbor =
true;
2558 A_rot_inv = A_rot.
inv();
2565 for (
int rr = old_optrefno; rr < old_optrefno +
nr_ref; rr++)
2568 if (refno >= nr_ref)
2603 static size_t jjjj=1;
2604 Maux.
write(
"kk.spi");
2609 std::cerr << s <<std::endl;
2616 corr =
A3D_ELEM(Maux,0,0,0) / (img_stddev * ref_stddev);
2631 corr =
A3D_ELEM(Maux,
k,
i,
j) / (img_stddev * ref_stddev);
2650 XX(opt_offsets) = -(double) ioptx;
2651 YY(opt_offsets) = -(double) iopty;
2652 ZZ(opt_offsets) = -(double) ioptz;
2682 sumw(opt_refno) += 1.;
2683 wsumimgs[iran_fsc *
nr_ref + opt_refno] += Mimg0;
2695 std::cerr<<
"finished maxConstrainedCorrSingleImage"<<std::endl;
2704 auto * thread_data =
2708 int thread_id = thread_data->thread_id;
2711 double *wsum_sigma_noise = thread_data->wsum_sigma_noise;
2712 double *wsum_sigma_offset = thread_data->wsum_sigma_offset;
2713 double *sumfracweight = thread_data->sumfracweight;
2714 double *LL = thread_data->LL;
2715 std::vector<MultidimArray<double> > *wsumimgs = thread_data->wsumimgs;
2716 std::vector<MultidimArray<double> > *wsumweds = thread_data->wsumweds;
2717 std::vector<Image<double> > *
Iref = thread_data->Iref;
2720 std::vector<size_t> *
imgs_id = thread_data->imgs_id;
2726 std::cerr<<
"start threadMLTomoExpectationSingleImage"<<std::endl;
2732 std::vector<MultidimArray<double> > allref_offsets;
2734 float old_psi = -999.;
2735 double fracweight, trymindiff, dLL;
2736 int opt_refno, opt_angno, missno;
2743 size_t firstIndex, lastIndex;
2745 if (prm->
verbose && thread_id == 0)
2753 while (distributor->
getTasks(firstIndex, lastIndex))
2755 for (
size_t imgno = firstIndex; imgno <= lastIndex; ++imgno)
2766 img().setXmippOrigin();
2784 *wsumimgs, *wsumweds, *wsum_sigma_noise, *wsum_sigma_offset,
2785 *sumw, *LL, dLL, fracweight, *sumfracweight, trymindiff,
2786 opt_refno, opt_angno, opt_offsets);
2792 *Iref, *wsumimgs, *wsumweds, *sumw, fracweight, *sumfracweight,
2793 opt_refno, opt_angno, opt_offsets);
2816 dAij(docfiledata, imgno, 6) = (double) (opt_refno + 1);
2817 dAij(docfiledata, imgno, 7) = (double) (missno + 1);
2819 dAij(docfiledata, imgno, 8) = fracweight;
2820 dAij(docfiledata, imgno, 9) = dLL;
2822 if (prm->
verbose && thread_id == 0)
2827 if (prm->
verbose && thread_id == 0)
2833 std::cerr<<
"finished threadMLTomoExpectationSingleImage"<<std::endl;
2840 int iter,
double &LL,
double &sumfracweight,
2847 std::cerr<<
"start expectation"<<std::endl;
2868 wsum_sigma_noise = 0.;
2869 wsum_sigma_offset = 0.;
2880 wsumimgs.assign(2 *
nr_ref, Mzero2);
2881 wsumweds.assign(2 *
nr_ref, Mzero);
2883 auto * th_ids = (pthread_t *) malloc(
threads *
sizeof(pthread_t));
2889 threads_d[
c].thread_id =
c;
2891 threads_d[
c].prm =
this;
2892 threads_d[
c].MDimg = &
MDimg;
2893 threads_d[
c].iter = &
iter;
2894 threads_d[
c].wsum_sigma_noise = &wsum_sigma_noise;
2895 threads_d[
c].wsum_sigma_offset = &wsum_sigma_offset;
2896 threads_d[
c].sumfracweight = &sumfracweight;
2897 threads_d[
c].LL = &LL;
2898 threads_d[
c].wsumimgs = &wsumimgs;
2899 threads_d[
c].wsumweds = &wsumweds;
2900 threads_d[
c].Iref = &
Iref;
2901 threads_d[
c].sumw = &sumw;
2910 pthread_join(*(th_ids +
c),
nullptr);
2929 std::cerr<<
"finished expectation"<<std::endl;
2939 double &sumfracweight,
double &sumw_allrefs,
2943 std::cerr<<
"started maximization"<<std::endl;
2951 std::vector<double> refs_resol(
nr_ref);
2958 for (
int refno = 0; refno <
nr_ref; refno++)
2960 calculateFsc(wsumimgs[refno], wsumimgs[nr_ref + refno], wsumweds[refno],
2961 wsumweds[nr_ref + refno], fsc[0], fsc[refno + 1], refs_resol[refno]);
2963 wsumimgs[refno] += wsumimgs[nr_ref + refno];
2964 wsumweds[refno] += wsumweds[nr_ref + refno];
2970 for (
int refno = 0; refno <
nr_ref; refno++)
2972 sumw_allrefs += sumw(refno);
2976 Msumallwedges += wsumweds[refno];
2981 if (sumw(refno) > 0.)
2984 for (
int iter2 = 0; iter2 <
Niter2; iter2++)
3021 if (sumw(refno) > 0.)
3036 sumfracweight /= sumw_allrefs;
3041 for (
int refno = 0; refno <
nr_ref; refno++)
3043 if (sumw(refno) > 0.)
3044 alpha_k(refno) = sumw(refno) / sumw_allrefs;
3061 double sum_complete_wedge = 0.;
3062 double sum_complete_fourier = 0.;
3066 if (
j <
XSIZE(Msumallwedges))
3076 (dim-
k)%dim,(dim-
i)%dim,dim-
j);
3080 #ifdef DEBUG_UPDATE_SIGMA 3081 std::cerr<<
" sum_complete_wedge= "<<sum_complete_wedge<<
" = "<<100*sum_complete_wedge/(sumw_allrefs*sum_complete_fourier)<<
"%"<<std::endl;
3082 std::cerr<<
" ddim3= "<<
ddim3<<std::endl;
3083 std::cerr<<
" sum_complete_fourier= "<<sum_complete_fourier<<std::endl;
3084 std::cerr<<
" sumw_allrefs= "<<sumw_allrefs<<std::endl;
3085 std::cerr<<
" wsum_sigma_noise= "<<wsum_sigma_noise<<std::endl;
3086 std::cerr<<
" sigma_noise_old= "<<
sigma_noise<<std::endl;
3087 std::cerr<<
" sigma_new_impute= "<<
sqrt((
sigma_noise*
sigma_noise*(sumw_allrefs*sum_complete_fourier - sum_complete_wedge ) + wsum_sigma_noise)/(sumw_allrefs * sum_complete_fourier))<<std::endl;
3088 std::cerr<<
" sigma_new_noimpute= "<<
sqrt(wsum_sigma_noise / (sum_complete_wedge))<<std::endl;
3089 std::cerr<<
" sigma_new_nomissing= "<<
sqrt(wsum_sigma_noise / (sumw_allrefs * sum_complete_fourier))<<std::endl;
3094 for (
int iter2 = 0; iter2 <
Niter2; iter2++)
3097 sigma_noise *= sumw_allrefs * sum_complete_fourier
3098 - sum_complete_wedge;
3101 sigma_noise / (sumw_allrefs * sum_complete_fourier));
3119 for (
int refno = 0; refno <
nr_ref; refno++)
3132 std::cerr<<
"finished maximization"<<std::endl;
3147 int vsize =
hdim + 1;
3175 std::complex<double> z1 = w2 *
dAkij(FT1,
k,
i,
j);
3176 std::complex<double> z2 = w1 *
dAkij(FT2,
k,
i,
j);
3177 double absz1 =
abs(z1);
3178 double absz2 =
abs(z2);
3179 num(idx) += real(
conj(z1) * z2);
3180 den1(idx) += absz1 * absz1;
3181 den2(idx) += absz2 * absz2;
3188 fsc(
i) = num(
i) /
sqrt(den1(
i) * den2(
i));
3195 for (idx = 1; idx <
XSIZE(freq); idx++)
3199 resolution = freq(idx);
3206 std::cerr<<freq(
i)<<
" "<<fsc(
i)<<std::endl;
3208 std::cerr<<
"resolution= "<<resolution<<std::endl;
3225 std::cerr<<
"start regularize"<<std::endl;
3229 for (
int refno = 0; refno <
nr_ref; refno++)
3233 Iref[refno].write(fnt);
3239 double sum_diff2 = 0.;
3242 #ifdef DEBUG_REGULARISE 3244 std::cerr<<
"written out oriref volumes"<<std::endl;
3248 for (
int refno = 0; refno <
nr_ref; refno++)
3251 Mavg =
Iref[refno]();
3253 Mavg +=
Iref[refno]();
3254 for (
int refno2 = 0; refno2 <
nr_ref; refno2++)
3256 Mdiff =
Iref[refno]() -
Iref[refno2]();
3257 sum_diff2 += Mdiff.
sum2();
3261 Favg *= std::complex<double>(reg_norm, 0.);
3262 #ifdef DEBUG_REGULARISE 3264 std::cerr<<
"calculated Favg"<<std::endl;
3268 for (
int refno = 0; refno <
nr_ref; refno++)
3273 #ifdef DEBUG_REGULARISE 3276 std::cerr<<
"refno= "<<refno<<
" sumw = "<<sumw<<
" reg_current= "<<
reg_current<<
" reg_norm= "<<reg_norm<<
" Fref1= "<<
DIRECT_MULTIDIM_ELEM(Fref,1) <<
" Favg1= "<<
DIRECT_MULTIDIM_ELEM(Favg,1)<<
" (sumw + nr_ref * reg_norm)= "<<(sumw + nr_ref * reg_norm)<<std::endl;
3279 Fref *= std::complex<double>(sumw, 0.);
3281 Fref /= std::complex<double>((sumw + nr_ref * reg_norm), 0.);
3282 #ifdef DEBUG_REGULARISE 3296 #ifdef DEBUG_REGULARISE 3299 std::cerr<<
"reg_sigma_noise2= "<<reg_sigma_noise2<<
" nr_exp_images="<<
nr_images_global<<
" ddim3= "<<
ddim3<<
" sigma_noise= "<<
sigma_noise<<
" sum_diff2= "<<sum_diff2<<
" reg_norm= "<<reg_norm<<std::endl;
3302 reg_sigma_noise2 += reg_norm * sum_diff2;
3305 #ifdef DEBUG_REGULARISE 3308 std::cerr<<
"new sigma_noise= "<<
sigma_noise<<std::endl;
3314 std::cerr<<
"finished regularize"<<std::endl;
3324 std::cerr<<
"started checkConvergence"<<std::endl;
3327 bool converged =
true;
3335 for (
int refno = 0; refno <
nr_ref; refno++)
3339 Maux =
Iold[refno]() *
Iold[refno]();
3341 Maux =
Iold[refno]() -
Iref[refno]();
3344 conv.push_back(convv);
3350 conv.push_back(-1.);
3355 std::cerr<<
"finished checkConvergence"<<std::endl;
3364 size_t first,
size_t last)
3369 for (
size_t imgno = first; imgno <= last; ++imgno)
3371 index = imgno -
first ;
3389 double &LL,
double &avefracweight, std::vector<double> &conv,
3398 std::string comment;
3417 fn_tmp =
formatString(
"%s_ref%06d.mrc", fn_base.c_str(), refno + 1);
3437 Vt().setXmippOrigin();
3449 dim-
j) / sumw_allrefs;
3453 fn_tmp =
formatString(
"%s_wedge%06d.mrc", fn_base.c_str(), refno + 1);
3458 fn_tmp = fn_base +
"_ref.xmd";
3460 fn_tmp =
fn_root +
"_ref.xmd";
3483 fn_tmp = fn_base +
".fsc";
3484 for (
int refno = 0; refno <
nr_ref; refno++)
3486 for (
int idx = 1; idx <
hdim + 1; idx++)
3497 fn_tmp = fn_base +
"_img.xmd";
3512 fn_tmp = fn_base +
"_img.xmd";
3514 fn_tmp = fn_base +
"_ref.xmd";
3517 fn_tmp = fn_base +
"_log.xmd";
3537 fn_tmp =
fn_root +
"_ref.xmd";
3538 for (
int refno = 0; refno <
nr_ref; refno++)
bool checkParameter(int argc, const char **argv, const char *param)
void init_progress_bar(long total)
void selfWindow(int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T init_value=0)
void setSampling(double sampling)
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
alglib::complex conj(const alglib::complex &z)
double getDoubleParam(const char *param, int arg=0)
void regularize(int iter)
Apply regularization.
bool do_missing
Internally store all missing wedges or re-compute on the fly?
void getMatrices(int i, Matrix2D< double > &L, Matrix2D< double > &R, bool homogeneous=true) const
Just an error for debugging purpose.
bool mdimg_contains_angles
std::vector< int > imgs_optrefno
#define SIGNIFICANT_WEIGHT_LOW
#define REPORT_ERROR(nerr, ErrormMsg)
Error with some arguments dependencies.
void Euler_angles2matrix(T alpha, T beta, T gamma, Matrix2D< T > &A, bool homogeneous)
void resizeNoCopy(const MultidimArray< T1 > &v)
std::vector< double > corrA2
void calculatePdfTranslations()
Calculate probability density distribution for in-plane transformations.
void BinaryWedgeMask(MultidimArray< int > &mask, double theta0, double thetaF, const Matrix2D< double > &A, bool centerOrigin)
MultidimArray< double > P_phi
Just for debugging, situation that can't happens.
void sqrt(Image< double > &op)
void BinaryCircularMask(MultidimArray< int > &mask, double radius, int mode, double x0, double y0, double z0)
std::vector< Image< double > > Iold
MultidimArray< double > alpha_k
MultidimArray< double > fourier_mask
void setNeighborhoodRadius(double neighborhood)
void setValue(const MDObject &object) override
int readSymmetryFile(FileName fn_sym, double accuracy=SYM_ACCURACY)
virtual void expectation(MetaDataVec &MDimg, std::vector< Image< double > > &Iref, int iter, double &LL, double &sumfracweight, std::vector< MultidimArray< double > > &wsumimgs, std::vector< MultidimArray< double > > &wsumweds, double &wsum_sigma_noise, double &wsum_sigma_offset, MultidimArray< double > &sumw)
Integrate over all experimental images.
bool getTasks(size_t &first, size_t &last)
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 isSymmetryGroup(FileName fn_sym, int &pgGroup, int &pgOrder)
std::vector< Matrix1D< double > > no_redundant_sampling_points_vector
MultidimArray< double > Mr2
void computeNeighbors(bool only_winner=false)
void reScaleVolume(MultidimArray< double > &Min, bool down_scale=true)
void inv(Matrix2D< T > &result) const
void abs(Image< double > &op)
MultidimArray< double > docfiledata
bool checkConvergence(std::vector< double > &conv)
check convergence
Matrix2D< T > transpose() const
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY3D(V)
void removeRedundantPointsExhaustive(const int symmetry, int sym_order, bool only_half_sphere, double max_ang)
virtual void generateInitialReferences()
Generate initial references from random subset averages.
Incorrect MultidimArray size.
void expectationSingleImage(MultidimArray< double > &Mimg, int imgno, const int missno, double old_rot, std::vector< Image< double > > &Iref, std::vector< MultidimArray< double > > &wsumimgs, std::vector< MultidimArray< double > > &wsumweds, double &wsum_sigma_noise, double &wsum_sigma_offset, MultidimArray< double > &sumw, double &LL, double &dLL, double &fracweight, double &sumfracweight, double &trymindiff, int &opt_refno, int &opt_angno, Matrix1D< double > &opt_offsets)
ML-integration over all hidden parameters.
ParallelTaskDistributor * distributor
void getShift(int i, Matrix1D< double > &shift) const
void saveSamplingFile(const FileName &fn_base, bool write_vectors=true, bool write_sampling_sphere=false)
std::vector< Matrix1D< double > > imgs_optoffsets
void Euler_apply_transf(const Matrix2D< double > &L, const Matrix2D< double > &R, double rot, double tilt, double psi, double &newrot, double &newtilt, double &newpsi)
MultidimArray< double > real_mask
std::vector< int > imgs_missno
void maxConstrainedCorrSingleImage(MultidimArray< double > &Mimg, int imgno, int missno, double old_rot, std::vector< Image< double > > &Iref, std::vector< MultidimArray< double > > &wsumimgs, std::vector< MultidimArray< double > > &wsumweds, MultidimArray< double > &sumw, double &maxCC, double &sumCC, int &opt_refno, int &opt_angno, Matrix1D< double > &opt_offsets)
Maximum constrained correlation search over all hidden parameters.
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
pthread_mutex_t mltomo_selfile_access_mutex
Incorrect number of objects in Metadata.
T & getValue(MDLabel label)
void CenterFFT(MultidimArray< T > &v, bool forward)
#define A3D_ELEM(V, k, i, j)
std::vector< Matrix1D< double > > exp_data_projection_direction_by_L_R
int argc
Original command line arguments.
virtual void writeOutputFiles(const int iter, std::vector< MultidimArray< double > > &wsumweds, double &sumw_allrefs, double &LL, double &avefracweight, std::vector< double > &conv, std::vector< MultidimArray< double > > &fsc)
Write out reference images, selfile and logfile.
#define FOR_ALL_ELEMENTS_IN_ARRAY3D(V)
std::vector< size_t > no_redundant_sampling_points_index
void computeSamplingPoints(bool only_half_sphere=true, double max_tilt=180, double min_tilt=0)
void log(Image< double > &op)
const char * getParam(const char *param, int arg=0)
size_t numberSamplesAsymmetricUnit
if(fabs(c[*nmax+ *nmax *c_dim1])==0.e0)
std::vector< double > imgs_optpsi
Incorrect argument received.
#define XMIPP_EQUAL_ACCURACY
virtual void setNumberOfLocalImages()
Set the number of images, this function is useful only for MPI.
void calculateFsc(MultidimArray< double > &M1, MultidimArray< double > &M2, MultidimArray< double > &W1, MultidimArray< double > &W2, MultidimArray< double > &freq, MultidimArray< double > &fsc, double &resolution)
Calculate resolution by FSC.
void progress_bar(long rlen)
#define FN_ITER_VOL(iter, base, refno)
void write(const FileName &fn) const
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define dAkij(V, k, i, j)
virtual void addPartialDocfileData(const MultidimArray< double > &data, size_t first, size_t last)
Add info of some processed images to later write to files.
#define DIRECT_MULTIDIM_ELEM(v, n)
void addExampleLine(const char *example, bool verbatim=true)
void print_elapsed_time(ProcessorTimeStamp &time, bool _IN_SECS)
FourierTransformer transformer
void perturbAngularSampling()
Calculate Angular sampling.
int verbose
Verbosity level.
#define DIRECT_A3D_ELEM(v, k, i, j)
void maskSphericalAverageOutside(MultidimArray< double > &Min)
void fillLRRepository(void)
__device__ float FFT_IDX2DIGFREQ(int idx, int size)
std::vector< std::vector< size_t > > my_neighbors
MultidimArray< unsigned char > fourier_imask
virtual void produceSideInfo()
Setup lots of stuff.
std::vector< double > imgs_trymindiff
virtual void produceSideInfo2(int nr_vols=1)
MultidimArray< double > real_omask
std::vector< Matrix1D< double > > no_redundant_sampling_points_angles
#define FOR_ALL_ELEMENTS_IN_ARRAY1D(v)
void readParams()
Read arguments from command line.
Incorrect number of GRID volumes or shapes.
double angular_sampling
Missing data information.
void defineParams()
Define the arguments accepted.
void precalculateA2(std::vector< Image< double > > &Iref)
Fill vector of matrices with all rotations of reference.
double psi(const double x)
void run()
Main body of the program.
void * threadMLTomoExpectationSingleImage(void *data)
std::vector< size_t > convert_refno_to_stack_position
String formatString(const char *format,...)
#define realWRAP(x, x0, xF)
bool checkParam(const char *param)
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
AnglesInfoVector all_angle_info
Incorrect MultidimArray dimensions.
std::vector< int > imgs_optangno
static String label2Str(const MDLabel &label)
void getMissingRegion(MultidimArray< unsigned char > &Mmeasured, const Matrix2D< double > &A, const int missno)
Get binary missing wedge (or pyramid)
pthread_mutex_t mltomo_weightedsum_update_mutex
void addUsageLine(const char *line, bool verbatim=false)
double computeStddev() const
void initZeros(const MultidimArray< T1 > &op)
double computeAvg() const
void annotate_time(TimeStamp *time)
unsigned int randomize_random_generator()
void fillExpDataProjectionDirectionByLR(const MetaData &DFi)
void maximization(std::vector< MultidimArray< double > > &wsumimgs, std::vector< MultidimArray< double > > &wsumweds, double &wsum_sigma_noise, double &wsum_sigma_offset, MultidimArray< double > &sumw, double &sumfracweight, double &sumw_allrefs, std::vector< MultidimArray< double > > &fsc, int iter)
Update all model parameters.
std::vector< Image< double > > Iref
void removePointsFarAwayFromExperimentalData()
void RaisedCosineMask(MultidimArray< double > &mask, double r1, double r2, int mode, double x0, double y0, double z0)
int getIntParam(const char *param, int arg=0)
Incorrect value received.
void resize(size_t Ydim, size_t Xdim, bool noCopy=false)
void postProcessVolume(Image< double > &Vin, double resolution=-1.)
void formatStringFast(String &str, const char *format,...)
void addParamsLine(const String &line)
std::vector< MissingInfo > all_missing_info
#define MLTOMO_DATALINELENGTH
std::vector< size_t > imgs_id