Skip to main content

PtyLab.py: Unified Ptychography Toolbox

Python 3.10+ PyPI Tests

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:

Open In Colab demo

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 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]"

You can check if GPU is detected with ptylab check gpu.

For the latest unreleased changes on main:

pip install git+https://github.com/PtyLab/PtyLab.py.git

Development

Clone the repo and install dev and gpu dependencies with uv:

git clone git@github.com:PtyLab/PtyLab.py.git
cd PtyLab.py
uv sync --extra dev,gpu # remove the GPU flag if you are on CPU

This creates a .venv virtual environment in the project root. Select this environment from your IDE.

Add tests for new implementations and run the suite:

uv run pytest tests

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},
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ptylab-0.3.1.tar.gz (96.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ptylab-0.3.1-py3-none-any.whl (126.4 kB view details)

Uploaded Python 3

File details

Details for the file ptylab-0.3.1.tar.gz.

File metadata

  • Download URL: ptylab-0.3.1.tar.gz
  • Upload date:
  • Size: 96.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ptylab-0.3.1.tar.gz
Algorithm Hash digest
SHA256 9b8ef7511a076fc2c5c0fc71e9a3fb61fd328b3de324ab22ed5684c09e2384a2
MD5 4d71ef31d22fc2056bed6021abd08071
BLAKE2b-256 005a554e76d29405c7ba1ce31e0fe019f6542dffa7870d5d59511ac8c38be280

See more details on using hashes here.

Provenance

The following attestation bundles were made for ptylab-0.3.1.tar.gz:

Publisher: publish.yml on PtyLab/PtyLab.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ptylab-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: ptylab-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 126.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ptylab-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c99d29f631bb9747ca70348162a1d946dc733a34d2b58e6dc1e3573a715c63c7
MD5 616713aadb3828d61ad3800ba469c7aa
BLAKE2b-256 534a391b7236484b8e0e9f0c218cf78c1c9db10f78d9367f1d3b4e23ad4b855f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ptylab-0.3.1-py3-none-any.whl:

Publisher: publish.yml on PtyLab/PtyLab.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 files

0.3.0

2 files

0.2.8

2 files

0.2.7

2 files

0.2.6

2 files

0.2.5

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page