|
Bsoft 2.1.4
Bernard's software package
|
Functions for CTF (contrast transfer function) processing. More...
Functions | |
| Bimage * | img_ctf_calculate (CTFparam &cp, bool flip, double wiener, Vector3< long > size, Vector3< double > sam, double lores, double hires) |
| Calculates an aberration image. More... | |
| Bimage * | img_ctf_calculate (CTFparam cp, int action, double wiener, Vector3< long > size, Vector3< double > sam, double lores=0, double hires=0) |
| Calculates a CTF image. More... | |
| Bimage * | img_ctf_gradient (CTFparam &cp, double def_min, double def_max, double def_inc, Vector3< long > size, Vector3< double > sam, double lores, double hires) |
| Calculates an aberration image. More... | |
| double | aberration (long n, long m, double s, double p) |
| vector< double > | aberration_terms (map< pair< long, long >, double > &wa, double u, double v) |
| vector< double > | aberration_terms (long nt, double u, double v) |
| vector< double > | aberration_even_terms (long nt, double u, double v) |
| vector< double > | aberration_odd_terms (long nt, double u, double v) |
| map< pair< long, long >, double > | aberration_weights (vector< double > v, int flag) |
| string | aberration_weight_string (map< pair< long, long >, double > &weights) |
| int | img_aberration_basis (Bimage *p, int flag) |
| int | img_create_aberration (Bimage *p, map< pair< long, long >, double > &weights, int flag) |
| int | img_create_aberration (Bimage *p, vector< map< pair< long, long >, double > > &weights, int flag) |
| int | img_create_aberration (Bimage *p, CTFparam cp, int flag) |
| int | img_create_aberration (Bimage *p, map< string, CTFparam > &cpa, int flag) |
| Bimage * | img_wave_aberration (CTFparam cp, Vector3< long > size, Vector3< double > sam) |
| Calculates a wave aberration function. More... | |
| int | img_ctf_apply (Bimage *p, CTFparam em_ctf, int action, double wiener, double lores, double hires, bool invert) |
| Applies or corrects for the contrast transfer function (CTF). More... | |
| int | img_ctf_apply (Bimage *p, CTFparam em_ctf, int action, double wiener, double lores, double hires, bool invert, fft_plan planf_2D, fft_plan planb_2D) |
| int | img_ctf_apply_complex (Bimage *p, CTFparam &cp, bool flip, double wiener, double lores, double hires) |
| Applies or corrects for the contrast transfer function (CTF). More... | |
| int | img_apply_phase_aberration (Bimage *p, CTFparam em_ctf) |
| 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, int invert) |
| Applies or corrects for the tilted contrast transfer function (TTF). More... | |
| int | img_ctf_apply_to_proj (Bimage *proj, CTFparam em_ctf, double defocus, double res_lo, double res_hi, bool invert, fft_plan planf_2D, fft_plan planb_2D) |
| Applies a CTF to a projection image. More... | |
| 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. More... | |
| 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. More... | |
| int | project_powerspectrum_isotropy (Bproject *project, double lores, double hires) |
| Calculates the isotropy at the CTF maxima. More... | |
| JSvalue | project_defocus_range (Bproject *project) |
| Determines the minimum and maximum defocus values. More... | |
| int | project_ctf_average (Bproject *project, Bstring &psname) |
| Calculates or fits CTF curves to multiple power spectra. More... | |
| Bimage * | project_powerspectrum_average (Bproject *project, double deftarget) |
| Averages multiple power spectra based on defocus estimates. More... | |
| int | project_merge_CTF_parameters (Bproject *project, Bproject *ctfproject) |
| Puts CTF parameters from one project into another. More... | |
| int | project_CTF_to_part (Bproject *project) |
| Transfers CTF parameters from micrographs to particles. More... | |
| int | project_set_defocus (Bproject *project, double def_avg, double def_dev, double ast_angle) |
| Sets the defocus values of all the micrographs. More... | |
| int | project_set_astigmatism (Bproject *project, double def_dev, double ast_angle) |
| Sets the defocus deviation and astigmatism angle of all the micrographs. More... | |
| int | project_update_ctf (Bproject *project, JSvalue &jsctf) |
| Updates the CTF parameters of all the micrographs. More... | |
| int | project_set_volts (Bproject *project, double volts) |
| Sets the acceleration voltage of all the micrographs. More... | |
| int | project_set_Cs (Bproject *project, double Cs) |
| Sets the spherical aberation constant of all the micrographs. More... | |
| int | project_set_amp_shift (Bproject *project, double amp_shift) |
| Sets the amplitude contribution of all the micrographs. More... | |
| int | project_set_focal_length (Bproject *project, double focal_length) |
| Sets the focal length of all the micrographs. More... | |
| int | project_set_aperture (Bproject *project, double aperture) |
| Sets the objective aperture of all the micrographs. More... | |
| int | project_set_slit_width (Bproject *project, double slit) |
| Sets the energy filter slit width of all the micrographs. More... | |
| int | project_set_alpha (Bproject *project, double alpha) |
| Sets the beam source size/divergence angle of all the micrographs. More... | |
| int | project_set_envelope_type (Bproject *project, int type) |
| Sets the envelope type of all the micrographs. More... | |
| int | project_set_envelope (Bproject *project, int type, vector< double > &coeff) |
| Sets the envelope equations of all the micrographs. More... | |
| int | project_set_coherence_envelope (Bproject *project) |
| Replaces envelope equations with those based on partial coherence in all micrographs. More... | |
| int | project_set_baseline_type (Bproject *project, int type) |
| Sets the baseline type of all the micrographs. More... | |
| int | project_set_baseline (Bproject *project, int type, vector< double > &coeff) |
| Sets the baseline equations of all the micrographs. More... | |
| map< string, CTFparam > | project_ctf_optics_groups (Bproject *project) |
| Retrieves unique optics groups as CTF parameters. More... | |
| long | project_update_ctf_aberration (Bproject *project, map< string, CTFparam > &cpa, int flag) |
| Updates the aberration weights for all optics groups. More... | |
| int | project_aberration_compare (Bproject *project, Bproject *project2) |
| Compares the aberration parameters from two projects. More... | |
| int | project_delete_aberration (Bproject *project, int which) |
| Deletes the aberration parameters of all the micrographs. More... | |
| int | project_update_first_zero (Bproject *project) |
| Updates the first zero from the defocus average for all the micrographs. More... | |
| int | project_plot_ctf (Bproject *project, Bstring &filename) |
| Plots the CTF curves. More... | |
| long | project_ctf_statistics (Bproject *project) |
| Calculates CTF parameter statistics. More... | |
Functions for CTF (contrast transfer function) processing.
| double aberration | ( | long | n, |
| long | m, | ||
| double | s, | ||
| double | p | ||
| ) |
| vector< double > aberration_even_terms | ( | long | nt, |
| double | u, | ||
| double | v | ||
| ) |
| vector< double > aberration_odd_terms | ( | long | nt, |
| double | u, | ||
| double | v | ||
| ) |
| vector< double > aberration_terms | ( | long | nt, |
| double | u, | ||
| double | v | ||
| ) |
| vector< double > aberration_terms | ( | map< pair< long, long >, double > & | wa, |
| double | u, | ||
| double | v | ||
| ) |
| string aberration_weight_string | ( | map< pair< long, long >, double > & | weights | ) |
| map< pair< long, long >, double > aberration_weights | ( | vector< double > | v, |
| int | flag | ||
| ) |
| int img_aberration_basis | ( | Bimage * | p, |
| int | flag | ||
| ) |
| int img_create_aberration | ( | Bimage * | p, |
| map< pair< long, long >, double > & | weights, | ||
| int | flag | ||
| ) |
| int img_create_aberration | ( | Bimage * | p, |
| vector< map< pair< long, long >, double > > & | weights, | ||
| int | flag | ||
| ) |
| int img_ctf_apply | ( | Bimage * | p, |
| CTFparam | em_ctf, | ||
| int | action, | ||
| double | wiener, | ||
| double | lores, | ||
| double | hires, | ||
| bool | invert | ||
| ) |
Applies or corrects for the contrast transfer function (CTF).
| *p | image (modified). |
| em_ctf | CTF parameter structure. |
| action | action to be taken. |
| wiener | Wiener factor (fraction). |
| lores | low resolution limit. |
| hires | high resolution limit. |
| invert | phase flip to invert contrast. |
The actions for this funtion are: 1 flip phase (multiply by the sign of the CTF) 2 apply a CTF (multiply with the CTF) 3 correct for the CTF: ctf/(ctf^2 + wiener_factor) 4 correct for the CTF: env*ctf/((env*ctf)^2 + noise^2) 5 correct for the CTF with baseline: ctf/(ctf^2*noise^2 + wiener_factor) 6 correct for the CTF with baseline: 1/(ctf*noise + sign*wiener_factor)
| int img_ctf_apply | ( | Bimage * | p, |
| CTFparam | em_ctf, | ||
| int | action, | ||
| double | wiener, | ||
| double | lores, | ||
| double | hires, | ||
| bool | invert, | ||
| fft_plan | planf_2D, | ||
| fft_plan | planb_2D | ||
| ) |
| int img_ctf_apply_complex | ( | Bimage * | p, |
| CTFparam & | cp, | ||
| bool | flip, | ||
| double | wiener, | ||
| double | lores, | ||
| double | hires | ||
| ) |
Applies or corrects for the contrast transfer function (CTF).
| *p | image (modified). |
| cp | CTF & aberration parameters. |
| flip | Flip phases of even aberrations. |
| wiener | Wiener factor (fraction), if 0, flip phases. |
| lores | low resolution limit. |
| hires | high resolution limit. |
| int img_ctf_apply_to_proj | ( | Bimage * | proj, |
| CTFparam | em_ctf, | ||
| double | defocus, | ||
| double | res_lo, | ||
| double | res_hi, | ||
| bool | invert, | ||
| fft_plan | planf_2D, | ||
| fft_plan | planb_2D | ||
| ) |
Applies a CTF to a projection image.
| *proj | projection image. |
| em_ctf | CTF parameters. |
| defocus | defocus. |
| res_lo | low resolution limit (angstrom). |
| res_hi | high resolution limit (angstrom). |
| invert | phase flip to invert contrast. |
| planf_2D | 2D forward fourier transform plan. |
| planb_2D | 2D backward fourier transform plan. |
| Bimage * img_ctf_calculate | ( | CTFparam & | cp, |
| bool | flip, | ||
| double | wiener, | ||
| Vector3< long > | size, | ||
| Vector3< double > | sam, | ||
| double | lores, | ||
| double | hires | ||
| ) |
Calculates an aberration image.
| cp | CTF & aberration parameters. |
| flip | Flip phases of even aberrations. |
| wiener | Wiener factor (fraction), if 0, flip phases. |
| size | new image size. |
| sam | new image pixel size. |
| lores | low resolution limit. |
| hires | high resolution limit. |
Functions:
angle = atan(y/x)
s2 = x*x + y*y
defocus_average = (defocus_max + defocus_min)/2
defocus_deviation = (defocus_max - defocus_min)/2
defocus = defocus_average + defocus_deviation*cos(2*(angle - astigmatism_angle))
phase = 0.5*PI*lambda*lambda*lambda*Cs*s2*s2 - PI*lambda*defocus*s2 - amp_shift;
CTF = sin(phase)
Note: Defocus is positive for underfocus and negative for overfocus.
| Bimage * img_ctf_calculate | ( | CTFparam | cp, |
| int | action, | ||
| double | wiener, | ||
| Vector3< long > | size, | ||
| Vector3< double > | sam, | ||
| double | lores, | ||
| double | hires | ||
| ) |
Calculates a CTF image.
| cp | CTF parameters. |
| action | type of CTF calculated (1-8). |
| wiener | Wiener factor (fraction). |
| size | new image size. |
| sam | new image pixel size. |
| lores | low resolution limit. |
| hires | high resolution limit. |
Functions:
angle = atan(y/x)
s2 = x*x + y*y
defocus_average = (defocus_max + defocus_min)/2
defocus_deviation = (defocus_max - defocus_min)/2
defocus = defocus_average + defocus_deviation*cos(2*(angle - astigmatism_angle))
phase = 0.5*PI*lambda*lambda*lambda*Cs*s2*s2 - PI*lambda*defocus*s2 - amp_shift;
CTF = sin(phase)
Note: Defocus is positive for underfocus and negative for overfocus.
| Bimage * img_ctf_gradient | ( | CTFparam & | cp, |
| double | def_min, | ||
| double | def_max, | ||
| double | def_inc, | ||
| Vector3< long > | size, | ||
| Vector3< double > | sam, | ||
| double | lores, | ||
| double | hires | ||
| ) |
Calculates an aberration image.
| cp | CTF & aberration parameters. |
| def_min | Minimum defocus. |
| def_max | Maximum defocus. |
| def_inc | Defocus increment. |
| size | new image size. |
| sam | new image pixel size. |
| lores | low resolution limit. |
| hires | high resolution limit. |
Functions:
angle = atan(y/x)
s2 = x*x + y*y
defocus_average = (defocus_max + defocus_min)/2
defocus_deviation = (defocus_max - defocus_min)/2
defocus = defocus_average + defocus_deviation*cos(2*(angle - astigmatism_angle))
phase = 0.5*PI*lambda*lambda*lambda*Cs*s2*s2 - PI*lambda*defocus*s2 - amp_shift;
CTF = sin(phase)
Note: Defocus is positive for underfocus and negative for overfocus.
| 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, | ||
| int | invert | ||
| ) |
Applies or corrects for the tilted contrast transfer function (TTF).
| *p | image (modified). |
| ctf | CTF parameter structure. |
| action | action to be taken. |
| wiener | Wiener factor (fraction). |
| tile_size | tile size for tilted CTF operations. |
| tilt | tilt angle (radians). |
| axis | tilt axis angle (radians). |
| res_lo | high resolution limit. |
| res_hi | low resolution limit. |
| invert | phase flip to invert contrast. |
The actions for this funtion are: 1 flip phase (multiply by the sign of the CTF) 2 apply a CTF (multiply with the CTF) 3 correct for the CTF: ctf/(ctf^2 + wiener_factor) 4 correct for the CTF: env*ctf/((env*ctf)^2 + noise^2) 5 correct for the CTF with baseline: ctf/(ctf^2*noise^2 + wiener_factor) 6 correct for the CTF with baseline: 1/(ctf*noise + sign*wiener_factor)
Calculates a wave aberration function.
| cp | CTF parameters. |
| size | new image size. |
| sam | new image pixel size. |
Functions:
angle = atan(y/x)
s2 = x*x + y*y
defocus_average = (defocus_max + defocus_min)/2
defocus_deviation = (defocus_max - defocus_min)/2
defocus = defocus_average + defocus_deviation*cos(2*(angle - astigmatism_angle))
phase = 0.5*PI*lambda*lambda*lambda*Cs*s2*s2 - PI*lambda*defocus*s2;
Note: Defocus is positive for underfocus and negative for overfocus.
Compares the aberration parameters from two projects.
| *project | project parameter structure. |
| *project2 | second project parameter structure. |
| 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.
| *project | project parameter structure. |
| action | CTF processing action. |
| lores | low resolution limit for CTF operations. |
| hires | high resolution limit for CTF operations. |
| tile_size | tile size for tilted CTF operations. |
| wiener | Wiener factor. |
| datatype | corrected particle file data type. |
| &partpath | corrected particle file path. |
| &newname | new file name for output. |
| flags | 1=use mg or rec, 2=filter, 4=background, 8=astigmatism, 16=use frames, 32=invert |
The default is to use the particle file. If the particle file is not specified, the micrograph is used. The selection can also be done with the use_mg flag.
Calculates or fits CTF curves to multiple power spectra.
| *project | project parameter structure. |
| &psname | postscript file name for output. |
The default is to use the particle file. If the particle file is not specified, the micrograph is used. The selection can also be done with the use_mg flag.
Retrieves unique optics groups as CTF parameters.
| *project | project parameter structure. |
| 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.
| *project | project parameter structure. |
| action | CTF processing action. |
| lores | low resolution limit for CTF operations. |
| hires | high resolution limit for CTF operations. |
| tile_size | tile size for power spectrum generation. |
| def_start | defocus search start (default 1e3). |
| def_end | defocus search end (default 2e5). |
| def_inc | defocus search increment (default 1e3). |
| &path | new power spectrum directory for output. |
| &newname | new file name for output. |
| flags | 1=use mg or rec, 2=filter, 4=background, 8=astigmatism, 16=frames, 32=aberration fit |
The default is to use the particle file. If the particle file is not specified, the micrograph is used.
| long project_ctf_statistics | ( | Bproject * | project | ) |
Calculates CTF parameter statistics.
| *project | project parameter structure. |
| int project_CTF_to_part | ( | Bproject * | project | ) |
Transfers CTF parameters from micrographs to particles.
| *project | project parameter structure with all parameters. |
Determines the minimum and maximum defocus values.
| *project | project parameter structure. |
| int project_delete_aberration | ( | Bproject * | project, |
| int | which | ||
| ) |
Deletes the aberration parameters of all the micrographs.
| *project | project parameter structure. |
| which | 0=all, 1=odd, 2=even. |
Puts CTF parameters from one project into another.
| *project | project parameter structure with all parameters. |
| *ctfproject | project parameter structure with CTF parameters. |
Plots the CTF curves.
| *project | project parameter structure. |
| &filename | Postscript file name. |
Averages multiple power spectra based on defocus estimates.
| *project | project parameter structure. |
| deftarget | target defocus (angstrom). |
| int project_powerspectrum_isotropy | ( | Bproject * | project, |
| double | lores, | ||
| double | hires | ||
| ) |
Calculates the isotropy at the CTF maxima.
| *project | project parameter structure. |
| lores | low resolution limit. |
| hires | high resolution limit |
| int project_set_alpha | ( | Bproject * | project, |
| double | alpha | ||
| ) |
Sets the beam source size/divergence angle of all the micrographs.
| *project | project parameter structure. |
| alpha | beam source size/divergence angle (radians). |
| int project_set_amp_shift | ( | Bproject * | project, |
| double | amp_shift | ||
| ) |
Sets the amplitude contribution of all the micrographs.
| *project | project parameter structure. |
| amp_shift | amplitude contribution phase shift. |
| int project_set_aperture | ( | Bproject * | project, |
| double | aperture | ||
| ) |
Sets the objective aperture of all the micrographs.
| *project | project parameter structure. |
| aperture | objective aperture in angstrom. |
| int project_set_astigmatism | ( | Bproject * | project, |
| double | def_dev, | ||
| double | ast_angle | ||
| ) |
Sets the defocus deviation and astigmatism angle of all the micrographs.
| *project | project parameter structure. |
| def_dev | defocus deviation. |
| ast_angle | astigmatism angle. |
| int project_set_baseline | ( | Bproject * | project, |
| int | type, | ||
| vector< double > & | coeff | ||
| ) |
Sets the baseline equations of all the micrographs.
| *project | project parameter structure. |
| type | baseline type. |
| &coeff | 5 baseline coefficients. |
| int project_set_baseline_type | ( | Bproject * | project, |
| int | type | ||
| ) |
Sets the baseline type of all the micrographs.
| *project | project parameter structure. |
| type | baseline type. |
| int project_set_coherence_envelope | ( | Bproject * | project | ) |
Replaces envelope equations with those based on partial coherence in all micrographs.
| *project | project parameter structure. |
Partial coherence envelope:
env = amp*exp(-(pi*alpha*defocus*s)^2)
The amplitude, defocus and alpha values are taken from the fields
in each micrograph. The defocus must already be determined.
| int project_set_Cs | ( | Bproject * | project, |
| double | Cs | ||
| ) |
Sets the spherical aberation constant of all the micrographs.
| *project | project parameter structure. |
| Cs | spherical aberation constant in angstrom. |
| int project_set_defocus | ( | Bproject * | project, |
| double | def_avg, | ||
| double | def_dev, | ||
| double | ast_angle | ||
| ) |
Sets the defocus values of all the micrographs.
| *project | project parameter structure. |
| def_avg | defocus average. |
| def_dev | defocus deviation. |
| ast_angle | astigmatism angle. |
| int project_set_envelope | ( | Bproject * | project, |
| int | type, | ||
| vector< double > & | coeff | ||
| ) |
Sets the envelope equations of all the micrographs.
| *project | project parameter structure. |
| type | envelope type. |
| &coeff | 5 envelope coefficients. |
| int project_set_envelope_type | ( | Bproject * | project, |
| int | type | ||
| ) |
Sets the envelope type of all the micrographs.
| *project | project parameter structure. |
| type | envelope type. |
| int project_set_focal_length | ( | Bproject * | project, |
| double | focal_length | ||
| ) |
Sets the focal length of all the micrographs.
| *project | project parameter structure. |
| focal_length | focal length in angstrom. |
| int project_set_slit_width | ( | Bproject * | project, |
| double | slit | ||
| ) |
Sets the energy filter slit width of all the micrographs.
| *project | project parameter structure. |
| slit | slit width in eV. |
| int project_set_volts | ( | Bproject * | project, |
| double | volts | ||
| ) |
Sets the acceleration voltage of all the micrographs.
| *project | project parameter structure. |
| volts | acceleration voltage. |
Updates the CTF parameters of all the micrographs.
| *project | project parameter structure. |
| jsctf | JSON parameters to be updated. |
Updates the aberration weights for all optics groups.
| *project | project parameter structure. |
| &cpa | list of CTF parameters for the optics groups. |
| flag | 0=replace, 1=add |
| int project_update_first_zero | ( | Bproject * | project | ) |
Updates the first zero from the defocus average for all the micrographs.
| *project | project parameter structure. |