deeptrack.optical.optics Module#
Features for optical imaging of samples.
This module provides features for simulating optical image formation from sample representations such as ScatteredVolume and ScatteredField. It includes a high-level Microscope wrapper, a base Optics class, and specialized optical systems for coherent and incoherent imaging.
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. Subclasses support internal oversampling via upscale, enabling more accurate propagation and detector integration before returning the final image on the detector grid.
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 dynamic and complex simulations, incorporating physics-based models and real-time adjustments to sample and imaging properties.
Module Structure#
Classes:
Microscope: Combines a sample-producing feature with an optical system. It
validates scatterer/optics compatibility, merges volumetric scatterers, forwards coherent fields, and applies detector downscaling when required.
Optics: Base class for optical systems. It defines common imaging
properties such as numerical aperture, wavelength, magnification, resolution, padding, output region, illumination, pupil, and upscale.
Brightfield: Coherent imaging model based on slice-by-slice propagation
through a contrast volume. Additional ScatteredField objects may be added at the detector plane.
Holography: Alias of Brightfield, representing coherent holographic
imaging.
Darkfield: Variant of Brightfield that suppresses the unscattered
reference field and returns a darkfield-like intensity.
ISCAT: Brightfield-based coherent imaging configuration for interferometric
scattering microscopy.
Fluorescence: Incoherent imaging model in which volumetric scatterers are
interpreted as emitting sources and projected through a fluorescence point-spread function.
IlluminationGradient: Modifies the amplitude of an input field by applying
a planar gradient and constant offset while preserving phase.
NonOverlapping: Resamples scatterer positions to enforce non-overlapping
volumetric placement.
SampleToMasks: Converts positioned sample objects into one or more mask
layers.
Utility Functions:
- _get_position(image, mode, return_z)
Extracts the position of the upper-left corner of a scatterer in the image.
- _create_volume(list_of_scatterers, pad, output_region, **kwargs)
Combines multiple scatterer objects into a single 3D volume for imaging.
- _pad_volume(volume, limits, padding, output_region, **kwargs)
Pads a volume with zeros to avoid edge effects during imaging.
- _merge_placed_volumes(contrast_volumes, contrast_limits)
Merges multiple placed volumes into a single volume based on their positions.
Examples#
>>> import deeptrack as dt
Simulating an image with the Brightfield class: >>> scatterer = dt.PointParticle() >>> optics = dt.Brightfield() >>> image = optics(scatterer) >>> image().shape (128, 128, 1)
>>> image.plot(cmap="gray")
Simulating an image with the Fluorescence class: >>> scatterer = dt.PointParticle() >>> optics = dt.Fluorescence() >>> image = optics(scatterer) >>> image().shape (128, 128, 1)
>>> image.plot(cmap="gray")
Classes#
|
Average pooling over spatial dimensions. |
|
Simulates imaging of coherently illuminated samples. |
|
Convert a dictionary of values to desired units. |
|
Images coherently illuminated samples using Darkfield microscopy. |
|
A no-op feature that simply returns the inputs 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. |
|
Simulates imaging of a sample using an optical system. |
|
Ensure volumes are placed non-overlapping in a 3D space. |
|
Base class for optical systems. |
|
|
|
Create a mask from a list of images. |
|
Complex field produced by a FieldScatterer. |
|
Voxelized volume produced by a VolumeScatterer. |
|
Provide the structure of a feature set without input transformations. |
|
Sum pooling over spatial dimensions. |