26 double part_weight,
int interp_type)
32 long xx, yy, zz, j, jx, jy, jz;
33 double w(part_weight);
41 if ( interp_type < 2 ) {
43 (
long) floor(m[1] + 0.5),
44 (
long) floor(m[2] + 0.5));
45 if ( interp_type == 1 ) {
56 }
else if ( interp_type == 2 ) {
61 for ( zz=0; zz<2; zz++ ) {
63 if ( jz < 0 ) jz += z;
64 else if ( jz >= z ) jz -= z;
65 dist[2] = 1.0 - dist[2];
66 for ( yy=0; yy<2; yy++ ) {
68 if ( jy < 0 ) jy += y;
69 else if ( jy >= y ) jy -= y;
70 dist[1] = 1.0 - dist[1];
71 for ( xx=0; xx<2; xx++ ) {
73 if ( jx < 0 ) jx += x;
74 else if ( jx >= x ) jx -= x;
75 dist[0] = 1.0 - dist[0];
76 w = dist.
volume() * part_weight;
77 j =
index(jx, jy, jz);
108 double lo_res,
Vector3<double> scale,
double part_weight,
int interp_type)
110 double min_rad_sq = (lo_res)?
sampling(0)[0]/lo_res: 0;
111 double max_rad_sq = (hi_res)?
sampling(0)[0]/hi_res: 0.5;
112 if ( max_rad_sq > 0.5 ) max_rad_sq = 0.5;
116 min_rad_sq *= min_rad_sq;
117 max_rad_sq *= max_rad_sq;
120 long hx = (p->x - 1)/2, hy = (p->y - 1)/2;
128 cout <<
"Packing an image into reciprocal space up to " << hi_res <<
" A resolution" << endl;
133 for ( yy=i=0; yy<p->y; yy++ ) {
135 if ( yy > hy ) iv[1] -= (double)p->y;
137 for ( xx=0; xx<p->x; xx++, i++ ) {
139 if ( xx > hx ) iv[0] -= (double)p->x;
142 if ( d >= min_rad_sq && d <= max_rad_sq ) {
146 if ( d < 1 ) w *= sqrt(d);
175 double lo_res,
Vector3<double> scale,
double part_weight,
int interp_type)
181 cout <<
"DEBUG Bimage::fspace_pack_2D: sym=" << sym->
label << endl;
182 cout <<
"DEBUG Bimage::fspace_pack_2D: view=" << asu_view << endl;
183 cout <<
"DEBUG Bimage::fspace_pack_2D: part_weight=" << part_weight << endl;
213 long ft_size,
double scale,
double hi_res,
double lo_res,
221 cout <<
"Packing an image into reciprocal space up to " << hi_res <<
" A resolution" << endl << endl;
223 long i, j, xx, yy, kx, ky;
224 long ix, iy, ixx, iyy, nover(0);
225 double w, dx, dy, d2;
236 double maxrad_sq = maxrad*maxrad;
237 double ymin = floor(-maxrad*p->y);
239 double xmin = floor(-maxrad*p->x);
257 for ( iv[1]=ymin; iv[1]<=ymax; iv[1]+=1 ) {
258 if ( iv[1] >= 0 ) yy = (long)iv[1];
259 else yy = (long)(iv[1] + p->y);
261 for ( iv[0]=xmin; iv[0]<=xmax; iv[0]+=1 ) {
262 if ( iv[0] >= 0 ) xx = (long)iv[0];
263 else xx = (long)(iv[0] + p->x);
266 if ( d2 <= maxrad_sq ) {
274 ix = (long) floor(m[0]);
275 iy = (long) floor(m[1]);
279 for ( ky=0; ky<2; ky++ ) {
281 if ( iyy < 0 ) iyy += y;
283 for ( kx=0; kx<2; kx++ ) {
285 if ( ixx < 0 ) ixx += x;
323 double rx, ry, rz, r2, maxrad, maxrad2, pwr, w;
332 double rad_scale =
real_size().
max(), rad_scale2 = rad_scale*rad_scale;
335 maxrad = rad_scale/hi_res;
338 maxrad2 = maxrad*maxrad;
340 for ( i=zz=0; zz<z; zz++ ) {
342 if ( zz > h[2] ) rz -= z;
345 for ( yy=0; yy<y; yy++ ) {
347 if ( yy > h[1] ) ry -= y;
350 for ( xx=0; xx<x; xx++, i++ ) {
352 if ( xx > h[0] ) rx -= x;
357 if ( pwr >= threshold ) {
358 r2 = rad_scale2*(rx + ry + rz);
359 if ( r2 <= maxrad2 ) {
414 long i, cov(0), ds(x*y*z);
423 for ( i=0; i<ds; i++ ) {
425 weight2[i] = weight[i] - weight2[i]/weight[i];
427 if ( weight2[i] > 1 )
power[i] /= weight2[i];
428 else if ( weight[i] > 1 )
power[i] /= weight[i];
465 double rad_scale(
real_size().max()/sampling_ratio);
466 double s, noise, signal, w, w2;
467 double res,
fsc, fscp(1), snr, snrp(10), sc(0), res_fsc(0), res_snr(0);
468 double fsc_cut(0.3), snr_cut(0.5);
471 cout <<
"Radius\ts(1/A)\tRes(A)\t"
472 <<
"Weight\tPower\tSignal\tNoise\tSNR\tFSC" << endl;
473 for ( i=1; i<maxrad; i++ ) {
476 fsc = snr = signal = noise = 0;
483 noise = ((*pfom)[i] - (*prad)[i])/w2;
484 signal = (w*(*prad)[i] - (*pfom)[i])/w2;
493 if ( noise > 0 ) snr = signal/noise;
498 if ( fscp >= fsc_cut &&
fsc < fsc_cut ) {
499 sc = s - (fsc_cut -
fsc)/((fscp -
fsc)*rad_scale);
502 if ( snrp >= snr_cut && snr < snr_cut ) {
503 sc = s - (snr_cut - snr)/((snrp - snr)*rad_scale);
508 cout << i <<
tab << setprecision(4) << s <<
tab
509 << setprecision(2) << res <<
tab
510 << setprecision(2) << w <<
tab
511 << setprecision(6) << (*prad)[i] <<
tab
512 << setprecision(6) << signal <<
tab
513 << setprecision(6) << noise <<
tab
514 << setprecision(4) << snr <<
tab <<
fsc << endl;
517 cout <<
"Resolution estimates:" << endl;
518 cout <<
"SNR(0.5): " << res_snr <<
" A" << endl;
519 cout <<
"FSC(0.3): " << res_fsc <<
" A" << endl << endl;
538 long i, cov(0), ds(x*y*z);
539 double signal, noise;
544 for ( i=0; i<ds; i++ ) {
546 noise =
power[i] - signal;
547 if ( noise < signal ) noise = signal;
551 power[i] = (weight[i]*signal -
power[i])/noise;