Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update brainflow to 5.0.1 #1064

Merged
merged 3 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v5.1.1

### Bug Fixes

### Improvements
* Update to BrainFlow 5.0.1

# v5.1.0

### Bug Fixes
Expand Down
15 changes: 6 additions & 9 deletions OpenBCI_GUI/DataProcessing.pde
Original file line number Diff line number Diff line change
Expand Up @@ -124,29 +124,26 @@ class DataProcessing {

//Apply BandStop filter if the filter should be active on this channel
if (filterSettings.values.bandStopFilterActive[Ichan].isActive()) {
double chebyshevRipple = filterSettings.values.bandStopFilterType[Ichan] == BrainFlowFilterType.CHEBYSHEV ? 1.0d : 0d;
DataFilter.perform_bandstop(
tempArray,
currentBoard.getSampleRate(),
filterSettings.values.bandStopCenterFreq[Ichan],
filterSettings.values.bandStopWidth[Ichan],
filterSettings.values.bandStopStartFreq[Ichan],
filterSettings.values.bandStopStopFreq[Ichan],
filterSettings.values.bandStopFilterOrder[Ichan].getValue(),
filterSettings.values.bandStopFilterType[Ichan].getValue(),
chebyshevRipple);
1.0);
}

//Apply BandPass filter if the filter should be active on this channel
if (filterSettings.values.bandPassFilterActive[Ichan].isActive()) {
Pair<Double, Double> centerAndWidth = filterSettings.values.getBandPassCenterAndWidth(Ichan);
double chebyshevRipple = filterSettings.values.bandPassFilterType[Ichan] == BrainFlowFilterType.CHEBYSHEV ? 1.0d : 0d;
DataFilter.perform_bandpass(
tempArray,
currentBoard.getSampleRate(),
centerAndWidth.getLeft(),
centerAndWidth.getRight(),
filterSettings.values.bandPassStartFreq[Ichan],
filterSettings.values.bandPassStopFreq[Ichan],
filterSettings.values.bandPassFilterOrder[Ichan].getValue(),
filterSettings.values.bandPassFilterType[Ichan].getValue(),
chebyshevRipple);
1.0);
}

//Apply Environmental Noise filter on all channels. Do it like this since there are no codes for NONE or FIFTY_AND_SIXTY in BrainFlow
Expand Down
27 changes: 10 additions & 17 deletions OpenBCI_GUI/FilterSettings.pde
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ public class FilterSettingsValues {
public GlobalEnvironmentalFilter globalEnvFilter;

public FilterActiveOnChannel masterBandStopFilterActive;
public double masterBandStopCenterFreq;
public double masterBandStopWidth;
public double masterBandStopStartFreq;
public double masterBandStopStopFreq;
public BrainFlowFilterType masterBandStopFilterType = BrainFlowFilterType.BUTTERWORTH;
public BrainFlowFilterOrder masterBandStopFilterOrder = BrainFlowFilterOrder.TWO;

public FilterActiveOnChannel[] bandStopFilterActive;
public double[] bandStopCenterFreq;
public double[] bandStopWidth;
public double[] bandStopStartFreq;
public double[] bandStopStopFreq;
public BrainFlowFilterType[] bandStopFilterType;
public BrainFlowFilterOrder[] bandStopFilterOrder;

Expand All @@ -38,19 +38,19 @@ public class FilterSettingsValues {

//Set Master Values for all channels for BandStop Filter
masterBandStopFilterActive = FilterActiveOnChannel.OFF;
masterBandStopCenterFreq = 60;
masterBandStopWidth = 4;
masterBandStopStartFreq = 58;
masterBandStopStopFreq = 62;
masterBandStopFilterType = BrainFlowFilterType.BUTTERWORTH;
masterBandStopFilterOrder = BrainFlowFilterOrder.FOUR;
//Create and assign master value to all channels
bandStopFilterActive = new FilterActiveOnChannel[channelCount];
bandStopCenterFreq = new double[channelCount];
bandStopWidth = new double[channelCount];
bandStopStartFreq = new double[channelCount];
bandStopStopFreq = new double[channelCount];
bandStopFilterType = new BrainFlowFilterType[channelCount];
bandStopFilterOrder = new BrainFlowFilterOrder[channelCount];
Arrays.fill(bandStopFilterActive, masterBandStopFilterActive);
Arrays.fill(bandStopCenterFreq, masterBandStopCenterFreq);
Arrays.fill(bandStopWidth, masterBandStopWidth);
Arrays.fill(bandStopStartFreq, masterBandStopStartFreq);
Arrays.fill(bandStopStopFreq, masterBandStopStopFreq);
Arrays.fill(bandStopFilterType, masterBandStopFilterType);
Arrays.fill(bandStopFilterOrder, masterBandStopFilterOrder);

Expand All @@ -73,13 +73,6 @@ public class FilterSettingsValues {
Arrays.fill(bandPassFilterType, masterBandPassFilterType);
Arrays.fill(bandPassFilterOrder, masterBandPassFilterOrder);
}

//Called in data processing to convert start & stop frequencies to center & width frequencies. Makes it simpler for users on the front-end.
public Pair<Double, Double> getBandPassCenterAndWidth(int chan) {
double centerFreq = (bandPassStartFreq[chan] + bandPassStopFreq[chan]) / 2.0;
double bandWidth = bandPassStopFreq[chan] - bandPassStartFreq[chan];
return new ImmutablePair<Double, Double>(centerFreq, bandWidth);
}
}

class FilterSettings {
Expand Down
32 changes: 16 additions & 16 deletions OpenBCI_GUI/FilterUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@ class FilterUIPopup extends PApplet implements Runnable {
firstColumnHeader = "Start (Hz)";
secondColumnHeader = "Stop (Hz)";
} else if (filterSettings.values.brainFlowFilter == BFFilter.BANDSTOP) {
firstColumnHeader = "Center (Hz)";
secondColumnHeader = "Width (Hz)";
firstColumnHeader = "Start (Hz)";
secondColumnHeader = "Stop (Hz)";
}
text(firstColumnHeader, columnObjX[1], headerHeight + sm_spacer, textfieldWidth, headerHeight);
text(secondColumnHeader, columnObjX[2], headerHeight + sm_spacer, textfieldWidth, headerHeight);
Expand Down Expand Up @@ -432,8 +432,8 @@ class FilterUIPopup extends PApplet implements Runnable {
if (filterSettings.values.masterBandStopFilterActive == FilterActiveOnChannel.ON) {
updateColor = onColor;
}
firstColumnTFValue = df.format(filterSettings.values.masterBandStopCenterFreq);
secondColumnTFValue = df.format(filterSettings.values.masterBandStopWidth);
firstColumnTFValue = df.format(filterSettings.values.masterBandStopStartFreq);
secondColumnTFValue = df.format(filterSettings.values.masterBandStopStopFreq);
updateFilterType = filterSettings.values.masterBandStopFilterType;
updateFilterOrder = filterSettings.values.masterBandStopFilterOrder;
break;
Expand Down Expand Up @@ -466,8 +466,8 @@ class FilterUIPopup extends PApplet implements Runnable {
updateColor = offColor;
}
//Fetch filter values
firstColumnTFValue = df.format(filterSettings.values.bandStopCenterFreq[chan]);
secondColumnTFValue = df.format(filterSettings.values.bandStopWidth[chan]);
firstColumnTFValue = df.format(filterSettings.values.bandStopStartFreq[chan]);
secondColumnTFValue = df.format(filterSettings.values.bandStopStopFreq[chan]);
//Fetch filter type
updateFilterType = filterSettings.values.bandStopFilterType[chan];
//Fetch order
Expand Down Expand Up @@ -704,9 +704,9 @@ class FilterUIPopup extends PApplet implements Runnable {
switch (filterSettings.values.brainFlowFilter) {
case BANDSTOP:
if (isFirstColumn) {
val = filterSettings.defaultValues.masterBandStopCenterFreq;
val = filterSettings.defaultValues.masterBandStopStartFreq;
} else {
val = filterSettings.defaultValues.masterBandStopWidth;
val = filterSettings.defaultValues.masterBandStopStopFreq;
}
break;
case BANDPASS:
Expand All @@ -726,11 +726,11 @@ class FilterUIPopup extends PApplet implements Runnable {
switch (filterSettings.values.brainFlowFilter) {
case BANDSTOP:
if (isFirstColumn) {
filterSettings.values.masterBandStopCenterFreq = valAsDouble;
Arrays.fill(filterSettings.values.bandStopCenterFreq, filterSettings.values.masterBandStopCenterFreq);
filterSettings.values.masterBandStopStartFreq = valAsDouble;
Arrays.fill(filterSettings.values.bandStopStartFreq, filterSettings.values.masterBandStopStartFreq);
} else {
filterSettings.values.masterBandStopWidth = valAsDouble;
Arrays.fill(filterSettings.values.bandStopWidth, filterSettings.values.masterBandStopWidth);
filterSettings.values.masterBandStopStopFreq = valAsDouble;
Arrays.fill(filterSettings.values.bandStopStopFreq, filterSettings.values.masterBandStopStopFreq);
}
break;
case BANDPASS:
Expand All @@ -755,9 +755,9 @@ class FilterUIPopup extends PApplet implements Runnable {
switch (filterSettings.values.brainFlowFilter) {
case BANDSTOP:
if (isFirstColumn) {
val = filterSettings.defaultValues.bandStopCenterFreq[chan];
val = filterSettings.defaultValues.bandStopStartFreq[chan];
} else {
val = filterSettings.defaultValues.bandStopWidth[chan];
val = filterSettings.defaultValues.bandStopStopFreq[chan];
}
break;
case BANDPASS:
Expand All @@ -777,9 +777,9 @@ class FilterUIPopup extends PApplet implements Runnable {
switch (filterSettings.values.brainFlowFilter) {
case BANDSTOP:
if (isFirstColumn) {
filterSettings.values.bandStopCenterFreq[chan] = valAsDouble;
filterSettings.values.bandStopStartFreq[chan] = valAsDouble;
} else {
filterSettings.values.bandStopWidth[chan] = valAsDouble;
filterSettings.values.bandStopStopFreq[chan] = valAsDouble;
}
break;
case BANDPASS:
Expand Down
9 changes: 3 additions & 6 deletions OpenBCI_GUI/FocusEnums.pde
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public enum FocusXLim implements IndexingInterface

public enum FocusMetric implements IndexingInterface
{
CONCENTRATION (0, "Concentration", BrainFlowMetrics.CONCENTRATION, "Concentrating"),
RELAXATION (1, "Relaxation", BrainFlowMetrics.RELAXATION, "Relaxing");
CONCENTRATION (0, "Concentration", BrainFlowMetrics.MINDFULNESS, "Concentrating"),
RELAXATION (1, "Relaxation", BrainFlowMetrics.RESTFULNESS, "Relaxing");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should update the text displayed in this dropdown. Concentration -> Mindfulness etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it and decided to keep it as before to dont confuse anybody, its technically the same metric as before but with different name


private int index;
private String label;
Expand Down Expand Up @@ -92,10 +92,7 @@ public enum FocusMetric implements IndexingInterface

public enum FocusClassifier implements IndexingInterface
{
REGRESSION (0, "Regression", BrainFlowClassifiers.REGRESSION),
KNN (1, "KNN", BrainFlowClassifiers.KNN),
SVM (2, "SVM", BrainFlowClassifiers.SVM),
LDA (3, "LDA", BrainFlowClassifiers.LDA);
REGRESSION (0, "Regression", BrainFlowClassifiers.DEFAULT_CLASSIFIER);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Andrey1994 What happened to the other classifiers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little silly to have a dropdown now if there is only one option. 😕


private int index;
private int value;
Expand Down
2 changes: 1 addition & 1 deletion OpenBCI_GUI/Info.plist.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleShortVersionString</key>
<string>5</string>
<key>CFBundleVersion</key>
<string>5.1.0</string>
<string>5.1.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import http.requests.*;
// Global Variables & Instances
//------------------------------------------------------------------------
//Used to check GUI version in TopNav.pde and displayed on the splash screen on startup
String localGUIVersionString = "v5.1.0";
String localGUIVersionDate = "May 2022";
String localGUIVersionString = "v5.1.1-alpha.0";
String localGUIVersionDate = "July 2022";
String guiLatestVersionGithubAPI = "https://api.github.com/repos/OpenBCI/OpenBCI_GUI/releases/latest";
String guiLatestReleaseLocation = "https://github.com/OpenBCI/OpenBCI_GUI/releases/latest";
Boolean guiIsUpToDate;
Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/W_Focus.pde
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,13 @@ class W_Focus extends Widget {

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

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

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

//Send band power and prediction data to AuditoryNeurofeedback class
Expand Down
Binary file modified OpenBCI_GUI/libraries/brainflow/library/brainflow.jar
Binary file not shown.