Skip to content
Roman Gascoin RG-003
All articles

Technical note TN-04 Spec sheet

Mind

My first long-term AI project, over six months

Issued
Reading
5 min read
Class
Association
Keywords
  • Association
  • MLOps
  • AI
Format
Raw Markdown
On this page

All the source code is available here.


Presentation

Mind is a project created by members of PoC, the French student innovation center. Its goal is to detect and analyze brainwaves using an EEG (electroencephalography) headset.

Subtitled video presentation:

Mind video presentation (YouTube)

The current version of the project uses the open-source EEG headset created by OpenBCI: the Ultracortex Mark IV. The chipset we use is the Cyton board with the WiFi Shield. Members of PoC printed and set up the headset during a previous iteration of the project.


How it works

The headset detects brainwaves and transmits them over its own Wi-Fi network. Once connected, a computer can receive the data through OpenBCI’s GUI and relay it through an LSL data stream. The data can then be used in a Python script thanks to the pylsl library.

The data transmitted through the OpenBCI GUI is not a raw data stream but a transformed one. What we send to our AI is the data transformed by the FFT plot.

Using this data, we created a dataset made up of the go and none labels.

The AI needed to be trained to tell a go signal from a none signal. To that end, we needed the following file structure:

  • Dataset:
    • data (data used for the training phase)
      • go
      • none
    • val (data used for the testing phase)
      • go
      • none

The AI training script gathers all the labeled data, regardless of context, and shuffles it randomly. The learning process then starts and generates a model based on the provided data.

Our neural network is based on convolutional layers. This allows us to analyze each data input separately and return a result in real time.

It is worth noting that the received data points can also be analyzed in bundles. This method requires a recurrent neural network (RNN). Part of our research focused on this approach. However, the headset does not have enough electrodes, so this method lacks precision.

The current iteration of the project uses this AI and sends its predictions to a Unity scene over the TCP protocol.

Architecture diagram: the OpenBCI headset sends its data to a Python script, which queries the AI model and forwards its guess (“Go”) to the Unity scene


Setup and usage

The complete documentation of the OpenBCI products is available here.

This project has been tested and works on Windows. Although Unity is unstable on Linux, the project should also work in that environment.

Installation

Usage

Headset (back view)

  • The button located on the right side of the Cyton chipset must be set to PC.

Close-up of the back of the headset: the switch on the side of the Cyton board, with its PC, OFF and BLE positions, is framed in yellow

  • The button located at the bottom left of the WiFi Shield must be set to ON.

Close-up of the WiFi Shield: the small ON / EXT PWR / OFF switch is framed in yellow

  • Turn the headset ON or OFF using the switch on the right side of the WiFi Shield.

Right side of the WiFi Shield: the power switch and its ON and OFF markings are framed in yellow

  • Once the headset is powered on, blue LEDs light up and it broadcasts a Wi-Fi network that your computer can connect to.
  • Place the headset on your head, with the chipset facing backward, and attach the two ear clips to your earlobes.

GUI

  • Start the GUI.
  • In the System Control Panel, select CYTON (live), then Wifi (from Wifi Shield) and finally STATIC IP.
  • Start the session by pressing START SESSION.
  • Start receiving data by selecting START DATA STREAM.

LSL data stream

  • Once your main data stream has started, change your Accelerometer widget to a Networking widget by opening the dropdown menu located on the widget’s name.
  • Open the Serial dropdown menu and choose LSL.
  • Under the Stream 1 title, open the None dropdown menu and select FFT.
  • Click on Start to start the LSL data stream.

Unity

  • Start the Unity Hub.
  • Add this project to your interface: click on ADD and navigate to the unity folder.
  • Launch the scene using a compatible version of Unity. This project was built with version 2019.4.12f1.

That’s it! Your data can easily be collected through a Python script. The following steps only apply to the scripts and files within this GitHub repository.

The scripts and their usage:

  • create_dataset.py: creates a NumPy data point containing 1 second of data, with the shape [25,8,60]
    • 25: average number of data points per second
    • 8: number of electrodes on our headset
    • 60: the FFT data is represented across 125 frequencies, but only the first 60 are usable because of electromagnetic noise
  • mindTrain.py: creates a deep learning model from a multitude of NumPy files
  • mindPred.py: runs predictions on a data point
  • real_time.py: allows for real-time predictions
    • Once all the installation steps are completed, you can use this script to predict go or none from data points in real time
    • $> python3 real_time.py path_to_model.pt
  • mindIM.py: real-time prediction, to be used with the Unity scene
    • Once all the installation, usage and Unity steps are completed, you can use this script to visualize your predictions in real time through Unity
    • $> python3 mindIM.py
    • Start the Unity scene

Unity editor running the scene, a fortune teller’s table with a crystal ball, a candle and tarot cards, with the Play button highlighted in yellow

Appendix

We also integrated a tool that brings MLOps to this project: MLflow.

MLflow is a tool that lets you precisely track the evolution of your AI’s learning rate, by adding tags to your parameters to make them appear in the tool’s GUI.

To launch this GUI, use the $> mlflow ui command in your terminal. MLflow starts on port 5000 by default and can be reached from your web browser at this address: http://127.0.0.1:5000/

Conclusion

The Ultracortex Mark IV headset lying on a table: white and blue printed frame, battery pack, electrode wires and the orange OpenBCI WiFi Shield

The goal of this iteration was to get back to the level of progress reached by the previous iteration, about which we had little to no information.

We wanted to build on this foundation to put the headset to concrete use. Unfortunately, our project is merely functional, and the results we obtained are not reliable.

Our current AI only works with two labels, and we have doubts about the precision of the headset.

This lack of precision had already been noted during previous iterations, and it does not seem fixable. In addition, the visuals of the OpenBCI GUI do not look like the product demonstrations available online, which calls the reliability of our headset into question, even compared with other Ultracortex Mark IV headsets.

In conclusion, for the next iteration, we recommend a more precise headset, one with stronger professional endorsement.

Another view of the headset: the battery pack, the colored wires and the electrode mounts on the white frame