Recorders¶
Spike train recording and analysis utilities.
BitstreamSpikeRecorder— records a 1D binary spike train (0/1per timestep), returns auint8NumPy view, counts spikes, computes mean firing rate fromdt_ms, and builds inter-spike-interval histograms.
from sc_neurocore import BitstreamSpikeRecorder
recorder = BitstreamSpikeRecorder(dt_ms=1.0)
for _ in range(1000):
spike = neuron.step(current)
recorder.record(spike)
print(f"Total spikes: {recorder.total_spikes()}")
print(f"Firing rate: {recorder.firing_rate_hz():.1f} Hz")
The recorder rejects non-binary spikes, negative dt_ms values, and non-positive
histogram bin counts. dt_ms=0.0 is still accepted for legacy dry-run callers and
returns a firing rate of 0.0.
Polyglot Mirrors¶
The Python API is the canonical recorder surface. Parity helper surfaces are kept
in accel/julia/recorders/spike_recorder.jl,
accel/rust/safety/spike_recorder.rs, and
accel/mojo/kernels/spike_recorder.mojo for backend validation and low-level
firing-rate/ISI helpers. The Rust safety mirror owns crate-level unit tests; the
Julia and Mojo mirrors are syntax-checked in the recorder maintenance lane.
sc_neurocore.recorders.spike_recorder.BitstreamSpikeRecorder
dataclass
¶
Record a binary spike train and compute basic spike statistics.
Parameters¶
dt_ms:
Duration represented by one recorded sample in milliseconds. A value of
0.0 is accepted for legacy zero-duration dry runs and produces a
firing rate of 0.0.
spikes:
Existing spike samples to seed the recorder with. Values must be binary
integers where 1 means a spike occurred at that sample.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
__post_init__()
¶
Validate seeded recorder state.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
42 43 44 45 46 47 | |
record(spike)
¶
Append one binary spike sample.
Parameters¶
spike:
Binary sample to record. 1 represents a spike and 0
represents silence for the current sample.
Raises¶
ValueError
If spike is not 0 or 1.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
reset()
¶
Remove all recorded spike samples while preserving dt_ms.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
71 72 73 | |
as_array()
¶
Return the recorded spike train as a NumPy uint8 array.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
75 76 77 | |
total_spikes()
¶
Return the number of recorded spike samples equal to 1.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
79 80 81 | |
firing_rate_hz()
¶
Return the mean firing rate in hertz.
The rate is computed as total_spikes / duration_seconds. Empty
recordings and legacy dt_ms == 0.0 dry runs return 0.0.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
83 84 85 86 87 88 89 90 91 92 93 94 95 96 | |
isi_histogram(bins=10)
¶
Compute a histogram of inter-spike intervals in milliseconds.
Parameters¶
bins: Number of histogram bins. Must be positive.
Returns¶
hist: Histogram counts. bin_edges: Bin edges (ms).
Raises¶
ValueError
If bins is less than one.
Source code in src/sc_neurocore/recorders/spike_recorder.py
| Python | |
|---|---|
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |