Skip to main content

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

Project description

psfmodels

PyPI Python Version CI codecov

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

This package contains three models:

  1. The vectorial model is described in Auget et al 20091. For more information and implementation details, see Francois' Thesis2.
  2. A scalar model, based on Gibson & Lanni3.
  3. A gaussian approximation (both paraxial and non-paraxial), using paramters from Zhang et al (2007)4.

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

3 F. Gibson and F. Lanni (1992) J. Opt. Soc. Am. A, vol. 9, no. 1, pp. 154-166

4 Zhang et al (2007). Appl Opt . 2007 Apr 1;46(10):1819-29.

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

pip install psfmodels

from source

git clone https://github.com/tlambert03/PSFmodels.git
cd PSFmodels
pip install -e ".[dev]"  # will compile c code via pybind11

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` microns from coverslip
# shape will be (127, 127, 127)
psf = psfm.make_psf(127, 127, dxy=0.05, dz=0.05, 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
psf = psfm.make_psf(np.linspace(-3, 3, 31), nx=127)
psf.shape  # (31, 127, 127)

all PSF functions accept the following parameters. Units should be provided in microns unless otherwise stated. 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: 150.0]
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.0]
tg (float):     coverslip thickness, experimental value (microns) [default: 170.0]
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]

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.3.2.tar.gz (577.5 kB view details)

Uploaded Source

Built Distributions

psfmodels-0.3.2-cp310-cp310-win_amd64.whl (108.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

psfmodels-0.3.2-cp310-cp310-musllinux_1_1_x86_64.whl (667.3 kB view details)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

psfmodels-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152.3 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

psfmodels-0.3.2-cp310-cp310-macosx_11_0_arm64.whl (103.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

psfmodels-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl (112.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

psfmodels-0.3.2-cp39-cp39-win_amd64.whl (108.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

psfmodels-0.3.2-cp39-cp39-musllinux_1_1_x86_64.whl (668.3 kB view details)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

psfmodels-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152.5 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

psfmodels-0.3.2-cp39-cp39-macosx_11_0_arm64.whl (103.8 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

psfmodels-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl (112.8 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

psfmodels-0.3.2-cp38-cp38-win_amd64.whl (108.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

psfmodels-0.3.2-cp38-cp38-musllinux_1_1_x86_64.whl (667.2 kB view details)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

psfmodels-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152.2 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

psfmodels-0.3.2-cp38-cp38-macosx_11_0_arm64.whl (103.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

psfmodels-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl (112.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

psfmodels-0.3.2-cp37-cp37m-win_amd64.whl (109.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

psfmodels-0.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl (669.1 kB view details)

Uploaded CPython 3.7m musllinux: musl 1.1+ x86-64

psfmodels-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (152.6 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

psfmodels-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl (112.1 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: psfmodels-0.3.2.tar.gz
  • Upload date:
  • Size: 577.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for psfmodels-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ca5adb4f6c015c71822fac23e7b9a8bdf25104df31c194a58bbdcf00df6d89f7
MD5 dfdad8531714d5c6f2a323f9d23e4a1f
BLAKE2b-256 a11c8e81e4a494673bc6a8cbbcad46e0f47a32ab498fb5a96cecc51c289c351a

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cb30fd39fbae56f8e1dad9607ab7b1c739013ae3175e76f7a1e1c9c22e5d7016
MD5 e8634d7aa681ea00b23cf8d6bbe44d5c
BLAKE2b-256 0d640a6b6c0b6c449063559214fd017c8990cea8e006f5bd60ac18cd28b158e4

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp310-cp310-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 eb35a690ecdde7c8a1e1a156de2360099e8c813a8a7d24f438bd23aa1096497b
MD5 120d3c5990212d1427bdde78c98ad63c
BLAKE2b-256 a897fbf3047832203df8d7aad3576acda3edbebabc162d0bffe5c75b10ac491a

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9245668a217a11a1b4f63d50a5a5e62d1fe375a9fa327c21bde4b122ca4367f0
MD5 c5ac0ee899f64a026af356b14409b600
BLAKE2b-256 9d71dc352d7238dab91a4f7b81e671fa1d51938173274bc6320b65f4eb0ec8c4

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2ad376719f990a3e2deebac6d94bfd6272aec47d57dfeeb915931d91c17c805d
MD5 5547b27f37366d02ac55e006f2af3449
BLAKE2b-256 38fbedf4db4aba169372d1304e71e9ff8ff530bfabdf5fc98de5ce816adc3a8c

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c39ea7d5324dc61938a3113cebc1b8e9b9ab3e666bf6fe5d0fed785f9f8a3324
MD5 77c3ce7a9579dffbf53465eaff72f159
BLAKE2b-256 e6951514bdc3a7a668b7be28cb9599f877fe03c8006754202a04157a0ec049d3

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: psfmodels-0.3.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 108.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for psfmodels-0.3.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 09aab52fed4de659e69026b543e9cba8a0e2a10d3730c770064a75c06be40355
MD5 7e070b1c2de31865107e112f1b719d2c
BLAKE2b-256 aa29539ed176436612cf672f621f1c04192114cb14789d618a307ac657b59ab4

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp39-cp39-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 41237dc44e8197ed00021dde9627ceb16739ac656b96c5b18b5bbf028a438547
MD5 db7ab6f3c1b0114d7e63a534b63bc261
BLAKE2b-256 7db32c1549ca9048202ce4d3cbc362cca8768077fb91626a58ea3f2b4c31d2b7

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 778654a69e5c2b605856766c8b4360aa2f7af680a04b753ca19e15f761ecd920
MD5 1471263bc68f2df3a6047b03804b15af
BLAKE2b-256 da10ce763d5a1b7cb8de0bc17e769748b32203964a3bce7e4f0a9d2e8d0f358b

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5faeee2fc093f9a108b7a35a075f417bd7d693d94fcd1aba67c234b9ff63b720
MD5 3540b023401181e7b59f0f7beef8260b
BLAKE2b-256 5cb3f4607b939735430da21e207c194770b264105929e4d07792a264773bdca7

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 184da7aee0f0ae8a4dddc61e3ecb512985a02a82055935e4f1a2addc5337129b
MD5 beb72827f1947d0b4cf1f832b9e40784
BLAKE2b-256 ff3ef7210604ad829992568f207ef5186c6b7031ac4806747fbd11e035bd8c9e

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: psfmodels-0.3.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 108.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for psfmodels-0.3.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 819ec445fa29694c4ec75d22d8b753370041043bc68c8dc5ec351f9fc988e7b7
MD5 baec8f826423e8bd23e8f116f12c7802
BLAKE2b-256 21826f28ec261ea55dba2f9fff4cf0d9ba3554aafcdee135ba31ee22ac21dbf2

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp38-cp38-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 7d88cce1288d749662bc52e70f1428bea106f33d2629355c9b5a03349e580b17
MD5 d89b6953a709f196e19830e3bb016021
BLAKE2b-256 81932168af65b8da1b63175f77ddf41f05735f4351c9255cb6168910a3b5fb4f

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 af32f1a5fc0aed2b29b735bdb4458ff3ae958ac072285b8e6e5c0e357bec3f2c
MD5 46867d89491940d5234de08259f48263
BLAKE2b-256 8965aea7c6bb1100809d35358e52f0ec3ba7eaa099af05bcdea1d6d1d24c86ae

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a60faf1055e72c123eb7fe26173276d45b7aa60e28ea96652170edc1bad4c12
MD5 e2bdf42de0b80537b00a471122dc5524
BLAKE2b-256 70f71c1f9a356d5708c122e7f182f8b3316a133c054826ed8e45b83f79305d09

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c025907e9d888a49761c3328b0c36e57c2484525c92514f9df73753af1f1ef5
MD5 9dc20b5d49e34c0beae48b830c120e55
BLAKE2b-256 3cd0c2f3ccaf48f2525bd26f24c2ab33aaa7ffd9f966a4b625ff94d673e427ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: psfmodels-0.3.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 109.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for psfmodels-0.3.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 aefc0323fd284eb3ff3de17c33f740301fffb28ad7a9102a356c3546bba1ab24
MD5 d7b09b6b1bc444dc45b75821a989d7da
BLAKE2b-256 61dab6de94bb038cad5d2639ef2717026427c9892fd97e851a1ff8be32c11169

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm Hash digest
SHA256 9cf708a2c2a922a87d90f8f3535e3b81e7444f83f4e9650eb91ed9da3516ba7e
MD5 94bdb2b026ef4a0dfd332e9932bd9b98
BLAKE2b-256 a0a3f80a5bdc1b84e195fada65e9d3517e3bff260c3dce83c2942e923a6e7f4f

See more details on using hashes here.

File details

Details for the file psfmodels-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 51a516edbfaf1754e7b3c01da83e3d801412523175133fa8556cf709b052b5c9
MD5 a691a18cd26ef8aa89a3557383933c9b
BLAKE2b-256 02b32c3e016f2a07e2ec350c4ba84a7570edbe2dbca0a7b70f4c707bf789db4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for psfmodels-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 52f79b3591886b2f77a0c6f79e7bcd64c809859e26686c575b4943603c44ccc9
MD5 9aa105d188cbd2cf17c48c2feab1cb12
BLAKE2b-256 dee0be9385b197b87d39a3eb58d0c94da748d25a362404a1c28d09bc7f5f472a

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