32 PTHREAD_MUTEX_INITIALIZER;
35 PTHREAD_MUTEX_INITIALIZER;
47 addUsageLine(
"Perform (multi-reference) 2D-alignment using a maximum-likelihood (ML) target function.");
48 addUsageLine(
"+Our recommended way of performing ML alignment is to introduce as little bias in the initial reference(s) as possible.");
49 addUsageLine(
"+This can be done by calculting average images of random subsets of the (unaligned!) input experimental images, using the --nref option.");
50 addUsageLine(
"+Note that the estimates for the standard deviation in the noise and in the origin offsets are re-estimated every iteration,");
51 addUsageLine(
"+so that the initial values should not matter too much, as long as they are \"reasonable\". For Xmipp-normalized images,");
52 addUsageLine(
"+the standard deviation in the noise can be assumed to be 1. For reasonably centered particles the default value of 3 for");
55 addUsageLine(
"+The output of the program consists of the refined reference images (weighted averages over all experimental images).");
56 addUsageLine(
"+The experimental images are not altered at all. In terms of the ML approach, optimal transformations and references for");
57 addUsageLine(
"+each image do not play the same role as in the conventional cross-correlation (or least-sqaures) approach. This program");
58 addUsageLine(
"+can also be used for reference-free 2D-alignment using only a single reference: just supply =--nref 1= .");
59 addUsageLine(
"+Although the calculations can be rather time-consuming (especially for many, large experimental images and a large number of references),");
60 addUsageLine(
"+we strongly recommend to let the calculations converge. In our experience this takes in the order of 10-100 iterations, depending on the");
61 addUsageLine(
"+number images, the amount of noise, etc. The default stopping criterium has yielded satisfactory results in our experience. A parallel ");
62 addUsageLine(
"+version of this program has been implemented.");
71 addExampleLine(
"xmipp_ml_align2d -i input/images_some.stk --ref input/seeds2.stk --oroot output/ml2d --fast --mirror");
81 char ** argv2 =
nullptr;
83 double restart_noise=0, restart_offset=0;
84 FileName restart_imgmd, restart_refmd;
85 int restart_iter=0, restart_seed=0;
167 seed = time(
nullptr);
169 std::cerr <<
"WARNING: *** Using a non random seed and not in restarting ***" <<std::endl;
185 istart = restart_iter + 1;
204 <<
" -----------------------------------------------------------------" << std::endl
205 <<
" | Read more about this program in the following publications: |" << std::endl
206 <<
" | Scheres ea. (2005) J.Mol.Biol. 348(1), 139-49 |" << std::endl
207 <<
" | Scheres ea. (2005) Bioinform. 21(suppl.2), ii243-4 (-fast) |" << std::endl
208 <<
" | |"<< std::endl
209 <<
" | *** Please cite them if this program is of use to you! *** |"<< std::endl
210 <<
" -----------------------------------------------------------------"<< std::endl;
213 std::cout <<
"--> Maximum-likelihood multi-reference refinement " << std::endl
219 std::cout <<
" Reference expanding factor : " <<
factor_nref << std::endl;
223 <<
" Output rootname : " <<
fn_root << std::endl
224 <<
" Stopping criterium : " <<
eps << std::endl
227 <<
" Psi sampling interval : " <<
psi_step << std::endl
228 <<
" Check mirrors : " << (
do_mirror ?
"true" :
"false") << std::endl;
231 std::cout <<
" Initial model fractions : " <<
fn_frac << std::endl;
235 std::cout <<
" -> Use fast, reduced search-space approach with C = " <<
C_fast << std::endl;
237 std::cout <<
" + Start from all-zero translations" << std::endl;
244 std::cout <<
" -> Save_memory A: recalculate real-space rotations in -fast" << std::endl;
247 std::cout <<
" -> Save_memory B: limit translations to 3 sigma_offset " << std::endl;
250 std::cout <<
" -> Do not update estimates of model fractions." << std::endl;
253 std::cout <<
" -> Do not update sigma-estimate of origin offsets." << std::endl;
256 std::cout <<
" -> Do not update sigma-estimate of noise." << std::endl;
260 std::cout <<
" -> Use t-student distribution with df = " <<
df << std::endl;
263 std::cout <<
" -> Use sigma-trick for t-student distributions" << std::endl;
267 std::cout <<
" -> Refine normalization for each experimental image" << std::endl;
270 std::cout <<
" -> Using " <<
threads <<
" parallel threads" << std::endl;
273 std::cout <<
" -> Doing IEM with " <<
blocks <<
" blocks" <<std::endl;
275 std::cout <<
" -----------------------------------------------------------------" << std::endl;
283 std::cerr <<
"================> " << msg << std::endl;
292 LOG(
" ProgML2D::produceSideInfo: start");
295 LOG(
" ProgML2D::produceSideInfo: reading MDimg");
312 size_t idum, idumLong;
313 LOG(
" ProgML2D::produceSideInfo: setting dimensions");
330 LOG(
" ProgML2D::produceSideInfo: generate an initial reference just by averaging the experimental images");
334 avg().setXmippOrigin();
340 img().setXmippOrigin();
352 LOG(
" ProgML2D::produceSideInfo show");
354 LOG(
" ProgML2D::produceSideInfo end");
370 double rot = 0., tilt = 0.;
379 img().setXmippOrigin();
411 refw.resize(num_output_refs);
412 refw2.resize(num_output_refs);
413 refwsc2.resize(num_output_refs);
416 A2.resize(num_output_refs);
417 fref.resize(num_output_refs * nr_psi);
418 mref.resize(num_output_refs * nr_psi);
420 mysumimgs.resize(num_output_refs * nr_psi);
421 Iold.resize(num_output_refs);
425 int mysize = num_output_refs * (
do_mirror ? 2 : 1);
448 for (
int refno = 0; refno <
model.
n_ref; refno++)
455 std::vector<double> Vdum;
464 for (
int refno = 0; refno <
idum; refno++)
538 for (
size_t objId : MDaux.
ids())
556 std::cerr <<
"Entering calculatePdfInplane" <<std::endl;
559 double x,
y,
r2, pdfpix, sum;
577 pdfpix = exp(-r2 / _2sigma_offset2);
578 pdfpix /= _sigma_offset_denominator;
582 if (
j == 0 &&
i == 0)
597 std::cerr <<
"Leaving calculatePdfInplane" <<std::endl;
606 std::cerr<<
"entering rotateReference"<<std::endl;
613 std::cerr<<
"leaving rotateReference"<<std::endl;
622 std::cerr<<
"entering reverseRotateReference"<<std::endl;
629 std::cerr<<
"leaving reverseRotateReference"<<std::endl;
637 double phi_ref, theta_ref, angle, angle2;
643 for (
int refno = 0; refno <
model.
n_ref; refno++)
645 if (!
limit_rot || (phi == -999. && theta == -999.))
656 angle = fabs(
realWRAP(angle, -180, 180));
658 angle2 = 180. + angle;
659 angle2 = fabs(
realWRAP(angle2, -180, 180));
678 std::cerr<<
"entering preselectFastSignificant"<<std::endl;
694 std::cerr<<
"leaving preselectFastSignificant"<<std::endl;
709 bool is_ok_trymindiff =
false;
731 for (
size_t iflip = 0; iflip <
nr_flip; iflip++)
745 int redo_counter = 0;
754 while (!is_ok_trymindiff)
781 if (redo_counter > 1)
786 is_ok_trymindiff =
true;
825 Maux2 = Maux2 - Maux;
829 std::cout << std::endl;
832 std::cout <<
"bgmean= " <<
bgmean <<
" changes to " 876 *
PI * sigma_noise2));
896 std::cerr <<
"----------------------------->>>" << std::endl;
897 std::cerr <<
" dLL: " <<
dLL << std::endl;
898 std::cerr <<
" sum_refw: " <<
sum_refw << std::endl;
899 std::cerr <<
" my_mindiff: " << my_mindiff << std::endl;
900 std::cerr <<
" sigma_noise2: " << sigma_noise2 << std::endl;
901 std::cerr <<
" ddim2: " <<
ddim2 << std::endl;
903 std::cerr <<
" wsum_corr: " <<
wsum_corr << std::endl;
904 std::cerr <<
" wsum_offset: " <<
wsum_offset << std::endl;
1010 pthread_exit(
nullptr);
1061 std::cerr <<
"entering doThreadRotateReference " << std::endl;
1064 double AA, stdAA=0.,
psi, dum, avg;
1076 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1078 refnoipsi = refno * nr_psi + ipsi;
1094 Maux *=
sqrt(stdAA / AA);
1097 mref[refnoipsi] = Maux;
1107 fref[refnoipsi] = Faux;
1121 double psi, dum, avg;
1126 Maux.setXmippOrigin();
1127 Maux2.setXmippOrigin();
1134 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1138 int refnoipsi = refno * nr_psi + ipsi;
1159 #define IIFLIP (imirror * nr_nomirror_flips + iflip) 1160 #define IROT (IIFLIP * nr_psi + ipsi) 1162 #define WEIGHT (dAij(pfs_weight, refno, IROT)) 1163 #define MAX_WEIGHT (dAij(pfs_maxweight, imirror, refno)) 1164 #define MSIGNIFICANT (dAij(Msignificant, refno, IROT)) 1169 double ropt, aux, diff, pdf, fracpdf;
1173 double local_mindiff;
1182 local_mindiff = 99.e99;
1189 A2_plus_Xi2 = 0.5 * (
A2[refno] +
Xi2);
1190 for (
int imirror = 0; imirror < nr_mirror; imirror++)
1196 ropt =
sqrt(trans(0) * trans(0) + trans(1) * trans(1));
1201 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1210 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1219 if (diff < local_mindiff)
1220 local_mindiff = diff;
1244 for (
int imirror = 0; imirror < nr_mirror; imirror++)
1252 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1258 pdf = fracpdf *
A2D_ELEM(
P_phi, (
int)trans(1), (
int)trans(0));
1262 aux = (
WEIGHT - local_mindiff) / sigma_noise2;
1264 WEIGHT = (aux > 1000. ? 0. : exp(-aux) * pdf);
1278 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1290 double aux, pdf, fracpdf, A2_plus_Xi2;
1291 double weight, stored_weight, weight2 = 0, my_maxweight;
1292 double my_sumweight, my_sumstoredweight, ref_scale = 1.;
1293 int irot, output_irefmir, refnoipsi, output_refnoipsi;
1295 double local_mindiff, local_wsum_corr, local_wsum_offset, maxw_ref;
1296 double local_wsum_sc, local_wsum_sc2, local_maxweight, local_maxweight2=0.0;
1298 int local_iopty=0, local_ioptx=0, local_iopt_psi=0, local_iopt_flip=0,
1311 local_transformer.
setReal(Maux);
1322 std::ostringstream msg;
1323 msg <<
"Division by zero: nr_nomirror_flips == 0";
1324 throw std::runtime_error(msg.str());
1335 local_maxweight = -99.e99;
1336 local_mindiff = 99.e99;
1337 local_wsum_sc = local_wsum_sc2 = local_wsum_corr = local_wsum_offset = 0;
1339 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1341 output_refnoipsi = output_refno * nr_psi + ipsi;
1352 A2_plus_Xi2 = 0.5 * (ref_scale * ref_scale *
A2[refno] +
Xi2);
1355 for (
size_t iflip = 0; iflip <
nr_flip; iflip++)
1359 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1361 refnoipsi = refno * nr_psi + ipsi;
1362 output_refnoipsi = output_refno * nr_psi + ipsi;
1363 irot = iflip * nr_psi + ipsi;
1372 std::cerr <<
iter <<
" iflip, ipsi, refno, irot: " << iflip <<
" " << ipsi <<
" " << refno <<
" " << irot << std::endl;
1373 std::cerr <<
iter <<
" A2_plus_Xi2: " << A2_plus_Xi2 << std::endl;
1374 std::cerr <<
"dAij(Msignificant): " <<
dAij(
Msignificant, refno, irot) << std::endl;
1404 <<
"Maux: " << std::endl << Maux
1405 <<
"Fimg_flip[iflip]" << std::endl<<
Fimg_flip[iflip]
1406 <<
"fref[refnoipsi]" << std::endl<<
fref[refnoipsi] << std::endl;
1410 my_sumweight = my_sumstoredweight = my_maxweight = 0.;
1420 std::cerr <<
"---------------------------------------" << std::endl
1421 <<
" pdf " << pdf << std::endl
1422 <<
" A2_plus_Xi2 " << A2_plus_Xi2 << std::endl
1423 <<
" A2D_ELEM(Maux, i, j) " <<
A2D_ELEM(Maux,
i,
j) << std::endl
1424 <<
" ref_scale " << ref_scale << std::endl
1425 <<
" ddim2 " << ddim2 << std::endl
1426 <<
"diff " << diff << std::endl
1428 <<
"sigma_noise2 " << sigma_noise2 << std::endl;
1436 weight = (aux > 1000.) ? 0. : exp(-aux) * pdf;
1441 std::cerr <<
"aux = (diff - trymindiff) / sigma_noise2: " << aux << std::endl
1442 <<
"weight: " << weight << std::endl;
1446 A2D_ELEM(Mweight,
i,
j) = stored_weight = weight;
1448 local_wsum_corr += weight * diff;
1461 weight = pow(aux,
df2) * pdf;
1464 weight2 = (
df +
ddim2) / (
df + (2. * diff / sigma_noise2));
1466 stored_weight = weight * weight2;
1469 local_wsum_corr += stored_weight * diff;
1470 refw2[output_refno] += stored_weight;
1473 local_mindiff =
XMIPP_MIN(local_mindiff, diff);
1476 my_sumweight += weight;
1477 my_sumstoredweight += stored_weight;
1484 local_wsum_sc += stored_weight * (A2_plus_Xi2 - diff) / ref_scale;
1486 local_wsum_sc2 += stored_weight *
A2[refno];
1490 my_maxweight =
XMIPP_MAX(my_maxweight, weight);
1492 if (weight > local_maxweight)
1495 local_maxweight2 = weight2;
1496 local_maxweight = weight;
1499 local_iopt_psi = ipsi;
1500 local_iopt_flip = iflip;
1501 local_opt_refno = output_refno;
1515 if (
iter == 3 && refno==0)
1517 std::cerr << Mweight << std::endl;
1518 std::cerr <<
"maxweight: " << my_maxweight <<
" " << my_sumstoredweight <<
" " << my_sumweight << std::endl;
1525 sumw_refpsi[output_refno * nr_psi + ipsi] += my_sumstoredweight;
1528 refw[output_refno] += my_sumweight;
1568 iopty = local_iopty;
1569 ioptx = local_ioptx;
1594 #define DP(x) << std::setw(15) << x 1599 std::cerr <<
"DEBUG_JM: ====== iter: " <<
iter <<
"======= block: " <<
current_block << std::endl;
1602 std::cerr <<
"Xi2: " <<
Xi2 << std::endl;
1603 std::cerr <<
"sum_refw: " <<
sum_refw << std::endl;
1605 std::cerr
DP(
"A2")
DP(
"refw")
DP(
"refw_mirror") << std::endl;
1606 for (
int refno = 0; refno <
model.
n_ref; ++refno)
1612 std::cerr <<
"DEBUG_JM: ..............EXITING....................: " << std::endl;
1638 int group_refno = group *
model.
n_ref + refno;
1652 = -(
double)
ioptx_ref[num_refs + output_refno]
1654 - (double)
iopty_ref[num_refs + output_refno]
1657 = -(
double)
ioptx_ref[num_refs + output_refno]
1659 - (double)
iopty_ref[num_refs + output_refno]
1685 std::complex<double> cscale_dim2_sumw=scale_dim2_sumw;
1686 for (
size_t ipsi = 0; ipsi <
nr_psi; ipsi++)
1688 int refnoipsi = output_refno * nr_psi + ipsi;
1718 LOG(
" ProgML2D::expectation BEGIN");
1721 std::cerr<<
"entering expectation"<<std::endl;
1742 sumw.assign(num_output_refs, 0.);
1743 sumw2.assign(num_output_refs, 0.);
1744 sumwsc.assign(num_output_refs, 0.);
1745 sumwsc2.assign(num_output_refs, 0.);
1759 double old_phi = -999., old_theta = -999.;
1767 static size_t img_done;
1790 img().setXmippOrigin();
1799 printf(
" ====================>>> Iter: %02d Image: %06lu: \n",
iter, imgno);
1800 printf(
" fn_img: %s", fn_img.c_str());
1905 std::cerr <<
" LL: " <<
LL << std::endl;
1908 std::cerr <<
" sumfracweight: " <<
sumfracweight << std::endl;
1927 LOG(
" ProgML2D::expectation END");
1937 std::cerr<<
"entering maximization"<<std::endl;
1949 int old_refno = local_model.
n_ref;
1955 for (
int refno = 0; refno < old_refno; refno++)
1958 local_model.
Iref[group * old_refno + refno] = local_model.
Iref[refno];
1969 #define ASSIGN(var) local_model.var = var 1973 local_model.
LL =
LL;
1982 for (
int refno = 0; refno < local_model.
n_ref; refno++)
1984 double weight =
sumw[refno];
1989 weight =
sumw2[refno];
1993 double avg, stddev,
min,
max;
1994 wsum_Mref[refno].computeStats(avg, stddev, min, max);
1999 local_model.
WsumMref[refno].setWeight(weight);
2003 local_model.
WsumMref[refno].setWeight(0.);
2005 local_model.
WsumMref[refno]().setXmippOrigin();
2018 std::cerr<<
"leaving maximization"<<std::endl;
2025 LOG(
" ProgML2D::maximization BEGIN");
2038 LOG(
" ProgML2D::maximization: readModel and substractModel");
2044 LOG(
" ProgML2D::maximization: maximizeModel");
2046 LOG(
" ProgML2D::maximization: maximizeModel");
2048 LOG(
" ProgML2D::maximization: addModels");
2061 model = block_model;
2077 LOG(
" ProgML2D::maximization END");
2121 size_t first,
size_t last)
2124 std::cerr <<
"Entering addPartialDocfileData" <<std::endl;
2127 for (
size_t imgno = first; imgno <= last; imgno++)
2130 size_t id =
img_id[imgno];
2139 double psi = -
dAij(data, index, 2);
2162 std::cerr <<
"Leaving addPartialDocfileData" <<std::endl;
2167 #define ITER_PREFIX "iter"//formatString("iter%06d", iter) 2168 #define FINAL_PREFIX "final" 2169 #define IS_FINAL outputType == OUT_FINAL 2173 FileName fn_tmp, fn_prefix, fn_base;
2176 bool write_img_xmd =
true, write_refs_log =
true, write_conv = !
do_ML3D;
2177 bool write_norm = model.
do_norm;
2183 std::vector<Image<double> >
const * ptrImages = &(model.
Iref);
2185 double avePmax = model.
avePmax;
2192 write_img_xmd =
false;
2214 write_refs_log =
false;
2221 write_img_xmd =
false;
2265 select_img = refno + 1;
2268 Itmp = (*ptrImages)[refno];
2276 weight = model.
WsumMref[refno].weight();
2278 count =
ROUND(weight);
2320 for (
size_t ref = 1; ref <=
n; ++ref)
2342 MDi.
read(fn_base +
"_logs.xmd");
2357 MDi.
read(fn_base +
"_refs.xmd");
2362 for (
size_t objId : MDi.
ids())
2366 img().setXmippOrigin();
2369 model.
WsumMref[refno].setWeight(weight);
2382 fn_base.
compose(fn_base, number,
"");
int getThreadRefnoJob(int &refno)
Assign refno jobs to threads.
int barrier_init(barrier_t *barrier, int needed)
virtual void printModel(const String &msg, const ModelML2D &model)
std::vector< size_t > img_id
void min(Image< double > &op1, const Image< double > &op2)
void preselectLimitedDirections(double &phi, double &theta)
#define A2D_ELEM(v, i, j)
virtual void addPartialDocfileData(const MultidimArray< double > &data, size_t first, size_t last)
Add docfiledata to docfile.
void resize(size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true)
Case or algorithm not implemented yet.
alglib::complex conj(const alglib::complex &z)
double getDoubleParam(const char *param, int arg=0)
__host__ __device__ float2 floor(const float2 v)
#define SIGNIFICANT_WEIGHT_LOW
#define REPORT_ERROR(nerr, ErrormMsg)
#define FOR_ALL_LOCAL_IMAGES()
void apply_binary_mask(const MultidimArray< int > &mask, const MultidimArray< T > &m_in, MultidimArray< T > &m_out, T subs_val=(T) 0)
#define FOR_ALL_DIRECT_ELEMENTS_IN_ARRAY2D(m)
MultidimArray< double > Mimg
std::vector< double > sumw_mirror
void Euler_direction(double alpha, double beta, double gamma, Matrix1D< double > &v)
void resizeNoCopy(const MultidimArray< T1 > &v)
std::vector< int > iopty_ref
MultidimArray< double > Mr2
void sqrt(Image< double > &op)
void BinaryCircularMask(MultidimArray< int > &mask, double radius, int mode, double x0, double y0, double z0)
void createThreads()
Create working threads.
std::vector< int > ioptx_ref
void initProgress(size_t total, size_t stepBin=60)
void write(const FileName &name="", size_t select_img=ALL_IMAGES, bool isStack=false, int mode=WRITE_OVERWRITE, CastWriteMode castMode=CW_CAST, int _swapWrite=0)
void readParams()
Read arguments from command line.
std::vector< MultidimArray< std::complex< double > > > fref
bool do_student_sigma_trick
void centerFFT2(MultidimArray< double > &v)
virtual void maximization()
Update all model parameters, adapted for IEM blocks use.
std::vector< double > mirror_fraction
void compose(const String &str, const size_t no, const String &ext="")
void doThreadExpectationSingleImageRefno()
Thread code to parallelize refno loop in expectationSingleImage.
void substractModel(const ModelML2D &model)
MultidimArray< int > omask
void destroyThreads()
Exit threads and free memory.
virtual void produceSideInfo2()
Try to merge produceSideInfo1 and 2.
structThreadTasks * threads_d
virtual void readModel(ModelML2D &model, int block)
Read model from file.
std::vector< MultidimArray< std::complex< double > > > Fimg_flip
virtual void expectation()
Integrate over all experimental images.
virtual void defineAdditionalParams(XmippProgram *prog, const char *sectionLine)
#define FN_CLASSES_MD(base)
#define rotate(a, i, j, k, l)
void computeStats_within_binary_mask(const MultidimArray< T1 > &mask, const MultidimArray< T > &m, double &min_val, double &max_val, double &avg, double &stddev)
#define FOR_ALL_ELEMENTS_IN_ARRAY2D(m)
void addSeeAlsoLine(const char *seeAlso)
size_t divide_equally_group(size_t N, size_t size, size_t myself)
std::vector< int > ioptflip_ref
void print(int tabs=0) const
Just for debugging now.
#define MAT_ELEM(m, i, j)
int argc
Original command line arguments.
#define FOR_ALL_THREAD_REFNO()
std::vector< MultidimArray< std::complex< double > > > wsumimgs
void doThreadRotateReferenceRefno()
Thread code to parallelize refno loop in rotateReference.
void log(Image< double > &op)
const char * getParameter(int argc, const char **argv, const char *param, const char *option)
const char * getParam(const char *param, int arg=0)
std::vector< double > sumw
void doThreadReverseRotateReferenceRefno()
Thread code to parallelize refno loop in reverseRotateReference.
std::vector< double > imgs_oldtheta
void maximizeModel(ModelML2D &model)
Update all model parameters.
virtual void defineBasicParams(XmippProgram *prog)
std::vector< Matrix2D< double > > F
void preselectFastSignificant()
FileName getIterExtraPath(const FileName &fn_root, int iter, bool makePath)
std::vector< double > refw_mirror
void max(Image< double > &op1, const Image< double > &op2)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
MultidimArray< double > docfiledata
#define FN_CLASS_IMAGES_MD(base, ref)
std::vector< std::vector< double > > imgs_offsets
void defineParams()
Params definition.
#define DIRECT_MULTIDIM_ELEM(v, n)
void addExampleLine(const char *example, bool verbatim=true)
std::vector< double > alpha_k
int verbose
Verbosity level.
#define FOR_ALL_THREAD_REFNO_NODECL()
Same macro as before, but without declaring refno and load.
std::vector< double > imgs_oldphi
#define IIFLIP
Some macro definitions for the following function.
void doThreadPreselectFastSignificantRefno()
Thread code to parallelize refno loop in preselectFastSignificant.
virtual void writeOutputFiles(const ModelML2D &model, OutputType outputType=OUT_FINAL)
Write model parameters.
std::vector< int > imgs_optrefno
virtual void defineHiddenParams(XmippProgram *prog)
std::vector< double > pdf_directions
std::vector< double > sumwsc2
MultidimArray< int > mask
std::vector< double > refwsc2
std::vector< MultidimArray< double > > mref
Threads cannot be initiated.
void setEulerAngles(double rot, double tilt, double psi, const size_t n=0)
std::vector< double > allref_offsets
std::vector< double > refw2
void setProgress(size_t value=0)
virtual void setNumberOfLocalImages()
Set the number of images, this function is useful only for MPI.
void translate(PDB *pdb_original, PDB *pdb_move, unsigned num_atoms, double x0, double y0, double z0)
void calculatePdfInplane()
Calculate probability density distribution for in-plane transformations.
#define FN_IMAGES_MD(base)
std::vector< Image< double > > Iref
T dotProduct(const Matrix1D< T > &v1, const Matrix1D< T > &v2)
void rotateReference()
Fill vector of matrices with all rotations of reference.
void reverseRotateReference()
Apply reverse rotations to all matrices in vector and fill new matrix with their sum.
void expectationSingleImage(Matrix1D< double > &opt_offsets)
ML-integration over all (or -fast) translations.
pthread_mutex_t update_mutex
std::vector< double > sumwsc
std::vector< MultidimArray< double > > wsum_Mref
void doThreadESIUpdateRefno()
Thread code to parallelize update loop in ESI.
double psi(const double x)
void awakeThreads(ThreadTask task, int start_refno, int load=1)
Awake threads for different tasks.
#define FN_CLASSES_STK(base)
void * doThreadsTasks(void *data)
Function for threads do different tasks.
std::vector< double > refw
String formatString(const char *format,...)
std::vector< double > sumw_refpsi
#define realWRAP(x, x0, xF)
MultidimArray< double > P_phi
virtual void randomizeImagesOrder()
Randomize initial images order, only once.
bool checkParam(const char *param)
constexpr int OUTSIDE_MASK
int read(const FileName &name, DataMode datamode=DATA, size_t select_img=ALL_IMAGES, bool mapData=false, int mode=WRITE_READONLY)
std::vector< double > imgs_trymindiff
void correctScaleAverage()
Correct references scale.
std::vector< double > sumw_mirror
void addUsageLine(const char *line, bool verbatim=false)
void initZeros(const MultidimArray< T1 > &op)
double computeAvg() const
std::vector< Image< double > > WsumMref
FileName getBaseName(String suffix="", int number=-1)
Get base name based on fn_root and some number.
void setWeight(double weight, const size_t n=0)
virtual void show()
Show info at starting program.
MultidimArray< double > pfs_weight
int barrier_wait(barrier_t *barrier)
virtual void iteration()
Perform an iteration.
int getIntParam(const char *param, int arg=0)
Incorrect value received.
std::vector< Image< double > > Iold
pthread_mutex_t refno_mutex
std::vector< MultidimArray< std::complex< double > > > mysumimgs
std::vector< double > conv
std::vector< double > scale
std::vector< double > imgs_bgmean
void addModel(const ModelML2D &model)
MultidimArray< int > Msignificant
std::vector< double > sumw2
virtual void produceSideInfo()
Try to merge produceSideInfo1 and 2.
std::vector< double > imgs_scale
MultidimArray< double > pfs_maxweight