Skip to main content

PSFmodels-py

Python bindings for scalar and vectorial models of the point spread function.

Original C++ code and MATLAB MEX bindings Copyright © 2006-2013, Francois Aguet, distributed under GPL-3.0 license. Python bindings by Talley Lambert

The model is described in Auget et al 20091. For more information and implementation details, see Francois' Thesis2.

1 F. Aguet et al., (2009) Opt. Express 17(8), pp. 6829-6848

2 F. Aguet. (2009) Super-Resolution Fluorescence Microscopy Based on Physical Models. Swiss Federal Institute of Technology Lausanne, EPFL Thesis no. 4418

see also:

For a different (faster) scalar-based Gibson–Lanni PSF model, see the MicroscPSF project, based on Li et al (2017) which has been implemented in Python, MATLAB, and ImageJ/Java

Install

Prebuilt binaries available on pypi for OS X and Windows, sdist available for linux

pip install psfmodels

from source

(requires cmake and a c++ compiler)

git clone https://github.com/tlambert03/PSFmodels-py.git
cd PSFmodels-py
python setup.py install

Usage

There are two main functions in psfmodels: vectorial_psf and scalar_psf. Additionally, each version has a helper function called vectorial_psf_centered and scalar_psf_centered respectively. The main difference is that the _psf functions accept a vector of Z positions zv (relative to coverslip) at which PSF is calculated. As such, the point source may or may not actually be in the center of the rendered volume. The _psf_centered variants, by contrast, do not accecpt zv, but rather accept nz (the number of z planes) and dz (the z step size in microns), and always generates an output volume in which the point source is positioned in the middle of the Z range, with planes equidistant from each other. All functions accept an argument pz, specifying the position of the point source relative to the coverslip. See additional keyword arguments below

Note, all output dimensions (nx and nz) should be odd.

import psfmodels as psfm
import matplotlib.pyplot as plt
from matplotlib.colors import PowerNorm

# generate centered psf with a point source at `pz` from coverslip
nx = 127
nz = nx
dxy = 0.05
psf = psfm.vectorial_psf_centered(nz=nz, nx=nx, dxy=dxy, dz=dxy, pz=0)
fig, (ax1, ax2) = plt.subplots(1, 2)
ax1.imshow(psf[nz//2], norm=PowerNorm(gamma=0.4))
ax2.imshow(psf[:, nx//2], norm=PowerNorm(gamma=0.4))
plt.show()

Image of PSF

# instead of nz and dz, you can directly specify a vector of z positions
import numpy as np

# generate 31 evenly spaced Z positions from -3 to 3 microns
zv = np.linspace(-3, 3, 31)
psf = psfm.vectorial_psf(zv, nx=127)
psf.shape  # (31, 127, 127)

all PSF functions accept the following parameters. In general, units should be provided in microns. Python API may change slightly in the future. See function docstrings as well.

nx (int):       XY size of output PSF in pixels, must be odd.
dxy (float):    pixel size in sample space (microns) [default: 0.05]
pz (float):     depth of point source relative to coverslip (in microns) [default: 0]
ti0 (float):    working distance of the objective (microns) [default: 1.515]
ni0 (float):    immersion medium refractive index, design value [default: 1.515]
ni (float):     immersion medium refractive index, experimental value [default: 1.515]
tg0 (float):    coverslip thickness, design value (microns) [default: 170]
tg (float):     coverslip thickness, experimental value (microns) [default: 170]
ng0 (float):    coverslip refractive index, design value [default: 1.515]
ng (float):     coverslip refractive index, experimental value [default: 1.515]
ns (float):     sample refractive index [default: 1.47]
wvl (float):    emission wavelength (microns) [default: 0.6]
NA (float):     numerical aperture [default: 1.4]
sf (int):       oversampling factor to approximate pixel integration [default: 3]
mode (int):     if 0, returns oversampled PSF [default: 1]

Comparison with other models

While these models are definitely slower than the one implemented in Li et al (2017) and MicroscPSF, there are some interesting differences between the scalar and vectorial approximations, particularly with higher NA lenses, non-ideal sample refractive index, and increasing spherical aberration with depth from the coverslip.

For an interactive comparison, see the examples.ipynb Jupyter notebook.

Release files for psfmodels 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for psfmodels 0.1.0
File Size Uploaded
psfmodels-0.1.0.tar.gz 163.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for psfmodels 0.1.0
File
psfmodels-0.1.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
psfmodels-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
psfmodels-0.1.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
psfmodels-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64 Details
psfmodels-0.1.0-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
psfmodels-0.1.0-cp35-cp35m-macosx_10_9_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64 Details
psfmodels-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ x86-64 Details

Total release size: 752.7 kB

Release files / psfmodels-0.1.0.tar.gz

Download URL psfmodels-0.1.0.tar.gz
Size 163.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e2786b5218978317f73001ea987d2d3ff398115a402426ef4a1c1d41c3d9e870
BLAKE2b-256 checksum
How to use checksums
143ba4a64c858fec5c32036caf469dbdc884fe35381a14f757ae53a7e976a019
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

Release files / psfmodels-0.1.0-cp37-cp37m-win_amd64.whl

Download URL psfmodels-0.1.0-cp37-cp37m-win_amd64.whl
Size 83.1 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
e8c31082c685e53caea0dc9d8f1190c5b4a735c0879f7199a32c8e805cf063c4
BLAKE2b-256 checksum
How to use checksums
1b3b1fef0cceff331bea1bd4f25b6751c1821006857dc71beba58de0aa64004f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / psfmodels-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL psfmodels-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
Size 85.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
48507079967b3251d6cca36868210448d3073fe6ea906dabb66fa94f168482dd
BLAKE2b-256 checksum
How to use checksums
0ea046df88ef4835450e075805256b691f3b7d106eca187c756f452aa016f492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.3

Release files / psfmodels-0.1.0-cp36-cp36m-win_amd64.whl

Download URL psfmodels-0.1.0-cp36-cp36m-win_amd64.whl
Size 83.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
cfb4250316206993db10b40b65672b900c344dd437a0e64e704a2046a85e9add
BLAKE2b-256 checksum
How to use checksums
89db35a317d499a97f73e367ba388226c2d4919eaeecdfd4da12d5f7182d336c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

Release files / psfmodels-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl

Download URL psfmodels-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
Size 85.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
e2f50e899c6e4aec252d6f457f98d947f3ad514a39e4e76ad2f0008b7ff918c0
BLAKE2b-256 checksum
How to use checksums
79664232f69ea7d18566f70e64b2ba85dbfb9d60cfb39137ad5332c5fc3351b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.7

Release files / psfmodels-0.1.0-cp35-cp35m-win_amd64.whl

Download URL psfmodels-0.1.0-cp35-cp35m-win_amd64.whl
Size 83.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
bbbf7207dd2d88ba7605982038d04c447874ef51e10737b20b373067dc0cd8d2
BLAKE2b-256 checksum
How to use checksums
e0ede4cfcfd550a897824ed9254626a2e8474fa0857a6a810ab4ac4750965196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

Release files / psfmodels-0.1.0-cp35-cp35m-macosx_10_9_x86_64.whl

Download URL psfmodels-0.1.0-cp35-cp35m-macosx_10_9_x86_64.whl
Size 85.1 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
658aa3f20c2fb2d1814b7274643a86f0e0cf63c6c009f21dfdbfd8528c7178db
BLAKE2b-256 checksum
How to use checksums
4c99202d1e39b764b7c691cf1793a13b30d8ec1ecc91522795abd04856309cfc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.5

Release files / psfmodels-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl

Download URL psfmodels-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
Size 85.3 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ x86-64
SHA-256 checksum
How to use checksums
fcece92e3dabde90b3abae0e7529e44ca3ec7d1cbbc1b67968bef9408ec288a3
BLAKE2b-256 checksum
How to use checksums
386c57f49efae391630cb9b9a1a1d2d3c1f919c3f6f1316e77b1c9c8d39d4d9e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.15

Release history Release notifications | RSS feed

0.3.2

20 release files

0.3.1

20 release files

0.3.0

20 release files

0.2.0

8 release files

This release

0.1.0 This release

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page