Explore 4D-STEM in three minutes

Explore 4D-STEM in three minutes#

Open in Colab

Question: Which scattering angles make the gold particles easiest to see?

In Colab, choose Runtime → Run all. Wait for the explorer to appear. There is nothing to upload or configure.

import quantem.widget as qw
qw.profile()

# @title 2. Load a small real dataset { display-mode: "form" }
from quantem.widget import Show4DSTEM
from quantem.widget.datasets import show4dstem_gold

stem_dataset = show4dstem_gold(size="medium")
quantem.widget  0.0.1rc44.dev0
  install       editable checkout
  commit        2d009a7f61ee (dirty checkout)
quantem.gpu     0.0.1rc18.dev0
  install       local build
  commit        not recorded
quantem         0.1.10
  install       installed package
  commit        not recorded
webgpu kernels  fa4a86c (fa4a86cfee85), pinned fa4a86cfee85ea719be2dd98206d2098f0dd3344
torch           2.14.1+cu130  device=cpu
python          3.12.15
quantem.widget: read data.npy densely on the CPU: (128, 128, 24, 24) uint16, 0.02 GB, 0.0 s. quantem.gpu, installed here, keeps it encoded on a GPU when it is read on one.
show4dstem_gold(size='medium') keeps every 2th scan position of the 128x128 scan; size='large' or 'full' loads every position.
Source: gold_128_npy_bin8 from Hugging Face
Full stack: (128, 128, 24, 24) uint16
Preview: (64, 64, 24, 24), scan stride 2
Sampling: [4.0, 4.0, 3.68, 3.68] ['A', 'A', 'mrad', 'mrad']
Processing: real-space 4x4 block average from gold_512_npy_bin8; detector remains bin8

Try three things#

Before you click, predict which panel will change.

  1. Choose a scan point: click a particle in the right image. The diffraction pattern on the left updates.

  2. Compare angles: click BF, then ADF, below the left panel. Which image makes the particles stand out?

  3. Measure a line: turn on Profile above either panel, then click two points. Drag an endpoint to move the measurement.

Use Reset above a panel whenever you want a clean view.

# @title 3. Open the explorer { display-mode: "form" }
from sys import modules

viewer = Show4DSTEM(
    stem_dataset,
    dp_scale_mode="linear",
    offline="google.colab" not in modules,
    offline_dtype="uint16",
    save_state=True,
    precompute_virtual_images=False,
    show_fft=False,
)

viewer
quantem.widget: device="auto" selected cpu.

What changed?#

  • A new scan point selects a different diffraction pattern.

  • A new detector integrates different scattering angles into the image.

  • A Profile plots intensity along the line you drew. No Python call is required.

Ready for microscope data? Open one dataset or several datasets.