39 cerr <<
"Error: Only single channel images are supported for correlation!" << endl;
43 if ( n > 1 || p->
images() > 1 ) {
44 cerr <<
"Error: Only single images are supported for correlation!" << endl;
49 error_show(
"Bimage::correlate", __FILE__, __LINE__);
54 double v1, v2, cc(0), sx(0), sy(0), sx2(0), sy2(0), sxy(0);
56 for ( i=0; i<datasize; i++ ) {
66 double varx = sx2 - sx*sx/datasize;
67 double vary = sy2 - sy*sy/datasize;
69 if ( varx > 0 && vary > 0 )
70 cc = (sxy - sx*sy/datasize)/sqrt(varx*vary);
92 if ( n > 1 || p->
images() > 1 ) {
93 cerr <<
"Error: Only single images are supported for correlation!" << endl;
98 error_show(
"Bimage::correlate", __FILE__, __LINE__);
102 if ( std <= 0 || p->std <= 0 )
return -1;
104 if ( rmin > x/2 ) rmin = 0;
105 if ( rmax <= rmin ) rmax =
size().
max();
108 cout <<
"Calculating a correlation map:" << endl;
110 cout <<
"Radii: " << rmin <<
" - " << rmax << endl;
112 cout <<
"Mask: " << pmask->
file_name() << endl;
116 long i, xx, yy, zz, ns(0);
117 double v1, v2, dx, dy, dz, d2, rmin2(rmin*rmin), rmax2(rmax*rmax);
118 double avg1(0), avg2(0), std1(0), std2(0), c12(0), denom, cc(0);
120 for ( i=zz=0; zz<z; zz++ ) {
123 for ( yy=0; yy<y; yy++ ) {
126 for ( xx=0; xx<x; xx++, i++ ) {
131 if ( pmask && (*pmask)[i] < 1 ) use_this = 0;
132 if ( d2 < rmin2 || d2 > rmax2 ) use_this = 0;
152 std1 = std1/ns - avg1*avg1;
153 std2 = std2/ns - avg2*avg2;
154 if ( std1 > 0 ) std1 = sqrt(std1);
156 if ( std2 > 0 ) std2 = sqrt(std2);
169 cc = (c12 - avg1*avg2) * denom;
172 for ( i=0; i<datasize; i++ )
if ( (*p)[i] )
173 p->
set(i, ((*
this)[i] - avg1)*((*p)[i] - avg2)*denom);
178 cout <<
"Averages: " << avg1 <<
" " << avg2 << endl;
179 cout <<
"Standard deviations: " << std1 <<
" " << std2 << endl;
180 cout <<
"Correlation: " << cc <<
" (" << ns <<
")" << endl << endl;
220 if ( n > 1 || p->
images() > 1 ) {
221 cerr <<
"Error: Only single images are supported for R factor calculation!" << endl;
226 error_show(
"Bimage::R_factor", __FILE__, __LINE__);
232 double sx(0), sy(0), sx2(0), sy2(0), sxy(0);
234 for ( i=0; i<datasize; i++ ) {
237 sx2 += (*this)[i]*(*this)[i];
238 sy2 += (*p)[i]*(*p)[i];
239 sxy += (*this)[i]*(*p)[i];
242 R = sqrt((sx2 - 2*sxy + sy2)/sqrt((sx2 - sx*sx/datasize)*(sy2 - sy*sy/datasize)));
267 if ( hires > lores ) swap(hires, lores);
269 long nn, i, xx, yy, zz;
271 double s2, sx2, sy2, sz2, smin2(0), smax2(0),
sum, scale;
275 if ( lores > 0 ) smin2 = 1/(lores*lores);
278 smax2 = 1/(hires*hires);
280 if ( x > 1 ) smax2 += 1.0/(4.0*u[0]*u[0]);
281 if ( y > 1 ) smax2 += 1.0/(4.0*u[1]*u[1]);
282 if ( z > 1 ) smax2 += 1.0/(4.0*u[2]*u[2]);
283 hires = 1/sqrt(smax2);
287 cout <<
"Auto-correlation:" << endl;
289 cout <<
"Resolution range: " << hires <<
" - " << lores <<
" A" << endl;
291 cout <<
"No resolution limits" << endl;
300 for ( i=nn=0; nn<n; nn++ ) {
302 for ( zz=0; zz<z; zz++ ) {
304 if ( zz > (z - 1)/2 ) iz -= z;
305 sz2 = iz/realsize[2];
307 for ( yy=0; yy<y; yy++ ) {
309 if ( yy > (y - 1)/2 ) iy -= y;
310 sy2 = iy/realsize[1];
312 for ( xx=0; xx<x; xx++, i++ ) {
314 if ( xx > (x - 1)/2 ) ix -= x;
315 sx2 = ix/realsize[0];
317 s2 = sx2 + sy2 + sz2;
318 if ( s2 >= smin2 && s2 <= smax2 ) {
329 scale = sqrt(x*y*z)/
sum;
366 if ( lores > 0 && hires > lores ) swap(hires, lores);
369 if ( !pc )
return NULL;
372 cout <<
"Cross-correlation:" << endl;
373 if ( lores > 0 || hires > 0 ) {
374 cout <<
"Resolution range: " << hires <<
" - ";
375 if ( lores > 0 ) cout << lores <<
" A" << endl;
376 else cout <<
"inf A" << endl;
378 cout <<
"No resolution limits" << endl;
393 for ( nn=0; nn<pc->
images(); nn++ )
419 if ( lores > 0 && hires > lores ) swap(hires, lores);
422 if ( !pc )
return NULL;
425 cout <<
"Cross-correlation:" << endl;
426 if ( lores > 0 || hires > 0 ) {
427 cout <<
"Resolution range: " << hires <<
" - ";
428 if ( lores > 0 ) cout << lores <<
" A" << endl;
429 else cout <<
"inf A" << endl;
431 cout <<
"No resolution limits" << endl;
433 cout <<
"With a mask: " << pmask->
file_name() << endl;
437 pc->
fft(FFTW_FORWARD, 0);
443 pc->
fft(FFTW_BACKWARD, 0);
448 for ( nn=0; nn<pc->
images(); nn++ )
476 for ( i=k[2]=0; k[2]<z; ++k[2] ) {
477 for ( k[1]=0; k[1]<y; ++k[1] ) {
478 for ( k[0]=0; k[0]<x; ++k[0], ++i ) {
481 cc += cv.
real()*cos(phi) - cv.
imag()*sin(phi);
504 double ds(1), cc(0), ccmax(0);
510 cout <<
size <<
tab << smn <<
tab << smx << endl;
514 for ( i=0, sh[2]=smn[2]; sh[2]<=smx[2]; sh[2]+=ds ) {
515 for ( sh[1]=smn[1]; sh[1]<=smx[1]; sh[1]+=ds ) {
516 for ( sh[0]=smn[0]; sh[0]<=smx[0]; sh[0]+=ds, ++i ) {
521 cout << setprecision(4) << ds <<
tab << sh <<
tab << cc << endl;
561 if ( lores > 0 && hires > lores ) swap(hires, lores);
564 if ( !pc )
return NULL;
567 cout <<
"Cross-correlation:" << endl;
568 if ( lores > 0 || hires > 0 ) {
569 cout <<
"Resolution range: " << hires <<
" - ";
570 if ( lores > 0 ) cout << lores <<
" A" << endl;
571 else cout <<
"inf A" << endl;
573 cout <<
"No resolution limits" << endl;
579 pc->
fft(FFTW_FORWARD, 0);
588 for ( nn=0; nn<pc->
images(); nn++ )
600 if ( lores > 0 && hires > lores ) swap(hires, lores);
603 if ( !pc )
return NULL;
606 cout <<
"Cross-correlation:" << endl;
607 if ( lores > 0 || hires > 0 ) {
608 cout <<
"Resolution range: " << hires <<
" - ";
609 if ( lores > 0 ) cout << lores <<
" A" << endl;
610 else cout <<
"inf A" << endl;
612 cout <<
"No resolution limits" << endl;
614 cout <<
"With a mask: " << pmask->
file_name() << endl;
629 cerr <<
"Error in cross_correlate: maximum > 1: " <<
image->
maximum() << endl;
634 for ( nn=0; nn<pc->
images(); nn++ )
670 if ( hires > lores ) swap(hires, lores);
673 if ( !pc )
return NULL;
678 cout <<
"Two-way cross-correlation:" << endl;
679 cout <<
"Resolution range: " << hires <<
" - " << lores <<
" A" << endl;
725 for ( nn=0; nn<pc->
images(); nn++ )
751 if ( !pc )
return NULL;
754 cout <<
"Cross-correlation with validation:" << endl;
756 cout <<
"With a mask: " << pmask->
file_name() << endl;
760 pc->
fft(FFTW_FORWARD, 0);
766 for ( nn=0; nn<pc->
images(); nn++ )
774 pc->
fft(FFTW_BACKWARD, 0);
775 pc->
next->
fft(FFTW_BACKWARD, 0);
802 double hires,
double lores,
double search_radius,
Bimage* pmask,
808 error_show(
"Bimage::rotate_cross_correlate", __FILE__, __LINE__);
822 cout <<
"DEBUG Bimage::rotate_cross_correlate: found origin = " << pcc->
image->
origin() << endl;
823 cout <<
"DEBUG Bimage::rotate_cross_correlate: cc = " << pcc->
image->
FOM() << endl;
860 double angle,
double res_hi,
double res_lo,
double shift_limit,
871 pcc->
origin(0.0, 0.0, 0.0);
895 cout <<
"DEBUG Bimage::rotate_cross_correlate_two_way: fom=" <<
image->
FOM() << endl;
896 cout <<
"DEBUG Bimage::rotate_cross_correlate_two_way: ori=" <<
image->
origin() << endl;
930 double lores,
double radius,
double sigma,
int refine_flag)
934 cout <<
"Finding shift by cross-correlation and polynomial fitting" << endl << endl;
936 cout <<
"Finding shift by cross-correlation" << endl << endl;
940 if ( !pc )
return -1;
950 for ( nn=0; nn<pc->
images(); nn++ ) {
956 cout <<
"Image\t ox\t oy\t oz\t CC" << endl;
957 for ( nn=0; nn<n; nn++ )
969 double lores,
double radius,
double sigma,
int refine_flag,
double& cc)
973 cout <<
"Finding shift by cross-correlation and polynomial fitting" << endl << endl;
975 cout <<
"Finding shift by cross-correlation" << endl << endl;
981 if ( !pc )
return shift;
1029 double lores,
double radius,
double sigma,
int refine_flag,
1034 cout <<
"Finding shift by cross-correlation and polynomial fitting" << endl << endl;
1036 cout <<
"Finding shift by cross-correlation" << endl << endl;
1042 if ( !pc )
return shift;
1092 double lores,
double radius,
double sigma,
int refine_flag,
1097 cout <<
"Finding shift by cross-correlation and polynomial fitting" << endl << endl;
1099 cout <<
"Finding shift by cross-correlation" << endl << endl;
1105 if ( !pc )
return shift;
1119 cerr <<
"Error in find_shift: cc > 1: " << cc << endl;
1145 double hi_res,
double lo_res,
double shift_limit,
1192 cout <<
"Template origin: " << pt->
image->
origin() << endl;
1193 cout <<
"Template avg & std: " << pt->
average() <<
1236 double lores,
double radius,
double sigma,
int refine_flag)
1240 cout <<
"Finding center by cross-correlation and polynomial fitting" << endl << endl;
1242 cout <<
"Finding center by cross-correlation" << endl << endl;
1247 pc->
fft(FFTW_FORWARD, 0);
1259 pc->
fft(FFTW_BACKWARD, 0);
1273 for ( nn=0; nn<n; nn++ ) {
1281 cout <<
"Image\t ox\t oy\t oz\t CC" << endl;
1282 for ( nn=0; nn<n; nn++ )
1309 double hires,
double lores,
double radius,
double sigma,
1312 if ( radius <= 0 ) radius = x/4;
1342 if ( !d.
uc )
return -1;
1348 if ( radius < 0 ) radius = 1e30;
1349 else if ( radius < 1 ) radius = 0.9;
1353 cout <<
"DEBUG Bimage::find_peak: radius=" << radius << endl;
1355 long i, nn, xx, yy, zz;
1356 long xh(x/2), yh(y/2), zh(z/2);
1357 double x2, y2, z2, r;
1358 double value, maxval, fac(
GOLDEN/sigma);
1362 cout <<
"Finding the brightest voxel:" << endl;
1363 cout <<
"Radius & sigma: " << radius <<
" " << sigma << endl;
1365 cout <<
"n\tx\ty\tz\tv" << endl;
1368 for ( i=nn=0; nn<n; nn++ ) {
1370 if ( x <= 1 ) ori[0] = 0;
1371 if ( y <= 1 ) ori[1] = 0;
1372 if ( z <= 1 ) ori[2] = 0;
1374 cout <<
"DEBUG Bimage::find_peak: ori=" << ori << endl;
1377 for ( zz=0; zz<z; zz++ ) {
1379 if ( z2 < -zh ) z2 += z;
1380 if ( z2 > zh ) z2 -= z;
1382 for ( yy=0; yy<y; yy++ ) {
1384 if ( y2 < -yh ) y2 += y;
1385 if ( y2 > yh ) y2 -= y;
1387 for ( xx=0; xx<x; xx++, i++ ) {
1389 if ( x2 < -xh ) x2 += x;
1390 if ( x2 > xh ) x2 -= x;
1392 r = sqrt(x2 + y2 + z2) - radius;
1394 if ( sigma > 1e-30 ) value *= 1/(1 + exp(fac*r));
1395 if ( r <= 0 && maxval < value ) {
1407 cout <<
"DEBUG Bimage::find_peak: peak=" << peak << endl;
1408 cout <<
"DEBUG Bimage::find_peak: maxval=" << maxval << endl;
1411 cerr <<
"Error in find_peak: maxval > 1: " << maxval << endl;
1437 long i, j, k, nterm(9);
1442 vector<double> b(nterm);
1443 vector<double> vec(nterm);
1447 for ( j=0; j<nterm; ++j ) {
1448 for ( k=0; k<nterm; ++k ) a[j][k] = 0;
1452 for ( i=zz=0; zz<z; ++zz ) {
1454 vec[8] = vec[2]*vec[2];
1455 for ( yy=0; yy<y; ++yy ) {
1457 vec[5] = vec[1]*vec[2];
1458 vec[7] = vec[1]*vec[1];
1459 for ( xx=0; xx<x; ++xx, ++i ) {
1461 vec[3] = vec[0]*vec[1];
1462 vec[4] = vec[0]*vec[2];
1463 vec[6] = vec[0]*vec[0];
1464 for ( j=0; j<nterm; ++j ) b[j] += vec[j]*(*
this)[i];
1465 for ( j=0; j<nterm; ++j )
1466 for ( k=0; k<=j; ++k ) a[j][k] += vec[j]*vec[k];
1471 for ( j=0; j<nterm; ++j )
1472 for ( k=j+1; k<nterm; ++k ) a[j][k] = a[k][j];
1473 for ( j=0; j<nterm; ++j )
1474 if ( fabs(a[j][j]) < 1e-37 ) a[j][j] = 1;
1477 cout <<
"DEBUG Bimage::fit_peak: Input matrix:" << endl;
1479 cout <<
"DEBUG Bimage::fit_peak: Input vector:";
1480 for ( j=0; j<nterm; ++j ) cout <<
tab << b[j];
1488 cout <<
"DEBUG Bimage::fit_peak: Ouput matrix:" << endl;
1490 cout <<
"DEBUG Bimage::fit_peak: Coefficients: ";
1491 for ( j=0; j<nterm; ++j ) cout <<
tab << b[j];
1496 vector<double> d(3);
1497 for ( j=0; j<3; ++j ) d[j] = -b[j];
1499 c[0][1] = c[1][0] = b[3];
1500 c[0][2] = c[2][0] = b[4];
1502 c[1][2] = c[2][1] = b[5];
1515 double cc = vm + b[0]*d[0] + b[1]*d[1] + b[2]*d[2]
1516 + b[3]*d[0]*d[1] + b[4]*d[0]*d[2] + b[5]*d[1]*d[2]
1517 + b[6]*d[0]*d[0] + b[7]*d[1]*d[1] + b[8]*d[2]*d[2];
1525 cout <<
"DEBUG Bimage::fit_peak: Shift: ";
1526 for ( j=0; j<3; ++j ) cout <<
tab << d[j];
1527 cout <<
tab << cc << endl;
1532 cerr <<
"Error in fit_peak: cc = " << cc << endl;
1533 cerr <<
"peak = " << peak << endl;
1576 if ( !d.
uc )
return -1;
1580 long nn, kernel_size(2);
1581 Vector3<long> ksize(2*kernel_size+1,2*kernel_size+1,2*kernel_size+1);
1586 cout <<
"Finding the shift in each image" << endl;
1587 cout <<
"n\tx\ty\tz" << endl;
1590 for ( nn=0; nn<n; nn++ ) {
1599 cout << nn+1 <<
tab <<
shift << endl;
1617 if ( !d.
uc )
return -1;
1621 long i, j, nn, kernel_size(5), nterm(7);
1622 long xx, yy, zz, xlo, xhi, ylo, yhi, zlo, zhi, ix, iy, iz;
1626 vector<double> b(nterm);
1627 vector<double> vec(nterm);
1630 cout <<
"Finding the shift in each image" << endl;
1631 cout <<
"n\tx\ty\tz\tv" << endl;
1634 for ( nn=0; nn<n; nn++ ) {
1636 int_shift[0] = (long)
shift[0];
1637 int_shift[1] = (long)
shift[1];
1638 int_shift[2] = (long)
shift[2];
1639 xlo = (long) (
shift[0] - kernel_size);
1640 xhi = (long) (
shift[0] + kernel_size);
1641 if ( xhi - xlo >= x ) {
1645 ylo = (long) (
shift[1] - kernel_size);
1646 yhi = (long) (
shift[1] + kernel_size);
1647 if ( yhi - ylo >= y ) {
1651 zlo = (long) (
shift[2] - kernel_size);
1652 zhi = (long) (
shift[2] + kernel_size);
1653 if ( zhi - zlo >= z ) {
1658 cout <<
"DEBUG Bimage::refine_peak: kernel limits = " <<
1659 xlo <<
tab << xhi <<
tab << ylo <<
tab << yhi <<
tab << zlo <<
tab << zhi << endl;
1660 for ( i=0; i<nterm; i++ ) {
1661 for ( j=0; j<nterm; j++ ) a[i][j] = 0;
1665 for ( zz=zlo; zz<=zhi; zz++ ) {
1667 if ( iz < 0 ) iz += z;
1668 if ( iz >= (
long)z ) iz -= z;
1671 for ( yy=ylo; yy<=yhi; yy++ ) {
1673 if ( iy < 0 ) iy += y;
1674 if ( iy >= (
long)y ) iy -= y;
1677 for ( xx=xlo; xx<=xhi; xx++ ) {
1679 if ( ix < 0 ) ix += x;
1680 if ( ix >= (
long)x ) ix -= x;
1681 i =
index(0,ix,iy,iz,nn);
1685 error_show(
"Error in Bimage::refine_peak", __FILE__, __LINE__);
1686 cerr << ix <<
" " << iy <<
" " << iz <<
" " << (*this)[i] << endl;
1689 for ( j=0; j<nterm; j++ ) b[j] += vec[j]*(*
this)[i];
1690 for ( i=0; i<nterm; i++ )
1691 for ( j=0; j<=i; j++ ) a[i][j] += vec[i]*vec[j];
1695 for ( i=0; i<nterm-1; i++ )
1696 for ( j=i+1; j<nterm; j++ ) a[i][j] = a[j][i];
1697 for ( i=0; i<nterm; i++ )
1698 if ( fabs(a[i][i]) < 1e-37 ) a[i][i] = 1;
1700 cout <<
"DEBUG Bimage::refine_peak: Input matrix:" << endl;
1702 cout <<
"DEBUG Bimage::refine_peak: Input vector:";
1703 for ( i=0; i<nterm; i++ ) cout <<
tab << b[i];
1708 cout <<
"DEBUG Bimage::refine_peak: Coefficients: " <<
1709 b[0] <<
tab << b[1] <<
tab << b[2] <<
tab << b[3] <<
tab << b[4] <<
tab << b[5] <<
tab << b[6] << endl;
1710 if ( b[4] )
shift[0] = -0.5*b[1]/b[4];
1711 if ( b[5] )
shift[1] = -0.5*b[2]/b[5];
1712 if ( b[6] )
shift[2] = -0.5*b[3]/b[6];
1719 cout << n+1 <<
tab <<
shift << endl;
1741 if ( kernelsize < 3 ) kernelsize = 3;
1742 if ( kernelsize%2 == 0 ) kernelsize++;
1744 long i, ii, ip, xx, yy, zz, nn, np(0);
1745 long xlo, xhi, ylo, yhi, zlo, zhi, kx, ky, kz, ix, iy, iz;
1749 hk = hk.
min(kernelsize/2);
1752 cout <<
"Finding peaks:" << endl;
1755 cout <<
"DEBUG Bimage::find_peaks: hk=" << hk << endl;
1759 for ( i=nn=0; nn<n; nn++ ) {
1760 for ( zz=0; zz<z; zz++ ) {
1763 for ( yy=0; yy<y; yy++ ) {
1766 for ( xx=0; xx<x; xx++, i++ ) {
1773 for ( kz=zlo; kz<=zhi; kz++ ) {
1775 if ( iz < 0 ) iz += z;
1776 if ( iz >= z ) iz -= z;
1777 for ( ky=ylo; ky<=yhi; ky++ ) {
1779 if ( iy < 0 ) iy += y;
1780 if ( iy >= y ) iy -= y;
1781 for ( kx=xlo; kx<=xhi; kx++ ) {
1783 if ( ix < 0 ) ix += x;
1784 if ( ix >= x ) ix -= x;
1785 ii =
index(ix, iy, iz, nn);
1786 if ( max < (*
this)[ii] ) {
1804 cout <<
"Peaks found: " << np << endl << endl;
1829 double& threshold_min,
double& threshold_max,
double pix_min,
double pix_max)
1831 if ( threshold_min < min ) threshold_min = min;
1832 if ( threshold_max > max ) threshold_max = max;
1834 long rad = (long) excl_dist/2;
1837 tile = tile.
min(rad);
1840 start = start.
max(tile);
1850 cout <<
"Finding peaks in the cross-correlation map:" << endl;
1851 cout <<
"Exclusion distance: " << excl_dist << endl;
1852 cout <<
"Thresholds: " << threshold_min <<
" - " << threshold_max << endl;
1853 cout <<
"Tile size: " << tile << endl;
1854 cout <<
"Starting coordinates: " << start << endl;
1855 cout <<
"Ending coordinates: " << end << endl;
1858 long i, k, l, nc, xx, yy, zz, tx, ty, tz, nn;
1859 long nt = ((x-1)/tile[0]+1)*((y-1)/tile[1]+1)*((z-1)/tile[2]+1);
1860 double max(-1e30), v;
1862 double* cc =
new double[nt];
1865 cout <<
"Allocated number of coordinates: " << nt << endl;
1867 for ( nn=0, nc=0; nn<n; nn++ ) {
1868 for ( zz=start[2]; zz<end[2]; zz+=rad ) {
1869 for ( yy=start[1]; yy<end[1]; yy+=rad ) {
1870 for ( xx=start[0]; xx<end[0]; xx+=rad ) {
1872 for ( tz=zz; tz<zz+tile[2] && tz<end[2]; tz++ ) {
1873 for ( ty=yy; ty<yy+tile[1] && ty<end[1]; ty++ ) {
1874 for ( tx=xx; tx<xx+tile[0] && tx<end[0]; tx++ ) {
1875 i =
index(0,tx,ty,tz,nn);
1877 if ( v > threshold_min && v <= threshold_max && cc[nc] < v ) {
1886 if ( cc[nc] > threshold_min && cc[nc] <= threshold_max ) {
1893 }
else cc[nc] = -1e30;
1903 cout <<
"Number of peaks found: " << nc << endl;
1904 cout <<
"Maximum CC: " << max << endl;
1905 cout <<
"Threshold: " << threshold_min << endl;
1908 for ( k=0, ncoor=0; k<nc; k++ )
if ( cc[k] > threshold_min ) {
1909 for ( l=k+1; l<nc; l++ )
if ( cc[l] > threshold_min ) {
1910 if ( (ct[k] - ct[l]).
length() < excl_dist ) {
1911 if ( cc[k] > cc[l] ) cc[l] = threshold_min - 1;
1912 else cc[k] = threshold_min - 1;
1915 if ( cc[k] > threshold_min ) ++ncoor;
1920 for ( i=k=0; k<nc; k++ )
if ( cc[k] >= threshold_min )
1927 cout <<
"Number of peaks found: " << ncoor << endl << endl;
1952 long i, j, imax(0), imgsize(x*y*z);
1953 double v, vmax(min), vmax2(min), zavg(0), zstd(0), pval(0);
1956 for ( i=nn*imgsize, j=0; j<imgsize; i++, j++ ) {
1963 }
else if ( vmax2 < v ) {
1977 zstd = zstd/imgsize - zavg*zavg;
1987 cout <<
"DEBUG Bimage::ccmap_confidence: z std:\t" << zstd <<
tab << 1/(sqrt(imgsize - 3.0)) << endl;
1988 cout <<
"DEBUG Bimage::ccmap_confidence: maxima:\t" << vmax <<
tab << vmax2 << endl;
2008 long xx, yy, zz, nv(0);
2009 double sigma(0), dx2, dy2, dz2, r2, v, vmax(
get(nn,coor));
2018 for ( zz=cmin[2]; zz<cmax[2]; zz++ ) {
2021 for ( yy=cmin[1]; yy<cmax[1]; yy++ ) {
2024 for ( xx=cmin[0]; xx<cmax[0]; xx++ ) {
2027 r2 = dx2 + dy2 + dz2;
2029 v =
get(nn, xx, yy, zz);
2031 if ( v > 0 && v < vmax ) {
2032 sigma += r2/log(vmax/v);
2040 if ( nv ) sigma = sqrt(sigma/(2*nv));