deeptrack.optics Module#
Features for optical imaging of samples.
This module provides classes and functionalities for simulating optical imaging systems, enabling the generation of realistic camera images of biological and physical samples. The primary goal is to offer tools for modeling and computing optical phenomena such as brightfield, fluorescence, holography, and other imaging modalities.
Key Features#
Microscope Simulation
The Microscope class acts as a high-level interface for imaging samples using defined optical systems. It coordinates the interaction between the sample and the optical system, ensuring seamless simulation of imaging processes.
Optical Systems
The Optics class and its derived classes represent various optical devices, defining core imaging properties such as resolution, magnification, numerical aperture (NA), and wavelength. Subclasses like Brightfield, Fluorescence, Holography, Darkfield, and ISCAT offer specialized configurations tailored to different imaging techniques.
Sample Illumination and Volume Simulation
Features like IlluminationGradient enable realistic simulation of non-uniform sample illumination, critical for generating realistic images. The _create_volume function facilitates combining multiple scatterers into a single unified volume, supporting 3D imaging.
Integration with feature pipelines
Full compatibility with feature pipelines, allows for dynamic and complex simulations, incorporating physics-based models and real-time adjustments to sample and imaging properties.
Module Structure#
Classes:
Microscope: Represents a simulated optical microscope that integrates the
sample and optical systems. It provides an interface to simulate imaging by combining the sample properties with the configured optical system.
Optics: An abstract base class representing a generic optical device.
Subclasses implement specific optical systems by defining imaging properties and behaviors.
Brightfield: Simulates brightfield microscopy, commonly used for observing
unstained or stained samples under transmitted light. This class serves as the base for additional imaging techniques.
Holography: Simulates holographic imaging, capturing phase information from
the sample. Suitable for reconstructing 3D images and measuring refractive index variations.
Darkfield: Simulates darkfield microscopy, which enhances contrast by
imaging scattered light against a dark background. Often used to highlight fine structures in samples.
ISCAT: Simulates interferometric scattering microscopy (ISCAT), an advanced
technique for detecting small particles or molecules based on scattering and interference.
Fluorescence: Simulates fluorescence microscopy, modeling emission
processes for fluorescent samples. Includes essential optical system configurations and fluorophore behavior.
IlluminationGradient: Adds a gradient to the illumination of the sample,
enabling simulations of non-uniform lighting conditions often seen in real-world experiments.
Utility Functions:
_get_position(image, mode, return_z)
- def _get_position(
image: np.ndarray, mode: str = “corner”, return_z: bool = False
) -> Tuple[int, int, Optional[int]]
Extracts the position of the upper-left corner of a scatterer in the image.
_create_volume(list_of_scatterers:, pad, output_region, refractive_index_medium, **kwargs)
- def _create_volume(
list_of_scatterers: List[np.ndarray], pad: int, output_region: Tuple[int, int, int, int], refractive_index_medium: float, **kwargs: Dict[str, Any],
) -> np.ndarray
Combines multiple scatterer objects into a single 3D volume for imaging.
_pad_volume(volume, limits, padding, output_region, **kwargs)
- def _pad_volume(
volume: np.ndarray, limits: np.ndarray, padding: Tuple[int, int, int, int], output_region: Tuple[int, int, int, int], **kwargs: Dict[str, Any],
) -> Tuple[np.ndarray, np.ndarray]
Pads a volume with zeros to avoid edge effects during imaging.
Examples#
Simulating an image with the Brightfield class:
>>> import deeptrack as dt
>>> scatterer = dt.PointParticle()
>>> optics = dt.Brightfield()
>>> image = optics(scatterer)
>>> print(image().shape)
(128, 128, 1)
>>> image.plot(cmap="gray")
Simulating an image with the Fluorescence class:
>>> import deeptrack as dt
>>> scatterer = dt.PointParticle()
>>> optics = dt.Fluorescence()
>>> image = optics(scatterer)
>>> print(image().shape)
(128, 128, 1)
>>> image.plot(cmap="gray")
Classes#
|
Apply average pooling to an images. |
|
Simulates imaging of coherently illuminated samples. |
|
Convert a dictionary of values to the desired units. |
|
Images coherently illuminated samples using Darkfield microscopy. |
|
A no-op feature that simply returns the input unchanged. |
|
Base feature class. |
|
Optical device for fluorescent imaging. |
|
An alias for the Brightfield class, representing holographic imaging setups. |
|
Images coherently illuminated samples using Interferometric Scattering (ISCAT) microscopy. |
|
Adds a gradient to the illumination of the sample. |
|
Wrapper for array-like values with property tracking. |
|
Simulates imaging of a sample using an optical system. |
|
Abstract base optics class. |
|
|
|
Provides the structure of a feature set without input transformations. |