Contrast transfer functions¤
Applying a contrast transfer function (CTF) to an image in cryojax is layered into two classes. The most important class is the AstigmaticCTF, which is a function that takes in a grid of in-plane frequency vectors and returns a JAX array of the CTF.
import cryojax.simulator as cxs
from cryojax.ndimage import make_frequency_grid
shape, pixel_size = (100, 100), 1.1
frequency_grid_in_angstroms = make_frequency_grid(shape, pixel_size)
ctf = cxs.AstigmaticCTF(
defocus_in_angstroms=10000.0,
astigmatism_in_angstroms=100.0,
astigmatism_angle=30.0,
spherical_aberration_in_mm=2.7,
amplitude_contrast_ratio=0.07,
phase_shift=0.0,
)
ctf_array = ctf(frequency_grid_in_angstroms, voltage_in_kilovolts=300.0)
Further, the ContrastTransferTheory is a class that takes in a projection image in a plane below the object and returns the contrast in the plane of the detector.
projection_image_in_fourier_domain = ...
ctf = AstigmaticCTF(...)
transfer_theory = cxs.ContrastTransferTheory(ctf)
contrast_in_fourier_domain = transfer_theory.propagate_object(projection_image_in_fourier_domain)
This documentation describes the elements of transfer theory in cryojax. More features are included than described above, such as the ability to include a user-specified envelope function to the ContrastTransferTheory. Much of the code and theory have been adapted from the Grigorieff Lab's CTFFIND4 program.
References
- Rohou, Alexis, and Nikolaus Grigorieff. "CTFFIND4: Fast and accurate defocus estimation from electron micrographs." Journal of structural biology 192.2 (2015): 216-221.
Transfer Functions¤
cryojax.simulator.AbstractCTF
cryojax.simulator.AbstractCTF
¤
An abstract base class for a CTF in cryo-EM.
compute_aberration_phase_shifts
¤
compute_aberration_phase_shifts(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], wavelength_in_angstroms: cryojax.jax_util.FloatLike, defocus_offset: cryojax.jax_util.FloatLike | None = None) -> Float[Array, 'y_dim x_dim']
cryojax.simulator.AstigmaticCTF(cryojax.simulator.AbstractCTF)
¤
Compute an astigmatic Contrast Transfer Function (CTF) with a spherical aberration correction and amplitude contrast ratio.
Info
cryojax uses a convention different from CTFFIND for
astigmatism parameters. CTFFIND returns defocus major and minor
axes, called "defocus1" and "defocus2". In order to convert
from CTFFIND to cryojax,
defocus1, defocus2 = ... # Read from CTFFIND
ctf = AstigmaticCTF(
defocus_in_angstroms=(defocus1+defocus2)/2,
astigmatism_in_angstroms=defocus1-defocus2,
...
)
__init__
¤
__init__(defocus_in_angstroms: cryojax.jax_util.FloatLike = 10000.0, astigmatism_in_angstroms: cryojax.jax_util.FloatLike = 0.0, astigmatism_angle: cryojax.jax_util.FloatLike = 0.0, spherical_aberration_in_mm: cryojax.jax_util.FloatLike = 2.7)
Arguments:
defocus_in_angstroms: The mean defocus in Angstroms.astigmatism_in_angstroms: The amount of astigmatism in Angstroms.astigmatism_angle: The defocus angle.spherical_aberration_in_mm: The spherical aberration coefficient in mm.
compute_aberration_phase_shifts
¤
compute_aberration_phase_shifts(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], wavelength_in_angstroms: cryojax.jax_util.FloatLike, defocus_offset: cryojax.jax_util.FloatLike | None = None) -> Float[Array, 'y_dim x_dim']
Compute the frequency-dependent phase shifts due to wave aberration.
This is often denoted as \(\chi(\boldsymbol{q})\) for the in-plane spatial frequency \(\boldsymbol{q}\).
Arguments:
frequency_grid_in_angstroms: The grid of frequencies in units of inverse angstroms. This can be computed withcryojax.coordinates.make_frequency_gridvoltage_in_kilovolts: The accelerating voltage of the microscope in kilovolts. This is converted to the wavelength of incident electrons using the functioncryojax.constants.convert_keV_to_angstromsdefocus_offset: An optional defocus offset to apply to thedefocus_in_angstromsat runtime.
__call__
¤
__call__(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], voltage_in_kilovolts: cryojax.jax_util.FloatLike, amplitude_contrast_ratio: cryojax.jax_util.FloatLike = 0.1, phase_shift: cryojax.jax_util.FloatLike = 0.0, outputs_exp: bool = False, defocus_offset: cryojax.jax_util.FloatLike | None = None) -> Float[Array, 'y_dim x_dim'] | Complex[Array, 'y_dim x_dim']
Compute the CTF as a JAX array.
Arguments:
frequency_grid_in_angstroms: The grid of frequencies in units of inverse angstroms. This can be computed withcryojax.coordinates.make_frequency_gridvoltage_in_kilovolts: The accelerating voltage of the microscope in kilovolts. This is converted to the wavelength of incident electrons using the functioncryojax.constants.convert_keV_to_angstromsamplitude_contrast_ratio: The amplitude contrast ratio. This argument is not used ifoutputs_exp = True, as the amplitude contrast ratio cannot simply be absorbed into a phase shift.phase_shift: Additional constant phase shift applied to the frequency-dependent phase shifts.outputs_exp: IfFalse, return the CTF used in linear image formation theory. IfTrue, return the CTF (or wave transfer function) as a complex exponential.
Transfer Theories¤
cryojax.simulator.ContrastTransferTheory
¤
A transfer theory for the weak-phase approximation. This class propagates the fourier spectrum of the object from a plane directly below it to the plane of the detector. In other terms, it computes a noiseless cryo-EM image from a 2D projection.
__init__
¤
__init__(ctf: cryojax.simulator.AbstractCTF, envelope: cryojax.ndimage.AbstractFourierOperator | None = None, amplitude_contrast_ratio: cryojax.jax_util.FloatLike = 0.1, phase_shift: cryojax.jax_util.FloatLike = 0.0)
Arguments:
ctf: The contrast transfer function model.envelope: The envelope function of the optics model.amplitude_contrast_ratio: The amplitude contrast ratio.phase_shift: The additional phase shift.
propagate_object
¤
propagate_object(object_spectrum: Complex[Array, '{image_config.padded_y_dim} {image_config.padded_x_dim//2+1}'] | Complex[Array, '{image_config.padded_y_dim} {image_config.padded_x_dim}'], image_config: cryojax.simulator.AbstractImageConfig, *, defocus_offset: cryojax.jax_util.FloatLike | None = None, input_is_ewald_sphere: bool = False) -> Complex[Array, '{image_config.padded_y_dim} {image_config.padded_x_dim//2+1}']
Apply the CTF directly to the phase shifts in the exit plane.
Arguments:
object_spectrum: The fourier spectrum of the scatterer phase shifts in a plane directly below it.image_config: The configuration of the resulting image.input_is_ewald_sphere: IfFalse, theobject_spectrum_in_exit_planeis a projection approximation and is therefore the fourier transform of a real-valued array. IfTrue,object_spectrum_in_exit_planeis extracted from the ewald sphere and is therefore the fourier transform of a complex-valued array.defocus_offset: An optional defocus offset to apply to the CTF defocus at runtime.