Optics#

class deeptrack.optics.Optics(NA: float | Callable[[...], float] = 0.7, wavelength: float | Callable[[...], float] = 6.6e-07, magnification: float | Callable[[...], float] = 10, resolution: float | Tuple[float, ...] | List[float] | ndarray | Callable[[...], float | Tuple[float, ...] | List[float] | ndarray] = 1e-06, refractive_index_medium: float | Callable[[...], float] = 1.33, padding: Tuple[int, ...] | List[int] | ndarray | Callable[[...], Tuple[int, ...] | List[int] | ndarray] = (10, 10, 10, 10), output_region: Tuple[int, ...] | List[int] | ndarray | Callable[[...], Tuple[int, ...] | List[int] | ndarray] = (0, 0, 128, 128), pupil: Feature | None = None, illumination: Feature | None = None, upscale: int = 1, **kwargs: Dict[str, Any])#

Bases: Feature

Abstract base optics class.

Provides structure and methods common for most optical devices. Subclasses implement specific optical systems by defining imaging properties and behaviors. The Optics class is used to define the core imaging properties of an optical system, such as resolution, magnification, numerical aperture (NA), and wavelength.

Parameters#

NA: float, optional

Numerical aperture (NA) of the limiting aperture, by default 0.7.

wavelength: float, optional

Wavelength of the scattered light in meters, by default 0.66e-6.

magnification: float, optional

Magnification of the optical system, by default 10.

resolution: float or array_like[float], optional

Distance between pixels in the camera (meters). A third value can define the resolution in the z-direction, by default 1e-6.

refractive_index_medium: float, optional

Refractive index of the medium, by default 1.33.

padding: array_like[int, int, int, int], optional

Padding applied to the sample volume to avoid edge effects, by default (10, 10, 10, 10).

output_region: array_like[int, int, int, int], optional

Region of the image to output (x, y, width, height). If None, the entire image is returned, by default (0, 0, 128, 128).

pupil: Feature, optional

Feature-set resolving the pupil function at focus. By default, no pupil is applied.

illumination: Feature, optional

Feature-set resolving the illumination source. By default, no specific illumination is applied.

upscale: int, optional

Scaling factor for the resolution of the optical system, by default 1.

**kwargs: Dict[str, Any]

Additional parameters passed to the base Feature class.

Attributes#

__conversion_table__: ConversionTable

Table used to convert properties of the feature to desired units.

NA: float

Numerical aperture of the optical system.

wavelength: float

Wavelength of the scattered light in meters.

refractive_index_medium: float

Refractive index of the medium.

magnification: float

Magnification of the optical system.

resolution: float or array_like[float]

Pixel spacing in the camera. Optionally includes the z-direction.

padding: array_like[int]

Padding applied to the sample volume to reduce edge effects.

output_region: array_like[int]

Region of the output image to extract (x, y, width, height).

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: int

Scaling factor for the resolution of the optical system.

limits: array_like[int, int]

Limits of the volume to be imaged.

fields: list[Feature]

List of fields to be imaged.

Methods#

_process_properties(propertydict: Dict[str, Any]) -> Dict[str, Any]

Processes and validates the input properties.

_pupil(shape: array_like[int, int], NA: float, wavelength: float, refractive_index_medium: float, include_aberration: bool, defocus: float, **kwargs: Dict[str, Any]) -> array_like[complex]

Calculates the pupil function at different focal points.

_pad_volume(volume: array_like[complex], limits: array_like[int, int], padding: array_like[int], output_region: array_like[int], **kwargs: Dict[str, Any]) -> tuple

Pads the volume with zeros to avoid edge effects.

__call__(sample: Feature, **kwargs: Dict[str, Any]) -> Microscope

Creates a Microscope instance with the given sample and optics.

Examples#

Creating an Optics instance:

>>> import deeptrack as dt
>>> optics = dt.Optics(NA=0.8, wavelength=0.55e-6, magnification=20)
>>> print(optics.NA())
0.8

Methods Summary

__call__(sample, **kwargs)

Creates a Microscope instance with the given sample and optics.

Methods Documentation

__call__(sample: Feature, **kwargs: Dict[str, Any]) Microscope#

Creates a Microscope instance with the given sample and optics.

Parameters#

sample: Feature

The sample to be imaged.

**kwargs: Dict[str, Any]

Additional parameters for the Microscope.

Returns#

Microscope: Microscope

A Microscope instance configured with the sample and optics.

Examples#

Creating a Microscope instance:

>>> import deeptrack as dt
>>> scatterer = dt.PointParticle()
>>> optics = dt.Optics()
>>> microscope = optics(scatterer)
>>> print(isinstance(microscope, dt.Microscope))
True