# plotting brain states - beta, alpha, theta, etc. over time

I tried out another EEG product that plotted a graph like this over time of gamma, beta, alpha, theta, delta. I it possible to do something like this with openBCI without programming?

I am aware of the playback feature, FFT plot, and the bandpower graphs, but looking for something that would show gamma, beta, alpha, theta, delta over the entire time of a session - usually 15 mins to 1 to 2 hours.

Thanks a lot!

## Comments

There are many Python tutorials online. The Brainflow example programs show how to compute band powers:

https://brainflow.readthedocs.io/en/stable/Examples.html#python-band-power

You could modify that simple program to have a loop instead of a one-time calculation. And in the loop you would insert a delay (say some number of seconds or even longer: 1 minute or 10 minutes), then print a line containing the band powers as 5 numbers per line. Saving the printed values to a file. You can then import that text file into any spreadsheet program and produce a graph.

The graph example you show seems to operating at ten, twenty, or more samples per minute. This would generate a lot of data, so you may want to use larger sample intervals.

At the top of the example program, you need to change the

`board_id`

to match your device.https://brainflow.readthedocs.io/en/stable/SupportedBoards.html#ganglion

William

Thank you, William, for the links.

My tasks are fairly simple at this point, however, and thus, I would like to see if I can do what I am after without learning a programming language.

I opened a session recording (csv file) in excel and see that the two channels I was sampling 1 and 2 are in columns "EXG Channel 0" and "EXG Channel 1", respectively. Let me know if this is incorrect. See attached for the Excel file.

The OpenBCI GUI takes solely the contents of these columns (and maybe the time column in addition?) to generate the Band Power and FFT Plot during playback. My guess is that to plot the praph I am after I'd need to simply extract the

band powerat every row of each brain state (gamma, beta, alpha, theta, delta) by applying a formula to a cell in "EXG Channel 0" and perhaps the time stamp of it. So for, example, column AA could have "gamma power", column AB could have "beta power", and so on to "delta power"Do you know what that formula is?

I can then manipulate the results futher and plot a graph I posted in the initial post. This would be a static praph, of course, not a live one.

Thanks a lot!

Thank you, William, for the links.

My tasks are fairly simple at this point, however, and thus, I would like to see if I can do what I am after without learning a programming language.

I opened a session recording (csv file) in excel and see that the two channels I was sampling 1 and 2 are in columns "EXG Channel 0" and "EXG Channel 1", respectively. Let me know if this is incorrect. See attached for the Excel file.

The OpenBCI GUI takes solely the contents of these columns (and maybe the time column in addition?) to generate the Band Power and FFT Plot during playback. My guess is that to plot the praph I am after I'd need to simply extract the

band powerat every row of each brain state (gamma, beta, alpha, theta, delta) by applying a formula to a cell in "EXG Channel 0" and perhaps the time stamp of it. So for, example, column AA could have "gamma power", column AB could have "beta power", and so on to "delta power"Do you know what that formula is?

I can then manipulate the results futher and plot a graph I posted in the initial post. This would be a static praph, of course, not a live one.

Thanks a lot!

Thank you, William, for the links.

My tasks are fairly simple at this point, however, and thus, I would like to see if I can do what I am after without learning a programming language. It seems that I should be able to calculate the numeric inputs for the graph in Excel buy applying a relatively straight forward calculation to the contents of recorded session.

I opened a session recording (csv file) in Excel and see that the two channels I was sampling 1 and 2 are in columns "EXG Channel 0" and "EXG Channel 1", respectively. Let me know if this is incorrect. See attached image of the Excel file.

The OpenBCI GUI takes solely the contents of these columns (and maybe the time column in addition?) to generate the Band Power and FFT Plot during playback, as far as I can tell. My guess is that to plot the praph I am after I'd need to simply extract the

band powerat every row of each brain state (gamma, beta, alpha, theta, delta) by applying a formula to a cell in "EXG Channel 0" and perhaps the time stamp of it. So for, example, Excel column AA could have "gamma power", column AB could have "beta power", and so on to "delta power"Do you know what that formula is? That is - how do I take the contents of cell B7, and convert it to power of gamma frequency, for example?

I can then manipulate the results futher and plot a graph I posted in the initial post. This would be a static graph, of course, not a live one.

Thanks a lot!

EEG data consists of 'samples', taken at the 'sample rate', which is 200 Hz for Ganglion.

The 'minimal' required steps to do the DSP Digital Signal Processing are shown in that Python program. As you can see there are a significant number of steps, such as computing the FFT, and then separating that into frequency bands corresponding to each desired brainwave band (alpha, beta, etc.)

In the Python example program these various steps are done by 'function calls' on DSP library routines. A huge amount of sub-steps are performed in each of these calls. For example the FFT call:

`psd = DataFilter.get_psd_welch(data[eeg_channel], nfft, nfft // 2, sampling_rate, WindowOperations.BLACKMAN_HARRIS.value)`

Internally does thousands of operations / steps to compute the FFT. This is not 'impossible' in Excel but it is not pretty and much more complex.

https://hackaday.com/2020/11/13/dsp-spreadsheet-the-goertzel-algorithm-is-fouriers-simpler-cousin/

William

https://www.google.com/search?q=python+dsp+tutorial

Thanks, William! I'll take a look at the Excel examples in depth a bit later tomorrow.

For now, though, what unit of measurement is used for data in columns B ("EXG Channel 0") and C ("EXG Channel 1") of the spreasheet image I posted?

Also, any idea on why column C values are so much higher then column B?

The recording files use microvolts. Did the EEG Time Series on the screen during recording appear to be 'railed' or not? The recording file is RAW with no pre-filtering.

It is recommended to remove the DC offset with a filter see,

https://openbci.com/forum/index.php?p=/discussion/201/large-millivolt-data-values-fbeeg-full-band-eeg

Yet another option you have, is to use the GUI Networking Widget to send Band Power data out via the protocol called LSL.

https://docs.openbci.com/Software/OpenBCISoftware/GUIWidgets/#networking

https://docs.openbci.com/Software/OpenBCISoftware/GUIWidgets/#lsl

https://github.com/OpenBCI/OpenBCI_GUI/blob/master/Networking-Test-Kit/LSL/lslStreamTest_BandPowerAllChannels.py

https://github.com/labstreaminglayer/pylsl/blob/master/pylsl/examples/ReceiveData.py

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