deeptrack.holography Module#

Core features for manipulating optical fields using Fourier transforms and propagation matrices.

This module includes operations to simulate optical field propagation and perform transformations in the frequency domain. These features can be combined in processing pipelines for optical simulations and holographic reconstructions.

Key Features#

  • Optical Field Processing

    Provides Fourier transforms, rescaling, and wavefront propagation for complex-valued optical fields, handling both real and imaginary components.

  • Fourier Optics and Wave Propagation

    Implements Fourier transforms with optional padding for accurate frequency-domain analysis and propagation matrices to simulate free-space wavefront propagation with spatial and frequency domain shifts.

  • Phase & Amplitude Manipulation

    Enables scaling, normalization, and modulation of phase and amplitude to preserve intensity distribution and enhance wavefront reconstruction.

Module Structure#

Classes:

  • Rescale:

    Rescales an optical field by subtracting the real part of the field before multiplication.

  • FourierTransform:

    Creates matrices for propagating an optical field.

  • InverseFourierTransform:

    Creates matrices for propagating an optical field.

  • FourierTransformTransformation:

    Applies a power of the forward or inverse propagation matrix to an optical field.

Functions:

  • get_propagation_matrix

    def get_propagation_matrix(

    shape: tuple[int, int], to_z: float, pixel_size: float, wavelength: float, dx: float = 0, dy: float = 0

    ) -> np.ndarray

    Computes the propagation matrix.

Examples#

Simulate optical field propagation with Fourier transforms:

>>> import deeptrack as dt
>>> import numpy as np

Define a random optical field: >>> field = np.random.rand(128, 128, 2)

Rescale the field and compute the Fourier transform: >>> rescale_op = dt.holography.Rescale(0.5) >>> scaled_field = rescale_op(field) >>> ft_op = dt.holography.FourierTransform() >>> transformed_field = ft_op(scaled_field)

Reconstruct the field using the inverse Fourier transform: >>> ift_op = dt.holography.InverseFourierTransform() >>> reconstructed_field = ift_op(transformed_field)

Functions#

get_propagation_matrix(shape, to_z, ...[, ...])

Computes the propagation matrix for simulating the propagation of an optical field.

maybe_cupy(array)

Convert an array to a CuPy array if GPU is available and enabled.

Classes#

Feature([_input])

Base feature class.

FourierTransform(**kwargs)

Computes the Fourier transform of an optical field with optional symmetric padding.

FourierTransformTransformation(Tz, Tzinv, i, ...)

Applies a power of the forward or inverse propagation matrix to an optical field.

Image(value[, copy])

Wrapper for array-like values with property tracking.

InverseFourierTransform(**kwargs)

Applies a power of the forward or inverse propagation matrix to an optical field.

Rescale([rescale])

Rescales an optical field by modifying its real and imaginary components.