Skip to content

Commit a13ba33

Browse files
committed
Display Average Band Power data from BrainFlow in the new Focus Widget
1 parent 8ca6a6f commit a13ba33

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

OpenBCI_GUI/W_Focus.pde

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class W_Focus extends Widget {
9191
dataGrid.setTableFontAndSize(p6, 10);
9292
dataGrid.setDrawTableBorder(true);
9393
dataGrid.setString("Metric Value", 0, 0);
94+
dataGrid.setString("Delta (1.5-4Hz)", 1, 0);
95+
dataGrid.setString("Theta (4-8Hz)", 2, 0);
96+
dataGrid.setString("Alpha (7.5-13Hz)", 3, 0);
97+
dataGrid.setString("Beta (13-30Hz)", 4, 0);
98+
dataGrid.setString("Gamma (30-45Hz)", 5, 0);
9499

95100
//Instantiate local cp5 for this box. This allows extra control of drawing cp5 elements specifically inside this class.
96101
focus_cp5 = new ControlP5(ourApplet);
@@ -248,9 +253,13 @@ class W_Focus extends Widget {
248253
new Integer[focusChanSelect.activeChan.size()]
249254
));
250255

256+
//Full Source Code for this method: https://github.com/brainflow-dev/brainflow/blob/c5f0ad86683e6eab556e30965befb7c93e389a3b/src/data_handler/data_handler.cpp#L1115
251257
Pair<double[], double[]> bands = DataFilter.get_avg_band_powers (dataArray, channelsInDataArray, currentBoard.getSampleRate(), true);
252258
double[] featureVector = ArrayUtils.addAll (bands.getLeft (), bands.getRight ());
253259

260+
//Left array is Averages, right array is Standard Deviations. Update values using Averages.
261+
updateBandPowerTableValues(bands.getLeft());
262+
254263
//Keep this here
255264
double prediction = mlModel.predict(featureVector);
256265
//println("Concentration: " + prediction);
@@ -264,6 +273,12 @@ class W_Focus extends Widget {
264273
}
265274
}
266275

276+
private void updateBandPowerTableValues(double[] bandPowers) {
277+
for (int i = 0; i < bandPowers.length; i++) {
278+
dataGrid.setString(df.format(bandPowers[i]), 1 + i, 1);
279+
}
280+
}
281+
267282
private void drawStatusCircle() {
268283
color fillColor;
269284
color strokeColor;

0 commit comments

Comments
 (0)