Acquire alpha brainwaves from openbci gui to arduino board

Shaima616Shaima616 United Arab Emirates
edited April 30 in Software

Dear OpenBCI team, 

Hope you are doing well,

I am a member of Biomedical Engineering bachelor students working at a project with your openbci headband kit , 

We are facing some difficulties with acquiring specific brainwaves data from the openbci gui to arduino board. 

I have connected the systems using ganglion board and openbci gui and did stream into our arduino board but then we were stuck. I could see the difference of arduino lights when we stream and when we stop so i know that it is indeed sent to the board.

Our project needs an output action ( for example lightening up a simple led light attached to arduino board) after detecting specific brainwaves , and turning off when detecting others , 

( we are using arduino IDE software to program)
We are having difficulties in calling out the data in the arduino program , we do not know in what format does the data come in and how can we filter specific data. 

We have researched a lot on your form and found a video of a person using openbci board targering alpha waves to light up led light but that was in 2013 and i don't even think he used openbci gui program to stream into the arduino.

We were wondering if you can assist us in the code which we want to :

  • scan through the live streamed data coming from openbci gui

  • detect alpha waves out of the data

  • trigger an action if alpha waves are detected 

Please if you may assist us in our issue as soon as possible as we have limited time and need a quick response please.

Thank you very much 

-Shyma.

Comments

  • Shaima616Shaima616 United Arab Emirates

    @retiutut , or anyone who can help please...

  • Do you have OpenBCI's GUI running on a computer connected to the board? If so, why not do all the processing on the computer that runs the OpenBCI GUI and just send the result as an on - off signal to the Arduino?

  • wjcroftwjcroft Mount Shasta, CA

    Bill, thanks.

    Yes, Shaima, the GUI Networking Widget can do all of these signal processing operations. And then send the result to your Arduino serial port.

    https://docs.openbci.com/docs/06Software/01-OpenBCISoftware/GUIWidgets#serial

    Network Guide:

    https://docs.google.com/document/d/e/2PACX-1vR_4DXPTh1nuiOwWKwIZN3NkGP3kRwpP4Hu6fQmy3jRAOaydOuEI1jket6V4V6PG4yIG15H1N7oFfdV/pub

    William

  • retiututretiutut Louisiana, USA

    Hey there Shyma,

    Check out this Instructable I made back in 2019: https://www.instructables.com/Send-Focus-Data-From-OpenBCI-GUI-to-Arduino/

    The goal of this lesson was to make BCI's accessible for middle school and high school, but there is certainly room for everyone to be creative. You will need to use GUI v4.2.0 for this tutorial to work, though a new version of the Focus widget will be in the next public release (May 2021). The old Focus widget looks for elevated Alpha waves with lowered Beta waves on Fp1 and Fp2 (left and right forehead electrodes). !

    https://github.com/OpenBCI/OpenBCI_GUI/releases/tag/v4.2.0

    We needed something more reliable than this to truly detect "Focus", so this was deprecated. New Widget uses actual machine learning for classification, and users will be able to change the algorithms used for this with a simple dropdown. https://github.com/OpenBCI/OpenBCI_GUI/pull/961

    This should get y'all up and running. If you really want to do BandPower output though, I'm sure I can help write an Arduino sketch and you would be able to use the current GUI. Though, I think using the Focus metric is easier and a great first step for everyone.

    Take Care,
    RW

  • Shaima616Shaima616 United Arab Emirates

    @Billh said:
    Do you have OpenBCI's GUI running on a computer connected to the board? If so, why not do all the processing on the computer that runs the OpenBCI GUI and just send the result as an on - off signal to the Arduino?

    Yes I do have OpenBCI's GUI running on a computer connected to arduino board, our main issue is that we don't know how to write the part of the code which calls out the data that is been sent from the GUI to the board, we can do the on-off commands but we do not know how to reference it back to( perhaps an array? )which has the streamed data.

  • Shaima616Shaima616 United Arab Emirates

    Hello! yes we have read your project (actually I have read it many times ) and we are really impressed by your work!.
    Initially we could not use it because we did not have the older openbci version and we had to mention an ongoing avaliable system in our project(because focus widget is not avaliable now). Also we thought the focus widget detects beta more than alpha(surprised) since in general alpha is for relaxation and beta is for being awake and focused.
    Then we decided to use bandpower streaming and write a code which would detect the alpha. Since we have basic coding skills we seeked help from Our lab instructor, she only encountered openbci now however she told us to try and do array command on arduino because based on https://docs.google.com/document/d/e/2PACX-1vR_4DXPTh1nuiOwWKwIZN3NkGP3kRwpP4Hu6fQmy3jRAOaydOuEI1jket6V4V6PG4yIG15H1N7oFfdV/pub the networking stream sends serial bandpower data to arduino in [1,0.000,etc.,4.000] type, then we can do a code which goes through the forth number which would be the alpha waves, however we got stuck in the code writing,
    I'm not sure if you could assist us through this, our issue now is that we just want to call out the data in the arduino program which would go through the brainwaves, and make an output[ simply light up LED light] if the amplitude of the alpha brainwaves is higher than other brainwaves ,
    or else we could try and download the old openbci gui and try the focus widget and tell in our project that there is a new version in may 2021 ,
    I'm just unsure what to do at this point because our doctor(professor) told us to write a code which would have a threshold and for example once a certain brainwave (for example alpha) is within this threshold then the light output would happen.

    @retiutut said:
    Hey there Shyma,

    Check out this Instructable I made back in 2019: https://www.instructables.com/Send-Focus-Data-From-OpenBCI-GUI-to-Arduino/

    The goal of this lesson was to make BCI's accessible for middle school and high school, but there is certainly room for everyone to be creative. You will need to use GUI v4.2.0 for this tutorial to work, though a new version of the Focus widget will be in the next public release (May 2021). The old Focus widget looks for elevated Alpha waves with lowered Beta waves on Fp1 and Fp2 (left and right forehead electrodes). !

    https://github.com/OpenBCI/OpenBCI_GUI/releases/tag/v4.2.0

    We needed something more reliable than this to truly detect "Focus", so this was deprecated. New Widget uses actual machine learning for classification, and users will be able to change the algorithms used for this with a simple dropdown. https://github.com/OpenBCI/OpenBCI_GUI/pull/961

    This should get y'all up and running. If you really want to do BandPower output though, I'm sure I can help write an Arduino sketch and you would be able to use the current GUI. Though, I think using the Focus metric is easier and a great first step for everyone.

    Take Care,
    RW

  • Shaima616Shaima616 United Arab Emirates

    Dear Mr.William,
    Yes we actually did this but we were confused on the arduino coding , how do we call the streamed data.
    Thank you

    Shyma

    @wjcroft said:
    Bill, thanks.

    Yes, Shaima, the GUI Networking Widget can do all of these signal processing operations. And then send the result to your Arduino serial port.

    https://docs.openbci.com/docs/06Software/01-OpenBCISoftware/GUIWidgets#serial

    Network Guide:

    https://docs.google.com/document/d/e/2PACX-1vR_4DXPTh1nuiOwWKwIZN3NkGP3kRwpP4Hu6fQmy3jRAOaydOuEI1jket6V4V6PG4yIG15H1N7oFfdV/pub

    William

  • retiututretiutut Louisiana, USA
    edited April 30

    Hi there,

    This could be a valuable learning opportunity in computer science. I will get a more detailed example of the data sent over serial.

    Take Care,
    RW

  • retiututretiutut Louisiana, USA
    edited April 30

    Here is an example of the GUI v5.0.4 Networking Widget BandPower data stream over Serial using Ganglion or 4 channel Synthetic mode.

    [Channel Number,Delta, Theta, Alpha, Beta, Gamma]

    [1,0.850,9.304,0.001,0.001,0.003]
    [2,0.003,0.008,79.558,0.032,0.041]
    [3,0.012,0.026,0.055,185.641,0.137]
    [4,0.009,0.098,0.085,334.509,0.602]
    [1,0.846,9.294,0.001,0.001,0.003]
    [2,0.003,0.007,79.698,0.029,0.043]
    [3,0.012,0.023,0.052,185.601,0.132]
    [4,0.007,0.109,0.095,335.999,0.594]
    [1,0.848,9.277,0.001,0.001,0.002]
    [2,0.003,0.006,79.835,0.029,0.046]
    [3,0.010,0.022,0.048,185.415,0.127]
    [4,0.008,0.120,0.109,336.958,0.584]
    [1,0.846,9.266,0.001,0.002,0.002]
    [2,0.003,0.005,79.982,0.027,0.048]
    [3,0.009,0.022,0.049,185.065,0.122]
    [4,0.009,0.133,0.106,337.276,0.568]
    

    https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/tofloat/

  • Shaima616Shaima616 United Arab Emirates

    Thank you very much ! will look into it and try what we can !

    @retiutut said:
    Here is an example of the GUI v5.0.4 Networking Widget BandPower data stream over Serial using Ganglion or 4 channel Synthetic mode.

    [Channel Number,Delta, Theta, Alpha, Beta, Gamma]

    [1,0.850,9.304,0.001,0.001,0.003]
    [2,0.003,0.008,79.558,0.032,0.041]
    [3,0.012,0.026,0.055,185.641,0.137]
    [4,0.009,0.098,0.085,334.509,0.602]
    [1,0.846,9.294,0.001,0.001,0.003]
    [2,0.003,0.007,79.698,0.029,0.043]
    [3,0.012,0.023,0.052,185.601,0.132]
    [4,0.007,0.109,0.095,335.999,0.594]
    [1,0.848,9.277,0.001,0.001,0.002]
    [2,0.003,0.006,79.835,0.029,0.046]
    [3,0.010,0.022,0.048,185.415,0.127]
    [4,0.008,0.120,0.109,336.958,0.584]
    [1,0.846,9.266,0.001,0.002,0.002]
    [2,0.003,0.005,79.982,0.027,0.048]
    [3,0.009,0.022,0.049,185.065,0.122]
    [4,0.009,0.133,0.106,337.276,0.568]
    

    https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/tofloat/

  • Shaima616Shaima616 United Arab Emirates

    Thank you very much ! we will try our best after studying the way more.

  • Generally, you take the data from the OpenBCI as above and use it and the sample rate to 1) filter the data, say excluding frequencies below 1 and above 40; 2) do a FFT of the data to get amplitudes at various frequencies; 3) "bin" the frquencies to look for a summed amplitude above a theshold 4) tell the arduino to toggle the light based on the binned FFT transform's amplitude. It's better to use the PC machine for the FFT and binning -- better memory and CPU. So why send the raw data to Arduino?

  • Shaima616Shaima616 United Arab Emirates

    Dear Billh,
    Well, we thought about streaming directly to arduino because we wanted to take real-time data that is happening to the user and then perhaps write a code which could do what you mentioned, we are researching about the possible simple ways throughout this,

    @Billh said:
    Generally, you take the data from the OpenBCI as above and use it and the sample rate to 1) filter the data, say excluding frequencies below 1 and above 40; 2) do a FFT of the data to get amplitudes at various frequencies; 3) "bin" the frquencies to look for a summed amplitude above a theshold 4) tell the arduino to toggle the light based on the binned FFT transform's amplitude. It's better to use the PC machine for the FFT and binning -- better memory and CPU. So why send the raw data to Arduino?

  • Shaima616Shaima616 United Arab Emirates
    edited May 1

    @retiutut may I ask a question please?
    for the brainwaves value, are those numbers the amplitude of each frequency ?
    and to say a certain frequency is higher than others at a certain time, what would the number approximately for that brainwave type be?

    Thank you,

    Shyma

    @retiutut said:
    Here is an example of the GUI v5.0.4 Networking Widget BandPower data stream over Serial using Ganglion or 4 channel Synthetic mode.

    [Channel Number,Delta, Theta, Alpha, Beta, Gamma]

    [1,0.850,9.304,0.001,0.001,0.003]
    [2,0.003,0.008,79.558,0.032,0.041]
    [3,0.012,0.026,0.055,185.641,0.137]
    [4,0.009,0.098,0.085,334.509,0.602]
    [1,0.846,9.294,0.001,0.001,0.003]
    [2,0.003,0.007,79.698,0.029,0.043]
    [3,0.012,0.023,0.052,185.601,0.132]
    [4,0.007,0.109,0.095,335.999,0.594]
    [1,0.848,9.277,0.001,0.001,0.002]
    [2,0.003,0.006,79.835,0.029,0.046]
    [3,0.010,0.022,0.048,185.415,0.127]
    [4,0.008,0.120,0.109,336.958,0.584]
    [1,0.846,9.266,0.001,0.002,0.002]
    [2,0.003,0.005,79.982,0.027,0.048]
    [3,0.009,0.022,0.049,185.065,0.122]
    [4,0.009,0.133,0.106,337.276,0.568]
    

    https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/tofloat/

  • Yes, if you can do digital signal processing on the Arduino fast enough, that should work. Look for a C or C++ signal processing library that runs on Arduino, if there is one.

Sign In or Register to comment.