A cross-platform, open-source inverse modeling toolbox for conventional and Fourier ptychography
Project description
PtyLab.py: Unified Ptychography Toolbox
Getting Started | Installation | Development | Documentation
PtyLab is an inverse modeling toolbox for Conventional (CP) and Fourier (FP) ptychography in a unified framework. For more information please check the paper.
Key Features
- Classic engines: ePIE, mPIE, mqNewton, qNewton
- Advanced corrections: position correction (pcPIE), defocus correction (zPIE), angle correction (aPIE), orthogonal probe relaxation (OPR)
- Multi-modal: multi-slice, multi-wavelength, mixed-state object and probe
- Multiple propagators: Fraunhofer, Fresnel, Angular Spectrum (ASP), scaled ASP, polychromatic variants
- GPU acceleration: same code runs on CPU and GPU
The reconstructed output is a 6D array of shape (nlambda, nosm, npsm, nslice, No, No):
| Dim | Meaning |
|---|---|
nlambda |
wavelengths |
nosm |
object state mixture |
npsm |
probe state mixture |
nslice |
depth slices |
No |
output frame size |
Getting started
Try the demo in Google Colab:
For more use cases, start with the tutorials in our documentation, then see the example_scripts directory.
Installation
Install from PyPI within your virtual environment:
pip install ptylab
[!NOTE]
For much faster installs, we recommend uv:uv pip install ptylab
This package uses cupy to utilize GPU for faster reconstruction. To enable GPU support:
pip install "ptylab[gpu]"
For the latest unreleased changes on main:
pip install git+https://github.com/PtyLab/PtyLab.py.git
Check GPU detection:
ptylab check gpu
Development
Clone the repo and install dev dependencies with uv:
git clone git@github.com:PtyLab/PtyLab.py.git
cd PtyLab.py
uv sync --extra dev
This creates a .venv virtual environment in the project root. Select this environment from your IDE.
To use the GPU as well, install with the gpu flag:
uv sync --extra dev,gpu
and check if GPU is detected with uv run ptylab check gpu.
Add tests for new behaviour and run the suite:
uv run pytest tests
CI runs this on every PR. Please bump the package version when modifying dependencies.
Releases are published to PyPI automatically: bump version in pyproject.toml, then publish a GitHub Release tagged v<version>.
Citation
If you use this package, please cite:
@article{Loetgering:23,
author = {Lars Loetgering and Mengqi Du and Dirk Boonzajer Flaes and Tomas Aidukas and Felix Wechsler and Daniel S. Penagos Molina and Max Rose and Antonios Pelekanidis and Wilhelm Eschen and J\"{u}rgen Hess and Thomas Wilhein and Rainer Heintzmann and Jan Rothhardt and Stefan Witte},
journal = {Opt. Express},
number = {9},
pages = {13763--13797},
publisher = {Optica Publishing Group},
title = {PtyLab.m/py/jl: a cross-platform, open-source inverse modeling toolbox for conventional and Fourier ptychography},
volume = {31},
month = {Apr},
year = {2023},
doi = {10.1364/OE.485370},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ptylab-0.2.5.tar.gz.
File metadata
- Download URL: ptylab-0.2.5.tar.gz
- Upload date:
- Size: 92.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
409924ac6758254e2ef56fdf4bd1f12ad3b9fdabce6e96deae95723a45c4c34c
|
|
| MD5 |
09a9269cf2376ed8a833aea6eb3fd28d
|
|
| BLAKE2b-256 |
efc5858a0c5a417ca5f0121470f23d87011fbd6a1f2fa848960650ba57f797ea
|
Provenance
The following attestation bundles were made for ptylab-0.2.5.tar.gz:
Publisher:
publish.yml on PtyLab/PtyLab.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ptylab-0.2.5.tar.gz -
Subject digest:
409924ac6758254e2ef56fdf4bd1f12ad3b9fdabce6e96deae95723a45c4c34c - Sigstore transparency entry: 2280726347
- Sigstore integration time:
-
Permalink:
PtyLab/PtyLab.py@83656f22d0eba74efd2e24b0ec913e062c2cb33a -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/PtyLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@83656f22d0eba74efd2e24b0ec913e062c2cb33a -
Trigger Event:
release
-
Statement type:
File details
Details for the file ptylab-0.2.5-py3-none-any.whl.
File metadata
- Download URL: ptylab-0.2.5-py3-none-any.whl
- Upload date:
- Size: 122.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c603e3525b511742506b2d7b2e2defa1d2615d06613bb767881af102c568e489
|
|
| MD5 |
2d2b59336f0f4bf833e41dfcd1fd7053
|
|
| BLAKE2b-256 |
82fd82224580ead864870f87a9d63049879cc10be3ef836efbad2ed4b9e0bdcd
|
Provenance
The following attestation bundles were made for ptylab-0.2.5-py3-none-any.whl:
Publisher:
publish.yml on PtyLab/PtyLab.py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ptylab-0.2.5-py3-none-any.whl -
Subject digest:
c603e3525b511742506b2d7b2e2defa1d2615d06613bb767881af102c568e489 - Sigstore transparency entry: 2280726372
- Sigstore integration time:
-
Permalink:
PtyLab/PtyLab.py@83656f22d0eba74efd2e24b0ec913e062c2cb33a -
Branch / Tag:
refs/tags/v0.2.5 - Owner: https://github.com/PtyLab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@83656f22d0eba74efd2e24b0ec913e062c2cb33a -
Trigger Event:
release
-
Statement type: