Skip to content

Commit e5a15c0

Browse files
authored
Merge pull request #1064 from OpenBCI/brainflow5
update brainflow to 5.0.1
2 parents 52447b7 + c4c79ad commit e5a15c0

9 files changed

Lines changed: 47 additions & 53 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# v5.1.1
2+
3+
### Bug Fixes
4+
5+
### Improvements
6+
* Update to BrainFlow 5.0.1
7+
18
# v5.1.0
29

310
### Bug Fixes

OpenBCI_GUI/DataProcessing.pde

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,29 +124,26 @@ class DataProcessing {
124124

125125
//Apply BandStop filter if the filter should be active on this channel
126126
if (filterSettings.values.bandStopFilterActive[Ichan].isActive()) {
127-
double chebyshevRipple = filterSettings.values.bandStopFilterType[Ichan] == BrainFlowFilterType.CHEBYSHEV ? 1.0d : 0d;
128127
DataFilter.perform_bandstop(
129128
tempArray,
130129
currentBoard.getSampleRate(),
131-
filterSettings.values.bandStopCenterFreq[Ichan],
132-
filterSettings.values.bandStopWidth[Ichan],
130+
filterSettings.values.bandStopStartFreq[Ichan],
131+
filterSettings.values.bandStopStopFreq[Ichan],
133132
filterSettings.values.bandStopFilterOrder[Ichan].getValue(),
134133
filterSettings.values.bandStopFilterType[Ichan].getValue(),
135-
chebyshevRipple);
134+
1.0);
136135
}
137136

138137
//Apply BandPass filter if the filter should be active on this channel
139138
if (filterSettings.values.bandPassFilterActive[Ichan].isActive()) {
140-
Pair<Double, Double> centerAndWidth = filterSettings.values.getBandPassCenterAndWidth(Ichan);
141-
double chebyshevRipple = filterSettings.values.bandPassFilterType[Ichan] == BrainFlowFilterType.CHEBYSHEV ? 1.0d : 0d;
142139
DataFilter.perform_bandpass(
143140
tempArray,
144141
currentBoard.getSampleRate(),
145-
centerAndWidth.getLeft(),
146-
centerAndWidth.getRight(),
142+
filterSettings.values.bandPassStartFreq[Ichan],
143+
filterSettings.values.bandPassStopFreq[Ichan],
147144
filterSettings.values.bandPassFilterOrder[Ichan].getValue(),
148145
filterSettings.values.bandPassFilterType[Ichan].getValue(),
149-
chebyshevRipple);
146+
1.0);
150147
}
151148

152149
//Apply Environmental Noise filter on all channels. Do it like this since there are no codes for NONE or FIFTY_AND_SIXTY in BrainFlow

OpenBCI_GUI/FilterSettings.pde

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ public class FilterSettingsValues {
88
public GlobalEnvironmentalFilter globalEnvFilter;
99

1010
public FilterActiveOnChannel masterBandStopFilterActive;
11-
public double masterBandStopCenterFreq;
12-
public double masterBandStopWidth;
11+
public double masterBandStopStartFreq;
12+
public double masterBandStopStopFreq;
1313
public BrainFlowFilterType masterBandStopFilterType = BrainFlowFilterType.BUTTERWORTH;
1414
public BrainFlowFilterOrder masterBandStopFilterOrder = BrainFlowFilterOrder.TWO;
1515

1616
public FilterActiveOnChannel[] bandStopFilterActive;
17-
public double[] bandStopCenterFreq;
18-
public double[] bandStopWidth;
17+
public double[] bandStopStartFreq;
18+
public double[] bandStopStopFreq;
1919
public BrainFlowFilterType[] bandStopFilterType;
2020
public BrainFlowFilterOrder[] bandStopFilterOrder;
2121

@@ -38,19 +38,19 @@ public class FilterSettingsValues {
3838

3939
//Set Master Values for all channels for BandStop Filter
4040
masterBandStopFilterActive = FilterActiveOnChannel.OFF;
41-
masterBandStopCenterFreq = 60;
42-
masterBandStopWidth = 4;
41+
masterBandStopStartFreq = 58;
42+
masterBandStopStopFreq = 62;
4343
masterBandStopFilterType = BrainFlowFilterType.BUTTERWORTH;
4444
masterBandStopFilterOrder = BrainFlowFilterOrder.FOUR;
4545
//Create and assign master value to all channels
4646
bandStopFilterActive = new FilterActiveOnChannel[channelCount];
47-
bandStopCenterFreq = new double[channelCount];
48-
bandStopWidth = new double[channelCount];
47+
bandStopStartFreq = new double[channelCount];
48+
bandStopStopFreq = new double[channelCount];
4949
bandStopFilterType = new BrainFlowFilterType[channelCount];
5050
bandStopFilterOrder = new BrainFlowFilterOrder[channelCount];
5151
Arrays.fill(bandStopFilterActive, masterBandStopFilterActive);
52-
Arrays.fill(bandStopCenterFreq, masterBandStopCenterFreq);
53-
Arrays.fill(bandStopWidth, masterBandStopWidth);
52+
Arrays.fill(bandStopStartFreq, masterBandStopStartFreq);
53+
Arrays.fill(bandStopStopFreq, masterBandStopStopFreq);
5454
Arrays.fill(bandStopFilterType, masterBandStopFilterType);
5555
Arrays.fill(bandStopFilterOrder, masterBandStopFilterOrder);
5656

@@ -73,13 +73,6 @@ public class FilterSettingsValues {
7373
Arrays.fill(bandPassFilterType, masterBandPassFilterType);
7474
Arrays.fill(bandPassFilterOrder, masterBandPassFilterOrder);
7575
}
76-
77-
//Called in data processing to convert start & stop frequencies to center & width frequencies. Makes it simpler for users on the front-end.
78-
public Pair<Double, Double> getBandPassCenterAndWidth(int chan) {
79-
double centerFreq = (bandPassStartFreq[chan] + bandPassStopFreq[chan]) / 2.0;
80-
double bandWidth = bandPassStopFreq[chan] - bandPassStartFreq[chan];
81-
return new ImmutablePair<Double, Double>(centerFreq, bandWidth);
82-
}
8376
}
8477

8578
class FilterSettings {

OpenBCI_GUI/FilterUI.pde

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ class FilterUIPopup extends PApplet implements Runnable {
249249
firstColumnHeader = "Start (Hz)";
250250
secondColumnHeader = "Stop (Hz)";
251251
} else if (filterSettings.values.brainFlowFilter == BFFilter.BANDSTOP) {
252-
firstColumnHeader = "Center (Hz)";
253-
secondColumnHeader = "Width (Hz)";
252+
firstColumnHeader = "Start (Hz)";
253+
secondColumnHeader = "Stop (Hz)";
254254
}
255255
text(firstColumnHeader, columnObjX[1], headerHeight + sm_spacer, textfieldWidth, headerHeight);
256256
text(secondColumnHeader, columnObjX[2], headerHeight + sm_spacer, textfieldWidth, headerHeight);
@@ -432,8 +432,8 @@ class FilterUIPopup extends PApplet implements Runnable {
432432
if (filterSettings.values.masterBandStopFilterActive == FilterActiveOnChannel.ON) {
433433
updateColor = onColor;
434434
}
435-
firstColumnTFValue = df.format(filterSettings.values.masterBandStopCenterFreq);
436-
secondColumnTFValue = df.format(filterSettings.values.masterBandStopWidth);
435+
firstColumnTFValue = df.format(filterSettings.values.masterBandStopStartFreq);
436+
secondColumnTFValue = df.format(filterSettings.values.masterBandStopStopFreq);
437437
updateFilterType = filterSettings.values.masterBandStopFilterType;
438438
updateFilterOrder = filterSettings.values.masterBandStopFilterOrder;
439439
break;
@@ -466,8 +466,8 @@ class FilterUIPopup extends PApplet implements Runnable {
466466
updateColor = offColor;
467467
}
468468
//Fetch filter values
469-
firstColumnTFValue = df.format(filterSettings.values.bandStopCenterFreq[chan]);
470-
secondColumnTFValue = df.format(filterSettings.values.bandStopWidth[chan]);
469+
firstColumnTFValue = df.format(filterSettings.values.bandStopStartFreq[chan]);
470+
secondColumnTFValue = df.format(filterSettings.values.bandStopStopFreq[chan]);
471471
//Fetch filter type
472472
updateFilterType = filterSettings.values.bandStopFilterType[chan];
473473
//Fetch order
@@ -704,9 +704,9 @@ class FilterUIPopup extends PApplet implements Runnable {
704704
switch (filterSettings.values.brainFlowFilter) {
705705
case BANDSTOP:
706706
if (isFirstColumn) {
707-
val = filterSettings.defaultValues.masterBandStopCenterFreq;
707+
val = filterSettings.defaultValues.masterBandStopStartFreq;
708708
} else {
709-
val = filterSettings.defaultValues.masterBandStopWidth;
709+
val = filterSettings.defaultValues.masterBandStopStopFreq;
710710
}
711711
break;
712712
case BANDPASS:
@@ -726,11 +726,11 @@ class FilterUIPopup extends PApplet implements Runnable {
726726
switch (filterSettings.values.brainFlowFilter) {
727727
case BANDSTOP:
728728
if (isFirstColumn) {
729-
filterSettings.values.masterBandStopCenterFreq = valAsDouble;
730-
Arrays.fill(filterSettings.values.bandStopCenterFreq, filterSettings.values.masterBandStopCenterFreq);
729+
filterSettings.values.masterBandStopStartFreq = valAsDouble;
730+
Arrays.fill(filterSettings.values.bandStopStartFreq, filterSettings.values.masterBandStopStartFreq);
731731
} else {
732-
filterSettings.values.masterBandStopWidth = valAsDouble;
733-
Arrays.fill(filterSettings.values.bandStopWidth, filterSettings.values.masterBandStopWidth);
732+
filterSettings.values.masterBandStopStopFreq = valAsDouble;
733+
Arrays.fill(filterSettings.values.bandStopStopFreq, filterSettings.values.masterBandStopStopFreq);
734734
}
735735
break;
736736
case BANDPASS:
@@ -755,9 +755,9 @@ class FilterUIPopup extends PApplet implements Runnable {
755755
switch (filterSettings.values.brainFlowFilter) {
756756
case BANDSTOP:
757757
if (isFirstColumn) {
758-
val = filterSettings.defaultValues.bandStopCenterFreq[chan];
758+
val = filterSettings.defaultValues.bandStopStartFreq[chan];
759759
} else {
760-
val = filterSettings.defaultValues.bandStopWidth[chan];
760+
val = filterSettings.defaultValues.bandStopStopFreq[chan];
761761
}
762762
break;
763763
case BANDPASS:
@@ -777,9 +777,9 @@ class FilterUIPopup extends PApplet implements Runnable {
777777
switch (filterSettings.values.brainFlowFilter) {
778778
case BANDSTOP:
779779
if (isFirstColumn) {
780-
filterSettings.values.bandStopCenterFreq[chan] = valAsDouble;
780+
filterSettings.values.bandStopStartFreq[chan] = valAsDouble;
781781
} else {
782-
filterSettings.values.bandStopWidth[chan] = valAsDouble;
782+
filterSettings.values.bandStopStopFreq[chan] = valAsDouble;
783783
}
784784
break;
785785
case BANDPASS:

OpenBCI_GUI/FocusEnums.pde

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public enum FocusXLim implements IndexingInterface
4747

4848
public enum FocusMetric implements IndexingInterface
4949
{
50-
CONCENTRATION (0, "Concentration", BrainFlowMetrics.CONCENTRATION, "Concentrating"),
51-
RELAXATION (1, "Relaxation", BrainFlowMetrics.RELAXATION, "Relaxing");
50+
CONCENTRATION (0, "Concentration", BrainFlowMetrics.MINDFULNESS, "Concentrating"),
51+
RELAXATION (1, "Relaxation", BrainFlowMetrics.RESTFULNESS, "Relaxing");
5252

5353
private int index;
5454
private String label;
@@ -92,10 +92,7 @@ public enum FocusMetric implements IndexingInterface
9292

9393
public enum FocusClassifier implements IndexingInterface
9494
{
95-
REGRESSION (0, "Regression", BrainFlowClassifiers.REGRESSION),
96-
KNN (1, "KNN", BrainFlowClassifiers.KNN),
97-
SVM (2, "SVM", BrainFlowClassifiers.SVM),
98-
LDA (3, "LDA", BrainFlowClassifiers.LDA);
95+
REGRESSION (0, "Regression", BrainFlowClassifiers.DEFAULT_CLASSIFIER);
9996

10097
private int index;
10198
private int value;

OpenBCI_GUI/Info.plist.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<key>CFBundleShortVersionString</key>
2424
<string>5</string>
2525
<key>CFBundleVersion</key>
26-
<string>5.1.0</string>
26+
<string>5.1.1</string>
2727
<key>CFBundleSignature</key>
2828
<string>????</string>
2929
<key>NSHumanReadableCopyright</key>

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ import http.requests.*;
6060
// Global Variables & Instances
6161
//------------------------------------------------------------------------
6262
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
63-
String localGUIVersionString = "v5.1.0";
64-
String localGUIVersionDate = "May 2022";
63+
String localGUIVersionString = "v5.1.1-alpha.0";
64+
String localGUIVersionDate = "July 2022";
6565
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
6666
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
6767
Boolean guiIsUpToDate;

OpenBCI_GUI/W_Focus.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,13 @@ class W_Focus extends Widget {
272272

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

277277
//Left array is Averages, right array is Standard Deviations. Update values using Averages.
278278
updateBandPowerTableValues(bands.getLeft());
279279

280280
//Keep this here
281-
double prediction = mlModel.predict(featureVector);
281+
double prediction = mlModel.predict(featureVector)[0];
282282
//println("Concentration: " + prediction);
283283

284284
//Send band power and prediction data to AuditoryNeurofeedback class
2.43 MB
Binary file not shown.

0 commit comments

Comments
 (0)