GET_SPIKE
Syntax
GET_SPIKE <ch> or GET_SPIKE ALL
Description
Reads the spike statistics of one channel, or a summary of all channels. Spike detection must have been started with SPIKE ON.
Response
One channel:
SPIKE <ch> en=<0|1> count=<n> rate_1s=<Hz> rate_ring=<Hz> last_ts=<ms> last_amp=<n> ring=<n> ready=<0|1>
| Field | Description |
|---|---|
en | 1 if detection is enabled on this channel. |
count | Total spikes since SPIKE ON. |
rate_1s | Spike rate over the last second (Hz). |
rate_ring | Spike rate over a longer rolling window (Hz). |
last_ts | Time of the last spike, in ms since START. |
last_amp | Amplitude of the last spike (raw counts). |
ring | Number of spikes in the rolling window. |
ready | 1 once at least one spike has been detected. |
All channels, on one line:
SPIKE_ALL en=<0|1> k=<k> pol=<pol> mask=0x<hex> <ch>:<count>/<rate_1s>/<rate_ring> ...
When detection is on, only the channels of the mask are listed.
Errors
| Reply | Condition |
|---|---|
ERR GET_SPIKE bad_arg | Missing argument or channel out of range. |
Example
get_spike.py
from hmcls_udp import Board
board = Board("192.168.1.11")
line = board.query("GET_SPIKE ALL")[0]
for item in line.split()[5:]:
ch, stats = item.split(":")
count, r1s, rring = stats.split("/")
print(f"channel {ch}: {count} spikes, {r1s} Hz")