Skip to main content

Spike Detection

HMCLS monitors the acquisition stream in real time. When a channel's signal crosses the configured threshold, a spike event is recorded and the corresponding event flag is set automatically.

How It Works​

Threshold = k × σ, where σ is the per-channel RMS amplitude and k is a configurable multiplier.

RMS must be enabled first

Place RMS on in Setup before starting spike detection. Without an active RMS window, thresholds cannot be computed.

Flag Assignment​

When a spike fires on channel N (0 to channels − 1), flag 33 + N is set:

ChannelFlag
033
134
……
3164

Block Reference​

Headstage
SPIKE onk4.0polarityNEGrefractory1.5 msmaskALL
Headstage
SPIKE off
Headstage
SPIKE maskmask0x0000000F
Acquisition
SPIKE getch0→ ampamplitudetstimestamp
BlockSectionDescription
SPIKE onLoopStarts detection (k, polarity, refractory, channel mask)
SPIKE offLoopStops detection and clears spike state
SPIKE maskLoopUpdates channel mask without restarting detection
SPIKE getLoopReads last spike on a channel → amplitude + timestamp

SPIKE on parameters​

ParameterDefaultDescription
k4.0Threshold multiplier. Higher → fewer but more certain spikes.
PolarityNEGNEG, POS, or BOTH
Refractory (ms)1.5Minimum gap between spikes on the same channel
Channel maskALLALL, a hex bitmask (bit N = channel N), or a channel list

Example Program​

SETUP
Acquisition
headstage setup
Acquisition
SPEEDrate1000
Acquisition
RMS on
Acquisition
ACQ start
Headstage
SPIKE onk4.0polarityNEGrefractory1.5 msmaskALL
LOOP ~1 kHz
Control
if flagflag33modeconsume
Acquisition
SPIKE getch0→ ampamptsts
Debug
say"amp="
Debug
log variableamp

Tips​

  • Choosing k: start with 4.0 for typical extracellular recordings. Lower to 3.0 for small units; raise to 5–6 to reduce noise triggers.
  • Refractory period: 1.5 ms is appropriate for most single-unit recordings. Increase for slow-firing cells.
  • Channel mask: use a hex bitmask to monitor only specific channels, e.g. 0x0000000F for channels 0–3.
  • RMS settling: allow a few seconds after RMS on before starting spike detection. Use RMS ready → var to detect when the window is full.