PtyLab.py: Unified Ptychography Toolbox
Key Features | Getting Started | Installation | 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, 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
For faster installs, we recommend uv: uv pip install ptylab
To utilize GPU for faster reconstruction, enable GPU support:
uv pip install "ptylab[gpu]" # supports CUDA 12
Check whether GPU is correctly configured with uv run ptylab check gpu. For additional information, check the installation guide.
Development
For the development setup, running the tests and building the documentation locally, see the development guide in the documentation.
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},
}
Metadata
Release files for ptylab 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ptylab-0.3.4.tar.gz | 150.6 kB | With provenance | Details for ptylab-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ptylab-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for ptylab-0.3.4-py3-none-any.whl |
Total release size: 322.7 kB
Release files / ptylab-0.3.4.tar.gz
| Download URL | ptylab-0.3.4.tar.gz |
|---|---|
| Size | 150.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65778aa7900f71e3b4afbb4b01f91aec8e5a9838809875eb911355ad3cb56c01
|
|
BLAKE2b-256 checksum How to use checksums |
c7ae103ebb9d12ffc07e2e90141227f055c87c61cbcff39c006fbe178bd32a1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / ptylab-0.3.4-py3-none-any.whl
| Download URL | ptylab-0.3.4-py3-none-any.whl |
|---|---|
| Size | 172.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
04d64a2ff2cca16ee28e2986c33a2b62ef432909e39c291921b960bea1fb0fc3
|
|
BLAKE2b-256 checksum How to use checksums |
39ffaa1b890339461011b2c87155b442cf5b6e178c0b3b80f0a894a6dcfac28c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logSecurity for ptylab 0.3.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for ptylab-0.3.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.