/focus-detection

The Simple ML program uses brain waves(EEG) and GSR to analyze user activity.

Primary LanguageJupyter NotebookMIT LicenseMIT

focus-detection

This is re-creation of the project that I worked on before graduated from college in 2019.
Main goal of this project is capturing features from the data measured by the sensors and detecting if the user is focusing on some kind of works, such as reading, watching videos, playing sudoku or whatever stimulus human nerve system.

Sensors

GSR


To achieve this goal, I used GSR sensor from Grove for measuring the stress level and put it on Raspberry Pi.
GSR stands for galvanic skin responce, which is a way of measuring the electrical conductance of the skin. Research shows that the value of GSR goes down when emotional arousal changes, on the other hand, it goes up when emotionally stable(relaxed).

[NEW] EEG


I added EEG sensor from NeuroSky. This tool can measure various brain waves such as alpha, beta, etc. It can be connected via bluetooth on any devices.
Each brain wave has its own characteristics and will be able to capture changes in arousal, relaxation, and emotions.

Neural Network

After measuring the data, system start training neural network model.
Since the data is time-series, I used LSTM as a main part of the architecture.
I used hyperas for auto-tuning.

Required Python libraries

hyperopt==0.2.5
tensorflow==2.4.0
Keras==2.4.3
pandas==1.2.0
hyperas==0.4.1
scipy==1.1.0
numpy==1.19.2
grove.py==0.6
grove==0.0.13
thinkgear==0.2

Usage

  1. Connect the MindWave to /dev/rfcomm0
  2. Run main.py in the focus-detection folder.
  3. Input csv folder name
  4. Start measuring GSR values
  • 1st session - calibration
  • 2nd session - focus (Training data)
  • 3rd session - relaxed (Training data)
  • 4th session - focus (Test data)
  • 5th session - relaxed (Test data)
  1. Auto Tuning ML model using hyperas
  2. Start Real time detection

Things to improve

  • It takes almost 2 minutes to train the model. (sort of slow)
  • Uncertain if trained model can be used for others.

Note

Thinkgear library is only available for Python2 so please replace the code with this