Expand description
dspk pipelines as data: a versioned node-graph spec (PipelineSpec) and an executor
(run) that streams a recording through dspk-ops stages on the device.
{"dspk_pipeline": 1,
"nodes": {"raw": {"op": "read", "path": "recording.bin"},
"hp": {"op": "iir", "band": "highpass", "cutoff": [300.0], "mode": "forward"},
"out": {"op": "write", "path": "filtered.zarr", "format": "zarr"}},
"edges": [["raw", "hp"], ["hp", "out"]]}- JSON is canonical; TOML is accepted for hand-written files (
PipelineSpec::load); the JSON Schema of the spec isPipelineSpec::json_schema. - The executor reads windows with read-ahead, uploads each window once (integer recordings as
stored integers, scaled on the device), runs every stage on the device, downloads once and
hands the result to a writer thread (raw, or Zarr chunks directly); the canonical spec is
written next to the output as provenance (
<output>.pipeline.json). The report counts the bytes moved at each step and the time spent in each (StageTimings). - One spec runs over many inputs (globs, lists) and may read several recordings as one (merge).
plansays what a run would do (mode, halos, windows, bytes) without touching the device;run_withreports progress after each window and can cancel.
Structs§
- Chain
- The chain of a valid spec, in order: the
readnode, the processing nodes, thewritenode. - Data
Movement - Bytes moved by a run, step by step (window halos included: they are read, uploaded and downloaded with their window).
- Execution
- How the executor runs the chain.
- Merge
Part - One recording of a merge.
- Pipeline
Spec - A pipeline: operations (nodes, by id) and the edges between them.
- Plan
- What running one input would do, without touching the device.
- Progress
- Where a run is, passed to the observer after each window.
- RunReport
- What a run did.
- Stage
Timings - Where a run spent its time, in seconds. Reading, the device and the writer run on three
threads at once, so these add up to more than
RunReport::seconds; the largest ofread_wait,deviceandencode + diskis the bottleneck. - Whiten
Fit - How a
whitennode is fitted (its spec fields).
Enums§
- Band
- Compression
- Compression of Zarr chunks:
{"codec": "zstd", "level": 3},{"codec": "blosc_lz4", "level": 5}(LZ4 after a byte shuffle; faster, usually a little larger) or{"codec": "none"}. - Design
- Direction
- Which way a
crossingsnode’s signal goes past its level:rising(up through a level above the baseline),falling(down through a level below it) orboth(past+|level|upwards or−|level|downwards; an event’s sign is its peak’s). - Edge
- Samples past the ends of a window (scipy names:
constant0,odd,reflect,nearest). - Exec
Mode stream: windows in order, filter state carried (exact; forward filters, point-wise and spatial stages only).windows: each window on its own with halos of the chain’s settling (zero-phase filters, stencil stages).auto:streamwhen the chain allows it.- Executed
Mode - How the chain runs.
- Input
- One input of a
readnode: a path (or glob), or several recordings merged side by side. - Mode
forward_backward: zero phase (sosfiltfilt);forward: causal (sosfilt).- Node
- One operation.
readandwriteare the ends; the others mirrordspk.ops.stage. - Output
Format - Pipeline
Error - Why a pipeline could not be read, checked or run.
- Start
- How a forward filter starts: at rest, or from the steady state of the first sample.
- Upload
- What crosses to the device.
stored: the recording’s stored integers, scaled on the device (int16 moves half the bytes of float32).scaled: float32 values scaled on the host.auto:storedfor integer recordings,scaledotherwise (float32 is the same either way; float64 is scaled on the host).
Constants§
- DEFAULT_
BLOSC_ LEVEL - Default LZ4 level of
Compression::BloscLz4(blosc’s 0–9). - DEFAULT_
CHUNK_ SAMPLES - Samples per channel in each window the executor processes (2.2 s at 30 kHz).
- DEFAULT_
ZSTD_ LEVEL - Default zstd level of
Compression::Zstd. - EVENTS_
VERSION - Format version of an events Zarr group (
dspk_eventsattribute). - PROVENANCE_
SUFFIX - Appended to the output path for the canonical spec written next to it (provenance).
- SPEC_
VERSION - The spec version this crate reads and writes (
dspk_pipelinefield). - WHITEN_
DEFAULT_ CHUNKS - Chunks those seconds are split into, by default.
- WHITEN_
DEFAULT_ FIT_ S - Seconds a
whitennode fits on, by default. - WRITE_
QUEUE_ WINDOWS - Downloaded windows waiting for the writer thread, at most: enough to absorb a slow write, and
a bound on the memory they hold (each is
channels × windowfloat32 values).
Functions§
- default_
open - Opens a recording with
dspk_io(generic formats):sourcepicks a source within the file. - events_
csv - The events table as CSV (the columns of
events_frame). - events_
frame - The events of a
crossingschain as a table, one row per event (seeOutputFormat::Events):channel(u32),channel_name,onset_sample/offset_sample/peak_sample(u64; offset null when the range ended inside the event),peak_value(f32),onset_s/offset_s/duration_s(f64). - fit_
whitening - Fits a global ZCA whitening of
channelsofsourceas processed bybefore(the stages ahead of it):fit.chunkschunks offit.fit_s / fit.chunksseconds spread evenly over the recording, each processed with the stages’ settling context, their covariance whitened. - plan
- What
crate::runwould do for each input ofspec, opening the inputs (metadata reads only) withdspk_io::openand never touching the device. - plan_
with planwith recordings opened byopen.- read_
events_ zarr - The events of a Zarr group written by
write_events_zarr, with its sample rate and channel names. - run
- Runs
speconce per input, resolving relative paths againstbase_dir, opening recordings withdspk_io::open(generic formats). One report per input, in order. - run_
with runwith recordings opened byopen(e.g. a crate that adds formats, such asdspk_synapse::io) andobservecalled after each window: returningfalsecancels the run (PipelineError::Cancelled; the unfinished output is removed, finished inputs stay).- unfitted_
whitening - The identity on
channelschannels: a whitening’s place in a pipeline before it is fitted (same channels, no settling), so a run can be planned without the device. - write_
events - Writes the events at
path: a Zarr group when it ends in.zarror lies inside a.zarrstore (e.g.rec.dspk.zarr/events/biceps; seewrite_events_zarr), CSV when it ends in.csv, Parquet otherwise. Returns the bytes written (Zarr: the values). - write_
events_ zarr - Writes the events as a Zarr group rooted at directory
dir(replacing it), the layout of dspk’s Zarr outputs: arrayschannel(int32),onset_sample,peak_sample(uint64),offset_sample(int64, −1 for an event still open at the end) andpeak_value(float32), one entry per event alongevents; attributesdspk_events(version),sample_rate_hzandchannel_names. A group inside another store (e.g.rec.dspk.zarr/events/<name>) is written the same way.