Darkfield#

class deeptrack.optical.optics.Darkfield(illumination_angle: float = 1.5707963267948966, **kwargs: Any)#

Bases: Brightfield

Images coherently illuminated samples using Darkfield microscopy.

This class models Darkfield microscopy by creating a discretized volume where each pixel represents the effective refractive index of the sample. Light is propagated through the sample iteratively, first in the Fourier space and then corrected in the real space for refractive index.

Parameters#

illumination: Feature

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

NA: float

Numerical aperture (NA) of the limiting aperture.

wavelength: float

Wavelength of the scattered light, in meters.

magnification: float

Magnification factor of the optical system.

resolution: array_like of float

Pixel spacing in the camera. Optionally includes a third value for z-direction resolution.

refractive_index_medium: float

Refractive index of the medium surrounding the sample.

padding: array_like of int

Padding for the sample volume to minimize edge effects. Format: (left, right, top, bottom).

output_region: array_like of int

Region of the image to output as (x_min, y_min, x_max, y_max). If None (default), the entire image is returned.

pupil: Feature

Feature-set defining the pupil function at focus. The feature-set takes an unaberrated pupil as input.

illumination_angle: float, optional

Angle of illumination relative to the optical axis, in radians. Default is π/2 radians.

Attributes#

illumination_angle: float

The angle of illumination, stored for reference.

Methods#

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

Retrieves the darkfield image of the illuminated volume.

Examples#

Creating a Darkfield instance:

>>> import deeptrack as dt
>>> darkfield = dt.Darkfield(NA=0.9, wavelength=0.532e-6)
>>> print(darkfield.illumination_angle())
1.5707963267948966

Methods Summary

downscale_image(image, upscale)

Detector downscaling (energy conserving)

extract_contrast_volume(scattered, ...)

Approximate darkfield contrast from a volume (toy model).

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

Retrieve the darkfield image of the illuminated volume.

validate_input(scattered)

Semantic validation for brightfield microscopy.

Methods Documentation

downscale_image(image: ndarray, upscale) ndarray#

Detector downscaling (energy conserving)

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

Approximate darkfield contrast from a volume (toy model).

This is a non-physical approximation intended for qualitative simulations.

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

Retrieve the darkfield image of the illuminated volume.

This method reuses the coherent propagation model of Brightfield, but returns a darkfield-like signal obtained from the propagated field after suppressing the unscattered reference contribution.

Parameters#

illuminated_volume: array_like

The volume of the sample being illuminated.

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 passed to the super class’s get method.

Returns#

numpy.ndarray

The darkfield image obtained by calculating the squared absolute difference from 1.

validate_input(scattered) None#

Semantic validation for brightfield microscopy.