This shows you the differences between two versions of the page.
iothings:proiecte:2022:open_bci_esp32 [2023/01/19 22:19] razvan.trombitas |
iothings:proiecte:2022:open_bci_esp32 [2023/01/20 07:21] (current) razvan.trombitas |
||
---|---|---|---|
Line 2: | Line 2: | ||
Master: **ACES** \\ | Master: **ACES** \\ | ||
Student: **Razvan Trombitas** | Student: **Razvan Trombitas** | ||
+ | |||
+ | All the materials, including the source code and presentation, are [[https://drive.google.com/drive/folders/1evuBMFwSy3p-BWxp4x56hw7jAbswl1sW?usp=share_link|here]] | ||
+ | |||
+ | Demo [[https://www.youtube.com/watch?v=ifWhXjAmhn4&ab_channel=Razvan|here]] | ||
===== 1. Project overview ===== | ===== 1. Project overview ===== | ||
Line 23: | Line 27: | ||
The headset with EEG electrodes is used to place electrodes on the scalp to record brain activity. The headset is connected to the OpenBCI Cyton board via the cable to transmit the EEG signals to the board. | The headset with EEG electrodes is used to place electrodes on the scalp to record brain activity. The headset is connected to the OpenBCI Cyton board via the cable to transmit the EEG signals to the board. | ||
+ | |||
+ | The acquired EEG signal was collected from the frontal lobe and temporal lobe from both hemispheres (left and right) using 4 electrodes positioned according to the 10-20 system. The electrodes were placed on the frontal and temporal lobes of both hemispheres, with the odd numbered channels (1, 3) representing the frontal and temporal lobes of the right hemisphere, and the even numbered channels (2, 4) representing the frontal and temporal lobes of the left hemisphere. This positioning allowed for the acquisition of EEG signals from both hemispheres, providing a more comprehensive understanding of brain activity. | ||
+ | |||
+ | {{:iothings:proiecte:2022:pozitionare_electrozi.jpg?360|}} | ||
+ | |||
+ | The entire hardware setup can be seen in the following picture: | ||
+ | |||
+ | {{:iothings:proiecte:2022:setup.png?720|}} | ||
+ | |||
+ | |||
===== 3. Software ===== | ===== 3. Software ===== | ||
Line 72: | Line 86: | ||
} | } | ||
</code> | </code> | ||
+ | |||
+ | Full code representation: | ||
+ | |||
+ | {{:iothings:proiecte:2022:softdiag.png?720|}} | ||
Line 77: | Line 95: | ||
The code uses the Firebase_ESP_Client library to communicate with the Firebase Real-time Database (RTDB) to store and retrieve data. The RTDB stores the EEG data, attention, concentration, and stress levels, which are then displayed on graphs. The FirebaseAuth and FirebaseConfig classes are used to authenticate and configure the connection to the RTDB. | The code uses the Firebase_ESP_Client library to communicate with the Firebase Real-time Database (RTDB) to store and retrieve data. The RTDB stores the EEG data, attention, concentration, and stress levels, which are then displayed on graphs. The FirebaseAuth and FirebaseConfig classes are used to authenticate and configure the connection to the RTDB. | ||
+ | The web page is composed of a canvas element that is used to create a Chart.js plot to display the data, as well as a series of script tags that include the necessary libraries for Firebase and Chart.js. | ||
+ | |||
+ | Once the data is obtained, a new Chart.js plot is created by passing the canvas element and the data to the Chart() function. The type of chart used is a line chart and the data for the chart is stored in the datasets array. The labels for the x-axis are stored in the labels array. | ||
+ | |||
+ | Finally, the script updates the chart with new data by periodically reading the data from the Firebase database and updating the data in the datasets array. | ||
Line 88: | Line 111: | ||
+ | {{:iothings:proiecte:2022:webserial.jpg?720|}} | ||
+ | |||
+ | The data in Firebase has the following template: | ||
+ | |||
+ | {{:iothings:proiecte:2022:firebase_data.jpg?720|}} | ||
+ | |||
+ | {{:iothings:proiecte:2022:graph2.jpg?720|}} | ||
+ | |||
+ | {{:iothings:proiecte:2022:graph1.jpg?360|}} | ||
In addition to the real-time processing and visualization of EEG data, this project also allows for the extraction and analysis of EEG data in a post-processing manner. The OpenBCI Cyton board is able to save the EEG data in a .csv file format, which can be easily exported and analyzed using a script such as Python. By using a script, it is possible to perform more advanced and detailed analysis of the EEG data. | In addition to the real-time processing and visualization of EEG data, this project also allows for the extraction and analysis of EEG data in a post-processing manner. The OpenBCI Cyton board is able to save the EEG data in a .csv file format, which can be easily exported and analyzed using a script such as Python. By using a script, it is possible to perform more advanced and detailed analysis of the EEG data. | ||
For example, by using a script, it is possible to determine the level of correlation between multiple users or multiple EEG recordings. This can be done by comparing the EEG data of different users or recordings and calculating the correlation coefficient between them. The correlation coefficient is a measure of the linear relationship between two variables and ranges from -1 to 1. A correlation coefficient of 1 indicates a perfect positive correlation, a coefficient of -1 indicates a perfect negative correlation, and a coefficient of 0 indicates no correlation. By calculating the correlation coefficient, it is possible to determine the similarity or dissimilarity between different EEG recordings. | For example, by using a script, it is possible to determine the level of correlation between multiple users or multiple EEG recordings. This can be done by comparing the EEG data of different users or recordings and calculating the correlation coefficient between them. The correlation coefficient is a measure of the linear relationship between two variables and ranges from -1 to 1. A correlation coefficient of 1 indicates a perfect positive correlation, a coefficient of -1 indicates a perfect negative correlation, and a coefficient of 0 indicates no correlation. By calculating the correlation coefficient, it is possible to determine the similarity or dissimilarity between different EEG recordings. | ||
+ | |||
+ | Output from the Python script: | ||
+ | |||
+ | {{:iothings:proiecte:2022:corr.jpg?720|}} | ||
+ | |||
Line 98: | Line 135: | ||
Overall, this project uses several concepts of signal processing, data visualization, and microcontroller programming to create a real-time EEG monitoring system. The use of EEG technology in combination with microcontroller programming and web technologies allows for the collection, processing, and visualization of brain activity data in a convenient and accessible way. | Overall, this project uses several concepts of signal processing, data visualization, and microcontroller programming to create a real-time EEG monitoring system. The use of EEG technology in combination with microcontroller programming and web technologies allows for the collection, processing, and visualization of brain activity data in a convenient and accessible way. | ||
+ | |||
+ | This project can be improved in several ways: | ||
+ | |||
+ | * Incorporating more channels: By using more channels, the EEG data can be acquired from more regions of the brain, which will provide a more comprehensive understanding of the brain activity. | ||
+ | |||
+ | * Improving the accuracy of the calculated attention, concentration and stress levels: This can be done by implementing more advanced algorithms and machine learning techniques to analyze the EEG data. | ||
+ | |||
+ | * Improving the real-time display: The website displaying the processed data could be optimized for better performance and user experience. | ||
+ | |||
+ | * Adding more features: Additional features such as online storage and sharing of the acquired data, or the ability to compare data between multiple users could be added. | ||
+ | |||
+ | * Improving the security: The data should be encrypted in order to protect it from unauthorized access. | ||
+ | |||
+ | * Improving the data visualization: The data visualization can be improved by adding more interactive elements, such as sliders to adjust the time range, or the ability to zoom in and out on specific parts of the data. | ||
+ | |||
+ | * Improving the data analysis: By incorporating more advanced data analysis techniques, such as machine learning, the data can be analyzed in more depth, which can lead to new insights. | ||
===== 6. References ===== | ===== 6. References ===== | ||
- | * https://raphaelvallat.com/bandpower.html | + | https://raphaelvallat.com/bandpower.html |
- | * https://rria.ici.ro/wp-content/uploads/2022/09/art._Chowdhuri_Mal.pdf | + | |
+ | https://rria.ici.ro/wp-content/uploads/2022/09/art._Chowdhuri_Mal.pdf | ||
+ | |||
+ | https://openbci.com/ | ||