Optical Transfer Functions#

These are functions for converting a 3D point spread function (PSF) volume into a radially averaged 2D complex Optical Transfer Function (OTF) that can be used for deconvolution. You can either write the OTF to file for later use using the make_otf function, or use the TemporaryOTF context manager to create and delete a temporary OTF from a 3D PSF input.


class pycudadecon.TemporaryOTF(psf, **kwargs)[source]#

Bases: object

Context manager to read OTF file or generate a temporary OTF from a PSF.

Normalizes the input PSF to always provide the path to an OTF file, converting the PSF to a temporary file if necessary.

self.path can be used within the context to get the filepath to the temporary OTF filepath.

psf (str, np.ndarray): 3D PSF numpy array, or a filepath to a 3D PSF

or 2D complex OTF file.

**kwargs: optional keyword arguments will be passed to the

pycudadecon.otf.make_otf() function

OTF files cannot currently be provided directly as 2D complex np.ndarrays

ValueError: If the PSF/OTF is an unexpected type NotImplementedError: if the PSF/OTF is a complex 2D numpy array

>>> with TemporaryOTF(psf, **kwargs) as otf:
...     print(otf.path)
pycudadecon.make_otf(psf, outpath=None, dzpsf=0.1, dxpsf=0.1, wavelength=520, na=1.25, nimm=1.3, otf_bgrd=None, krmax=0, fixorigin=10, cleanup_otf=False, max_otf_size=60000, **kwargs)[source]#

Generate a radially averaged OTF file from a PSF file.

  • psf (str) – Filepath of 3D PSF TIF

  • outpath (str, optional) – Destination filepath for the output OTF (default: appends “_otf.tif” to filename), by default None

  • dzpsf (float, optional) – Z-step size in microns, by default 0.1

  • dxpsf (float, optional) – XY-Pixel size in microns, by default 0.1

  • wavelength (int, optional) – Emission wavelength in nm, by default 520

  • na (float, optional) – Numerical Aperture, by default 1.25

  • nimm (float, optional) – Refractive indez of immersion medium, by default 1.3

  • otf_bgrd (int, optional) – Background to subtract. “None” = autodetect., by default None

  • krmax (int, optional) – pixels outside this limit will be zeroed (overwriting estimated value from NA and NIMM), by default 0

  • fixorigin (int, optional) – for all kz, extrapolate using pixels kr=1 to this pixel to get value for kr=0, by default 10

  • cleanup_otf (bool, optional) – clean-up outside OTF support, by default False

  • max_otf_size (int, optional) – make sure OTF is smaller than this many bytes. Deconvolution may fail if the OTF is larger than 60KB (default: 60000), by default 60000


Path to the OTF file

Return type