fpm-rs¶
fpm-rs is a CPU library for reconstructing and simulating image-plane
Fourier ptychographic microscopy (FPM) acquisitions. It combines a Rust core
for physical modelling and iterative algorithms with a typed Python interface
for NumPy-based scientific workflows.
Use it to compile illumination geometry into a Fourier-space model, simulate detector measurements, reconstruct a complex object with AP, FPIE, EPRY, ADMM, or gradient descent, and record diagnostics or checkpoints. It is intended for microscopy researchers, algorithm developers, and applications that need a reusable FPM core. Diffraction-plane ptychography, multislice propagation, and GPU execution are outside the current scope.
Install from PyPI¶
With Python 3.12 or newer:
For notebook and plotting support, install "fpm-rs[notebook]". See
Installation for supported platforms, source
builds, Pixi setup, and troubleshooting.
Minimal example¶
import numpy as np
import fpm_rs as fpm
optics = fpm.Optics(532e-9, 0.10, 4.0, 6.5e-6)
leds = fpm.LEDArray((3, 3), 4e-3, 90e-3, (1.0, 1.0))
model = fpm.compile_model(optics, leds, (32, 32))
simulation = fpm.simulate(
model,
np.ones(model.reconstruction_shape, dtype=np.complex128),
seed=1234,
)
problem = fpm.ReconstructionProblem(
simulation.measurements,
simulation.reconstruction_model,
)
result = fpm.AlternatingProjection(iterations=10).run(problem)
print(result.amplitude.shape) # (42, 42)
Continue through the Quickstart, run the first reconstruction tutorial, or go straight to the Python API.
Library components¶
experimentdescribes optics and planar, spherical, angular, and calibrated illumination sources.modelcompiles sampling, pupil, Fourier crops, and the shared forward model.measurementsprovides resident and lazy intensity stacks plus preprocessing.algorithmsimplements AP, FPIE, EPRY, linearized ADMM, and gradient descent.reconstructionprovides problems, state, results, schedules, batches, and runner orchestration.callbacksrecords images, CSV history, checkpoints, progress, and early stopping.simulationsupplies synthetic objects, acquisition effects, camera response, and ground-truth metrics.datasetsvalidates local bundles, discovers and downloads registered bundles, manages cache, and selects deterministic subsets.backendprovides the CPU backend and future resident-buffer boundary.benchmarkruns single cases and writes versioned benchmark records and artifacts.
Documentation map¶
- Tutorials provide executable, public-API workflows.
- Guides answer task-oriented questions.
- Concepts and conventions explain the physical and computational model.
- Python API is generated from the typed package surface and docstrings.
- Rust API links to native rustdoc for lower-level use.
- Contributor guide covers builds, tests, notebooks, and documentation.
- Datasets documents the generic converted-bundle workflow.
- Project information covers citation, licensing, and the roadmap.