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,
Timesheet | Slack channel | Project report |
---|
-
Navigate to the
EEG_Web
directory:cd src/EEG_Web
-
Run the
server.py
script:python server.py
-
Open the website URL from the terminal
-
Upload a raw EEG csv file and you should see something similar to below
-
Scrolling EEG Data Visualization:
-
Navigate to the
src > EEG_Data > dataProcessing > dataAnalyze
directorycd .\src\EEG_Data\dataProcessing\dataAnalyze\
-
Run the
visualize_scrolling_eeg.py
orvisualize_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.
-
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
To run this project, set up your development environment by following the steps below:
- Ensure you have at least Python 3.10
- Install a package manager (
pip
).
-
Clone the Repository:
git clone git@github.com:sfu-cmpt340/2024_3_project_15.git
-
Create a virtual environment:
python -m venv .venv
-
Activate the virtual environment:
Windows:
.\.venv\Scripts\activate
Mac:source ./venv/bin/activate
-
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
- 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.
Follow these steps to reproduce the results of this project:
-
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)
-
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.
- Navigate to the src/EEG_Web directory:
-
Upload Data Set:
- Click the 'Upload and Analyze' button to classify the CSV data
-
Result:
- The processed dataset will be analyzed and classified with the confusion matrix, ROC curve, and precision recall curve on the web page.
- 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
- 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)