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

Class Graph

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

Source from the content-addressed store, hash-verified

8
9
10class Graph:
11 def __init__(self, board_shim):
12 pg.setConfigOption('background', 'w')
13 pg.setConfigOption('foreground', 'k')
14
15 self.board_id = board_shim.get_board_id()
16 self.board_shim = board_shim
17 self.exg_channels = BoardShim.get_exg_channels(self.board_id)
18 self.sampling_rate = BoardShim.get_sampling_rate(self.board_id)
19 self.update_speed_ms = 50
20 self.window_size = 4
21 self.num_points = self.window_size * self.sampling_rate
22
23 self.app = QtWidgets.QApplication([])
24 self.win = pg.GraphicsLayoutWidget(title='BrainFlow Plot', size=(800, 600), show=True)
25
26 self._init_pens()
27 self._init_timeseries()
28 self._init_psd()
29 self._init_band_plot()
30
31 timer = QtCore.QTimer()
32 timer.timeout.connect(self.update)
33 timer.start(self.update_speed_ms)
34 QtWidgets.QApplication.instance().exec()
35
36 def _init_pens(self):
37 self.pens = list()
38 self.brushes = list()
39 colors = ['#A54E4E', '#A473B6', '#5B45A4', '#2079D2', '#32B798', '#2FA537', '#9DA52F', '#A57E2F', '#A53B2F']
40 for i in range(len(colors)):
41 pen = pg.mkPen({'color': colors[i], 'width': 2})
42 self.pens.append(pen)
43 brush = pg.mkBrush(colors[i])
44 self.brushes.append(brush)
45
46 def _init_timeseries(self):
47 self.plots = list()
48 self.curves = list()
49 for i in range(len(self.exg_channels)):
50 p = self.win.addPlot(row=i, col=0)
51 p.showAxis('left', False)
52 p.setMenuEnabled('left', False)
53 p.showAxis('bottom', False)
54 p.setMenuEnabled('bottom', False)
55 if i == 0:
56 p.setTitle('TimeSeries Plot')
57 self.plots.append(p)
58 curve = p.plot(pen=self.pens[i % len(self.pens)])
59 # curve.setDownsampling(auto=True, method='mean', ds=3)
60 self.curves.append(curve)
61
62 def _init_psd(self):
63 self.psd_plot = self.win.addPlot(row=0, col=1, rowspan=len(self.exg_channels) // 2)
64 self.psd_plot.showAxis('left', False)
65 self.psd_plot.setMenuEnabled('left', False)
66 self.psd_plot.setTitle('PSD Plot')
67 self.psd_plot.setLogMode(False, True)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected