Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

The open-source 4D-STEM software ecosystem

A healthy ecosystem of open-source Python packages has grown up around 4D-STEM analysis. They overlap in places, and that is a feature: you can move data between them, cross-check results, and pick the tool whose workflow fits your problem. This module gives a whirlwind tour of the packages used in this course.

py4DSTEM

py4DSTEM Savitzky et al. (2021) is an open-source Python package for 4D-STEM analysis, developed at Lawrence Berkeley National Laboratory and by a broad community of contributors. It covers the full pipeline used in this course: file I/O across many vendor formats, calibration, virtual imaging, Bragg disk detection, strain mapping, automated crystal orientation mapping (ACOM), fluctuation microscopy, and phase contrast imaging methods including ptychography. Most of the hands-on Colab sessions today use py4DSTEM.

quantEM

quantEM is a newer open-source toolkit for quantitative electron microscopy built on PyTorch, so the same analysis code runs on CPUs and GPUs and integrates naturally with deep learning workflows. It spans imaging, diffraction, ptychography, tomography, and spectroscopy, and is under active development by several of the course instructors and collaborators (code on GitHub).

pyxem / HyperSpy

pyxem is a 4D-STEM analysis library built on the HyperSpy multi-dimensional data framework. It is particularly strong for scanning (precession) electron diffraction workflows: template-matching orientation mapping Cautaerts et al. (2022), virtual imaging, and vector-based diffraction analysis, with lazy/out-of-core processing for datasets larger than memory via Dask.

Kelvin_STEM

Kelvin_STEM is a set of fast 4D-STEM analysis tools developed by Ian MacLaren’s group at the University of Glasgow, used in this course for virtual imaging, digital dark field, and clustering workflows on large datasets.

abTEM

abTEM Madsen & Susi (2021) simulates TEM and STEM experiments from first principles: multislice and PRISM image simulation directly from atomic models, entirely in Python. Simulation matters for 4D-STEM analysis: it lets you generate test data with known ground truth, design experiments (convergence angle, thickness, tilt sensitivity), and build the diffraction template libraries used in orientation mapping.

Which tool should I use?

TaskGood starting points
Load / browse / calibrate 4D datapy4DSTEM, pyxem, quantEM
Virtual imaging (BF/ADF/custom masks)any of the above; Kelvin_STEM for speed on large data
Strain mappingpy4DSTEM, pyxem, quantEM
Orientation / phase mappingpy4DSTEM (ACOM), pyxem (template matching)
ML clustering / decompositionpyxem + scikit-learn, Kelvin_STEM
Amorphous / PDF analysispy4DSTEM, quantEM
SimulationabTEM
Ptychography / phase retrievalquantEM, PtyRAD, phaser
References
  1. Savitzky, B. H., Zeltmann, S. E., Hughes, L. A., Brown, H. G., Zhao, S., Pelz, P. M., Pekin, T. C., Barnard, E. S., Donohue, J., Rangel DaCosta, L., Kennedy, E., Xie, Y., Janish, M. T., Schneider, M. M., Herring, P., Gopal, C., Anapolsky, A., Dhall, R., Bustillo, K. C., … Ophus, C. (2021). py4DSTEM: A Software Package for Four-Dimensional Scanning Transmission Electron Microscopy Data Analysis. Microscopy and Microanalysis, 27(4), 712–743. 10.1017/s1431927621000477
  2. Cautaerts, N., Crout, P., Ånes, H. W., Prestat, E., Jeong, J., Dehm, G., & Liebscher, C. H. (2022). Free, flexible and fast: Orientation mapping using the multi-core and GPU-accelerated template matching capabilities in the Python-based open source 4D-STEM analysis toolbox Pyxem. Ultramicroscopy, 237, 113517. 10.1016/j.ultramic.2022.113517
  3. Madsen, J., & Susi, T. (2021). The abTEM code: transmission electron microscopy from first principles. Open Research Europe, 1, 24. 10.12688/openreseurope.13015.1