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.

Nanobeam disk detection and strain mapping

Before any physics can come out of a 4D-STEM dataset, the data has to be loaded, organized, and, critically, calibrated. This module walks through the py4DSTEM data pipeline Savitzky et al. (2021): reading files, browsing the 4D datacube interactively, and applying the chain of calibrations that turn detector pixels into physical units.

Loading data across formats

4D-STEM data arrives in many containers: vendor formats (Gatan .dm4, Thermo Fisher .emd/Velox, DECTRIS, Merlin/Medipix .mib, EMPAD raw), community HDF5 layouts (EMD 1.0), and plain arrays (.npy/.npz). py4DSTEM reads most of these directly, and any NumPy array can be wrapped into a DataCube:

import py4DSTEM
datacube = py4DSTEM.import_file("experiment.dm4")

# or, from a raw array:
import numpy as np
data = np.load("scan.npz")["arr_0"]     # shape (Rx, Ry, Qx, Qy)
datacube = py4DSTEM.DataCube(data=data)

The four dimensions are conventionally ordered (Rx, Ry, Qx, Qy): two real-space scan coordinates, then two reciprocal-space detector coordinates. Analysis products (mean patterns, virtual images, Bragg peaks, calibrations) are stored alongside the data in a tree structure that can be saved to and reloaded from HDF5, which also means expensive intermediate results (like Bragg disk detection over millions of patterns) can be checkpointed and shared.

Browsing the datacube

The first thing to do with any new dataset is look at it. Scrubbing through diffraction patterns as a function of probe position builds intuition about what is in the data (where the vacuum is, which regions are crystalline, how much the pattern changes between neighboring positions) and immediately reveals problems like detector saturation or beam damage. The mean and maximum diffraction patterns computed over all probe positions give a compact overview of everything the detector saw:

Standard summary views of a 4D-STEM dataset: vacuum probe, maximum diffraction pattern, Bragg vector map, simultaneous HAADF image, and Bragg peak histogram

Standard first-look products for a 4D-STEM dataset: the vacuum probe, the maximum diffraction pattern over all positions, the Bragg vector map, the simultaneously recorded HAADF image, and the radial histogram of detected Bragg peaks.

The calibration chain

A useful mental model: every measurement we make in this course is a position or intensity in the diffraction pattern, so every distortion of the diffraction pattern propagates directly into the physics. The standard calibration chain is:

  1. Pixel sizes. The real-space step size (from the scan settings) and the reciprocal-space pixel size (from the camera length, or better, measured from a known reference). Always sanity-check the scale bars on your virtual images afterwards.

  2. Origin / descan correction. The center of the diffraction pattern shifts as the beam scans, due to imperfect descan alignment. A classic signature: the central disk in the maximum diffraction pattern looks like a rounded rectangle: the circular center disk convolved with the rectangle traced out by the descan across the scan. We measure the origin at every probe position and fit a smooth low-order surface to it, with robust fitting to suppress outliers.

  3. Elliptical distortion. Projector lens distortions and detector tilt stretch the diffraction pattern into a slight ellipse. This can be measured from the amorphous halo of a carbon support film, or from a standard sample, and then corrected, or handled directly by working in polar-elliptical coordinates:

A diffraction pattern resampled in polar and polar-elliptical coordinates, with the elliptical transform straightening the rings

Elliptical distortion in practice: resampling a ring pattern in plain polar coordinates leaves the rings wavy along the angular direction; including the fitted ellipticity straightens them, which sharpens every radial measurement downstream.

  1. Real-space ↔ reciprocal-space rotation. The scan direction and detector axes are rotated relative to each other (scan coils and camera each have their own orientation), and data can additionally be transposed on read-in. This rotation must be measured, for example with a center-of-mass (DPC-style) analysis of the center beam, where a correct rotation produces clean dipole contrast along x in CoMx and along y in CoMy. Getting this wrong rotates your strain tensor and orientation maps!

  2. Pixel size against a known structure. For quantitative work, the reciprocal pixel size can be refined by comparing measured Bragg peak positions against structure factors calculated from a known reference crystal (e.g., from a CIF file).

Strain mapping

Schematic of nanobeam strain mapping: a converged probe scanned over a strained crystal produces diffraction patterns whose Bragg disk positions encode the local lattice vectors

Strain, the local deviation of the lattice from its relaxed spacing, controls band structure in semiconductor devices, mobility in strained channels, ferroelastic domain patterns, and mechanical response around defects and precipitates. Nanobeam electron diffraction (NBED) strain mapping Ozdol et al. (2015) measures it directly: the positions of the Bragg disks in each diffraction pattern encode the local reciprocal lattice vectors, so tracking how disk positions shift as the probe scans across the sample gives the full 2D strain tensor (εxx, εyy, εxy, and lattice rotation θ) at every probe position, over fields of view of microns with nanometer resolution. Among the many strain-measurement techniques in the TEM Béché et al. (2013), including geometric phase analysis of high-resolution images Hÿtch et al. (1998), NBED stands out for combining large fields of view, high precision, and modest dose.

How it works

  1. Probe template. Record a vacuum probe image (or extract a template from a thin region of the dataset). Its cross-correlation kernel, typically shaped with a sigmoid edge, is what makes disk detection precise.

  2. Bragg disk detection. Cross-correlate the template with every diffraction pattern and locate the correlation maxima with subpixel precision Pekin et al. (2017). The key hyperparameters are the correlation power, minimum peak intensity/spacing, and the subpixel mode ('poly' is fast for tutorials; 'multicorr' is recommended for high-precision strain mapping). Always tune the detection parameters on a handful of test patterns before running the full scan.

  3. Calibration. Correct the origin (descan), elliptical distortion, and the real-space/reciprocal-space rotation; see the calibration section above. Calibration errors map directly into artificial strain.

  4. Lattice fitting. Choose basis vectors g₁ and g₂ from the Bragg vector map (ideally perpendicular, well-separated reflections), and fit the full lattice at every probe position.

  5. Strain from a reference. Strain is always measured relative to a reference lattice: either the median lattice over a region of interest known to be unstrained, or manually specified reference vectors. The transformation between the local and reference lattice vectors, rotated into your chosen coordinate system, gives εxx, εyy, εxy, and θ.

Mean diffraction pattern with fitted lattice, and resulting strain component maps of a multilayer film

A complete result: the mean diffraction pattern with the fitted reciprocal lattice, and the four strain-tensor component maps (εxx, εyy, εxy, θ) across a multilayer structure.

Precision and pitfalls

Conventional versus precession-averaged diffraction patterns and the corresponding strain maps, showing reduced artifacts with precession

Conventional (top) vs. precession/multi-beam-averaged (bottom) acquisition of the same region: averaging through the rocking condition suppresses the dynamical intensity variations inside the disks, and the strain maps get visibly cleaner.

Focused-ion-beam-fabricated bullseye condenser apertures

Bullseye and patterned condenser apertures fabricated with a focused ion beam. Installed in the condenser system, they shape every diffraction disk into a self-registering target.

Bullseye probe template and detected diffraction disks in an experimental pattern

Disk detection with a bullseye probe: the patterned template cross-correlates sharply against each reflection, even where diffraction contrast varies across the disk.

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. Ozdol, V. B., Gammer, C., Jin, X. G., Ercius, P., Ophus, C., Ciston, J., & Minor, A. M. (2015). Strain mapping at nanometer resolution using advanced nano-beam electron diffraction. Applied Physics Letters, 106(25). 10.1063/1.4922994
  3. Béché, A., Rouvière, J. L., Barnes, J. P., & Cooper, D. (2013). Strain measurement at the nanoscale: Comparison between convergent beam electron diffraction, nano-beam electron diffraction, high resolution imaging and dark field electron holography. Ultramicroscopy, 131, 10–23. 10.1016/j.ultramic.2013.03.014
  4. Hÿtch, M. J., Snoeck, E., & Kilaas, R. (1998). Quantitative measurement of displacement and strain fields from HREM micrographs. Ultramicroscopy, 74(3), 131–146. 10.1016/s0304-3991(98)00035-7
  5. Pekin, T. C., Gammer, C., Ciston, J., Minor, A. M., & Ophus, C. (2017). Optimizing disk registration algorithms for nanobeam electron diffraction strain mapping. Ultramicroscopy, 176, 170–176. 10.1016/j.ultramic.2016.12.021
  6. Midgley, P. A., & Eggeman, A. S. (2015). Precession electron diffraction – a topical review. IUCrJ, 2(1), 126–136. 10.1107/s2052252514022283
  7. Zeltmann, S. E., Müller, A., Bustillo, K. C., Savitzky, B., Hughes, L., Minor, A. M., & Ophus, C. (2020). Patterned probes for high precision 4D-STEM bragg measurements. Ultramicroscopy, 209, 112890. 10.1016/j.ultramic.2019.112890
  8. Ma, K., Ferreirós, P. A., Pfeifer, T. W., Abernethy, R. G., von Tiedemann, S., Peng, N., Greaves, G., Ophus, C., Sun, K., Mir, A. H., Wang, L., Huang, S., Zhao, S., Hopkins, P. E., Hardie, C. D., & Knowles, A. J. (2025). Intermetallic dispersion-strengthened ferritic superalloys with exceptional resistance to radiation-induced hardening. Acta Materialia, 293, 121095. 10.1016/j.actamat.2025.121095