Connect Brain to ChatGPT With Low-cost Brain-cmputer Interface Ironbci From Pieeg
by Roni2016 in Workshop > Science
47 Views, 1 Favorites, 0 Comments
Connect Brain to ChatGPT With Low-cost Brain-cmputer Interface Ironbci From Pieeg
Real-time emotional detection via ChatGPT (LLM) and Brain-Computer interface (EEG)
Recent studies have highlighted the efficacy of ChatGPT in emotional awareness evaluations, illustrating its potential to compete with human responses in certain contexts. Elyoseph et al. [1] showcase ChatGPT’s ability to identify and articulate emotions reflected in various behavioral scenarios, suggesting that LLMs can grasp complex emotional states in a nuanced and integrative manner. This finding reinforces the premise that AI can complement traditional models of emotional intelligence, providing a basis for utilizing such technology in practical applications like psychotherapy or emotional therapy [2]. Simultaneously, the field of BCI has significantly evolved, with various methodologies emerging to leverage electroencephalogram (EEG) signals for emotion detection. The research agenda by Yan et al. [3] outlines a framework for affective BCIs that exploits brain-computer technology to personalize emotional detection.
GitHub https://github.com/pieeg-club/ironbci/tree/master/Chat_GPT
Dataset
We used an open-source electroencephalography (EEG) dataset [4] based on the emotion stage. The dataset includes EEG recordings of 46 participants, obtained using a portable dual-channel device Biopic. The recordings were obtained during the presentation of 22 video clips to the participants, which were designed to detect different emotional responses. Along with the EEG data, a self-assessment questionnaire contains demographic information and subjective emotion ratings such as “funny”, “sad”, and “scary”. These annotations provide labels to facilitate supervised machine learning methods. Fig. schematically shows the process of collecting EEG data while viewing video clips and recording EEG data.
Materials and Methods
We used a brain-computer interface — ironbci [5], with data transmission via BLE5 to a mobile application. This is an 8-channel interface with a data acquisition rate of 250 samples with an internal noise of about 1 µV.
A standard connection with two ear-clip electrodes was used — one serving as the reference and the other as the active electrode. Since the provided dataset included only two electrodes, we also limited our recordings to two electrodes. Dry electrodes made of silver/silver chloride (Ag/AgCl) were employed, without the use of conductive gel.
ChatGPT Implementation
For data processing, we used standard functions. Starting from the raw EEG signals with a sampling rate of 250 Hz, a fourth-order Butterworth bandpass filter was applied to preserve frequencies in the range of 1 to 40 Hz, typical for EEG analysis. This step removes baseline drift and high-frequency noise. Next, spike artifacts and extreme outliers were mitigated by limiting the signal amplitude to three standard deviations from the mean, which reduced distortion caused by short-term spikes. After removing artifacts, a smoothing step using a moving average filter (window size 5) further reduced residual noise while preserving signal trends.
ChatGPT was used as a predictive tool for real-time emotional state classification. The approach integrated an external labeled dataset containing power information in the alpha frequency band, with annotated emotional categories of sad, funny, and scary. Metadata such as device specifications, sampling rate, and electrode placement were also provided to the model as contextual prompts. Real-time brain-computer interface (BCI) signals were then streamed into ChatGPT (model gpt-4o-mini), which utilized the prior dataset information to interpret and classify the emotional state in real time. This process is schematically shown in Fig
So we have 3 steps here.
Reference Data.
To send reference data to ChatGPT, we work with the following prompt:
“few_shot_examples = “””
EEG: alpha_power=0.000028 → Emotion: Scary
EEG: alpha_power=0.001195 → Emotion: Sad
EEG: alpha_power=0.001614 → Emotion: Funny”””
Data info.
Next step, send some additional information about the dataset
“It’s EEG data, 250 samples per second, power in alpha…”
Real-time data.
To transfer EEG data and receive the result, we used the following prompt for ChatGPT
“
Uses GPT to classify EEG alpha power values into discrete emotions.
Few-shot examples + dataset description are included in the prompt.
”
During testing, we collected 60 recordings: 20 during group viewings of the videos provided in the dataset, as well as additional sessions for the funny and scary categories. The results were highly dependent on the prompt; however, in our case, the accuracy exceeded 75%. Overall, the performance can be further improved with optimized prompting and refinements to the experimental setup.
Discussion
Even in this case, performance can be significantly improved by employing a deeper model, incorporating additional reference data, and increasing the number of electrodes, among other methods. The primary aim of this article, however, is to demonstrate that even with a few electrodes and an extremely limited dataset, it is possible to rapidly establish a basic model capable of extracting information from EEG signals. Further improvements could be achieved by transmitting not just single values but entire sets of values collected over longer time windows, for example, 10 seconds. Increasing the depth of the model is also essential; while we employed GPT-4 mini, higher performance would require providing more reference data and streaming larger volumes of real-time EEG input for analysis. Moreover, utilizing large language models specifically trained to interpret EEG data would likely yield substantial gains [6].
References
1. Elyoseph Z, Hadar-Shoval D, Asraf K and Lvovsky M (2023) ChatGPT outperforms humans in emotional awareness evaluations. Front. Psychol. 14:1199058. doi: 10.3389/fpsyg.2023.1199058
2. Fatahi S, Vassileva J and Roy CK (2024) Comparing emotions in ChatGPT answers and human answers to the coding questions on Stack Overflow. Front. Artif. Intell. 7:1393903. doi: 10.3389/frai.2024.1393903
3. Yan W, Liu X, Shan B, Zhang X and Pu Y (2021) Research on the Emotions Based on Brain-Computer Technology: A Bibliometric Analysis and Research Agenda. Front. Psychol. 12:771591. doi: 10.3389/fpsyg.2021.771591
4. Emotions based EEG dataset [26.08.2025]. Kaggle. https://www.kaggle.com/datasets/thejaswinishrinivas/emotions-based-eeg-dataset
5. Rakhmatulin, I. (2025). IronBCI: A Low-Cost, Open-Source BCI Platform with Mobile SDK for Rapid Neurotech Prototyping. Preprints. https://doi.org/10.20944/preprints202507.1198.v1
6. Jiang, W.-B., Wang, Y., Lu, B.-L., & Li, D. (2025). NeuroLM: A universal multi-task foundation model for bridging the gap between language and EEG signals. In The Thirteenth International Conference on Learning Representations (ICLR 2025). OpenReview. https://openreview.net/forum?id=Io9yFt7XH7