Parallax-based UDFs for LiberTEM
Project description
libertem-parallax
Streaming parallax imaging UDFs for 4D-STEM, built on top of LiberTEM.
This package provides two streaming-capable user-defined functions (UDFs) for parallax imaging. While applicable to offline analysis, the UDFs are primarily designed for live processing during acquisition using LiberTEM-live.
Installation
The package is available on the Python Package Index (PyPI) as
libertem-parallax.
Install using pip:
pip install libertem-parallax
For a developer installation, please refer to CONTRIBUTORS.md.
Usage example
The UDFs are not meant to be instantiated directly via ParallaxUDF(...).
Instead, use the provided classmethod constructor to specify the acquisition and reconstruction parameters:
import libertem.api
import libertem_parallax as prlx
import numpy as np
ctx = libertem.api.Context()
# dataset available at https://doi.org/10.5281/zenodo.18346853
ds = ctx.load("auto", path="../data/apoF_4mrad_1.5um-df_3A-step_30eA2_binary_uint8.npy")
udf = prlx.ParallaxUDF.from_parameters(
shape=ds.shape,
scan_sampling=(256/72,256/72),
angular_sampling=(0.307617,0.307617),
energy=300e3,
semiangle_cutoff=4.0,
aberration_coefs={"C10":-1.5e4},
rotation_angle=np.deg2rad(-15),
upsampling_factor=2,
)
udf_flip = prlx.ParallaxPhaseFlipUDF.from_parallax_udf(
udf
)
result, result_flip = ctx.run_udf(
dataset=ds, udf=[udf, udf_flip],
progress=True, plots=True
)
Parallax imaging background
Parallax imaging^1, also known as tilt-corrected bright-field (tcBF) STEM^2, is a STEM phase contrast technique which can be understood as a quadratic approximation^3 to direct ptychography techniques such as phase-compensated single-sideband^4.
In direct ptychography methods, phase contrast is recovered by applying a frequency-dependent deconvolution kernel to each diffraction pattern. Parallax imaging replaces this with a simple yet remarkably robust bright-field–frequency-dependent phase ramp. This leads to an important practical consequence:
Parallax imaging replaces expensive Fourier-domain operations with simple, real-space updates.
Each bright-field pixel is associated with a real-space parallax shift, determined by the gradient of the aberration phase surface. During acquisition, each diffraction frame contributes locally to the reconstruction at the shifted position.
Two closely related variants are implemented:
- Parallax imaging (
ParallaxUDF)
Each BF pixel contributes a delta-like update at its shifted location, correcting for the parallax effect. - Phase-flipped parallax imaging (
ParallaxPhaseFlipUDF)
Each BF pixel contributes a shifted fixed real-space kernel, correcting for both the parallax effect and contrast reversals, enabling dark-field-like contrast.
License
LiberTEM-parallax is licensed under the MIT license.
The project includes code adapted from existing quantEM utilities where noted, under a compatible license. See individual source files for attribution details.
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 libertem_parallax-0.1.2.tar.gz.
File metadata
- Download URL: libertem_parallax-0.1.2.tar.gz
- Upload date:
- Size: 223.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fd6c8d7074da75df06519a9cb86649c92ae79da697fb315b503877c7d9c6c32
|
|
| MD5 |
d2354ded34988d045d416b04c3acfd61
|
|
| BLAKE2b-256 |
f5d3ca357859e9b09a98eb0e2b0b48b00460fb8a5aa538406f63662929b4d607
|
File details
Details for the file libertem_parallax-0.1.2-py3-none-any.whl.
File metadata
- Download URL: libertem_parallax-0.1.2-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a554d6abdabed4d62d983391e2ca87be28a34ee7f7897f86d571e1cfec096cb1
|
|
| MD5 |
1135cb2f33680b3f94beac9728840af1
|
|
| BLAKE2b-256 |
2163fbe9a894e4e79c8b6893534f18f931f75fccff3e8cff85cf5b64fe440b6d
|