Skip to content

Configuring images¤

The InstrumentConfig is an object at the core of simulating images in cryojax. It stores a configuration for the simulated image and the electron microscope, such as the shape of the desired image and the wavelength of the incident electron beam.

cryojax.simulator.InstrumentConfig ¤

Configuration and utilities for an electron microscopy image.

cryojax.simulator.InstrumentConfig.__init__(shape: tuple[int, int], pixel_size: float | Float[Array, ''], voltage_in_kilovolts: float | Float[Array, ''], electrons_per_angstrom_squared: float | Float[Array, ''] = 100.0, padded_shape: Optional[tuple[int, int]] = None, *, pad_scale: float = 1.0, pad_mode: Union[str, Callable] = 'constant') ¤

Arguments:

  • shape: Shape of the imaging plane in pixels.
  • pixel_size: The pixel size of the image in angstroms.
  • voltage_in_kilovolts: The incident energy of the electron beam.
  • electrons_per_angstrom_squared: The integrated dose rate of the electron beam.
  • padded_shape: The shape of the image after padding. If this argument is not given, it can be set by the pad_scale argument.
  • pad_scale: A scale factor at which to pad the image. This is optionally used to set padded_shape and must be greater than 1. If padded_shape is set, this argument is ignored.
  • pad_mode: The method of image padding. By default, "constant". For all options, see jax.numpy.pad.
cryojax.simulator.InstrumentConfig.wavelength_in_angstroms: Float[Array, ''] property ¤

The incident electron wavelength corresponding to the beam energy voltage_in_kilovolts.

cryojax.simulator.InstrumentConfig.wavenumber_in_inverse_angstroms: Float[Array, ''] property ¤

The incident electron wavenumber corresponding to the beam energy voltage_in_kilovolts.

cryojax.simulator.InstrumentConfig.n_pixels: int property ¤

Convenience property for math.prod(shape)

cryojax.simulator.InstrumentConfig.y_dim: int property ¤

Convenience property for shape[0]

cryojax.simulator.InstrumentConfig.x_dim: int property ¤

Convenience property for shape[1]

cryojax.simulator.InstrumentConfig.coordinate_grid_in_pixels: Float[Array, '{self.y_dim} {self.x_dim} 2'] cached property ¤

A spatial coordinate system for the shape.

cryojax.simulator.InstrumentConfig.coordinate_grid_in_angstroms: Float[Array, '{self.y_dim} {self.x_dim} 2'] cached property ¤

Convenience property for pixel_size * coordinate_grid_in_pixels

cryojax.simulator.InstrumentConfig.frequency_grid_in_pixels: Float[Array, '{self.y_dim} {self.x_dim//2+1} 2'] cached property ¤

A spatial frequency coordinate system for the shape, with hermitian symmetry.

cryojax.simulator.InstrumentConfig.frequency_grid_in_angstroms: Float[Array, '{self.y_dim} {self.x_dim//2+1} 2'] cached property ¤

Convenience property for frequency_grid_in_pixels / pixel_size

cryojax.simulator.InstrumentConfig.full_frequency_grid_in_pixels: Float[Array, '{self.y_dim} {self.x_dim} 2'] cached property ¤

A spatial frequency coordinate system for the shape, without hermitian symmetry.

cryojax.simulator.InstrumentConfig.full_frequency_grid_in_angstroms: Float[Array, '{self.y_dim} {self.x_dim} 2'] cached property ¤

Convenience property for full_frequency_grid_in_pixels / pixel_size

cryojax.simulator.InstrumentConfig.padded_n_pixels: int property ¤

Convenience property for math.prod(padded_shape)

cryojax.simulator.InstrumentConfig.padded_y_dim: int property ¤

Convenience property for padded_shape[0]

cryojax.simulator.InstrumentConfig.padded_x_dim: int property ¤

Convenience property for padded_shape[1]

cryojax.simulator.InstrumentConfig.padded_coordinate_grid_in_pixels: Float[Array, '{self.padded_y_dim} {self.padded_x_dim} 2'] cached property ¤

A spatial coordinate system for the padded_shape.

cryojax.simulator.InstrumentConfig.padded_coordinate_grid_in_angstroms: Float[Array, '{self.padded_y_dim} {self.padded_x_dim} 2'] cached property ¤

Convenience property for pixel_size * padded_coordinate_grid_in_pixels

cryojax.simulator.InstrumentConfig.padded_frequency_grid_in_pixels: Float[Array, '{self.padded_y_dim} {self.padded_x_dim//2+1} 2'] cached property ¤

A spatial frequency coordinate system for the padded_shape, with hermitian symmetry.

cryojax.simulator.InstrumentConfig.padded_frequency_grid_in_angstroms: Float[Array, '{self.padded_y_dim} {self.padded_x_dim//2+1} 2'] cached property ¤

Convenience property for padded_frequency_grid_in_pixels / pixel_size

cryojax.simulator.InstrumentConfig.padded_full_frequency_grid_in_pixels: Float[Array, '{self.padded_y_dim} {self.padded_x_dim} 2'] cached property ¤

A spatial frequency coordinate system for the padded_shape, without hermitian symmetry.

cryojax.simulator.InstrumentConfig.padded_full_frequency_grid_in_angstroms: Float[Array, '{self.padded_y_dim} {self.padded_x_dim} 2'] cached property ¤

Convenience property for padded_full_frequency_grid_in_pixels / pixel_size

cryojax.simulator.InstrumentConfig.crop_to_shape(image: Float[Array, 'y_dim x_dim']) -> Float[Array, '{self.y_dim} {self.x_dim}'] ¤

Crop an image to shape.

cryojax.simulator.InstrumentConfig.pad_to_padded_shape(image: Float[Array, 'y_dim x_dim'], **kwargs: Any) -> Float[Array, '{self.padded_y_dim} {self.padded_x_dim}'] ¤

Pad an image to padded_shape.

cryojax.simulator.InstrumentConfig.crop_or_pad_to_padded_shape(image: Float[Array, 'y_dim x_dim'], **kwargs: Any) -> Float[Array, '{self.padded_y_dim} {self.padded_x_dim}'] ¤

Reshape an image to padded_shape using cropping or padding.