StimVector
Overview
StimVector
is a class designed to generate either regular or random stimulation patterns, which can be queried on a frame-by-frame basis. The purpose is to control stimulation delivery during closed-loop experiments depending on system state (e.g. burst detected).
The stimulation pattern is defined over a fixed-length window of time and subdivided into time bins (e.g. 1 ms), with either True or False flags denoting whether a stimulation should occur at each bin.
The pattern is: - Regular: evenly spaced stimulations (e.g. at 5 Hz) - Random: stimulation bins selected randomly, respecting the average frequency
Timeline Behavior
Below is a conceptual timeline of how stimulation decisions are made using StimVector.
Frame #: 0 10 20 30 40 50 60 70 80 90 100 ...
Bins: | | | | | | | | | | |
[ ] [X] [ ] [ ] [ ] [X] [ ] [ ] [ ] [X] [ ] ← random mode
Bins are spaced based on the interval (e.g. 0.001 sec × fps = 10 frames)
Every shuffleFrequency seconds (e.g. 5s), a new random pattern is generated
If in regular mode, stimulation occurs every framesPerStim frames
Usage Notes
stimulate(frame) should be called every frame
In random mode, it returns true if the current frame aligns with a bin and that bin is marked as true
In regular mode, it returns true every N frames, where N is derived from the desired frequency
Integration
StimVector is typically used in experiments in conjunction with burst detectors. For example:
if (previousBurst == 1) {
stimulate = rightStim.stimulate(i);
}
See Also
WaveDetector — used to determine when and where bursts occur
BurstTrainer — full experiment loop integration
Documentation note
These were initially generated by AI and then edited by hand by Wesley Clawson.