snnlab

Visualisation

Compose figures from retained recordings without inventing evidence.

snnlab.viz owns renderer-neutral recording and diagram contracts, numerical transforms, layout helpers, Matplotlib composition, and animation export.

Construct a recording from graph results

After running the quickstart:

from snnlab import viz

recording = viz.Recording(
    dt_ms=0.1,
    signals={
        name: tensor.detach().cpu().numpy()
        for name, tensor in result.recordings.items()
    },
    metadata={"seed": 17, "network": "small_ping"},
)
print(recording.steps, recording.duration_ms)

Recording requires a positive finite timestep and consistent leading time axes. recording.require("signal_name") fails if a requested signal is absent. Select actual keys from result.recordings; do not guess a legacy field name.

load_snnsim_recording(run_dir) adapts the canonical legacy recording.npz layout, including its dt field and established time-series anchors. It is not a universal loader for every graph artifact layout.

Diagrams

snnlab.lang.diagram projects an authored bundle into a renderer-neutral diagram. viz.render_diagram renders it; bundle.write(..., visualise=True) delegates through the same boundary. Graphviz is required for exports.

Figures and animation

Scene composes panels over a Recording and ordinary Matplotlib axes. A panel implements draw(ax, recording) and update(frame). FigureGrid provides named layout regions. FrameTimeline makes source-step sampling explicit; save_animation uses FFmpeg for video export.

Keep scientific meaning in the experiment's presentation code. Use retained recordings, preserve units and timelines, and fail on missing evidence. Never replace absent activity with invented zeros.

Scientific presentation conventions

  1. Use an opaque white background and stable encodings; the shared palette begins with near-black and deep red.
  2. Reinforce important distinctions with labels, markers, line styles, or position.
  3. Identify illustrative trials, aggregation, and uncertainty explicitly.
  4. Synchronise animation panels to the same simulation step and disclose altered pacing.
  5. Inspect exports at their intended display width and provide meaningful alternative text and captions.

The detailed visual conventions remain in src/snnlab/viz/README.md.

API reference

See the complete snnlab.viz API reference for signatures, defaults, fields, methods and validation.

On this page