A python library for simulating and analyzing microscope point spread functions (PSFs)
A simulation software package for modelling optical transfer functions (OTF)/point spread functions (PSF) of optical microscopes written in python.
The majority of this package's documentation is included in the source code and should be available in any interactive session. The intent of this document is to give a quick overview of the package's features and potential uses. Much of the code has been designed with interactive sessions in mind but it should still be usable in larger scripts and programs.
Installation is simplest with
conda install -c david-hoffman pyotf
The package is made up of four component modules:
otf.pywhich contains classes for generating different types of OTFs and PSFs
phase_retrieval.pywhich contains functions and classes to perform iterative phase retrieval of the rear aperature of the optical system
zernike.pywhich contains functions for calculating Zernike Polynomials
utils.pywhich contains various utility functions used throughout the package.
Two models of optical imaging systems are available in this module one described by Hanser et al and one described by Arnison and Sheppard. They are, in fact, mathematically equivalent but in practice each have their strengths and weaknesses. A big benefit of
HanserPSF is that it allows one to calculate selected z planes of the PSF. However, if the choosen z-planes are not equispaced then the field OTF (
OTFa) and intensity OTF (
OTFi) calculated from the model won't make physical sense.
HanserPSF have much the same interface. When instantiating them the user must provide a set of model parameters. To fully describe a PSF or OTF of an objective lens, assuming no abberation, we generally need a few parameters:
- The wavelength of operation (assume monochromatic light)
- the numerical aperature of the objective
- the index of refraction of the medium
For numerical calculations we'll also want to know the x/y resolution and number of points. Note that it is assumed that z is the optical axis of the objective lens.
The phase retrieval algorithm implemented in this module is described by Hanser et. al.
Zernike Polynomials are orthonormal functions defined over the unit disk. Being orthonormal any function defined on a unit disk has a unique decomposition into Zernike polynomials. In this package, the Zernike polynomials are used to quantify the abberation of the phase and magnitude of the retrieved back pupil of the optical system. To do so one can call the
fit_to_zernikes method of a
PhaseRetrievalResult object, which will fit a specified number of Zernike modes to the back pupil's retrieved phase and magnitude, each independently, and return a
ZernikeDecomposition object. The
ZernikeDecomposition that is returned is also saved as an attribute of the
PhaseRetreivalResult object on which the
fit_to_zernikes method was called, for convenience.
ZernikeDecomposition objects have plotting methods so that the user can inspect the decomposition.
ZernikeDecomposition objects also have methods for reconstructing the phase, magnitude or complete complex pupil which can be fed back into
HanserPSF to generate an abberated, but noise free, PSF. The method for doing this simply is currently a member of the
PhaseRetreivalResult class but will probably be moved to the
ZernikeDecomposition class later.
Most of the contents of
utils won't be useful to the average user save one function:
prep_data_for_PR(data, xysize=None, multiplier=1.5).
prep_data_for_PR can, as its name suggests, be used to quickly prep PSF image data for phase retrieval using the
retrieve_phase function of the
An example of inputing a 3D stack and running this python function from LabVIEW (>2018) is given in
\labview\Test Phase Retrieval.vi
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pyotf-0.0.1-py3-none-any.whl (27.5 kB)||File type Wheel||Python version py3||Upload date||Hashes View|
|Filename, size pyotf-0.0.1.tar.gz (41.7 kB)||File type Source||Python version None||Upload date||Hashes View|