 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
51 if ( lores < 0 ) lores = 0;
52 if ( hires <= 0 ) hires = sam[0];
53 if ( lores > 0 && lores < hires ) swap(lores, hires);
56 double slo = (lores > 0)? 1/lores: 0;
61 long i, x, y, z, sign;
62 double sx, sy, sz, s, s2, w, ctf_fac,
base(0), env(0), ctf_env;
70 cout <<
"Calculating a CTF function:" << endl;
72 case 1: cout <<
"Flipping phases" << endl;
break;
73 case 2: cout <<
"Applying a CTF" << endl;
break;
74 case 3: cout <<
"Correcting for the CTF" << endl;
break;
75 case 4: cout <<
"Correcting for the CTF with an optimal Wiener filter" << endl;
break;
76 case 5: cout <<
"Correcting for the CTF with baseline enhancement" << endl;
break;
77 case 6: cout <<
"Correcting for the CTF with baseline2 enhancement" << endl;
break;
78 case 7: cout <<
"Flipping phases with baseline enhancement" << endl;
break;
79 case 8: cout <<
"Correcting for the CTF with baseline3 enhancement" << endl;
break;
87 cout <<
"Resolution range: " << hires <<
" - ";
88 if ( lores > 0 ) cout << lores <<
" A" << endl;
89 else cout <<
"inf A" << endl;
90 if ( action == 3 || action == 5 || action == 6 )
91 cout <<
"Wiener factor: " << wiener << endl;
93 cout <<
"Envelope: " << env_eq << endl;
94 cout <<
"Noise: " << base_eq << endl;
99 for ( i=z=0; z<p->
sizeZ(); z++ ) {
101 if ( z > h[2] ) sz -= p->
sizeZ();
103 for ( y=0; y<p->
sizeY(); y++ ) {
105 if ( y > h[1] ) sy -= p->
sizeY();
107 for ( x=0; x<p->
sizeX(); x++, i++ ) {
109 if ( x > h[0] ) sx -= p->
sizeX();
111 s2 = sx*sx + sy*sy + sz*sz;
113 if ( s >= slo && s <= shi ) {
114 ctf_fac = cp.
calculate(s2, atan2(sy,sx));
116 sign = ( ctf_fac < 0 )? -1: 1;
119 case 1: w = sign;
break;
120 case 2: w = ctf_fac;
break;
122 w = ctf_fac/(ctf_fac*ctf_fac + wiener);
127 ctf_env = ctf_fac*env;
128 w = ctf_fac*sqrt(env)/(ctf_fac*ctf_env +
base);
132 w = ctf_fac/(ctf_fac*ctf_fac*
base + wiener);
135 w = 1/(ctf_fac*
base + sign*wiener);
138 if (
base > 0 ) w = sign/sqrt(
base);
142 w = sign/sqrt(ctf_fac*ctf_fac*env +
base);
180 double sx, sy, sz, s2;
185 cout <<
"Calculating a wave aberration function:" << endl;
188 cout <<
"Voltage: " << cp.
volt() <<
" V" << endl;
189 cout <<
"Wavelength: " << cp.
lambda() <<
" A" << endl;
190 cout <<
"Cs: " << cp.
Cs() <<
" A" << endl;
191 cout <<
"Amplitude contrast: " << sin(cp.
amp_shift()) << endl;
195 for ( i=n=0; n<p->
images(); n++ ) {
196 for ( z=0; z<p->
sizeZ(); z++ ) {
198 if ( z > h[2] ) sz -= p->
sizeZ();
200 for ( y=0; y<p->
sizeY(); y++ ) {
202 if ( y > h[1] ) sy -= p->
sizeY();
204 for ( x=0; x<p->
sizeX(); x++, i++ ) {
206 if ( x > h[0] ) sx -= p->
sizeX();
208 s2 = sx*sx + sy*sy + sz*sz;
238 double lores,
double hires)
240 if ( action < 1 || action > 10 )
return 0;
242 if ( wiener < 0.01 ) wiener = 0.01;
251 int back_transform(0);
261 for ( nn=j=0; nn<p->
images(); nn++ )
269 if ( back_transform ) p->
fft(FFTW_BACKWARD);
279 if ( action < 1 || action > 10 )
return 0;
281 if ( wiener < 0.01 ) wiener = 0.01;
287 int back_transform(0);
292 cout <<
"DEBUG img_ctf_apply: image transformed" << endl;
297 for ( nn=j=0; nn<p->
images(); nn++ )
303 if ( back_transform ) {
307 cout <<
"DEBUG img_ctf_apply: image back-transformed" << endl;
316 double wiener,
double def,
double res_lo,
double res_hi,
333 pt->
resize(oldsize, translate);
357 cout <<
"DEBUG img_ctf_apply_to_proj: def_avg=" << em_ctf.
defocus_average() << endl;
361 img_ctf_apply(proj, em_ctf, 2, 0, res_lo, res_hi, planf_2D, planb_2D);
389 Vector3<long> tile_size,
double tilt,
double axis,
double res_lo,
double res_hi)
391 if ( res_lo > 0 && res_lo < res_hi ) swap(res_lo, res_hi);
399 tile_size = tile_size.
min(p->
size());
401 tile_size = tile_size.
max(min_size);
402 tile_size = tile_size.
min(max_size);
404 tile_size = tile_size.
min(p->
size());
413 double ca(cos(axis)), sa(sin(axis)), tt(tan(tilt));
415 double* d =
new double[pt->
images()];
419 for ( nn=0; nn<pt->
images(); nn++ ) {
431 cout <<
"Applying a tilted image transfer function:" << endl;
433 case 1: cout <<
"Flipping phases" << endl;
break;
434 case 2: cout <<
"Applying a CTF" << endl;
break;
435 case 3: cout <<
"Correcting for the CTF" << endl;
break;
436 case 4: cout <<
"Correcting for the CTF with an optimal Wiener filter" << endl;
break;
437 case 5: cout <<
"Correcting for the CTF with baseline enhancement" << endl;
break;
438 case 6: cout <<
"Correcting for the CTF with baseline2 enhancement" << endl;
break;
439 case 7: cout <<
"Flipping phases with baseline enhancement" << endl;
break;
440 case 8: cout <<
"Correcting for the CTF with baseline3 enhancement" << endl;
break;
445 cout <<
"Tile size: " << tile_size << endl;
446 cout <<
"Defocus range: " << d[0] <<
" - " << d[nn-1] <<
" (" << nn <<
")" << endl;
447 cout <<
"Tilt angle and axis: " << tilt*180.0/
M_PI <<
" " << axis*180.0/
M_PI << endl;
449 cout <<
"Resolution range: " << res_hi <<
" - ";
450 if ( res_lo > 0 ) cout << res_lo <<
" A" << endl;
451 else cout <<
"inf A" << endl;
452 if ( action == 3 || action == 5 || action == 6 )
453 cout <<
"Wiener factor: " << wiener << endl;
455 cout <<
"Envelope: " << env_eq << endl;
456 cout <<
"Noise: " << base_eq << endl;
469 dispatch_apply(pt->
images(), dispatch_get_global_queue(0, 0), ^(
size_t i){
470 img_ttf_apply_one(pt, i, ctf, action, wiener, d[i], res_lo, res_hi, psize,
planf,
planb);
473 #pragma omp parallel for
474 for (
long i=0; i<pt->
images(); i++ )
475 img_ttf_apply_one(pt, i, ctf, action, wiener, d[i], res_lo, res_hi, psize,
planf,
planb);
503 if ( ( ext ==
"tif" ) || ( ext ==
"jpg" ) || ( ext ==
"jpeg" )
504 || ( ext ==
"png" ) || ext.
contains(
"dm") )
520 Vector3<long> tile_size,
double def_start,
double def_end,
double def_inc,
int flags)
522 int img_type(0), img_num(-1);
529 if ( action == 12 && mg->
fps.
length() ) {
534 cout <<
"Processing power spectrum " << mg->
fps <<
" (" << img_num <<
")" << endl;
535 }
else if ( flags & 1 ) {
545 cout <<
"Processing micrograph " << filename <<
" (" << img_num <<
")" << endl;
547 filename = mg->
fpart;
554 cout <<
"Processing particles " << filename << endl;
559 cout <<
"Processing particles from micrograph " << mg->
id << endl;
562 if ( img_type < 4 && !filename.
length() ) {
564 cerr <<
"Warning: no file specified for micrograph " << mg->
id << endl;
570 cout <<
"Processing file " << filename <<
" (" << img_num <<
")" << endl;
572 if ( action == 11 || action == 13 )
insert =
"_ps.";
576 if ( filename.
length() ) {
579 cerr <<
"Warning: File " << filename <<
" not found or read!" << endl;
588 if ( !p )
return NULL;
590 if ( img_type > 1 ) tile_size = p->
size();
600 if ( action == 11 || action == 13 ) {
602 double iCL2(1.0/(mg->
ctf->
Cs()*lamda*lamda));
613 if ( action == 12 || action == 13 )
614 mg->
wri =
img_ctf_fit(p, 0, *mg->
ctf, lores, hires, def_start, def_end, def_inc, (flags & 8));
620 Vector3<long> tile_size,
double def_start,
double def_end,
double def_inc,
628 cout <<
"Processing reconstruction " << rec->
id <<
" (" << rec->
frec <<
")" << endl;
631 if ( action == 12 && rec->
fps.
length() ) {
634 }
else if ( ( flags & 1 ) && rec->
frec.
length() ) {
635 filename = rec->
frec;
638 filename = rec->
fpart;
644 if ( img_type < 4 && !filename.
length() ) {
646 cerr <<
"Warning: no file specified for reconstruction " << rec->
id << endl;
652 cout <<
"Processing file " << filename << endl;
654 if ( action == 11 || action == 13 )
insert =
"_ps.";
658 if ( filename.
length() ) {
661 cerr <<
"Warning: File " << filename <<
" not found or read!" << endl;
668 cout <<
"Processing image " << p->
file_name() << endl;
673 if ( p && ( flags & 2 ) )
676 if ( p && ( action == 11 || action == 13 ) ) {
684 if ( ( ext ==
"tif" ) || ( ext ==
"jpg" ) || ( ext ==
"jpeg" )
685 || ( ext ==
"png" ) || ext.
contains(
"dm") )
692 if ( action == 12 || action == 13 )
693 rec->
fom =
img_ctf_fit(p, 0, *rec->
ctf, lores, hires, def_start, def_end, def_inc, (flags & 8));
721 double def_start,
double def_end,
double def_inc,
724 if ( action < 1 )
return 0;
726 if ( lores < 0 ) lores = 0;
727 if ( lores > 0 && lores < hires ) swap(lores, hires);
729 if ( path.
length() > 1 ) {
730 mkdir(path.
c_str(), (mode_t)0755);
731 if ( path[-1] !=
'/' ) path +=
"/";
741 cout <<
"CTF operations on all micrographs:" << endl;
743 cout <<
"CTF operations on all reconstructions:" << endl;
745 case 11: cout <<
"Calculating power spectra" << endl;
break;
746 case 12: cout <<
"Fitting power spectra" << endl;
break;
747 case 13: cout <<
"Calculating and fitting power spectra" << endl;
break;
750 if ( action == 12 || action == 13 ) {
752 cout <<
"Baseline type: " << em_ctf->
baseline_type() << endl;
753 cout <<
"Envelope type: " << em_ctf->
envelope_type() << endl;
754 cout <<
"Defocus min, max, inc: " << def_start <<
" - " << def_end <<
" ∆ " << def_inc << endl << endl;
756 cout <<
"Resolution range: " << hires <<
" - ";
757 if ( lores > 0 ) cout << lores <<
" A" << endl;
758 else cout <<
"inf A" << endl;
759 cout <<
"Flags: " << flags << endl << endl;
762 long nmg, onefile(0);
767 if ( action == 11 || action == 13 )
insert =
"_ps.";
772 for ( nmg = 1, mg = field->
mg; mg->
next; mg = mg->
next ) nmg++;
773 if ( ( action == 11 || action == 13 ) && ( field->
mg->
fmg == mg->
fmg ) ) {
778 for ( mg = field->
mg; mg; mg = mg->
next ) {
779 ps1 =
mg_ctf_prepare(mg, action, lores, hires, tile_size, def_start, def_end, def_inc, flags);
781 if ( action == 11 || action == 13 ) {
782 if ( onefile == 1 ) {
786 if ( onefile == 2 ) {
798 cerr <<
"Warning: No power spectrum calculated for micrograph "
810 def_start, def_end, def_inc, newname, flags);
824 cout <<
"DEBUG part_ctf: partlist=" << partlist << endl;
827 if ( !part )
return -1;
833 cout <<
"DEBUG part_ctf: mg=" << mg <<
" rec=" << rec << endl;
844 filename = mg->
fpart;
846 if ( mg->
ctf ) ctf = mg->
ctf;
849 filename = rec->
fpart;
851 if ( rec->
ctf ) ctf = rec->
ctf;
855 for ( part = partlist; part; part = part->
next ) npart++;
859 filename = part->
fpart;
863 if ( !filename.
length() ) {
865 cerr <<
"Warning: no particle file specified!" << endl;
872 cerr <<
"Warning: particle file " << filename <<
" not read!" << endl;
879 if ( pixel_size[0] < 0.01 ) pixel_size = p->
sampling(0);
885 cout <<
"DEBUG part_ctf: p->images()=" << p->
images() <<
" npart=" << npart << endl;
887 if ( fn_flag < 1 || p->images() > 1 ) {
888 if ( p->
images() != npart ) {
889 cerr <<
"Error: Micrograph " << mg->
id <<
" has " << npart <<
" particles," << endl;
890 cerr <<
" but particle image file " << p->
file_name() <<
" has " << p->
images() <<
" images!" << endl;
907 double cosax(1), sinax(0), sintilt(0);
915 for ( part = partlist; part; part = part->
next ) {
919 fabs(cosax*part->
loc[0] - sinax*part->
loc[1])*sintilt);
925 else if ( mg ) filename = mg->
fpart;
926 else if ( rec ) filename = rec->
fpart;
933 cout <<
"Processing image " << p->
file_name() <<
" (" << part->
id <<
")" << endl;
941 if ( newname.
length() ) filename = newname;
944 if ( partpath.
length() > 1 ) {
946 filename = partpath + filename;
951 part->
fpart = filename;
958 if ( fabs(sintilt) > 1e-6 ) part->
def =
part_ctf.defocus_average();
963 if ( mg ) mg->
fpart = filename;
964 else if ( rec ) rec->
fpart = filename;
979 if ( !filename.length() ) {
981 cerr <<
"Warning: no file specified for micrograph " << mg->
id << endl;
991 cerr <<
"Warning: File " << filename <<
" not found or read!" << endl;
1002 if ( pmg ) nudatatype = pmg->
data_type();
1005 if ( p && ( flags & 2 ) )
1026 if ( newname.
length() ) filename = newname;
1029 if ( filename.contains(
".dm") )
1030 filename = filename.pre_rev(
'.') +
insert + ext;
1032 filename = filename.
pre_rev(
'.') +
insert + filename.post_rev(
'.');
1037 cout <<
"DEBUG mg_ctf: Writing file " << filename << endl;
1053 if ( !filename.length() ) {
1055 cerr <<
"Warning: no file specified for reconstruction " << rec->
id << endl;
1062 cerr <<
"Warning: File " << filename <<
" not found or read!" << endl;
1082 if ( newname.
length() ) filename = newname;
1083 else filename = filename.
pre_rev(
'.') +
insert + filename.post_rev(
'.');
1085 rec->
frec = filename;
1090 cout <<
"DEBUG rec_ctf: Writing file " << filename << endl;
1123 if ( action < 1 )
return 0;
1125 if ( lores < 0 ) lores = 0;
1126 if ( lores > 0 && lores < hires ) swap(lores, hires);
1136 cout <<
"CTF operations on all micrographs:" << endl;
1138 cout <<
"CTF operations on all reconstructions:" << endl;
1140 case 1: cout <<
"Flipping phases" << endl;
break;
1141 case 2: cout <<
"Applying a CTF" << endl;
break;
1142 case 3: cout <<
"Correcting for the CTF" << endl;
break;
1143 case 4: cout <<
"Correcting for the CTF with an optimal Wiener filter" << endl;
break;
1144 case 5: cout <<
"Correcting for the CTF with baseline enhancement" << endl;
break;
1145 case 6: cout <<
"Correcting for the CTF with baseline2 enhancement" << endl;
break;
1146 case 7: cout <<
"Flipping phases with baseline enhancement" << endl;
break;
1147 case 8: cout <<
"Correcting for the CTF with baseline3 enhancement" << endl;
break;
1150 cout <<
"Resolution range: " << hires <<
" - ";
1151 if ( lores > 0 ) cout << lores <<
" A" << endl;
1152 else cout <<
"inf A" << endl;
1153 cout <<
"Flags: " << flags << endl << endl;
1159 for ( mg = field->
mg; mg->
next; mg = mg->
next ) ;
1162 cout <<
"Reading: " << mg->
fmg <<
" (" << mg->
img_num + 1 <<
")" << endl;
1167 cout <<
"Image\tNumber\tTilt" << endl;
1168 for ( mg = field->
mg; mg; mg = mg->
next ) {
1170 mg_ctf(mg, p, action, lores, hires, wiener, tile_size,
1171 datatype, newname, flags);
1174 datatype, partpath, newname, flags);
1178 if ( newname.
length() ) filename = newname;
1185 for ( mg = field->
mg; mg; mg = mg->
next ) mg->
fmg = filename;
1187 cout <<
"Writing: " << filename << endl;
1195 rec_ctf(rec, action, lores, hires, wiener,
1196 datatype, newname, flags);
1199 datatype, partpath, newname, flags);
1213 double def_min(1e37), def_max(0), pdef(0);
1219 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
select ) {
1220 for ( part = mg->
part; part; part = part->
next )
if ( part->
sel ) {
1222 if ( def_min > part->
def )
1223 def_min = part->
def;
1224 if ( def_max < part->def )
1225 def_max = part->
def;
1229 if ( !pdef && mg->
ctf ) {
1232 if ( def_max < mg->ctf->defocus_average() )
1239 js[
"defocus_minimum"] = def_min;
1240 js[
"defocus_maximum"] = def_max;
1265 for ( mg = field->
mg; mg; mg = mg->
next )
1269 cerr <<
"Error: No micrograph with a box size specified!" << endl;
1273 int i, j, n(0), maxrad = mg->
box_size[0]/2;
1274 double recip_interval = 1.0/(2*maxrad*mg->
pixel_size[0]);
1278 Bstring title(
"Compound CTF curves"), txt;
1299 for ( mg = field->
mg; mg; mg = mg->
next ) {
1302 for ( i=0, j=maxrad; i<maxrad; i++, j++ )
1303 (*plot)[j] += ctf[i]*ctf[i];
1310 for ( i=0, j=maxrad; i<maxrad; i++, j++ ) {
1311 (*plot)[i] = i*recip_interval;
1315 txt =
"Number of micrographs: " +
Bstring(n,
"%d");
1344 cout <<
"Calculating an average power spectrum with target defocus: " << deftarget << endl;
1345 cout <<
"Micrograph\tDefocus\tScale" << endl;
1349 for ( mg = field->
mg; mg; mg = mg->
next ) {
1354 psavg = ps->
copy(1);
1385 if ( !
project || ! ctfproject )
return 0;
1387 Bfield *field, *ctffield;
1392 cout <<
"Merging CTF parameters into the main project" << endl << endl;
1395 for ( mg=field->
mg, ctfmg=ctffield->
mg; mg && ctfmg; mg=mg->
next, ctfmg=ctfmg->
next ) {
1406 for ( rec=
project->
rec, ctfrec=ctfproject->
rec; rec && ctfrec; rec=rec->
next, ctfrec=ctfrec->
next ) {
1408 if ( ctfrec->
ctf ) {
1432 cout <<
"Transferring CTF parameters to particles" << endl << endl;
1435 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
ctf ) {
1436 for ( part = mg->
part; part; part = part->
next ) {
1445 for ( part = rec->
part; part; part = part->
next ) {
1464 double def_dev,
double ast_angle)
1474 cout <<
"DEBUG project_set_defocus: avg=" << def_avg <<
" dev=" << def_dev <<
" ang=" << ast_angle*180.0/
M_PI << endl;
1477 for ( mg = field->
mg; mg; mg = mg->
next ) {
1489 cout <<
"DEBUG project_set_defocus: micrographs set = " << n << endl;
1502 cout <<
"DEBUG project_set_defocus: reconstructions set = " << n << endl;
1523 cout <<
"DEBUG project_set_astigmatism: dev=" << def_dev <<
" ang=" << ast_angle*180.0/
M_PI << endl;
1526 for ( mg = field->
mg; mg; mg = mg->
next ) {
1557 cout <<
"CTF parameters:" << endl << jsctf << endl;
1560 for ( mg = field->
mg; mg; mg = mg->
next ) {
1583 if ( volts < 1e4 ) volts *= 1000;
1590 for ( mg = field->
mg; mg; mg = mg->
next ) {
1612 if ( Cs < 10 ) Cs *= 1e7;
1619 for ( mg = field->
mg; mg; mg = mg->
next ) {
1647 for ( mg = field->
mg; mg; mg = mg->
next ) {
1669 if ( focal_length < 10 ) focal_length *= 1e7;
1676 for ( mg = field->
mg; mg; mg = mg->
next ) {
1698 if ( aperture < 1000 ) aperture *= 1e4;
1705 for ( mg = field->
mg; mg; mg = mg->
next ) {
1733 for ( mg = field->
mg; mg; mg = mg->
next ) {
1761 for ( mg = field->
mg; mg; mg = mg->
next ) {
1789 for ( mg = field->
mg; mg; mg = mg->
next ) {
1818 for ( mg = field->
mg; mg; mg = mg->
next ) {
1853 for ( mg = field->
mg; mg; mg = mg->
next ) {
1881 for ( mg = field->
mg; mg; mg = mg->
next ) {
1911 for ( mg = field->
mg; mg; mg = mg->
next ) {
1941 cout <<
"DEBUG project_update_first_zero: start" << endl;
1944 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
ctf ) {
1956 cout <<
"DEBUG project_update_first_zero: done" << endl;
1979 for ( mg = field->
mg; mg; mg = mg->
next )
if ( mg->
ctf ) {
1982 psname = basename +
"_" + mg->
fps.
pre_rev(
'.') +
".ps";
int rec_ctf(Breconstruction *rec, int action, double lores, double hires, double wiener, DataType datatype, Bstring &newname, int flags)
int project_ctf_average(Bproject *project, Bstring &psname)
Calculates or fits CTF curves to multiple power spectra.
Vector3< double > real_size()
int ps_plot(Bstring filename, Bplot *plot)
Generates postscript graphs.
int project_set_volts(Bproject *project, double volts)
Sets the acceleration voltage of all the micrographs.
double calc_envelope(double s)
void set(long j, double v)
Sets a single value at the given index.
int update(CTFparam *ctf)
Vector3< double > voxel_size
int mg_ps_name(Bmicrograph *mg, int img_num, Bstring &path, Bstring &newname, Bstring insert)
string base(string &filename)
int project_update_first_zero(Bproject *project)
Updates the first zero from the defocus average for all the micrographs.
Bimage * mg_ctf_prepare(Bmicrograph *mg, int action, double lores, double hires, Vector3< long > tile_size, double def_start, double def_end, double def_inc, int flags)
double img_ctf_fit(Bimage *p, long n, CTFparam &em_ctf, double lores, double hires, double def_start=1e3, double def_end=2e5, double def_inc=1e3, int flag=0)
Determines the CTF parameters from a power spectrum.
double objective_aperture()
Bimage * copy()
Copies the header information and data of an image into a new image structure.
double astigmatism_angle()
int bexit(int value)
Exit function for cleanup and debugging.
int project_set_envelope(Bproject *project, int type, double *coeff)
Sets the envelope equations of all the micrographs.
int project_set_Cs(Bproject *project, double Cs)
Sets the spherical aberation constant of all the micrographs.
Vector3< long > size() const
int calculate_background(long nn, int flag)
Calculates the background for one sub-image.
int transform(Vector3< double > scale, Vector3< double > origin, Vector3< double > translate, Matrix3 mat, int fill_type=0, double fill=0)
Transforms an image by translation, rotation, scaling and skewing, in place.
int img_ttf_apply_one(Bimage *p, long nn, CTFparam ctf, int action, double wiener, double def, double res_lo, double res_hi, Vector3< long > psize, fft_plan planf, fft_plan planb)
int correct_background(long nn, int flag)
Corrects the background for one sub-image.
Header file for postscript output functions.
int project_set_coherence_envelope(Bproject *project)
Replaces envelope equations with those based on partial coherence in all micrographs.
double calc_baseline(double s)
int project_set_slit_width(Bproject *project, double slit)
Sets the energy filter slit width of all the micrographs.
double calculate(double s2, double angle)
int project_set_focal_length(Bproject *project, double focal_length)
Sets the focal length of all the micrographs.
int project_CTF_to_part(Bproject *project)
Transfers CTF parameters from micrographs to particles.
int project_set_baseline_type(Bproject *project, int type)
Sets the baseline type of all the micrographs.
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 ps_ctf_plot(Bstring &filename, CTFparam &em_ctf, size_t n, double freq_step)
Generates a postscript plot from CTF parameters for defocus and the envelope.
void multiply(long j, Complex< double > cv)
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Header file for postscript output functions.
void add(long j, double v)
int project_set_defocus(Bproject *project, double def_avg, double def_dev, double ast_angle)
Sets the defocus values of all the micrographs.
string insert(string &filename, string ins)
int fft_destroy_plan(fft_plan plan)
Deallocates a plan for fast Fourier transforms.
int slices_to_images()
Changes the slices in a 3D image into a set of 2D images.
int project_set_aperture(Bproject *project, double aperture)
Sets the objective aperture of all the micrographs.
int img_ttf_apply(Bimage *p, CTFparam ctf, int action, double wiener, Vector3< long > tile_size, double tilt, double axis, double res_lo, double res_hi)
Applies or corrects for the tilted contrast transfer function (TTF).
FourierType fourier_type()
Functions for CTF (contrast transfer function) processing.
void add_text(Bstring &s)
General image parameter class.
Utilities for timing functions.
Bstring envelope_equation()
Generates an envelope equation string from 4 coefficients.
Bimage * extract_tiles(long nn, vector< Vector3< long >> &coords, Vector3< long > tile_size)
Extracts a set of tiles at specified positions from an image into a new image.
unsigned char * data_alloc()
Vector3< double > pixel_size
int replace(Bimage *img)
Replaces the data with that from the given image.
Bimage * project_powerspectrum_average(Bproject *project, double deftarget)
Averages multiple power spectra based on defocus estimates.
int project_set_amp_shift(Bproject *project, double amp_shift)
Sets the amplitude contribution of all the micrographs.
Complex< double > complex(long j)
Returns a complex value at the given index.
double defocus_deviation()
int assemble_tiles(Bimage *pt, int flag=0)
Assembles overlapping tiles into this image.
Header file for general utilities.
ostream & tab(ostream &out)
double delta_phi(double s2, double angle)
int project_set_baseline(Bproject *project, int type, double *coeff)
Sets the baseline equations of all the micrographs.
fft_plan fft_setup_plan(long x, long y, long z, fft_direction dir, int opt)
Sets up a plan for fast Fourier transforms.
int project_ctf(Bproject *project, int action, double lores, double hires, Vector3< long > tile_size, double wiener, DataType datatype, Bstring &partpath, Bstring &newname, int flags)
Calculates or fits CTF curves to multiple power spectra.
int mg_ctf(Bmicrograph *mg, Bimage *pmg, int action, double lores, double hires, double wiener, Vector3< long > tile_size, DataType datatype, Bstring &newname, int flags)
void origin(double ox, double oy, double oz)
void change_type(char letter)
Get the data type indicated by a single letter code.
vector< double > & baseline()
Header file for 2D and 3D image I/O.
Bimage * img_wave_aberration(CTFparam cp, Vector3< long > size, Vector3< double > sam)
Calculates a wave aberration function.
JSvalue project_defocus_range(Bproject *project)
Determines the minimum and maximum defocus values.
Header file for micrograph processing.
Bimage * extract(long nn)
Extracts one sub-image into new image structure.
Bimage * powerspectrum_tiled_and_tilted(Vector3< long > tile_size, double tilt_axis, double tilt_angle, double tilt_offset, double defocus, double iCL2, int flags=0)
Prepares a tiled powerspectrum from a tilted image for determining CTF parameters.
double electron_wavelength(double volt)
Calculates the wavelength in angstrom from the acceleration voltage.
void invert()
Inverts the data in the image.
unsigned char * data_pointer()
int pad(long sz, int fill_type=0, double fill=0)
Pads an image to a new size with a given fill value.
Vector3< double > pixel_size
int project_plot_ctf(Bproject *project, Bstring &filename)
Plots the CTF curves.
void sampling(long nn, Vector3< double > u)
Bimage * powerspectrum_tiled(long img_num, Vector3< long > tile_size, int flags=0)
Prepares a tiled power spectrum from an image for determining CTF parameters.
Bimage * img_ctf_calculate(CTFparam cp, int action, double wiener, Vector3< long > size, Vector3< double > sam, double lores, double hires)
Calculates a CTF complex image.
Header file for CTF (contrast transfer function) functions.
int rec_ctf_prepare(Breconstruction *rec, int action, double lores, double hires, Vector3< long > tile_size, double def_start, double def_end, double def_inc, Bstring &newname, int flags)
DataType
Base data type specifier.
bool contains(const Bstring &s)
int img_ctf_apply(Bimage *p, CTFparam em_ctf, int action, double wiener, double lores, double hires)
Applies or corrects for the contrast transfer function (CTF).
int project_set_astigmatism(Bproject *project, double def_dev, double ast_angle)
Sets the defocus deviation and astigmatism angle of all the micrographs.
CTFparam ctf_from_json(JSvalue &js)
Converts a JSON object list to microscope parameters.
Bstring baseline_equation()
Generates a baseline equation string from 4 to 10 coefficients.
Bimage * img_ctf_radial_average(Bimage *p, long n, CTFparam &em_ctf)
Calculates the power spectrum radial average corrected for astigmatism.
int project_merge_CTF_parameters(Bproject *project, Bproject *ctfproject)
Puts CTF parameters from one project into another.
vector< double > & envelope()
int part_ctf(Bparticle *partlist, int action, double lores, double hires, double wiener, DataType datatype, Bstring &partpath, Bstring &newname, int flags)
int findNextPowerOf(int startNumber, int powerOf)
Finds the next greatest number that is a power of a given number.
int img_ctf_apply_to_proj(Bimage *proj, CTFparam em_ctf, double defocus, double res_lo, double res_hi, fft_plan planf_2D, fft_plan planb_2D)
Applies a CTF to a projection image.
int project_update_ctf(Bproject *project, JSvalue &jsctf)
Sets the acceleration voltage of all the micrographs.
void complex_to_real()
The real part of a complex image is written to a simple image.
int project_set_envelope_type(Bproject *project, int type)
Sets the envelope type of all the micrographs.
long statistics()
Calculates the statistics for an image.
int project_ctf_prepare(Bproject *project, int action, double lores, double hires, Vector3< long > tile_size, double def_start, double def_end, double def_inc, Bstring &path, Bstring &newname, int flags)
Calculates power spectra and optionally fits CTF curves.
int filter_extremes()
Filters the extremes out of a micrograph image.
int resize(Vector3< long > nusize, Vector3< long > translate, int fill_type=0, double fill=0)
Resizes without interpolation or rescaling.
int project_set_alpha(Bproject *project, double alpha)
Sets the beam source size/divergence angle of all the micrographs.