MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / Graph

Class Graph

python_package/examples/plot_real_time/plot_real_time_min.py:10–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class Graph:
11 def __init__(self, board_shim):
12 self.board_id = board_shim.get_board_id()
13 self.board_shim = board_shim
14 self.exg_channels = BoardShim.get_exg_channels(self.board_id)
15 self.sampling_rate = BoardShim.get_sampling_rate(self.board_id)
16 self.update_speed_ms = 50
17 self.window_size = 4
18 self.num_points = self.window_size * self.sampling_rate
19
20 self.app = QtWidgets.QApplication([])
21 self.win = pg.GraphicsLayoutWidget(title='BrainFlow Plot', size=(800, 600), show=True)
22
23 self._init_timeseries()
24
25 timer = QtCore.QTimer()
26 timer.timeout.connect(self.update)
27 timer.start(self.update_speed_ms)
28 QtWidgets.QApplication.instance().exec()
29
30 def _init_timeseries(self):
31 self.plots = list()
32 self.curves = list()
33 for i in range(len(self.exg_channels)):
34 p = self.win.addPlot(row=i, col=0)
35 p.showAxis('left', False)
36 p.setMenuEnabled('left', False)
37 p.showAxis('bottom', False)
38 p.setMenuEnabled('bottom', False)
39 if i == 0:
40 p.setTitle('TimeSeries Plot')
41 self.plots.append(p)
42 curve = p.plot()
43 self.curves.append(curve)
44
45 def update(self):
46 data = self.board_shim.get_current_board_data(self.num_points)
47 for count, channel in enumerate(self.exg_channels):
48 # plot timeseries
49 DataFilter.detrend(data[channel], DetrendOperations.CONSTANT.value)
50 DataFilter.perform_bandpass(data[channel], self.sampling_rate, 3.0, 45.0, 2,
51 FilterTypes.BUTTERWORTH_ZERO_PHASE, 0)
52 DataFilter.perform_bandstop(data[channel], self.sampling_rate, 48.0, 52.0, 2,
53 FilterTypes.BUTTERWORTH_ZERO_PHASE, 0)
54 DataFilter.perform_bandstop(data[channel], self.sampling_rate, 58.0, 62.0, 2,
55 FilterTypes.BUTTERWORTH_ZERO_PHASE, 0)
56 self.curves[count].setData(data[channel].tolist())
57
58 self.app.processEvents()
59
60
61def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected