---
title: "4D-STEM: One Scan, Many Virtual Images Interactive Lab | Sandbox Physics"
description: "What can you learn by recording a full diffraction pattern at every probe position? Many different images from a single scan. The full diffraction pattern is saved at every probe position, so afterwards you can choose which detector pixels to add up and build bright-field, dark-field or other virtual images. The positions of the diffraction disks also give the crystal orientation and how much the lattice has stretched, limited by disk spacing, angular sampling and counts."
canonical_url: "https://sandboxphysics.com/labs/four-d-stem/"
language: "en"
page_type: "lab"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/labs/four-d-stem/"
last_modified: "2026-10-25"
---

E37 · Electron imaging

# 4D-STEM: One Scan, Many Virtual Images

**What can you learn by recording a full diffraction pattern at every probe position?** Many different images from a single scan. The full diffraction pattern is saved at every probe position, so afterwards you can choose which detector pixels to add up and build bright-field, dark-field or other virtual images. The positions of the diffraction disks also give the crystal orientation and how much the lattice has stretched, limited by disk spacing, angular sampling and counts.

Move the probe across two grains and look at the diffraction frame recorded at each spot, then rotate a virtual detector after the scan is done. Once the disks are separated, the same counts give each grain's orientation and lattice dilation. You trade off convergence angle, camera length, scan sampling, dose and data size.

> Interactive simulation: open this page in a web browser to change the parameters and run the model.

Model assumptions

The beam is fixed at 200 kV and 2 pA. The specimen is an invented square lattice with 0.4 nm reference spacing and a straight grain boundary; the right grain's rotation and isotropic dilation are adjustable. The kinematic model puts 60% of the intensity in the direct disk and 10% in each of four first-order disks, and integrates each circle exactly over the pixels before counts are drawn. These yields are assumptions, not structure factors. Near the boundary, a Gaussian probe width mixes the intensities of the two grains incoherently. The model leaves out interference, multislice propagation, dynamical scattering, higher orders, aberrations, drift, inelastic scattering, detector saturation and damage. The 12 mm detector has 48 square pixels along each axis, and the effective camera length sets its angular field. The cube is stored as uint32; changing a virtual mask or the selected probe adds no exposure. A fourfold angular moment and four measured centroids estimate the orientation, modulo 90 degrees, and one scalar dilation. Disks that overlap, are clipped or have too few counts are marked gray. This is not general indexing or a strain-tensor solver. Data colors saturate at the labeled display scales, but the numerical analysis uses linear counts. Changing an acquisition parameter replaces the seeded random counts; animation adds no dose. Atomic markers are drawn 35 times farther apart than the scan coordinates would give, so they show grain orientation, not real atomic positions.

Physics tutorial

## Four axes, one measurement history

**Background** The probe moves over the specimen in two directions, and at every position a pixelated detector records the scattered electrons over two angles. Keeping all four axes lets one acquisition answer several questions.

**Why it matters** A conventional detector throws angle information away while it records. A virtual detector picks the angles afterward, but it cannot bring back clipped angles, counts that were never collected or scan positions that were never recorded.

Start with the essentials

- **Focus question**: What can you learn by recording a full diffraction pattern at every probe position?
- **One-sentence intuition**: Changing a virtual aperture only re-sums the recorded pixels and adds no electron exposure; orientation and dilation come from measured disk positions and are limited by disk separation, angular sampling and counts.

### Core mathematical model

#### Four independent data axes

$$
D_{ijmn}=D(x_i,y_j,\theta_{x,m},\theta_{y,n})
$$

The first two axes give the probe position and the last two give a detector pixel. The readout shows the memory actually used to store the uint32 counts, without metadata or compression.

#### A virtual detector sums acquired counts

$$
V_{ij}=\sum_{m,n}M_{mn}D_{ijmn},\qquad M_{mn}\in\{0,1\}
$$

The green mask selects whole recorded detector pixels. A central mask gives a bright-field image, and a displaced mask picks out one first-order disk. The mask edge follows pixel boundaries; it is not a smooth physical aperture.

#### Camera length converts angle to position

$$
r=L\theta,\qquad \theta_B\simeq\frac{\lambda}{a}
$$

The detector is 12 mm wide. A longer effective camera length samples angles more finely but covers a smaller angular range. Here the square lattice appears as the direct beam plus four assumed first-order disks.

#### Scalar dilation from four Bragg centroids

$$
\varepsilon=\frac{\theta_{B,\mathrm{ref}}}{\overline{\theta}_{B,\mathrm{meas}}}-1
$$

When the lattice expands, its disks move inward in reciprocal space. The fourfold angular moment estimates the orientation modulo 90 degrees, and four count-weighted centroids give the mean disk radius. This is a simple isotropic estimate, not a full strain tensor.

#### Dose and storage scale differently

$$
\begin{gathered}N_e=\frac{I\tau}{e},\qquad d=\frac{N_eN_xN_y}{A}\\ S=4N_xN_yN_{\theta x}N_{\theta y}\ \mathrm{bytes}\end{gathered}
$$

A finer scan means more probe exposures and more stored frames. Moving the inspected position or the virtual mask reuses the cube you already have. Animation collects no extra electrons.

### Common difficulties

#### A cube is not a larger image

**Typical misconception** Four-dimensional STEM is one high-resolution two-dimensional picture.

**Better mental model** Two axes describe where the probe is and two describe where the electrons scatter. Summing over the detector axes with different masks gives different images from the same data.

#### Convergence angle is a tradeoff

**Typical misconception** A tighter real-space probe always gives more precise strain.

**Better mental model** A larger convergence angle makes the disks bigger in reciprocal space. The probe gets narrower, but the Bragg disks can overlap, and then the lattice positions can no longer be found.

### Run the experiment

1. 01

   #### Predict which grain a mask selects

   Start with Resolve · select left grain. Move the probe to each side and inspect the recorded frame.

   **What to observe:** In the right grain the disk pattern rotates and draws inward. Its orientation and dilation are computed from the counts at the selected position.

2. 02

   #### Reuse the same data cube

   Rotate the virtual dark-field mask from 0 to 30 degrees, then compare with the right-grain preset and the central bright-field mask.

   **What to observe:** The bright grain in the dark-field image switches sides, while the diffraction frames, dose and memory stay the same.

3. 03

   #### Break the estimate on purpose

   Compare the presets for overlapping disks, clipped diffraction and a sparse, low-count scan.

   **What to observe:** Disks that overlap or are cut off make the lattice estimate invalid. A partial frame that looks bright does not bring back the missing information.

4. 04

   #### Meet the target

   Reach the stated coverage, valid fraction, scan step, dwell and dark-field contrast, then check.

   **What to observe:** Passing shows that this acquisition and estimate work together here; it does not certify the strain or orientation of a real material.

Physical conclusion

Record the angular range and scan sampling you need before you process anything. A gray estimate means the lattice could not be resolved, not that the strain is zero.

Fields & matter · Starter path

## From a field to an electron microscope

Map an electric field and steer a charged particle. Then find the electron's wavelength and use electron beams to see a crystal and a surface.

[Start here → **Make an Electric Field Visible** Move the probe around a dipole and check that the field always points downhill on the potential landscape. Observe · 8 min](https://sandboxphysics.com/labs/electric-field/)

1. [1 Make an Electric Field Visible](https://sandboxphysics.com/labs/electric-field/)
2. [2 A Charge Bending through Fields](https://sandboxphysics.com/labs/charged-particle/)
3. [3 Electron Wavelength & Voltage](https://sandboxphysics.com/labs/electron-wavelength/)
4. [4 Electron Diffraction & Reciprocal Space](https://sandboxphysics.com/labs/electron-diffraction/)
5. [5 TEM Bright Field, Dark Field & SAED](https://sandboxphysics.com/labs/tem-mode-selector/)
6. [6 SEM Secondary-Electron Topography](https://sandboxphysics.com/labs/sem-topography/)

[View the full path →](https://sandboxphysics.com/topics/fields-and-matter/#starter-path)
