Microscope#

class deeptrack.optical.optics.Microscope(sample: Feature, objective: Optics, **kwargs: Any)#

Bases: StructuralFeature

Simulates imaging of a sample using an optical system.

This class combines the sample to be imaged with the optical system, enabling the simulation of optical imaging processes. A Microscope: - validates the semantic compatibility between scatterers and optics - interprets volume-based scatterers into scalar fields when needed - delegates numerical propagation to the objective (Optics) - performs detector downscaling according to its physical semantics

The microscope evaluates the sample in an internally upscaled coordinate system determined by objective.upscale. The final image is then downscaled to detector resolution using the optics-specific detector model.

Parameters#

sample: Feature

A feature resolving one or more scatterers to be imaged, typically ScatteredVolume, ScatteredField, or a list containing them.

objective: “Optics”

A feature-set defining the optical device that images the sample.

Attributes#

__distributed__: bool

If True, the feature is distributed across multiple workers.

_sample: Feature

The feature-set defining the sample to be imaged.

_objective: “Optics”

The feature-set defining the optical system imaging the sample.

Methods#

get(image, **kwargs) -> np.ndarray | torch.Tensor

Simulates the imaging process using the defined optical system and returns the resulting image.

Notes#

All volume scatterers imaged by a Microscope instance are assumed to share the same contrast mechanism (e.g. refractive index or fluorescence). Mixing contrast types is not supported.

Examples#

Simulating an image using a brightfield optical system:

>>> import deeptrack as dt
>>> scatterer = dt.PointParticle()
>>> optics = dt.Brightfield()
>>> microscope = dt.Microscope(sample=scatterer, objective=optics)
>>> image = microscope.get(None)
>>> print(image.shape)
(128, 128, 1)

Methods Summary

get([image])

Generate an image of the sample using the defined optical system.

Methods Documentation

get(image: ndarray | Tensor | None = None, **kwargs: Any) ndarray | Tensor#

Generate an image of the sample using the defined optical system.

This method processes the sample through the optical system to produce a simulated image.

Parameters#

image: np.ndarray | torch.Tensor | None

The input image to be processed. If None, a new image is created.

**kwargs: Any

Additional parameters for the imaging process.

Returns#

image: np.ndarray | torch.Tensor

The processed image after applying the optical system.

Examples#

Simulating an image with specific parameters:

>>> import deeptrack as dt
>>> scatterer = dt.PointParticle()
>>> optics = dt.Brightfield()
>>> microscope = dt.Microscope(sample=scatterer, objective=optics)
>>> image = microscope.get(None)
>>> print(image.shape)
(128, 128, 1)