Brightfield#

class deeptrack.optical.optics.Brightfield(NA: float | Callable[[...], float] = 0.7, wavelength: float | Callable[[...], float] = 6.6e-07, magnification: float | Callable[[...], float] = 10, resolution: float | tuple[float, float] | tuple[float, float, float] | Callable[[...], float | tuple[float, float] | tuple[float, float, float]] = 1e-06, refractive_index_medium: float | Callable[[...], float] = 1.33, padding: tuple[int, int, int, int] | Callable[[...], tuple[int, int, int, int]] = (10, 10, 10, 10), output_region: tuple[int, int, int, int] | Callable[[...], tuple[int, int, int, int]] = (0, 0, 128, 128), pupil: Feature | None = None, illumination: Feature | None = None, upscale: int | tuple[int, int, int] | Callable[[...], int | tuple[int, int, int]] = 1, **kwargs: Any)#

Bases: Optics

Simulates imaging of coherently illuminated samples.

The Brightfield class models a brightfield microscopy setup, imaging samples by iteratively propagating light through a discretized volume. Each voxel in the volume represents the effective refractive index of the sample at that point. Light is propagated iteratively through Fourier space and corrected in real space.

Parameters#

illumination: Feature, optional

Feature-set representing the complex field entering the sample. Default is a uniform field with all values set to 1.

NA: float

Numerical aperture of the limiting aperture.

wavelength: float

Wavelength of the incident light in meters.

magnification: float

Magnification of the optical system.

resolution: array_like[float (, float, float)]

Pixel spacing in the camera. A third value can define the resolution in the z-direction.

refractive_index_medium: float

Refractive index of the medium.

padding: array_like[int, int, int, int]

Padding added to the sample volume to minimize edge effects.

output_region: array_like[int, int, int, int], optional

Specifies the region of the image to output (x_min, y_min, x_max, y_max). Default is None, which outputs the entire image.

pupil: Feature, optional

Feature-set defining the pupil function. The input is the unaberrated pupil.

Attributes#

__conversion_table__: ConversionTable

Table used to convert properties of the feature to desired units.

NA: float

Numerical aperture of the optical system.

wavelength: float

Wavelength of the scattered light in meters.

magnification: float

Magnification of the optical system.

resolution: array_like[float (, float, float)]

Pixel spacing in the camera. Optionally includes the z-direction.

refractive_index_medium: float

Refractive index of the medium.

padding: array_like[int, int, int, int]

Padding applied to the sample volume to reduce edge effects.

output_region: array_like[int, int, int, int]

Region of the output image to extract (x_min, y_min, x_max, y_max).

voxel_size: function

Function returning the voxel size of the optical system.

pixel_size: function

Function returning the pixel size of the optical system.

upscale: PropertyLike[int | tuple[int, int, int]]

Scaling factor for the resolution of the optical system.

limits: np.ndarray | torch.Tensor | None

Array of shape (3, 2) with volume bounds [[x_min, x_max], [y_min, y_max], [z_min, z_max]]. If None, bounds are initialized to zeros.

fields: list[Feature]

List of fields to be imaged.

Methods#

get(illuminated_volume, limits, fields, …) -> np.ndarray | torch.Tensor

Simulates imaging with brightfield microscopy.

Examples#

Create a Brightfield instance:

>>> import deeptrack as dt
>>> optics = dt.Brightfield(NA=1.4, wavelength=0.52e-6, magnification=60)
>>> print(optics.NA())
1.4

Methods Summary

extract_contrast_volume(scattered, ...)

Extract refractive index contrast volume for brightfield imaging.

get(illuminated_volume, limits, fields, **kwargs)

Simulates imaging with brightfield microscopy.

validate_input(scattered)

Semantic validation for brightfield microscopy.

Methods Documentation

extract_contrast_volume(scattered: ScatteredVolume, refractive_index_medium: float, **kwargs: Any) ndarray | Tensor#

Extract refractive index contrast volume for brightfield imaging.

get(illuminated_volume: ndarray | Tensor, limits: ndarray | Tensor | None, fields: list[ScatteredField], **kwargs: Any) ndarray | Tensor#

Simulates imaging with brightfield microscopy.

This method propagates a coherent field through the contrast volume slice by slice, applies the pupil response, optionally adds externally supplied ScatteredField contributions at the detector plane, and returns either the complex field or its intensity.

Parameters#

illuminated_volume: np.ndarray | torch.Tensor

Discretized volume representing the sample to be imaged.

limits: np.ndarray | torch.Tensor | None

Array of shape (3, 2) with volume bounds [[x_min, x_max], [y_min, y_max], [z_min, z_max]]. If None, bounds are initialized to zeros.

fields: list[ScatteredField]

Additional coherent fields to be added at the detector plane. Each field must provide an .array with shape (H, W) or (H, W, 1).

**kwargs: Any

Additional parameters for the imaging process, including: - ‘padding’: Padding to apply to the sample volume. - ‘output_region’: Specific region to extract from the image. - ‘wavelength’: Wavelength of the light. - ‘refractive_index_medium’: Refractive index of the medium.

Returns#

image: np.ndarray | torch.Tensor

Processed image after simulating the brightfield imaging process.

Examples#

Simulate imaging a volume:

>>> import deeptrack as dt
>>> import numpy as np
>>> optics = dt.Brightfield(
...     NA=1.4,
...     wavelength=0.52e-6,
...     magnification=60,
... )
>>> volume = np.ones((128, 128, 10), dtype=complex)
>>> limits = np.array([[0, 128], [0, 128], [0, 10]])
>>> fields = [
...     dt.ScatteredField(array=np.ones((162, 162, 1), dtype=complex))
... ]
>>> properties = optics.properties()
>>> filtered_properties = {
...     k: v for k, v in properties.items()
...     if k in {'padding', 'output_region', 'NA',
...              'wavelength', 'refractive_index_medium'}
... }
>>> image = optics.get(volume, limits, fields, **filtered_properties)
>>> print(image.shape)
(128, 128, 1)
validate_input(scattered) None#

Semantic validation for brightfield microscopy.