by Tomas Cabrera.
This project analyzes EEG signals to classify different brain activities. It focuses on detecting changes when a subject listens to music (Beethoven and death metal) compared to a baseline state.
The EEG dataset includes recordings from a single subject under different conditions:
- Baseline: The subject is at rest; used as negative examples.
- Beethoven: EEG while listening to Beethoven's music.
- Deathmetal: EEG while listening to death metal music.
The data files are located in the data
directory:
baseline.dat
beethoven.dat
deathmetal.dat
Each .dat
file contains the following columns:
timestamp
counter
eeg
attention
meditation
blinking
- Duration: Each recording is between 10 and 11 minutes long.
- Sampling Frequency (Fs): 512 Hz.
- Reads EEG data from
.dat
files using pandas.
- Temporal Smoothing: Applies a moving average filter to smooth the EEG signals.
- Spectral Filtering: Uses a Butterworth bandpass filter to isolate frequencies between 1 Hz and 50 Hz.
- Plots raw, smoothed, and filtered EEG signals for each condition.
- Computes statistical features (mean, standard deviation, skewness, kurtosis) over sliding windows.
- Labels extracted features according to the condition (Beethoven or death metal).
- Merges features into a single dataset.
- Splits data into training and testing sets.
- Trains a Random Forest classifier to distinguish between the two conditions.
- Generates a confusion matrix.
- Calculates accuracy, precision, recall, and F1-score.
- Provides a classification report.
- Python +3.11
pandas
numpy
matplotlib
scipy
scikit-learn
seaborn
git clone https://github.com/tomycabre/BrainSignalClassifier.git
cd AI-Web-Scrapper
py -m venv venv
python3 -m venv venv
.\venv\Scripts\activate.bat
source venv/bin/activate
py -m pip install -r requirements.txt
pip install -r requirements.txt
Ensure that the EEG data files (baseline.dat
, beethoven.dat
, deathmetal.dat
) are placed in the data
directory.
python main.py
- Evaluation:
- Displays a confusion matrix.
- Prints accuracy and classification report.
- Accuracy: Proportion of correct predictions over total predictions.
- Precision: True positives divided by the sum of true and false positives.
- Recall: True positives divided by the sum of true positives and false negatives.
- F1-Score: Harmonic mean of precision and recall.
Reporte de Clasificación:
precision recall f1-score support
0 0.99 0.99 0.99 15234
1 0.99 0.99 0.99 14871
accuracy 0.99 30105
macro avg 0.99 0.99 0.99 30105
weighted avg 0.99 0.99 0.99 30105
- Raw Signals: Visual representation of the original EEG data.
- Smoothed Signals: EEG data after applying the moving average filter.
- Filtered Signals: EEG data after bandpass filtering.
- Confusion Matrix: Heatmap showing the classifier's performance.
We welcome contributions! Please open issues or submit pull requests.
-
Fork the Repository:
- Click the 'Fork' button on the repository page.
-
Clone Your Fork:
git clone https://github.com/tomycabre/BrainSignalClassifier.git cd brain-signal-classifier
-
Create a New Branch:
git checkout -b feature/your_feature_name
-
Make Changes: Implement your feature or fix.
-
Commit Changes:
git commit -am 'Add new feature'
-
Push to Your Fork:
git push origin feature/your_feature_name
-
Submit a Pull Request: Go to the original repository and create a new pull request.
This project is licensed under the MIT License - see the LICENSE file for details.