Tutorial Datasets#
The quantem.widget.datasets module provides small, named examples for
tutorials, smoke tests, and Colab notebooks. Choose a named example; image and
scan previews also take an explicit size. The loader handles Hugging Face
paths, cache layout, and calibration details.
from quantem.widget.datasets import (
gold_session,
show1d_ducky,
show2d_gold,
show3d_gold,
show4dstem_gold,
showpdf_ta,
showpdf_ta_ground_truth,
)
Images and stacks come back as quantem core Dataset2d and Dataset3d
(show2d_gold, show3d_gold), and the 4D-STEM scan
as every 4D-STEM file reads (read_4dstem): a quantem.gpu.io.Dataset4dstemGPU
when quantem.gpu is installed and a GPU is present, else a quantem core
Dataset4dstem (show4dstem_gold). showpdf_ta returns a quantem core
Dataset4dstem with its detector calibrated in 1/Å, and
showpdf_ta_ground_truth the (r, g) arrays of its atomic model’s g(r). On
an Intel Mac or Windows on ARM, which cannot install quantem core, the
widget’s stand-in carries the same array, name, sampling, units,
metadata, shape, ndim and dtype.
show1d_ducky and gold_session return folders.
show1d_ducky() selects one collection and has no size argument. For helpers that expose a size selector:
Size |
Intended use |
|---|---|
|
Documentation, Colab, CI smoke tests, quick first view |
|
Better visual detail for local notebooks |
|
Local workstation review |
|
Full available tutorial source where practical |
For Show1D, the synthetic Ducky example is a file-backed monitor run.
Ducky simulation tutorial: Georgios Varnavides, Trademark ducky dataset (October 23, 2025). The viewer files contain subsequent reconstruction results for the synthetic example.
from quantem.widget import Show1D
from quantem.widget.datasets import show1d_ducky
run = show1d_ducky()
widget = Show1D.from_monitor_file(
run / "show1d_monitor.jsonl",
title="Synthetic Ducky reconstructions (tutorial: Georgios Varnavides)",
x_label="frame",
y_label="final loss",
log_scale=False,
)
widget
Diffraction example#
The ShowDiffraction notebook uses a labeled deterministic synthetic magnetite
control. No measured Fe3O4 pattern is published, so there is no download helper
for that missing input. Open your own measured image with ShowDiffraction.
Pair distribution function example#
showpdf_ta() and showpdf_ta_ground_truth() read 4dstem/ta_amorphous_sim/
(data.npy, meta.json and ground_truth_gr.npz) at revision
fe907499a3a2c1f827c8827c0b3472c5b08f47bf, the dataset commit that added that
folder (the next commit after the default revision above); pass revision to read
another. The scan is a simulation of an atomic model, not a measured
acquisition.
Reference#
Tutorial inputs: real acquisitions and synthetic reconstruction examples.
Image and scan loaders take a friendly size name and return a calibrated quantem
dataset (or a folder of files), so the tutorials never ship data in git: a
quantem core Dataset2d/Dataset3d for images and stacks, and for the
4D-STEM scan a quantem.gpu.io.Dataset4dstemGPU on a GPU or a quantem core
Dataset4dstem elsewhere (the widget’s stand-in where quantem core cannot
install).
- quantem.widget.datasets.gold_session(*, size: str = 'small', cache_dir: str | Path | None = None, revision: str | None = None, force_download: bool = False, verbose: bool = True) Path#
Download the public gold HAADF session for image-reader tutorials.
The pinned default uses
widget/gold_session. The one measured session is downloaded intact;sizeis retained for existing notebook calls.- Parameters:
size – Tutorial size, normally
"small".cache_dir – Download cache, dataset revision and refresh controls.
revision – Download cache, dataset revision and refresh controls.
force_download – Download cache, dataset revision and refresh controls.
verbose – Print the number of downloaded EMD files.
- Returns:
Cached folder containing the public EMD images.
- Return type:
Path
Examples
>>> folder = gold_session() >>> images = sorted(folder.glob("*.emd"))
- quantem.widget.datasets.show1d_ducky(*, cache_dir: str | Path | None = None, revision: str | None = None, force_download: bool = False, verbose: bool = True) Path#
Download reconstruction snapshots for the synthetic Ducky example.
The returned folder contains
show1d_monitor.jsonland snapshot.npyfiles. Open it withquantem.widget.Show1D.from_monitor_file().The original
Trademark ducky datasetsimulation tutorial is by Georgios Varnavides (October 23, 2025). These files contain subsequent reconstruction results, not measured detector data.- Parameters:
cache_dir – Optional Hugging Face cache directory.
revision – Hugging Face dataset revision. The default pins the documented inputs; an explicit revision is never mixed with files from another revision.
force_download – If
True, ask Hugging Face Hub to refresh the cached files.verbose – If
True, print a short dataset summary.
- Returns:
Local folder containing the Show1D monitor run.
- Return type:
Path
- quantem.widget.datasets.show2d_gold(*, size: str = 'small', cache_dir: str | Path | None = None, revision: str | None = None, force_download: bool = False, verbose: bool = True)#
Load the gold HAADF Show2D tutorial image by friendly size name.
The source image is downloaded once from
haadf/gold_haadf_npy; every size but"full"keeps every Nth pixel of it (stride 8, 4, 2) and says so in one line. The same source is reused byshow3d_gold().
- quantem.widget.datasets.show3d_gold(*, size: str = 'small', cache_dir: str | Path | None = None, revision: str | None = None, force_download: bool = False, verbose: bool = True)#
Load the gold HAADF Show3D tutorial stack by friendly size name.
The stack is built from moving crops of the shared gold HAADF tutorial source instead of storing a second copy of the image for Show3D. Every size but
"full"crops from every Nth pixel and says so in one line.
- quantem.widget.datasets.show4dstem_gold(*, size: str = 'small', cache_dir: str | Path | None = None, revision: str | None = None, force_download: bool = False, verbose: bool = True)#
Load the gold 4D-STEM Show4DSTEM tutorial scan by friendly size name.
The source scan is stored once under
4dstem/gold_128_npy_bin8;"small"and"medium"keep every 4th or 2nd scan position and say so in one line. The file is read as every 4D-STEM file is (read_4dstem): aquantem.gpu.io.Dataset4dstemGPUthat stays on the GPU when quantem.gpu and a GPU are present, else a quantem coreDataset4dstem.
- quantem.widget.datasets.showpdf_ta(*, cache_dir: str | Path | None = None, revision: str | None = 'fe907499a3a2c1f827c8827c0b3472c5b08f47bf', force_download: bool = False, verbose: bool = True)#
Load the simulated amorphous Ta 4D-STEM scan used by the ShowPDF tutorial.
The scan is downloaded from
4dstem/ta_amorphous_sim: a 20 x 20 scan of 307 x 307 float32 patterns simulated from a 1,024,000-atom amorphous Ta model, with the detector calibrated in 1/Å (k = 1/d). The model’s number density is 1,024,000 / 268.6053³ atoms/ų.- Parameters:
cache_dir – Optional Hugging Face cache directory.
revision – Hugging Face dataset revision; defaults to the pinned one.
force_download – If
True, ask Hugging Face Hub to refresh the cached files.verbose – If
True, print a short dataset summary.
- Returns:
The calibrated scan, a quantem core
Dataset4dstem(the widget’s stand-in where quantem core cannot install).- Return type:
Dataset4dstem
- quantem.widget.datasets.showpdf_ta_ground_truth(*, cache_dir: str | Path | None = None, revision: str | None = 'fe907499a3a2c1f827c8827c0b3472c5b08f47bf', force_download: bool = False)#
g(r) of the atomic model behind
showpdf_ta:(r, g)arrays, r in Å.