Skip to main content

Scalar and vectorial models of the microscope point spread function (PSF).

Project description

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 --recurse-submodules https://github.com/tlambert03/PSFmodels-py.git
cd PSFmodels-py
python setup.py install
# or python setup.py build to just build but not 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.

Lightsheet PSF utility function

The psfmodels.tot_psf() function provides a quick way to simulate the total system PSF (excitation x detection) as might be observed on a light sheet microscope (currently, only strictly orthogonal illumination and detection are supported). See the lightsheet.ipynb Jupyter notebook for examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psfmodels-0.2.0.tar.gz (164.3 kB view details)

Uploaded Source

Built Distributions

psfmodels-0.2.0-cp37-cp37m-win_amd64.whl (84.4 kB view details)

Uploaded CPython 3.7m Windows x86-64

psfmodels-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (86.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

psfmodels-0.2.0-cp36-cp36m-win_amd64.whl (84.4 kB view details)

Uploaded CPython 3.6m Windows x86-64

psfmodels-0.2.0-cp36-cp36m-macosx_10_7_x86_64.whl (86.4 kB view details)

Uploaded CPython 3.6m macOS 10.7+ x86-64

psfmodels-0.2.0-cp35-cp35m-win_amd64.whl (84.4 kB view details)

Uploaded CPython 3.5m Windows x86-64

psfmodels-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl (86.4 kB view details)

Uploaded CPython 3.5m macOS 10.9+ x86-64

psfmodels-0.2.0-cp27-cp27m-macosx_10_6_x86_64.whl (86.6 kB view details)

Uploaded CPython 2.7m macOS 10.6+ x86-64

File details

Details for the file psfmodels-0.2.0.tar.gz.

File metadata

  • Download URL: psfmodels-0.2.0.tar.gz
  • Upload date:
  • Size: 164.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9482ae47ef37e7d1305376885458becfa8536bd15d69de157930325a2b412885
MD5 3ebc26adba2481edc55d6a1e024d113b
BLAKE2b-256 d83b0c82b3e25c27453ef453c476fd90cc1a6d2526a7e4f6c368563c06d0fc28

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 84.4 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 c2cc28b9eaacf02b2290a76eb9a4c218925510c2f41b7459f145b4193e2f78e1
MD5 8aee12ba9f9a4aa74f64b08cab70f913
BLAKE2b-256 83bf6044f4385d99444c710981dac3967e3e5dcdda180562a174f3d228153f6b

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 86.3 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e97d96224057d2c6a7265471ef140a388fb7c8d70b57b2114db73c27c2dfb3fe
MD5 bb147cbc78e726fa2d784d7567ccdfd2
BLAKE2b-256 6d9473cda46babaa47af15ed8bdf1046ab60258f810b65c8c4782206ac9f3552

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 84.4 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 ae0159178cf11f7f167f7ba1c5241edbf2067f4230f1f105763bb5893f310d9f
MD5 26ec8d9c19bb6f818ab23938ed9294e7
BLAKE2b-256 e3c5e01563e019644568c9f991bbc65625496a3080fffeb941aad67159bcd4b8

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp36-cp36m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp36-cp36m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 86.4 kB
  • Tags: CPython 3.6m, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 979c5405de2cf7c89f76f736386cf432d3ac380bc4fc11b321a59355aa65a59f
MD5 93325b215be1d9f8a8cb1d2e912cb48c
BLAKE2b-256 792fe0f00a3ad5fcb1b38388bff392908333a86a8747eec465e7e3b486e06158

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 84.4 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 282b27e24dc975fe29766f159fee8a0c55536ed48043c9ee7d87acc19dcffee3
MD5 418dc3d9132e3313643ef27ff2d79d53
BLAKE2b-256 2718c4356fe60c33ed3dc8bb877d4af2ece08b506b35c973258c62131803c29f

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 86.4 kB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5a024e2b124d783efe3434e751e7bcccd2394eb6f472cd6cb2bc4f2cec927b23
MD5 61b13077367112e0e4a814524621df9d
BLAKE2b-256 a246febbdcb9bfa7e5ce054129dbb66d95c5c9e19c08319dcf66615ef74486c0

See more details on using hashes here.

File details

Details for the file psfmodels-0.2.0-cp27-cp27m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: psfmodels-0.2.0-cp27-cp27m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 2.7m, macOS 10.6+ x86-64
  • Uploaded using 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

File hashes

Hashes for psfmodels-0.2.0-cp27-cp27m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 c2281c2b8ceaf385585967017ca2542b69bdf284589e5987ece9fabbf179a4c6
MD5 ac8ac6d60757bc22a33be01152813420
BLAKE2b-256 1abff847aa12cf844ded03a51e9b8aa43cb2240739f251a0ebd3fb5d96beb13f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page