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:
| Channel | Flag |
|---|---|
| 0 | 33 |
| 1 | 34 |
| … | … |
| 31 | 64 |
Block Reference
Headstage
SPIKE onk4.0polarityNEGrefractory1.5 msmaskALL
Headstage
SPIKE off
Headstage
SPIKE maskmask0x0000000F
Acquisition
SPIKE getch0→ ampamplitudetstimestamp
| Block | Section | Description |
|---|---|---|
| SPIKE on | Loop | Starts detection (k, polarity, refractory, channel mask) |
| SPIKE off | Loop | Stops detection and clears spike state |
| SPIKE mask | Loop | Updates channel mask without restarting detection |
| SPIKE get | Loop | Reads last spike on a channel → amplitude + timestamp |
SPIKE on parameters
| Parameter | Default | Description |
|---|---|---|
| k | 4.0 | Threshold multiplier. Higher → fewer but more certain spikes. |
| Polarity | NEG | NEG, POS, or BOTH |
| Refractory (ms) | 1.5 | Minimum gap between spikes on the same channel |
| Channel mask | ALL | ALL, 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.
0x0000000Ffor channels 0–3. - RMS settling: allow a few seconds after
RMS onbefore starting spike detection. UseRMS ready → varto detect when the window is full.