Fluorescence#

class deeptrack.optical.optics.Fluorescence(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

Optical device for fluorescent imaging.

The Fluorescence class simulates the imaging process in fluorescence microscopy by creating a discretized volume where each pixel represents the intensity of light emitted by fluorophores in the sample. It extends the Optics class to include fluorescence-specific functionalities.

Parameters#

NA: float

Numerical aperture of the optical system.

wavelength: float

Emission wavelength of the fluorescent 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 imaging 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], optional

Region of the output image to extract (x_min, y_min, x_max, y_max). If None, returns the full image.

pupil: Feature, optional

A feature set defining the pupil function at focus. The input is the unaberrated pupil.

illumination: Feature, optional

A feature set defining the illumination source.

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

Scaling factor for the resolution of the optical system.

**kwargs: Any

Attributes#

NA: float

Numerical aperture of the optical system.

wavelength: float

Emission wavelength of the fluorescent 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 imaging 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, **kwargs) -> np.ndarray | torch.Tensor

Simulates the imaging process using a fluorescence microscope.

Examples#

Create a Fluorescence instance:

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

Methods Summary

downscale_image(image, upscale)

Downscale an internally oversampled image to detector resolution.

extract_contrast_volume(scattered, **kwargs)

Extract the fluorescence-emitting contrast volume.

get(illuminated_volume, limits, **kwargs)

Backend-dispatched fluorescence imaging.

validate_input(scattered)

Semantic validation for fluorescence microscopy.

Methods Documentation

downscale_image(image: ndarray | Tensor, upscale: int | tuple[int, int, int]) ndarray | Tensor#

Downscale an internally oversampled image to detector resolution.

The fluorescence model performs image formation on an upscaled grid and then applies detector integration. The result is normalized to account for the oversampling factors. Normalization includes uz because fluorescence emission is accumulated over the internally oversampled axial coordinate before detector downscaling.

Parameters#

image: np.ndarray | torch.Tensor

The upscaled image to be downscaled.

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

The internal oversampling factor used during image formation.

Returns#

np.ndarray | torch.Tensor

The downscaled image at detector resolution.

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

Extract the fluorescence-emitting contrast volume.

The fluorescence model interprets the scatterer output as a discretized source distribution. Depending on how the scatterer is represented on the grid, additional measure corrections may already be included in the scatterer mask:

  • PointParticle includes voxel-volume scaling

  • Ellipse includes axial-thickness scaling

  • volumetric scatterers such as Sphere and Ellipsoid require no

additional geometric measure correction beyond their voxelized support

This method therefore applies only the fluorescence intensity scaling itself.

get(illuminated_volume: ndarray | Tensor, limits: ndarray | Tensor | None, **kwargs: Any) ndarray | Tensor#

Backend-dispatched fluorescence imaging.

Parameters#

illuminated_volume: np.ndarray | torch.Tensor

The illuminated 3D volume 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.

**kwargs: Any

Additional properties for the imaging process, such as: - ‘padding’: Padding to apply to the sample. - ‘output_region’: Specific region to extract from the image.

Returns#

image: np.ndarray | torch.Tensor

A 2D image object representing the fluorescence projection.

validate_input(scattered) None#

Semantic validation for fluorescence microscopy.