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
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()
# 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.
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
Built Distributions
File details
Details for the file psfmodels-0.1.0.tar.gz
.
File metadata
- Download URL: psfmodels-0.1.0.tar.gz
- Upload date:
- Size: 163.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2786b5218978317f73001ea987d2d3ff398115a402426ef4a1c1d41c3d9e870 |
|
MD5 | fcac082be7ba9f47c64686471fdd5cfc |
|
BLAKE2b-256 | 143ba4a64c858fec5c32036caf469dbdc884fe35381a14f757ae53a7e976a019 |
File details
Details for the file psfmodels-0.1.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 83.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8c31082c685e53caea0dc9d8f1190c5b4a735c0879f7199a32c8e805cf063c4 |
|
MD5 | 31119a47389035985dc220285a1baa2b |
|
BLAKE2b-256 | 1b3b1fef0cceff331bea1bd4f25b6751c1821006857dc71beba58de0aa64004f |
File details
Details for the file psfmodels-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp37-cp37m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 85.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48507079967b3251d6cca36868210448d3073fe6ea906dabb66fa94f168482dd |
|
MD5 | 1621cbe837e0c0b1537d1c2319c93f75 |
|
BLAKE2b-256 | 0ea046df88ef4835450e075805256b691f3b7d106eca187c756f452aa016f492 |
File details
Details for the file psfmodels-0.1.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 83.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfb4250316206993db10b40b65672b900c344dd437a0e64e704a2046a85e9add |
|
MD5 | ddb031d7a1c08a23ec2dd52c458427eb |
|
BLAKE2b-256 | 89db35a317d499a97f73e367ba388226c2d4919eaeecdfd4da12d5f7182d336c |
File details
Details for the file psfmodels-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp36-cp36m-macosx_10_7_x86_64.whl
- Upload date:
- Size: 85.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2f50e899c6e4aec252d6f457f98d947f3ad514a39e4e76ad2f0008b7ff918c0 |
|
MD5 | 895b45d209d41149e5848a965a188acf |
|
BLAKE2b-256 | 79664232f69ea7d18566f70e64b2ba85dbfb9d60cfb39137ad5332c5fc3351b3 |
File details
Details for the file psfmodels-0.1.0-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 83.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbbf7207dd2d88ba7605982038d04c447874ef51e10737b20b373067dc0cd8d2 |
|
MD5 | 22f623ea147c09e84b310e903338e255 |
|
BLAKE2b-256 | e0ede4cfcfd550a897824ed9254626a2e8474fa0857a6a810ab4ac4750965196 |
File details
Details for the file psfmodels-0.1.0-cp35-cp35m-macosx_10_9_x86_64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp35-cp35m-macosx_10_9_x86_64.whl
- Upload date:
- Size: 85.1 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 658aa3f20c2fb2d1814b7274643a86f0e0cf63c6c009f21dfdbfd8528c7178db |
|
MD5 | 9ffd2364b9e5a84c16016f716756faa3 |
|
BLAKE2b-256 | 4c99202d1e39b764b7c691cf1793a13b30d8ec1ecc91522795abd04856309cfc |
File details
Details for the file psfmodels-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
.
File metadata
- Download URL: psfmodels-0.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
- Upload date:
- Size: 85.3 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcece92e3dabde90b3abae0e7529e44ca3ec7d1cbbc1b67968bef9408ec288a3 |
|
MD5 | 9a46a21bbf2aafc763d5c35aa92ed954 |
|
BLAKE2b-256 | 386c57f49efae391630cb9b9a1a1d2d3c1f919c3f6f1316e77b1c9c8d39d4d9e |