Skip to content

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 ContrastTransferFunction, 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.coordinates import make_frequency_grid

shape, pixel_size = (100, 100), 1.1
frequency_grid_in_angstroms = make_frequency_grid(shape, pixel_size)
ctf = cxs.ContrastTransferFunction(
    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 = ContrastTransferFunction(...)
transfer_theory = cxs.ContrastTransferTheory(ctf)
contrast_in_fourier_domain = transfer_theory.propagate_object_to_detector_plane(projection_image_in_fourier_domain)

This documentation describes the elements of . 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.AbstractTransferFunction

cryojax.simulator.AbstractTransferFunction ¤

An abstract base class for a transfer function in cryo-EM.

cryojax.simulator.AbstractTransferFunction.compute_aberration_phase_shifts(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], voltage_in_kilovolts: Float[Array, ''] | float) -> 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:

cryojax.simulator.AbstractTransferFunction.__call__(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], voltage_in_kilovolts: Float[Array, ''] | float) -> Float[Array, 'y_dim x_dim'] | Complex[Array, 'y_dim x_dim'] abstractmethod ¤

cryojax.simulator.ContrastTransferFunction ¤

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 = ContrastTransferFunction(
    defocus_in_angstroms=(defocus1+defocus2)/2,
    astigmatism_in_angstroms=defocus1-defocus2,
    ...
)
cryojax.simulator.ContrastTransferFunction.__init__(defocus_in_angstroms: float | Float[Array, ''] = 10000.0, astigmatism_in_angstroms: float | Float[Array, ''] = 0.0, astigmatism_angle: float | Float[Array, ''] = 0.0, spherical_aberration_in_mm: float | Float[Array, ''] = 2.7, amplitude_contrast_ratio: float | Float[Array, ''] = 0.1, phase_shift: float | Float[Array, ''] = 0.0) ¤

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.
  • amplitude_contrast_ratio: The amplitude contrast ratio.
  • phase_shift: The additional phase shift.
cryojax.simulator.ContrastTransferFunction.__call__(frequency_grid_in_angstroms: Float[Array, 'y_dim x_dim 2'], voltage_in_kilovolts: Float[Array, ''] | float) -> Float[Array, 'y_dim x_dim'] ¤

Compute the CTF as a JAX array.

Arguments:

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.

cryojax.simulator.ContrastTransferTheory.__init__(ctf: ContrastTransferFunction, envelope: Optional[FourierOperatorLike] = None) ¤

Arguments:

  • ctf: The contrast transfer function model.
  • envelope: The envelope function of the optics model.
cryojax.simulator.ContrastTransferTheory.propagate_object_to_detector_plane(object_spectrum_at_exit_plane: Complex[Array, '{instrument_config.padded_y_dim} {instrument_config.padded_x_dim//2+1}'] | Complex[Array, '{instrument_config.padded_y_dim} {instrument_config.padded_x_dim}'], instrument_config: InstrumentConfig, *, is_projection_approximation: bool = True) -> Complex[Array, '{instrument_config.padded_y_dim} {instrument_config.padded_x_dim//2+1}'] ¤

Apply the CTF directly to the phase shifts in the exit plane.

Arguments:

  • object_spectrum_at_exit_plane: The fourier spectrum of the object in a plane directly below it.
  • instrument_config: The configuration of the resulting image.
  • is_projection_approximation: If True, the object_spectrum_in_exit_plane is a projection approximation and is therefore the fourier transform of a real-valued array. If False, object_spectrum_in_exit_plane is extracted from the ewald sphere and is therefore the fourier transform of a complex-valued array.