Psf is a Python library to calculate Point Spread Functions (PSF) for fluorescence microscopy.
The psf library is no longer actively developed.
| Author: | Christoph Gohlke |
|---|---|
| License: | BSD-3-Clause |
| Version: | 2026.11.15 |
Install the psf package and all dependencies from the Python Package Index:
python -m pip install -U "psf[all]"
See Examples for using the programming interface.
Source code and support are available on GitHub.
This revision was tested with the following requirements and dependencies (other versions may work):
- CPython 3.12.10, 3.13.17, 3.14.10, 3.15.2 64-bit
- Numpy 2.5.4
- Matplotlib 3.11.2 (optional for plotting)
2026.11.15
- Fix pixel size of pinhole kernel and Gaussian sigma (breaking).
- Use emission wavelength for 8 AU pinhole cutoff.
- Fix several bugs in C extension and Python module.
- Fix byte-swapped array handling in C extension.
- Improve validation of input parameters.
- Use common array converters and helper functions in C extensions.
2026.8.8
- Make C extension ABI3 and free-threading compatible.
- Drop support for Python 3.11 and numpy 2.0 (SPEC0).
- Support Python 3.15.
2026.1.18
- …
Refer to the CHANGES file for older revisions.
- Electromagnetic diffraction in optical systems. II. Structure of the image field in an aplanatic system. B Richards and E Wolf. Proc R Soc Lond A, 253 (1274), 358-379, 1959.
- Focal volume optics and experimental artifacts in confocal fluorescence correlation spectroscopy. S T Hess, W W Webb. Biophys J (83) 2300-17, 2002.
- Electromagnetic description of image formation in confocal fluorescence microscopy. T D Viser, S H Wiersma. J Opt Soc Am A (11) 599-608, 1994.
- Photon counting histogram: one-photon excitation. B Huang, T D Perroud, R N Zare. Chem Phys Chem (5), 1523-31, 2004. Supporting information: Calculation of the observation volume profile.
- Gaussian approximations of fluorescence microscope point-spread function models. B Zhang, J Zerubia, J C Olivo-Marin. Appl. Optics (46) 1819-29, 2007.
- The SVI-wiki on 3D microscopy, deconvolution, visualization and analysis. https://svi.nl/NyquistRate
>>> import psf
>>> args = dict(
... shape=(32, 32),
... dims=(4, 4),
... ex_wavelen=488,
... em_wavelen=520,
... num_aperture=1.2,
... refr_index=1.333,
... pinhole_radius=0.55,
... pinhole_shape='round',
... )
>>> obsvol = psf.PSF(psf.GAUSSIAN | psf.CONFOCAL, **args)
>>> obsvol.sigma.ou
(2.588..., 1.370...)
>>> obsvol = psf.PSF(psf.ISOTROPIC | psf.CONFOCAL, **args)
>>> print(obsvol, end='')
PSF
ISOTROPIC|CONFOCAL
shape: (32, 32) pixel
dimensions: (4.00, 4.00) um, (55.64, 61.80) ou, (8.06, 8.06) au
excitation wavelength: 488.0 nm
emission wavelength: 520.0 nm
numeric aperture: 1.20
refractive index: 1.33
half cone angle: 64.19 deg
magnification: 1.00
underfilling: 1.00
pinhole radius: 0.550 um, 8.498 ou, 1.1086 au, 4.26 px
computing time: ... ms
>>> obsvol[0, :3]
array([1. , 0.51026, 0.04382])
>>> # write the image plane to file
>>> obsvol.slice(0).tofile('_test_slice.bin')
>>> # write a full 3D PSF volume to file
>>> obsvol.volume().tofile('_test_volume.bin')Refer to psf_example.py in the source distribution for more examples.