 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
33 return error_show(
"No markers found!", __FILE__, __LINE__);
38 for ( mark =
model; mark; mark=mark->
next ) {
63 return error_show(
"No model markers found!", __FILE__, __LINE__);
72 cout <<
"DEBUG mg_marker_update: mg=" << mg->
id << endl;
74 for ( modmark =
model; modmark; modmark = modmark->
next ) {
75 upd = update_location;
76 for ( mark = mg->
mark; mark && mark->
id != modmark->
id; mark = mark->
next ) ;
79 mark->
id = modmark->
id;
114 return error_show(
"No model markers found!", __FILE__, __LINE__);
119 for ( mark = mg->
mark; mark; mark = mark->
next ) {
120 for ( modmark =
model; modmark && mark->
id != modmark->
id; modmark = modmark->
next ) ;
123 modmark->
id = mark->
id;
192 double outrad = sqrt(2.0)*radius;
200 cout <<
"DEBUG img_gold_particle: rad=" << radius << endl;
230 if ( radius < 1 )
return NULL;
234 if ( img_select > -1 ) {
235 if ( img_select >= p->
images() ) img_select = p->
images() - 1;
236 img_start = img_select;
237 img_end = img_start + 1;
242 long i, j, x, y, z, n, nn, np(0);
244 double fom_avg(0), fom_std(0), fom_max(0);
249 cout <<
"Finding particles:" << endl;
250 cout <<
"Particle radius: " << radius*p->
sampling(0)[0]
251 <<
" A " << radius <<
" pixels" << endl;
252 cout <<
"Edge: " << edge <<
" pixels" << endl;
256 cout <<
"DEBUG img_find_gold_particles: radius=" << radius << endl;
262 long fomsize(imgsize);
263 if ( img_select < 0 ) fomsize *= p->
images();
264 float* fom =
new float[fomsize];
265 for ( i=0; i<fomsize; i++ ) fom[i] = 0;
269 for ( i=0, n=img_start; n<img_end; n++ ) {
275 for ( j=0; j<imgsize; j++, i++ )
if ( (*pone)[j] ) {
278 fom_std += fom[i]*fom[i];
279 if ( fom_max < fom[i] ) fom_max = fom[i];
284 cout <<
"Image " << n <<
": " << np <<
" gold fiducials" << endl;
288 fom_std = fom_std/np - fom_avg*fom_avg;
289 if ( fom_std > 0 ) fom_std = sqrt(fom_std);
291 if ( cutoff == 0 ) cutoff = fom_avg + fom_std;
292 else if ( cutoff < 0 ) cutoff = fom_max/2;
294 cout <<
"Cutoff = " << cutoff << endl;
301 cout <<
"Marker\tx\ty\tz\tn\tFOM" << endl;
302 for ( j=nn=0, n=img_start; n<img_end; n++, nn++ ) {
303 for ( z=0; z<p->
sizeZ(); z++ ) {
305 if ( zz < 0 ) zz += p->
sizeZ();
306 if ( zz >= ve[2] && zz < p->sizeZ()-ve[2] )
307 for ( y=0; y<p->
sizeY(); y++ ) {
309 if ( yy < 0 ) yy += p->
sizeY();
310 if ( yy >= ve[1] && yy < p->sizeY()-ve[1] )
311 for ( x=0; x<p->
sizeX(); x++ ) {
313 if ( xx < 0 ) xx += p->
sizeX();
314 if ( xx >= ve[0] && xx < p->sizeX()-ve[0] ) {
315 i = p->
index(x, y, z, nn);
316 if ( fom[i] > cutoff ) {
318 if ( !mark ) mark = m;
347 cout <<
"Number of particles found: " << j << endl << endl;
380 DataType datatype,
int setinputZslices,
int setoutputZslices,
381 double cutmin,
double cutmax,
double replace_threshold)
394 for ( mg = field->
mg; mg; mg = mg->
next ) {
395 if ( oldname != mg->
fmg ) {
399 error_show(
"project_mass_normalize", __FILE__, __LINE__);
402 nudatatype = datatype;
408 if ( setinputZslices )
410 error_show(
"project_mass_normalize", __FILE__, __LINE__);
416 if ( replace_threshold != 0 )
419 if ( norm_type >= 0 )
422 if ( setoutputZslices )
424 error_show(
"project_mass_normalize", __FILE__, __LINE__);
448 double R(0), df, fs(0), fs2(0);
452 for ( i=0; i<simp.
points(); i++ ) {
464 if ( df > 0 ) R = sqrt(R/df);
475 for ( i=0; i<I.size(); ++i )
if ( Imax < I[i] ) Imax = I[i];
477 Bsimplex simp(1, 3, 0, a.size(), a, I);
482 simp.
limits(0, 0.9*Imax, 5*Imax);
484 simp.
limits(2, -0.5, 0.5);
491 for ( i=0; i<maxiter && ( !
isfinite(R) || R > 1 ); ++i ) {
499 vector<double> result;
500 for ( i=0; i<3; ++i )
526 double amin(0), amax(0), Imin(1e30), Imax(-1e30);
549 for ( mg = field->
mg; mg; mg = mg->
next ) {
569 error_show(
"project_thickness_to_lambda_ratio", __FILE__, __LINE__);
579 for ( i=0, j=plot->
rows(), k=2*j, mg = field->
mg; mg; mg = mg->
next )
585 if ( amax < mg->tilt_angle ) amax = mg->
tilt_angle;
593 if ( -amin < amax ) amin = -amax;
595 Imin = f*long(Imin/f);
596 Imax = f*long(Imax/f+1);
630 cerr <<
"Too few micrographs to determine the thickness!" << endl;
637 vector<double> a(plot->
rows()), I(plot->
rows());
638 for ( i=0, j=plot->
rows(); i<plot->rows(); ++i, ++j ) {
646 double I0 = result[0];
647 double tlr = result[1];
648 double da = result[2];
649 double R = result[3];
653 cout << endl <<
"Tilt\tInt\tInt(calc)" << endl;
654 for ( i=0, j=plot->
rows(), k=2*j; i<plot->rows(); ++i, ++j, ++k ) {
655 Ip = I0*exp(-tlr/cos(a[i]+da));
656 (*plot)[i] = a[i]*180.0/
M_PI;
659 cout << a[i]*180.0/
M_PI <<
tab << I[i] <<
tab << Ip << endl;
663 txt =
Bstring(I0,
"Direct beam intensity: %lg");
665 txt =
Bstring(tlr,
"Tilt-lambda ratio: %lg");
667 txt =
Bstring(da*180.0/
M_PI,
"Specimen tilt angle: %lg");
673 for ( mg = field->
mg; mg; mg = mg->
next )
677 cout << endl <<
"Calculating tilt intensity parameters:" << endl;
678 cout <<
"Residual: " << R << endl;
679 cout <<
"Direct beam intensity: " << I0 << endl;
680 cout <<
"Specimen tilt: " << da*180.0/
M_PI <<
" degrees" << endl;
681 cout <<
"Thickness to lambda ratio: " << tlr << endl << endl;
706 vector<double> a(nmg), I(nmg);
711 for ( mg = field->
mg; mg; mg = mg->
next ) {
731 error_show(
"project_thickness_to_lambda_ratio", __FILE__, __LINE__);
741 for ( i=0, mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
752 cerr <<
"Too few micrographs to determine the thickness!" << endl;
758 double I0 = result[0];
759 double tlr = result[1];
760 double da = result[2];
761 double R = result[3];
765 cout << endl <<
"Tilt\tInt\tInt(calc)" << endl;
766 for ( i=0, j=a.size(), k=2*j; i<a.size(); ++i, ++j, ++k ) {
767 Ip = I0*exp(-tlr/cos(a[i]+da));
769 cout << a[i]*180.0/
M_PI <<
tab << I[i] <<
tab << Ip << endl;
772 for ( mg = field->
mg; mg; mg = mg->
next )
776 cout << endl <<
"Calculating tilt intensity parameters:" << endl;
777 cout <<
"Residual: " << R << endl;
778 cout <<
"Direct beam intensity: " << I0 << endl;
779 cout <<
"Specimen tilt: " << da*180.0/
M_PI <<
" degrees" << endl;
780 cout <<
"Thickness to lambda ratio: " << tlr << endl << endl;
801 double lambda = thickness/tlr;
804 cout <<
"Thickness: " << thickness <<
" A" << endl;
805 cout <<
"Proportionality parameter: " << lambda <<
" A" << endl << endl;
826 double thickness = lambda*tlr;
829 cout <<
"Thickness: " << thickness <<
" A" << endl << endl;
830 cout <<
"Proportionality parameter: " << lambda <<
" A" << endl << endl;
850 cout <<
"Sorting markers" << endl << endl;
853 for ( mg = field->
mg; mg; mg = mg->
next )
881 double d(0), dsum(0), dmgsum, w(0), wmg, mgfom, avg_axis(0), wa, wax(0);
903 for ( mr = rec->
mark; mr; mr = mr->
next ) {
910 cout <<
"Tomography alignment results:" << endl;
911 cout <<
"Mg\tShiftX\tShiftY\tScaleX\tScaleY\tAxis\tTilt\tLevel\tn\tResid\tFOM" << endl;
923 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
925 dmgsum = wmg = mgfom = 0;
928 for ( mr = rec->
mark; mr; mr = mr->
next ) {
929 for ( m = mg->
mark; m && m->
id != mr->
id; m = m->
next ) ;
946 cout << mg->
id <<
tab << m->
id <<
tab << loc[0] <<
tab << loc[1] <<
tab << loc[2] <<
tab << d << endl;
952 mg->
fom = sqrt(dmgsum/wmg);
961 cout << mg->
id <<
tab << fixed << setprecision(2) << shift[0] <<
tab << shift[1] <<
tab
966 << wmg <<
tab << mg->
fom <<
tab << mgfom << endl;
970 if ( wax ) avg_axis /= wax;
971 if ( w ) d = sqrt(dsum/w);
978 for ( mr = rec->
mark; mr; mr = mr->
next ) {
984 cout <<
"Average tilt axis angle: " << avg_axis*180.0/
M_PI << endl << endl;
985 cout <<
"Marker errors:\nMarker\tn\tx\ty\tResid\tFOM" << endl;
986 for ( mr = rec->
mark; mr; mr = mr->
next )
988 setprecision(3) << mr->
err[0] <<
tab << mr->
err[1] <<
tab <<
989 mr->
res <<
tab << setprecision(4) << mr->
fom << endl;
990 cout <<
"Average residual = " << d <<
" pixels" << endl << endl;
1010 double d(0), dsum(0), w(0);
1013 for ( m = mg->
mark; m && m->
id != mr->
id; m = m->
next ) ;
1027 if ( w ) d = sqrt(dsum/w);
1049 for ( i=0; i<1000; i++ ) h[i] = 0;
1052 for ( mg = field->
mg; mg->
next; mg = mg->
next ) {
1054 i = (int) (scale*(m1->
err - m2->
err).length() + 0.5);
1064 cout <<
"Histogram of marker refinement shifts:" << endl;
1065 cout <<
"Shift\tCount" << endl;
1066 for ( i=0; i<=n; i++ )
1067 cout << setprecision(2) << i/scale <<
tab << h[i] << endl;
1098 if ( !mg_ref->
mark )
1102 return error_show(
"project_calculate_model: No markers defined!", __FILE__, __LINE__);
1112 cout <<
"Calculating a 3D marker model" << endl << endl;
1120 for ( mg = field->
mg; mg; mg = mg->
next ) {
1121 for ( m = mg->
mark; m; m = m->
next ) {
1122 for ( mr = rec->
mark; mr && mr->
id != m->
id; mr = mr->
next ) ;
1138 for ( mg = field->
mg; mg; mg = mg->
next ) {
1141 for ( mr = rec->
mark; mr; mr = mr->
next ) {
1142 for ( m = mg->
mark; m && m->
id != mr->
id; m = m->
next ) ;
1156 for ( mr = rec->
mark; mr; mr = mr->
next ) {
1161 for ( mg = field->
mg; mg; mg = mg->
next ) {
1162 for ( mr = rec->
mark; mr; mr = mr->
next ) {
1163 for ( m = mg->
mark; m && m->
id != mr->
id; m = m->
next ) ;
1174 if ( mg->
matrix[2][0] ) {
1178 if ( mg->
matrix[2][1] ) {
1186 for ( mr = rec->
mark; mr; mr = mr->
next ) {
1212 cout <<
"Generating missing markers" << endl << endl;
1215 for ( mg = field->
mg; mg; mg = mg->
next )
1219 for ( mg = field->
mg; mg; mg = mg->
next )
1238 if ( marker_radius < 1 )
return 0;
1242 for ( ; mark; mark = mark->
next, nm++ ) {
1263 cout <<
"Reading image " << mg->
img_num <<
" (micrograph " << mg->
id <<
")" << endl;
1267 error_show(
"mg_erase_markers", __FILE__, __LINE__);
1277 if ( marker_radius < 1 )
return p;
1298 if ( nmg < 1 )
return -1;
1307 cout <<
"Removing markers with radius " << marker_radius << endl << endl;
1313 error_show(
"project_erase_markers", __FILE__, __LINE__);
1320 for ( n=0, mg = field->
mg; mg; mg = mg->
next, n++ ) {
1322 cout <<
"Reading image " << mg->
img_num <<
" (micrograph " << mg->
id <<
")" << endl;
1325 error_show(
"project_remove_markers", __FILE__, __LINE__);
1351 if ( !mg->
mark )
return 0;
1357 cout <<
"Resetting 3D model x and y coordinates:" << endl;
1358 cout <<
"Micrograph: " << mg->
id << endl << endl;
1363 for ( m = mg->
mark; m; m = m->
next ) {
1374 for ( mr =
model; mr; mr = mr->
next, n++ ) ns += mr->
sel;
1377 cout <<
"Markers in model: " << n <<
" (" << ns <<
")" << endl << endl;
1400 for ( mg = field->
mg; mg; mg = mg->
next )
1422 cerr <<
"Error: The marker radius is too low! (" << mg->
mark_radius <<
")" << endl;
1428 return error_show(
"mg_find_markers", __FILE__, __LINE__);
1457 error_show(
"No markers found!", __FILE__, __LINE__);
1467 cout <<
"DEBUG mg_composite_particle: size = " << size << endl;
1471 error_show(
"mg_composite_particle", __FILE__, __LINE__);
1481 for ( n=0, mark = mg->
mark; mark; mark = mark->
next, n++ )
if ( mark->
sel > 0 ) {
1482 gorigin = mark->
loc - ghalf;
1483 pmark = p->
extract(0, gorigin, size);
1520 for ( mg = field->
mg; mg; mg = mg->
next )
1545 cout <<
"Project markers:" << endl;
1547 cout <<
"Field: " << field->
id << endl;
1548 for ( mg = field->
mg; mg; mg = mg->
next ) {
1551 cout <<
"\tMicrograph: " << mg->
id <<
tab << i <<
" markers\tselection = " << mg->
select << endl;
1554 cout <<
"Total:\t" << nmark <<
" markers" << endl << endl;
1570 long nmark(0), nerr(0);
1575 cout <<
"Project marker errors:" << endl;
1576 cout <<
"Micrograph\tMarker\tx\ty\tex\tey\ted" << endl;
1578 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
1579 for ( m = mg->
mark; m; m = m->
next )
if ( m->
sel > 0 ) {
1580 if ( m->
res > error_cutoff ) {
1589 cout <<
"Total above " << error_cutoff <<
":\t" << nerr <<
" markers (" << nerr*100.0/nmark <<
"%)" << endl << endl;
1614 for ( mg = field->
mg; mg; mg = mg->
next )
1615 for ( mark = mg->
mark; mark; mark = mark->
next )
1616 if ( maxid < mark->
id ) maxid = mark->
id;
1619 for ( mark = rec->
mark; mark; mark = mark->
next )
1620 if ( maxid < mark->
id ) maxid = mark->
id;
1630 cout <<
"Deselecting markers" << endl << endl;
1632 for ( mg = field->
mg; mg; mg = mg->
next ) {
1633 for ( mark = mg->
mark; mark; mark = mark->
next )
1634 if ( sel[mark->
id] ) mark->
sel = 0;
1639 for ( mark = rec->
mark; mark; mark = mark->
next ) {
1640 if ( sel[mark->
id] ) mark->
sel = 0;
1671 for ( mg = field->
mg; mg; mg = mg->
next )
1672 for ( mark = mg->
mark; mark; mark = mark->
next )
1673 if ( maxid < mark->
id ) maxid = mark->
id;
1683 cout <<
"Deleting markers:" << endl;
1686 cout <<
"Field: " << field->
id <<
":" << endl;
1687 for ( mg = field->
mg; mg; mg = mg->
next ) {
1689 cout <<
"\tMicrograph: " << mg->
id << endl;
1690 for ( mark = mg->
mark; mark; ) {
1691 if ( sel[mark->
id] ) {
1693 cout <<
"\t\tDeleting marker: " << mark->
id << endl;
1704 cout <<
"Reconstruction: " << rec->
id << endl;
1705 for ( mark = rec->
mark; mark; ) {
1706 if ( sel[mark->
id] ) {
1708 cout <<
"\t\tDeleting marker: " << mark->
id << endl;
1744 for ( mg = field->
mg; mg; mg = mg->
next )
1745 for ( mark = mg->
mark; mark; mark = mark->
next )
1746 if ( maxid < mark->
id ) maxid = mark->
id;
1749 for ( mark = rec->
mark; mark; mark = mark->
next );
1750 if ( maxid < mark->
id ) maxid = mark->
id;
1753 cout <<
"DEBUG project_renumber_markers: maxid=" << maxid << endl;
1758 int*
id =
new int[maxid];
1759 for ( i=0; i<maxid; i++ )
id[i] = 0;
1762 for ( mg = field->
mg; mg; mg = mg->
next )
1763 for ( mark = mg->
mark; mark; mark = mark->
next )
1767 for ( mark = rec->
mark; mark; mark = mark->
next );
1771 for ( i=j=0; i<maxid; i++ )
1772 if (
id[i] )
id[i] = ++j;
1775 cout <<
"DEBUG project_renumber_markers: new maxid=" << j << endl;
1778 for ( mg = field->
mg; mg; mg = mg->
next )
1779 for ( mark = mg->
mark; mark; mark = mark->
next )
1780 mark->
id =
id[mark->
id];
1783 for ( mark = rec->
mark; mark; mark = mark->
next );
1784 mark->
id =
id[mark->
id];
1804 if ( mg_select.
length() < 1 )
return 0;
1813 cout <<
"Selecting micrographs:" << endl;
1815 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
1817 for (
size_t i=0; i<en.size(); i++ ) {
1822 cout <<
"Micrograph " << mg->
id <<
" (" << mg->
img_num <<
") selected" << endl;
1828 cout <<
"Total Selected: " << n << endl << endl;
1843 long i, nmg(0), n(0);
1847 if ( mg_exclude.
contains(
"none") ) {
1849 for ( mg = field->
mg; mg; mg = mg->
next ) mg->
select = 1;
1854 for ( nmg=0, mg = field->
mg; mg; mg = mg->
next )
1855 if ( nmg <= mg->img_num ) nmg++;
1863 cout <<
"Deselecting micrographs:" << endl;
1865 for ( i=0, mg = field->
mg; mg; mg = mg->
next, i++ )
if ( en[i] ) {
1869 cout <<
"Micrograph " << mg->
id <<
" (" << mg->
img_num <<
") deselected" << endl;
1873 cout <<
"Total deselected: " << n << endl << endl;
1895 for ( mg = field->
mg; mg; mg = mg->
next )
1917 for ( mg = field->
mg; mg; mg = mg->
next )
1942 if ( fabs(tilt_step) < 0.005 ) {
1943 cerr <<
"Error: The tilt step size is too small (" << tilt_step <<
")!" << endl;
1948 for ( tilt=tilt_start, mg = field->
mg; mg; mg = mg->
next, tilt+=tilt_step )
1968 double axis_angle, avg_axis(0), wa, wax(0);
1978 if ( field->
next ) {
1986 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
1993 tilt_axis = q.
axis();
1994 axis_angle = atan2(tilt_axis[1], tilt_axis[0]);
1995 if ( !
isfinite(axis_angle) ) axis_angle = 0;
2018 if ( wax ) avg_axis /= wax;
2022 for ( mg = field->
mg; mg; mg = mg->
next )
2042 for ( mg = field->
mg; mg; mg = mg->
next )
2065 for ( mg = field->
mg; mg; mg = mg->
next )
2066 for ( mark = mg->
mark; mark; mark = mark->
next )
2067 if ( mark->
fom >= fom ) mark->
sel = 1;
2086 for ( mg = field->
mg; mg; mg = mg->
next )
2116 cout <<
"Markers outside micrograph boundaries:" << endl;
2117 cout <<
"Micrograph\tMarker\tx\ty" << endl;
2121 for ( mg = field->
mg; mg; mg = mg->
next ) {
2122 for ( m = mg->
mark; m; m = m->
next ) {
2124 if ( flags & 1 ) cout << mg->
id <<
tab << m->
id <<
tab << m->
loc[0] <<
tab << m->
loc[1] << endl;
2125 if ( flags & 2 ) m->
sel = 0;
2126 if ( flags & 4 ) m->
fom = 0;
2127 if ( flags & 8 ) m->
err = m->
res = 0;
2152 for ( mg = field->
mg; mg; mg = mg->
next ) {
2183 for ( mg = field->
mg; mg; mg = mg->
next ) {
2194 double de(0), dr(0), edge, a(
GOLDEN/width);
2201 for ( i=yy=0; yy<p->
sizeY(); yy++ ) {
2203 for ( xx=0; xx<p->
sizeX(); xx++ ) {
2206 if ( r[0] < r[1] ) dr = a*r[1];
2208 de = a*(fabs(vec[0]*d[0] + vec[1]*d[1]) - dist);
2209 if ( dr > de ) de = dr;
2210 if ( de > 50 ) edge = 1e30;
2211 else edge = exp(de);
2213 cerr << xx <<
" " << yy <<
": Value too large or not finite!: " << edge <<endl;
2216 for ( cc=0; cc<p->
channels(); cc++, i++ )
2217 p->
set(i, ((*p)[i] + fill*edge)/(1+edge));
2235 return error_show(
"micrograph_clear_extraneous_areas", __FILE__, __LINE__);
2240 if ( v[0] && d > fabs(p->
sizeX()*0.5/v[0]) ) d = fabs(p->
sizeX()*0.5/v[0]);
2241 if ( v[1] && d > fabs(p->
sizeY()*0.5/v[1]) ) d = fabs(p->
sizeY()*0.5/v[1]);
2269 newfile = newfile.
insert(newfile.
rfind(
"."),
"_clr");
2272 for ( nmg=0, mg = field->
mg; mg; mg = mg->
next, nmg++ ) {
2274 cout <<
"Micrograph " << mg->
img_num <<
": " << mg->
fmg << endl;
2277 return error_show(
"project_clear_extraneous_areas", __FILE__, __LINE__);
2287 cout <<
"Clearing extraneous areas from micrographs:" << endl;
2288 cout <<
"Thickness: " << thickness << endl;
2289 cout <<
"Edge width: " << width << endl;
2290 cout <<
"New micrograph file name: " << newfile << endl << endl;
2305 for ( nmg=0, mg = field->
mg; mg; mg = mg->
next, nmg++ ) {
2344 double avg_z_offset(0), zs(0), d;
2349 for ( n=0, mg = field->
mg; mg; mg = mg->
next ) {
2356 if ( n ) avg_z_offset = zs/n;
2358 cout <<
"Average z offset: " << avg_z_offset << endl << endl;
2360 cout <<
"Micrograph\tOffset\tAdjusted" << endl;
2361 for ( mg = field->
mg; mg; mg = mg->
next ) {
2363 cout << mg->
id <<
tab << d <<
tab << d - fabs(avg_z_offset*sin(mg->
tilt_angle)) << endl;
2367 return avg_z_offset;
2391 cout <<
"Marker\tLocation\tResidual" << endl;
2392 for ( n=0, mark1 = rec1->
mark; mark1; mark1 = mark1->
next )
if ( mark1->
sel ) {
2393 for ( mark2 = rec2->
mark; mark2 && mark2->
id != mark1->
id; mark2 = mark2->
next ) ;
2394 if ( mark2 && mark2->
sel ) {
2397 R += mark1->
res*mark1->
res;
2399 mark1->
loc = (mark1->
loc + mark2->
loc)/2;
2401 cout << mark1->
id <<
tab << mark1->
loc <<
tab << mark1->
res << endl;
2405 if ( n ) R = sqrt(R/n);
2408 cout <<
"Markers selected: " << n << endl;
2409 cout <<
"Residual: " << R << endl << endl;
Bmicrograph * field_find_low_tilt_mg_with_markers(Bfield *field)
Finds the micrograph closest to a zero degree tilt in a series with markers.
int mg_marker_init(Bmicrograph *mg, Bmarker *model)
Initializes markers from the reference.
long field_count_micrographs(Bfield *field)
Counts all the micrographs in the field-of-view structure.
double project_thickness_to_lambda_ratio(Bproject *project)
Determines the thickness to mean free path ratio from a tilt series.
Header file for matrix functions.
long project_mg_select(Bproject *project, Bstring &mg_select)
Selects micrographs in a project hierarchy.
long markers_add(Bmarker **mark, Bmarker *mark2, double mindist, int sel)
Adds a set of markers to another.
Bmarker * img_find_gold_particles(Bimage *p, int img_select, double radius, long edge, double cutoff)
Finds gold particles in micrograph images.
long project_show_errors(Bproject *project, double error_cutoff)
Shows the errors in marker coordinates in a project hierarchy.
Bimage * find_peaks(long kernelsize)
Finds peaks in a map with periodic boundaries.
Bimage * symmetrize_cylinder(int flag)
Calculates a cylindrically symmetrized map.
Bstring insert(long pos, const Bstring &s)
long kill_list(char *list, unsigned long size)
Frees all the items in a linked list.
Bimage * cross_correlate(Bimage *p, double hires, double lores, fft_plan planf, fft_plan planb)
Calculates a cross-correlation map by Fast Fourier transformation.
double project_thickness(Bproject *project, double lambda)
Determines the thickness from a tilt series and mean free path.
void set(long j, double v)
Sets a single value at the given index.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Matrix3 transpose() const
double mg_tomo_residuals(Bmicrograph *mg, Bmarker *model, Vector3< double > oriref)
Calculates the residuals for an alignment solution of one micrograph.
int project_sort_markers_by_id(Bproject *project)
Sorts markers for each micrograph by ID number.
Bmarker * markers_copy(Bmarker *mark)
Copies a set of markers.
Transform marker_find_transform(Bmarker *markers1, Bmarker *markers2, Vector3< double > origin)
Determines the rotation matrix between two sets of markers.
long project_deselect_markers(Bproject *project, Bstring &deselect_list)
Deletes selected markers in a project hierarchy.
int project_set_nominal_mg_origins(Bproject *project)
Sets micrograph origins to the centers of the micrographs.
int mg_update_model(Bmicrograph *mg, Bmarker *model, Vector3< double > oriref)
Fills in missing markers in the 3D model from micrograph markers.
int project_fix_markers(Bproject *project)
Checks if the markers in a project parameter structure fall within micrographs.
int bexit(int value)
Exit function for cleanup and debugging.
int mg_marker_update(Bmicrograph *mg, Bmarker *model, Vector3< double > oriref, int update_location)
Calculates the predicted positions of markers from the reference.
long project_show_markers(Bproject *project)
Shows the markers in a project hierarchy.
Header file for micrograph processing.
int error_show(string message, string file, int line)
Displays the error with file and line reference.
int normalize(long imgnum, double average, double stdev, int norm_type, long bins)
Normalizes a sub-image to a desired average and standard deviation.
double background(long nn)
Vector3< long > size() const
Nelder and Mead downhill simplex method for generalized parameter fitting.
int project_erase_markers(Bproject *project, double marker_radius)
Erases or paints markers in micrographs.
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
Bimage * mg_erase_markers(Bmicrograph *mg, double marker_radius)
Erases or paints markers in micrographs.
void view(double x, double y, double z, double a)
vector< double > & dependent_values()
Structure used in the downhill simplex method.
long count_list(char *list)
Counts the number of items in a linked list.
double intensity(JSvalue &el, double d, double thickness, Batomtype *atompar, CTFparam &ctf)
Calculates the expected intensity given a thickness of vitreous ice.
double project_fit_intensities(Bproject *project, Bplot *plot, int flag)
Determines the thickness to mean free path ratio from a tilt series.
double angle_set_negPI_to_PI(double angle)
Returns an angle between -PI and PI.
long project_delete_markers(Bproject *project, Bstring &delete_list)
Deletes selected markers in a project hierarchy.
Bimage * mg_composite_particle(Bmicrograph *mg, Vector3< long > size)
Generates an average particle image from a micrograph.
Bimage * img_gold_particle(Vector3< long > size, double radius)
Generates an image representing a gold particle.
double distance(const Vector3 &v)
int project_mg_tilt_to_matrix(Bproject *project)
Sets the matrix from the tilt and axis angles for each micrograph.
int images_to_slices()
Changes the 2D images to slices in a 3D image.
vector< double > & independent_values()
long project_mg_exclude(Bproject *project, Bstring &mg_exclude)
Deselects micrographs in a project hierarchy.
Bimage * read_img(char *filename, int readdata, int img_select)
General driver function to read multiple image formats.
void origin(double x, double y, double z)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
void add(long j, double v)
int project_set_marker_radius(Bproject *project, double mark_radius)
Sets the marker radius in a project parameter structure.
double project_marker_rotation_axis(Bproject *project)
Determines the most likely rotation axis location for a tilt series.
long rfind(const Bstring &s)
long project_renumber_markers(Bproject *project)
Renumbers the markers in a project hierarchy.
int slices_to_images()
Changes the slices in a 3D image into a set of 2D images.
double project_tomo_errors(Bproject *project)
Analyzes marker errors.
int project_check_markers(Bproject *project, int flags)
Checks if the markers in a project parameter structure fall within micrographs.
Bplot * project_intensity_plot(Bproject *project)
Transfers the micrograph intensities for a field into a plot.
int project_merge_rec_markers(Bproject *project)
Merges the markers for two reconstructions.
void add_text(Bstring &s)
General image parameter class.
CompoundType compound_type()
Utilities for timing functions.
double lambda_R(Bsimplex &simp)
double run(long maxcycles, double tolerance, double(funk)(Bsimplex &))
unsigned char * data_alloc()
int project_mass_normalize(Bproject *project, double avg, double std, int norm_type, DataType datatype, int setinputZslices, int setoutputZslices, double cutmin, double cutmax, double replace_threshold)
Normalizes a set of images in a project to a desired average and standard deviation.
double project_lambda(Bproject *project, double thickness)
Determines the mean free path from a tilt series and thickness.
long field_count_mg_selected(Bfield *field)
Counts all the micrographs in the field-of-view structure.
int project_set_tilt_axis(Bproject *project, double tilt_axis)
Sets the tilt axis angle in a project parameter structure.
char * remove_item(char **list, char *item, unsigned long size)
Finds the given item and deletes it from the linked list.
int micrograph_clear_extraneous_areas(Bmicrograph *mg, Bimage *p, long thickness, double width)
Clears extraneous areas from a micrograph.
int project_calculate_model(Bproject *project)
Calculates the z-coordinates of the marker model.
int replace(Bimage *img)
Replaces the data with that from the given image.
Header file for image processing from micrograph structures.
void parameter(long i, double p)
int truncate_to_min_max(double minim, double maxim)
Truncates image data to a given minimum and maximum.
Vector3< double > mg_3D_location_from_marker(Vector3< double > loc, Vector3< double > ori3D, Matrix3 mat, Vector3< double > ori)
int project_mg_marker_select(Bproject *project, double fom)
Selects markers.
long img_erase_markers(Bimage *p, Bmarker *mark, double marker_radius)
Erases or paints markers in an image.
Header file for general utilities.
Bmicrograph * field_find_micrograph_by_tiltang(Bfield *field, double tiltang)
Returns a pointer to the micrograph in a field-of-view structure with the specified tilt angle.
ostream & tab(ostream &out)
int project_set_tilt_angles(Bproject *project, double tilt_start, double tilt_step)
Sets the tilt and tilt axis angles in a project parameter structure.
double project_tomo_residuals(Bproject *project, int show)
Calculates the residuals for an alignment solution.
bool isfinite(complex< T > &value)
void origin(double ox, double oy, double oz)
int reconstruction_kill(Breconstruction *rec)
Frees a whole reconstruction parameter structure.
Bmicrograph * field_find_zero_tilt_mg(Bfield *field)
Finds the micrograph closest to a zero degree tilt in a series.
long project_count_markers(Bproject *project)
Counts the markers in a project hierarchy.
int project_invert_tilt_axis(Bproject *project)
Inverts the tilt axis in a project parameter structure.
void change_type(char letter)
Get the data type indicated by a single letter code.
long index(long nx, long ny) const
Header file for 2D and 3D image I/O.
vector< double > simplex_fit_tilt_intensities(vector< double > &a, vector< double > &I)
Header file for micrograph processing.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
long project_find_markers(Bproject *project, long edge, int add)
Finds all markers in a project.
Header file for generalized linked list functions.
int mg_reset_model(Bmicrograph *mg, Bmarker *model)
Resets the model x and y coordinates from the zero-tilt micrograph.
Vector3< double > pixel_size
int img_clear_extraneous_areas(Bimage *p, Vector3< double > vec, double dist, double width)
void sampling(long nn, Vector3< double > u)
int project_generate_markers(Bproject *project)
Generates missing micrograph and model markers.
Bmarker * markers_sort_by_id(Bmarker **mark)
Sorts a set of markers by ID number.
DataType
Base data type specifier.
bool contains(const Bstring &s)
Breconstruction * reconstruction_add(Breconstruction **rec, Bstring &rec_id)
Adds a reconstruction parameter structure to a linked list.
int project_clear_extraneous_areas(Bproject *project, long thickness, double width)
Clears areas from a tilt series not used in a reconstruction.
void limits(long i, double vlo, double vhi)
Vector3< double > mg_location_from_3D_model(Vector3< double > loc3D, Matrix3 mat, Vector3< double > ori)
Calculates the 2D location of a marker from a 3D model.
int project_invert_matrices(Bproject *project)
Inverts the micrograph matrices in a project parameter structure.
long stats_within_radii(long nn, Vector3< double > loc, double rad_min, double rad_max, double &vavg, double &vstd)
Calculates the statistics for an image within given radii from a location.
int select_numbers(Bstring &string, int n, int *numsel)
Converts a string with a selection specification into an integer array.
long mg_find_markers(Bmicrograph *mg, long edge, int add)
Finds markers in a micrograph.
int project_calculate_angles(Bproject *project)
Calculates tilt and tilt axis angles from matrices in a project parameter structure.
Quaternion quaternion() const
long project_count_micrographs(Bproject *project)
Counts all the micrographs in the project structure.
long statistics()
Calculates the statistics for an image.
vector< long > split_into_integers(const Bstring &delim)
int sphere(Vector3< double > center, double radius, double width=0, int fill_type=0, double fill=0)
Fills a sphere within an image with a uniform value.
Header file for single particle image processing in Bsoft.
long replace_maxima(double threshold)
Replaces maxima above a threshold using local averages.