Record and Replay

save_as records what every source of a pipeline produced. load_from puts that recording back in place of the sources, on the same block boundaries, so the same pipeline runs again on the same input – with no amplifier plugged in and nobody in the chair.

With save_as, each source's frames are written to a run directory as they leave the source. With load_from, the sources are not built and the recorded frames are replayed in their place into the same pipeline.

Recording a run

Both are launch settings, set before the first node is built. In a script:

import gpype as gp

gp.LaunchConfig.configure(save_as="raw")  # before building any node
# ... then build and start the pipeline as usual

Or on the command line, with no change to the script: python my_script.py --save-as raw. save_as is a name stem: the run is a directory, raw_ followed by the date and time it started, created in the working directory and holding a manifest.json and one HDF5 file per source. A Generator named eeg beside a Marker named mrk, recorded for four seconds, gave:

raw_20260930_145558_505/
    manifest.json    823 bytes
    eeg.h5        73 456 bytes
    mrk.h5        34 056 bytes

The files are named after the nodes where you named them, and <Class>_<n> where you did not – one more reason to pass name= to a source. Each is an ordinary g.Pype HDF5 recording, so HDF5Reader still opens it. Both settings need the formats extra, and setting both at once is refused.

What is recorded is what the source produced, not what the amplifier’s converter measured: after the driver and the source’s own channel selection, and before anything g.Pype does to the stream afterwards. Plan the disk for it: the stored samples are 64-bit, so eight channels at 250 Hz take about 23 kB/s, and a 256-channel g.HIamp at 4800 Hz about 9.9 MB/s – 36 GB an hour. If the disk falls behind, frames are dropped rather than stalling the acquisition, and the log says how many.

Replaying it

Set load_from to the run’s directory – in the script, or as --load-from raw_20260930_145558_505 – and run the same script again. The sources it builds are then not run: no device is opened and no file read, so an amplifier’s run replays on a machine without the amplifier or its driver. The recorded frames come back in their place, with the same block boundaries and the same spacing, and a replay keeps the mode it was recorded in – realtime runs with start(), batch runs with run().

Recorded streams are matched to sources by name, never by position. A pipeline that has gained or lost a source since the recording is refused when the source is built, naming what the run holds: “this run has no raw stream ‘extra’ to replay; it holds eeg, mrk.” Pairing the n-th source with the n-th stream is how two streams get crossed silently.

Events land where they landed live. Recorded, then replayed, the five markers of the run above fell on samples 154, 254, 355, 455 and 557 both times, and the replay produced the same 896 rows. A batch run replayed through run() returned the same values bit for bit.

What a replay does not reproduce

  • The output. A replay reproduces the input. Everything downstream still runs against the live clock – scope refresh, queues, frames shed under load.

  • Live markers. Under load_from, marker.emit() does nothing, and says so once in the log: “this run is replaying a recording, so markers come from the recording and emit() does nothing.” A paradigm script runs unchanged against a replay, without placing each event twice.

  • A stop at the end. When a realtime replay runs out, each stream says so – “replayed the whole of ‘eeg’ … this stream is now silent” – and goes quiet. The pipeline keeps running, as it would after a device stopped sending.

  • The original run’s mark. A recording an unlicensed run wrote carries a non-commercial mark: a label on the file, not an error. A replay of a marked recording writes marked files, licence or not; a replay of an unmarked one is marked only where no licence is held.

load_from replaces every source of the pipeline, and a replayed stream is paced by the host clock and stamped in it. That is why the time-base refusal of Execution Modes never fires on a replay, while it does on a file read in realtime by a recording reader.