{"name":"psfmodels","display_name":"psfmodels","visibility":"public","icon":"","categories":[],"schema_version":"0.2.0","on_activate":null,"on_deactivate":null,"contributions":{"commands":[{"id":"psfmodels.make_psf","title":"Generate 3D Point Spread Function","python_name":"psfmodels._napari:make_psf","short_title":null,"category":null,"icon":null,"enablement":null}],"readers":null,"writers":null,"widgets":[{"command":"psfmodels.make_psf","display_name":"PSF Generator","autogenerate":true}],"sample_data":null,"themes":null,"menus":{},"submenus":null,"keybindings":null,"configuration":[]},"package_metadata":{"metadata_version":"2.1","name":"psfmodels","version":"0.3.3","dynamic":null,"platform":null,"supported_platform":null,"summary":"Scalar and vectorial models of the microscope point spread function (PSF).","description":"# psfmodels\n\n[![PyPI](https://img.shields.io/pypi/v/psfmodels.svg?color=green)](https://pypi.org/project/psfmodels)\n[![Python\nVersion](https://img.shields.io/pypi/pyversions/psfmodels.svg?color=green)](https://python.org)\n[![CI](https://github.com/tlambert03/psfmodels/actions/workflows/ci.yml/badge.svg)](https://github.com/tlambert03/psfmodels/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/tlambert03/psfmodels/branch/main/graph/badge.svg)](https://codecov.io/gh/tlambert03/psfmodels)\n\nPython bindings for scalar and vectorial models of the point spread function.\n\nOriginal C++ code and MATLAB MEX bindings Copyright © 2006-2013, [Francois\nAguet](http://www.francoisaguet.net/software.html), distributed under GPL-3.0\nlicense. Python bindings by Talley Lambert\n\nThis package contains three models:\n\n1. The vectorial model is described in Auget et al 20091. For more\ninformation and implementation details, see Francois' Thesis2.\n2. A scalar model, based on Gibson & Lanni3.\n3. A gaussian approximation (both paraxial and non-paraxial), using paramters from Zhang et al (2007)4.\n\n\n\n1 [F. Aguet et al., (2009) Opt. Express 17(8), pp.\n6829-6848](https://doi.org/10.1364/OE.17.006829)\n\n2 [F. Aguet. (2009) Super-Resolution Fluorescence Microscopy Based on\nPhysical Models. Swiss Federal Institute of Technology Lausanne, EPFL Thesis no.\n4418](http://bigwww.epfl.ch/publications/aguet0903.html)\n\n3 [F. Gibson and F. Lanni (1992) J. Opt. Soc. Am. A, vol. 9, no. 1, pp. 154-166](https://opg.optica.org/josaa/abstract.cfm?uri=josaa-9-1-154)\n\n4 [Zhang et al (2007). Appl Opt\n. 2007 Apr 1;46(10):1819-29.](https://doi.org/10.1364/AO.46.001819)\n\n\n\n### see also:\n\nFor a different (faster) scalar-based Gibson–Lanni PSF model, see the\n[MicroscPSF](https://github.com/MicroscPSF) project, based on [Li et al\n(2017)](https://doi.org/10.1364/JOSAA.34.001029) which has been implemented in\n[Python](https://github.com/MicroscPSF/MicroscPSF-Py),\n[MATLAB](https://github.com/MicroscPSF/MicroscPSF-Matlab), and\n[ImageJ/Java](https://github.com/MicroscPSF/MicroscPSF-ImageJ)\n\n## Install\n\n```sh\npip install psfmodels\n```\n\n### from source\n\n```sh\ngit clone https://github.com/tlambert03/PSFmodels.git\ncd PSFmodels\npip install -e \".[dev]\" # will compile c code via pybind11\n```\n\n## Usage\n\nThere are two main functions in `psfmodels`: `vectorial_psf` and `scalar_psf`.\nAdditionally, each version has a helper function called `vectorial_psf_centered`\nand `scalar_psf_centered` respectively. The main difference is that the `_psf`\nfunctions accept a vector of Z positions `zv` (relative to coverslip) at which\nPSF is calculated. As such, the point source may or may not actually be in the\ncenter of the rendered volume. The `_psf_centered` variants, by contrast, do\n_not_ accecpt `zv`, but rather accept `nz` (the number of z planes) and `dz`\n(the z step size in microns), and always generates an output volume in which the\npoint source is positioned in the middle of the Z range, with planes equidistant\nfrom each other. All functions accept an argument `pz`, specifying the position\nof the point source relative to the coverslip. See additional keyword arguments\nbelow\n\n_Note, all output dimensions (`nx` and `nz`) should be odd._\n\n```python\nimport psfmodels as psfm\nimport matplotlib.pyplot as plt\nfrom matplotlib.colors import PowerNorm\n\n# generate centered psf with a point source at `pz` microns from coverslip\n# shape will be (127, 127, 127)\npsf = psfm.make_psf(127, 127, dxy=0.05, dz=0.05, pz=0)\nfig, (ax1, ax2) = plt.subplots(1, 2)\nax1.imshow(psf[nz//2], norm=PowerNorm(gamma=0.4))\nax2.imshow(psf[:, nx//2], norm=PowerNorm(gamma=0.4))\nplt.show()\n```\n\n![Image of PSF](fig.png)\n\n```python\n# instead of nz and dz, you can directly specify a vector of z positions\nimport numpy as np\n\n# generate 31 evenly spaced Z positions from -3 to 3 microns\npsf = psfm.make_psf(np.linspace(-3, 3, 31), nx=127)\npsf.shape # (31, 127, 127)\n```\n\n**all** PSF functions accept the following parameters. Units should be provided\nin microns unless otherwise stated. Python API may change slightly in the\nfuture. See function docstrings as well.\n\n```\nnx (int): XY size of output PSF in pixels, must be odd.\ndxy (float): pixel size in sample space (microns) [default: 0.05]\npz (float): depth of point source relative to coverslip (in microns) [default: 0]\nti0 (float): working distance of the objective (microns) [default: 150.0]\nni0 (float): immersion medium refractive index, design value [default: 1.515]\nni (float): immersion medium refractive index, experimental value [default: 1.515]\ntg0 (float): coverslip thickness, design value (microns) [default: 170.0]\ntg (float): coverslip thickness, experimental value (microns) [default: 170.0]\nng0 (float): coverslip refractive index, design value [default: 1.515]\nng (float): coverslip refractive index, experimental value [default: 1.515]\nns (float): sample refractive index [default: 1.47]\nwvl (float): emission wavelength (microns) [default: 0.6]\nNA (float): numerical aperture [default: 1.4]\n```\n\n## Comparison with other models\n\nWhile these models are definitely slower than the one implemented in [Li et al\n(2017)](https://doi.org/10.1364/JOSAA.34.001029) and\n[MicroscPSF](https://github.com/MicroscPSF), there are some interesting\ndifferences between the scalar and vectorial approximations, particularly with\nhigher NA lenses, non-ideal sample refractive index, and increasing spherical\naberration with depth from the coverslip.\n\nFor an interactive comparison, see the [examples.ipynb](notebooks/examples.ipynb) Jupyter\nnotebook.\n\n## Lightsheet PSF utility function\n\nThe `psfmodels.tot_psf()` function provides a quick way to simulate the total\nsystem PSF (excitation x detection) as might be observed on a light sheet\nmicroscope (currently, only strictly orthogonal illumination and detection are\nsupported). See the [lightsheet.ipynb](notebooks/lightsheet.ipynb) Jupyter notebook for\nexamples.\n","description_content_type":"text/markdown","keywords":null,"home_page":"https://github.com/tlambert03/psfmodels","download_url":null,"author":"Talley Lambert","author_email":"talley.lambert@gmail.com","maintainer":null,"maintainer_email":null,"license":"GPL-3.0","classifier":["Development Status :: 3 - Alpha","Framework :: napari","License :: OSI Approved :: GNU General Public License v3 (GPLv3)","Natural Language :: English","Programming Language :: Python :: 3","Programming Language :: Python :: 3 :: Only","Programming Language :: Python :: 3.7","Programming Language :: Python :: 3.8","Programming Language :: Python :: 3.9","Programming Language :: Python :: 3.10"],"requires_dist":["numpy","scipy (>=0.14.0)","typing-extensions","black ; extra == 'dev'","flake8 ; extra == 'dev'","flake8-docstrings ; extra == 'dev'","flake8-typing-imports ; extra == 'dev'","ipython ; extra == 'dev'","isort ; extra == 'dev'","mypy ; extra == 'dev'","pre-commit ; extra == 'dev'","pydocstyle ; extra == 'dev'","pytest ; extra == 'dev'","pytest-cov ; extra == 'dev'","tox ; extra == 'dev'","tox-conda ; extra == 'dev'","pytest ; extra == 'testing'","pytest-cov ; extra == 'testing'","jax ; extra == 'testing'","magicgui ; (platform_system != \"Linux\") and extra == 'testing'","qtpy ; (platform_system != \"Linux\") and extra == 'testing'","pyside2 ; (platform_system != \"Linux\" and python_version < \"3.11\") and extra == 'testing'"],"requires_python":">=3.7","requires_external":null,"project_url":["Source Code, https://github.com/tlambert03/psfmodels"],"provides_extra":["dev","testing"],"provides_dist":null,"obsoletes_dist":null},"npe1_shim":false}