Adding FILTERS to the openBCI_GUI
nejemia
argentina
in OpenBCI_GUI
Hello everybody. Hope you are all well and taking care of yourselves.
I would like to add an additional FILTER to the standard sets already available in openBCI_GUI 4.2.0
A 13-30 Hz would do fine.
In which .pde should I look and where are the parameters to define a Bandpass filter (High order)?
Thanks a lot folks.
Nelson
Comments
Hi Nejemia,
General filters are here:
https://github.com/OpenBCI/OpenBCI_GUI/blob/master/OpenBCI_GUI/DataProcessing.pde
Widgets are the W_* files in the same folder.
William
With GUI v4, the filters use constants generated by a Matlab expression that are tailored to the sample rate. This makes it hard to add a new filter. To fix this in near future, we may switch over to use a library (such as BrainFlow) to handle filtering data.
https://github.com/OpenBCI/OpenBCI_GUI/blob/9634ae767007eaa7b0f7d888e4f56ce9886ba17c/OpenBCI_GUI/DataProcessing.pde#L387
I tried to add a 16-24 Hz bandpass filter recently, so if you need an example you can look at the link below that shows the changes I made to the widget. Note that you need access to Matlab or some other signal processing software as Richard said in order to generate the Butterworth coefficients.
https://github.com/winson-ye/OpenBCI_GUI/commit/7390dd56d25fc362a852dc76fd750bda57263adb?diff=unified
Dear All. Thanks a lot. The information provided is highly valuable! Will post my results once ready.
Dear All.
Can you help me to add a 0.5 to 15 Hz filter for the GUI 5.0.1?
We are running tests in the Hospital and I am overwhelmed with lot of other details and I am alone in this crusade.
Any "tip" on how to implement such filter will be extremely useful.
Also, I need to change the Hardware Setting defaults, to NO-BIAS and SRB1 and SRB2 both OFF.
I tried the Save button with the desired configuration but once I use the Load option on Hardware Setting, the GUI hangs (very weird).
Also, layouts and filters selected are not saved.
So, please, take a look on the Saving/Loading routines, something is behaving weird.
Thank a million !!!!
Nelson
Next version of the GUI will have updated Hardware Settings Controller. Pull Request is in progress.
Ok!
Look forward to test new version.
In reference to add a 0.5 to 15 Hz, any shortcut on how to implement it?
All the best.
@nejemia Here is the .pde file for the GUI filters, you can add an option to one of the Enums:
https://github.com/OpenBCI/OpenBCI_GUI/blob/master/OpenBCI_GUI/FilterEnums.pde
This should do what you are expecting. Hope this helps!
RW
I see.
I am a little bit confused.
The GUI 5.0.1 uses the Matlab filter design or everything is done inside BrainFlow?
If it uses Matlab, I need the coeficients for a Bandpass filter Butterworth 2nd order 0.5-15 Hz and I need to know where to add the option for the Filter Selector Widget. Is there any place I can get the coefficients without running the Matlab (I do not have the DSP Toolbox....).
But, If everything is done inside the BrainFlow, I can add my filter to the enums, but how do I implement it in the dataProcessing.pde?
OPTION: I can redefine an existing filter, for example, the 1-50 Hz and make it 0.5-15 Hz, buy I need to replace the coefficients and update the Filter Selector Widget. How do I do this?
GUI 5.0.1 now uses BrainFlow filters.
I just tested the above code change:
I think this is all that is necessary for a temporary fix. Software team has considered adding custom filters, and I will mention this to the team.
Wow, now with the BrainFlow it is a charm.
Can you share the code with the extra 0.5-15Hz filter added?
It looks nice and smooth.
I am impressed !!
Nice... Very nice indeed.
Apologize for my previous question, I did not see that you already added the 0.5-15Hz option.
It works happy.
Question.
Where are the default settings for the Hardware Configuration? I need to start with NO-BIAS, SRB2 not connected and SRB1 not connected at start up.
Nelson
Hi, novice here.
I could edit the FilterEnums.pde to add a new filter, but lost after that.
Please is there a guide that explains steps from there to having the filter available in the openBCI_GUI app?
Regards,
Stu
Add option to Filter Enum
https://github.com/OpenBCI/OpenBCI_GUI/blob/master/OpenBCI_GUI/FilterEnums.pde
Use BrainFlow doc to check usage
https://brainflow.readthedocs.io/en/stable/Examples.html#java-signal-filtering
Implement new filter in DataProcessing.pde in processChannel(). This happens for each channel. If you've simply added a value to the enum for BandStop or BandPass, this step is not necessary. Though, here you will find the code where the filter is applied to the data.
https://github.com/OpenBCI/OpenBCI_GUI/blob/4b3dfbda16b0d9239996db2c37c4f4b3b1cbf742/OpenBCI_GUI/DataProcessing.pde#L135
Option will automatically be added to Filter toggle buttons in top left of SubNav bar next to Start/Stop Stream. The callback for these buttons will increment the filter when pressed using the Enums.
https://github.com/OpenBCI/OpenBCI_GUI/blob/4b3dfbda16b0d9239996db2c37c4f4b3b1cbf742/OpenBCI_GUI/TopNav.pde#L442
Take Care,
RW