Help with Adding Custom Python Script for Neurofeedback Study

Come here to discuss about OpenViBE in general!
Post Reply
AnnaV
Posts: 3
Joined: Fri Apr 16, 2021 6:19 am

Help with Adding Custom Python Script for Neurofeedback Study

Post by AnnaV »

Hello,

I am currently setting up my university's first neurofeedback study! We are using BrainVision Products (electrodes>actiCHamp>BrainVision Recorder>OpenVibe via remote data access), if that is helpful to know.

Once we get our footing, we will want to do something a bit more complex than this, but for now we are trying to set up a 20-min neurofeedback protocol where alpha power inhibition is rewarded (and increases in alpha power are punished). We want to set 1 second time windows, further divided into 200 ms bins for (power-related) thresholding purposes.

So far, I have successfully acquired the EEG signal, set a reference and active channel (only interested in one for now), filtered out 10-13 Hz activity (alpha), and set time-based epoching to 1 second. At this point, I run into two problems:
1. I am not sure if it is correct to add another time-based epoching box to further divide each 1 second window into 200 ms bins. Being able to analyze across each window and each bin is important, I do not want everything just separated into 200 ms windows.
2. This is probably where I need to specify our threshold criteria and where a live power analysis needs to be done. Basically, we want to compare the most recent full 1 second of EEG activity to the second before it (so two 1-second windows, each comprised of 5 200-ms bins). We would need to calculate alpha power for each bin. So, for example, if 3/5 of the bins or more in the most recent 1-second window have a lower alpha power value than any of the bins in the preceding 1-second window, they will get a visual reward (in the form of a bar moving up the screen). I do not believe the built-in fast fourier transform box will suffice for this, as it seems to just display the power values. It looks like it needs to be the last step in the pipeline (more or less).
Given these two problems, I believe the solution would be to insert custom code that will epoch the data as we desire and allow us to get ongoing an alpha power values for each bin.
So, my primary question is, how can I connect OpenVibe to a python environment/library? We have Anaconda (which includes SciPy), but I am having a hard time following the tutorials and some of the previous posts about this, as I do not personally have too much coding experience. Also, does anyone have a recommendation of how to best do the power analysis (FFT vs. wavelet analysis, etc.)? I have peaked at the motor imagery neurofeedback scenario, and it is not apparently clear to me how they did their power analysis.
If someone could offer any (very simplified) advice, that would be greatly appreciated!

Thank you!!
Anna

Thomas
Posts: 210
Joined: Wed Mar 04, 2020 3:38 pm

Re: Help with Adding Custom Python Script for Neurofeedback Study

Post by Thomas »

Hi Anna,

Thanks for your message, it's a really interesting topic.

I will try to bring some answers where I can:

1. Having two time-based epoching shouldn't be a problem. Depending on the intervals setting use for each, it could have an impact on the amount of samples processed.

2. You can use python scripting in OpenViBE thanks to the python box. Make sure you have the right version of python installed. Informations here.
The page also contains the rules to follow in order for your python script to communicate with the other boxes of the scenario. I know, another tutorail...
You may find easier to look at already made scripts, such as the ones shipped with OpenViBE (in AppData\Roaming\openvibe-x.x.x\scenarios\box-tutorials\python3) to understand their functioning.
Don't hesitate to ask questions on the forum if you get stuck.

In the neurofeedback scenario provided with OpenViBE, the calculation of the power of the signal in a specific frequency band is performed with a temporal filter to select the frequency (you've done that already), and then with the Simple DSP and simple average boxes, squaring the signal and then averaging to get the power. It is not necessary to go through a FFT.

Hope this helps.

Cheers,
Thomas

Post Reply