Skip to content

sfu-cmpt340/2024_3_project_15

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SFU CMPT 340 Project - EEG Scrolling Direction Classification with Muse2 Brain Sensing Headband

This project focuses on collecting, cleaning, feature extracting, and classifying EEG data from the Muse2 Brain Sensing Headband. The goal is to classify the direction of scrolling (up or down) based on brain activity using machine learning models like Random Forest,

Important Links

Timesheet Slack channel Project report

Video/demo/GIF

11271-ezgif com-video-to-gif-converter

Full Demo Video

Table of Contents

  1. Demo

  2. Installation

  3. Reproducing this project

  4. Troubleshooting

1. Demo - Running Website and Visualizing EEG Data

Running the website

  1. Navigate to the EEG_Web directory:

    cd src/EEG_Web
  2. Run the server.py script:

    python server.py
  3. Open the website URL from the terminal

  4. Upload a raw EEG csv file and you should see something similar to below

pic1

Visualizing EEG Data

  1. Scrolling EEG Data Visualization:

    • Navigate to the src > EEG_Data > dataProcessing > dataAnalyze directory

      cd .\src\EEG_Data\dataProcessing\dataAnalyze\
    • Run the visualize_scrolling_eeg.py or visualize_swiping_eeg.py script:

      python visualize_scrolling_eeg.py
      python visualize_swiping_eeg.py
    • This script will generate EEG signal plots for scrolling/swiping data, giving an insight into how EEG activity varies during these interactions.

    pic2
    pic3

Directory Overview

To make it easier to understand the project structure, here's a brief summary:

repository
├── src                          ## Root folder
  ├── EEG_Data                   ## EEG data and process
    ├── dataProcessing           ## Scripts for processing (visualization, cleaning, extracting)
    ├── MLModel                  ## Different iterations of the ML models 
  ├── EEG_Web                    ## Code for the website 
├── README.md                    
├── requirements.yml             

2. Installation

To run this project, set up your development environment by following the steps below:

Prerequisites:

  • Ensure you have at least Python 3.10
  • Install a package manager (pip).

Using pip:

  1. Clone the Repository:

    git clone git@github.com:sfu-cmpt340/2024_3_project_15.git
  2. Create a virtual environment:

    python -m venv .venv
  3. Activate the virtual environment:

    Windows: .\.venv\Scripts\activate
    Mac: source ./venv/bin/activate

  4. Install Dependencies:

    pip install -r requirements.yml

    Dependencies include:

    • matplotlib==3.9.2
    • pandas==2.2.3
    • scipy==1.14.1
    • mne==1.8.0
    • scikit-learn
    • flask==3.1.0
    • Flask-Cors==5.0.0

Verifying the Setup:

  1. Test the installation by running:
    python -c "import matplotlib, pandas, scipy, mne, sklearn, flask; print('All dependencies are installed.')"

This ensures the environment is correctly set up and ready to run the project.

3. Reproduction

Follow these steps to reproduce the results of this project:

Step 1: Dataset Preparation

  1. Collect EEG Data:

    • Download and install the MuseLab 1.9.5 onto a MAC.
    • Download Mobile App: Muse:Brain Health & Sleep App from App Store.
    • Connect Muse2 with Mobile App.
    • Use the Muse Headband and the Muse app to record around 20 seconds of scrolling up or scrolling down EEG signals (See entire demo for detailed setup steps).
    • Save the recordings as a CSV file (Make sure to include 'up' or 'down' in the csv filename)
  2. Classifying the data through the website:

    • Navigate to the src/EEG_Web directory:
      cd src/EEG_Web
    • Run the server.py script to start the web application:
      python server.py
    • This will start a website that runs the EEG data processing, analyzing, and classification.
    • Click the link in the terminal to open the web page.
  3. Upload Data Set:

    • Click the 'Upload and Analyze' button to classify the CSV data
  4. Result:

    • The processed dataset will be analyzed and classified with the confusion matrix, ROC curve, and precision recall curve on the web page.

Important Notes:

  • MuseLab 1.9.5 only works on a MAC device. It does not connect to the museband on a Windows device.
  • Instead of manually collecting data with the museband, you can also test by uploading the data in EEG_Data > dataProcessing > EEG_Data > museFiles_scrolling > original_data
  • The ROC curve and precision recall curve will only display if both scrolling up and scrolling down data is uploaded

4. Troubleshooting

  • If you get Error occured while processing the EEG signal error message on the website, make sure the scipy version is 1.14.1 (If you can't install scipy 1.14.1, make sure your Python version is up to date)

About

This is your first repository

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6