Unsupervised clustering algorithm for efficient processing of 4D-STEM and 5D-STEM data
Serin Lee, Stephanie M. Ribet, Arthur R. C. McCray, Andrew Barnum, Jennifer A. Dionne, Colin Ophus
TL;DR
This work tackles the challenge of analyzing high-dimensional 4D-STEM/5D-STEM data by introducing an unsupervised marching-square clustering framework that segments diffraction patterns into spatially coherent crystallographic domains. The method leverages local diffraction-pattern similarity to delineate domain boundaries and produces cluster-averaged diffraction cubes, which significantly improve signal-to-noise and reduce data volume, enabling rapid orientation, phase, and strain mapping. By applying correlative prefiltering and an efficient clustering pipeline, the approach achieves substantial data compression (reducing the effective data size by orders of magnitude) while maintaining physically meaningful structural information. Demonstrated on in situ liquid-cell 4D-STEM of Au nanoparticle growth, the framework yields robust grain delineation and smooth strain gradients, and is implemented as an open-source module within py4DSTEM to support reproducibility and reuse.
Abstract
Four-dimensional scanning transmission electron microscopy (4D-STEM) enables mapping of diffraction information with nanometer-scale spatial resolution, offering detailed insight into local structure, orientation, and strain. However, as data dimensionality and sampling density increase, particularly for in situ scanning diffraction experiments (5D-STEM), robust segmentation of spatially coherent regions becomes essential for efficient and physically meaningful analysis. Here, we introduce a clustering framework that identifies crystallographically distinct domains from 4D-STEM datasets. By using local diffraction-pattern similarity as a metric, the method extracts closed contours delineating regions of coherent structural behavior. This approach produces cluster-averaged diffraction patterns that improve signal-to-noise and reduce data volume by orders of magnitude, enabling rapid and accurate orientation, phase, and strain mapping. We demonstrate the applicability of this approach to in situ liquid-cell 4D-STEM data of gold nanoparticle growth. Our method provides a scalable and generalizable route for spatially coherent segmentation, data compression, and quantitative structure-strain mapping across diverse 4D-STEM modalities. The full analysis code and example workflows are publicly available to support reproducibility and reuse.
