Brain-computer interface with chat ChatGPT in real-time with PIEEG

Hello, today I want to show a simple example of how to use  ChatGPT and brain-computer interface for real-time feature extraction from EEG signals without programming skills to detect stress levels.

My goal is not to show how stress can be detected in practice, but the main task is to show how ChatGPT can be used.  In the future, those who are interested can try to implement their ideas. (so everything here for for educational purposes only on how to connect BCI to ChatGPT, this example just clearly demonstrates how it can work in practice).
As a Brain-Computer interface I use a PiEEG (link) device, it is 8 channels shield for RaspberryPi

PiEEG low-cost device to measure EEG, EMG, EKG

PiEEG low-cost device to measure biodata

PiEEG measures microvolts, it is very noisy data, which is subject to various noises, movements, and electromagnetic. It is quite difficult to find data in practice due to the fact that the nature of the signal is extremely not stationary, but it is precisely the AI ​​that can solve this problem.

I believe that don’t need to explain what is it ChatGPT so let’s start

1. We need to login to OpenAI and receive an API key to establish a connection for our script (Python IDE).  I like this manual  (link) where it is shown in more than detail step by step how it is done.

The first make test of OpenAI (details about OpenAI, how to receive API key) and male test for your response. We can male practice directly in ChatGPT, to receive a necessary answer. In my case, I need to receive only one word about stress level – “stress, neutral, happy”

I practical in ChatGPT and found that the next response works for me
Based on the power in alpha rhythm for one EEG channel with fps 250 = [50,60,70,50,60,80,90,50,60], please evaluate my stress level and respond with one of the following words: [calm, neutral, stress]

My plan, send massive with information about power in alpha rhythm from one channel and receive a response from ChatGPT about my current stage. So now, just send some random data, and let’s see, what we receive in Python.

The source for the script is here https://github.com/pieeg-club/ChatGPT_PiEEG

So, it works I received neutral, so move forward.

Next, I used this created script in open source to start reading data in PiEEG, for signal processing I used a band-pass filter and only power frequency analysis to calculate power in theta rhythm (12-14 Hz) for EEG data every 3 sec, collect massive with 15 data and send it to ChatGPT. Of course, one channel is not enough for clear stress detection, but increasing the number of channels in the future is not a problem, for now, we will do it this way.

So chatGPT is sure that I am a happy person, well done.

Of course, we can or need to provide more specific information and instructions for ChatGPT about how to calculate stress level and some more technical details about measurement process, electrode location, SNR, fps, health condition, personal data more datasets, etc. So it is a very huge area for research.  Also, we can ask, about the recommendation

The most interesting moment was that all this script also can be created by ChatGPT, I checked it. So it is possible to do without programming skills.

So now, connect the dry electrode to PiEEG and launch the script.
Just one small script allows you to establish direct communication between AI and you.

Here you can find a short video with an introduction to this process.

Would you like to receive news?