Optics#

class deeptrack.optical.optics.Optics(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: Feature

Base class for optical systems.

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_min, y_min, x_max, y_max). 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 or tuple[int, int, int], optional

Internal oversampling factor used during image formation. A scalar applies the same factor along all axes; a tuple specifies (ux, uy, uz). Larger values improve spatial sampling during propagation, after which the simulated image is downscaled back to detector resolution.

**kwargs: 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_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: int or tuple[int, int, int], optional

Internal oversampling factor used during image formation. A scalar applies the same factor along all axes; a tuple specifies (ux, uy, uz). Larger values improve spatial sampling during propagation, after which the simulated image is downscaled back to detector resolution.

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#

_process_properties(propertydict) -> dict[str, Any]

Processes and validates the input properties.

_pupil(…) -> array_like[complex]

Calculates the pupil function at different focal points.

_pad_volume(volume, limits, padding, output_region, **kwargs) -> tuple

Pads the volume with zeros to avoid edge effects.

__call__(sample: Feature, **kwargs: 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: Any) Microscope#

Creates a Microscope instance with the given sample and optics.

Parameters#

sample: Feature

The sample to be imaged.

**kwargs: 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