Show1D#

Open in Colab

Show1D is the iteration dashboard for traces, optimizer losses, image line profiles, and reconstruction snapshots. It is useful when a ptychography or denoising run produces scalar metrics every iteration and object/probe images at lower-rate checkpoints.

This tutorial uses the reconstruction snapshots for the synthetic Ducky example hosted in the public bobleesj/quantem-data Hugging Face dataset. The default pins widget/ducky, and show1d_ducky() hides those storage details. See Tutorial datasets for the immutable revision and canonical folder paths.

Ducky simulation tutorial: Georgios Varnavides, Trademark ducky dataset (October 23, 2025). The viewer files contain subsequent reconstruction results for the synthetic example.

import quantem.widget as qw
qw.profile()

import json

import numpy as np

from quantem.widget import Show1D
from quantem.widget.datasets import show1d_ducky
Kernel          Unknown
quantem.widget  0.0.1rc44.dev0
  install       editable checkout
  commit        d983c24e5c6f (dirty checkout)
  branch        main
  workspace     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  80dd876 (80dd8765cbfa), pinned 80dd8765cbfa89f30f925473418e2a66074c5a1f
torch           2.15.0+cu132  device=cpu
python          3.12.16

Compare loss traces with reconstruction snapshots#

A joint reconstruction sweep often has many related loss curves: a frame-by-frame baseline plus several regularization strengths. The Ducky folder holds one JSON line per frame with every loss and the paths of that frame’s snapshot images. The cell below plots the losses and attaches four representative checkpoints with four image candidates each, so this live documentation page remains compact.

Each snapshot group contains a reference image and the reconstruction candidates for the selected frame. The selected frame in the loss plot and the image grid stay linked. Use the star beside playback to bookmark an important iteration; the same action is available as star_snapshot_group(...) from Python.

ducky_run = show1d_ducky(verbose=False)
events = [json.loads(line) for line in (ducky_run / "show1d_monitor.jsonl").read_text().splitlines()]
snapshot_names = ("reference", "lambda 0.3", "lambda 30", "lambda 300")

widget = Show1D(
    {name: [event["losses"][name] for event in events] for name in events[0]["losses"]},
    x=[event["iteration"] for event in events],
    title="Synthetic Ducky reconstructions (tutorial: Georgios Varnavides)",
    x_label="frame",
    y_label="loss",
    x_integer=True,
    snapshot_columns=4,
    snapshot_panel_width_px=720,
    snapshot_histogram_width=360,
    snapshot_histogram_height=52,
)
for event in events[::3]:
    widget.snapshot(
        event["iteration"],
        label=event["label"],
        **{name: np.load(ducky_run / event["snapshots"][name]) for name in snapshot_names},
    )
widget.star_snapshot_group(3)
widget

Profile a single image#

Show1D.from_image samples a line profile from a 2D image and keeps the image context beside the trace. Coordinates use the scientific (row, col) convention. Here we reuse the reference snapshot downloaded by show1d_ducky().

reference = np.load(ducky_run / "snapshots" / "reference.npy")

Show1D.from_image(
    reference,
    line=((70, 45), (170, 190)),
    profile_width=3,
    title="Ducky reference (tutorial: Georgios Varnavides)",
    image_cmap="viridis",
)