WaveDetector
Overview
Example closed-loop program
1#include <iostream>
2#include "hal.h"
3
4#define SYS_START_BUFFER 50000
5
6int main(int argc, char *argv[]) {
7 maxlab::verifyStatus(maxlab::DataStreamerFiltered_open(maxlab::FilterType::IIR));
8
9 int sampleRate = 10000;
10
11 // ignore system startup activity
12 for (int i = 0; i < SYS_START_BUFFER; i++) {
13 maxlab::FilteredFrameData frameData;
14 maxlab::Status status = maxlab::DataStreamerFiltered_receiveNextFrame(&frameData);
15
16 if (status == maxlab::Status::MAXLAB_NO_FRAME) {
17 i--;
18 continue;
19 }
20 }
21
22 char *configPath = "/home/mxwbio/config.cfg";
23
24 // window length, configuration path, burst threshold, min length, hz
25 WaveDetector wd = WaveDetector(200, configPath, 0.1, 1000, sampleRate);
26
27 // examine the culture for 20 seconds
28 for (int i = 0; i < 200000; i++) {
29 maxlab::FilteredFrameData frameData;
30 maxlab::Status status = maxlab::DataStreamerFiltered_receiveNextFrame(&frameData);
31
32 if (status == maxlab::Status::MAXLAB_NO_FRAME) {
33 i--;
34 continue;
35 }
36
37 // extend the window and check for burst waves
38 int val = wd.processFrame(frame, i + 200 + SYS_START_BUFFER);
39
40 if (val == Wave::leftToRight) {
41 cout << "Culture bursted left to right!" << endl;
42 } else if (val == Wave::rightToLeft) {
43 cout << "Culture bursted right to left!" << endl;
44 }
45 }
46
47 maxlab::verifyStatus(maxlab::DataStreamerFiltered_close());
48}
Members
-
class WaveDetector
Public Functions
-
WaveDetector()
Constructs a new Wave Detector object.
-
WaveDetector(int windowLength, const char *configPath, float threshold, int minFrames, int frameHz, float firstBurstThreshold, float burstDoneThreshold)
Constructs a new Wave Detector object and inititalizes the window.
- Parameters:
windowLength –
int
length of the windowconfigPath – c-style string containing the full path of the electrode config
threshold –
float
threshold used to check the total spike count againstminFrames –
int
minimum number of frames during which the window must be over the spike threshold in order to be considered a burstframeHz –
int
framerate, defaults to10000
. It shoud be10000
for the MaxTwo, and20000
for the MaxOnefirstBurstThreshold –
float
the amount of time (in seconds) during which the total spike count of the window cannot go over the threshold in order for the first birst to be considered done.burstDoneThreshold –
float
the amount of time (in seconds) during which the total spike count of the window cannot go over the threshold in order for the entire birst to be considered done.
-
~WaveDetector()
Destroys the Wave Detector Object.
-
ChannelWindow *getWindow()
Returns the window.
- Returns:
pointer to
ChannelWindow
-
WaveMetadata getMetadata()
Gets metadata of the Wave Detector.
- Returns:
WaveMetadata
struct
-
void shiftWindow(maxlab::FilteredFrameData frame)
Shifts the window, adding a new frame.
- Parameters:
frame –
maxlab::FilteredFrameData
frame to add to the window
-
int processFrame(maxlab::FilteredFrameData frame, int frameNo)
Processes a frame.
Shifts the window, and returns the status of the burst
- Parameters:
frame –
maxlab::FilteredFrameData
frame to processframeNo –
int
frame number whenframe
was received
- Returns:
int
-
int checkBurst(int frameNo)
Checks the direction of a burst.
- Parameters:
frameNo –
int
frame number of the most recently received frame- Returns:
int
, corresponds toenum Wave
-
WaveDetector()