MischaRauch / Stable_Diffusion_on_EEG_Signals

Using Stable Diffusion on the DEAP Dataset to argument new data and improve classification
17 stars 2 forks source link

Stable Diffusion on EEG Signals

Using Stable Diffusion on the DEAP Dataset (http://www.eecs.qmul.ac.uk/mmv/datasets/deap/) to argument new data and improve classification

Description

The subfield of psychology, emotion recognition, focuses on identifying emotions and addressing mental conditions like autism. Due to advancements in machine learning and deep learning the automation of emotion recognition was drastically improved. These techniques allow for the development of models that analyze facial expressions, speech, and texts to evaluate human emotions. The emotion evaluation based on Elec- troencephalogram (EEG) signals offers a promising approach for emotion recognition since its not susceptible to facial suppression. EEG is also cost-effective, non-invasive, and advantageous over traditional methods like Magnetic Resonance Imaging. However, the limited availability of EEG data hampers progress due to restricted access and privacy concerns. By augmenting the existing dataset with artificially generated signals mimicking the actual data distribution, emotion classification can be improved. In this thesis, a Probabilistic Diffusion Model (PDM) is proposed as generative artificial intelligence. Three major feature extraction approaches are tested. The first is with a direct comparison to a Generative Adversarial Network, the second in which features from the frequency domain are extracted, and a third in which a reduced subset is tested. Additionally, experiments with different augmentation factors [x1,x2,x3,x4] are tested to evaluate the impact of the data augmentation. The experimental results demonstrated that the GAN model achieved higher improvements than the PDM, but the PDM achieves classification improvements of up to 20% if the signal is transformed into the frequency domain before. Lastly, the reduced subset approach yielded similar accuracies proposing future work to use a subset of the initial signals.

Problem Statement: Is it possible to get better classification performance by using an augmented dataset generated by a probabilistic diffusion model?

This research is aimed to answer the following research questions:

  1. Are diffusion based approaches better than other augmentation models, for example GAN’s
  2. Which features are more suitable for a diffusion model basd data augmentation approach?
  3. What are good features to classify EEG signals, with respect to feature importance

Structure of the code

The organization of the files and work can be understood as follows:

  1. pre_processing_bhat.ipynb the applied preprocessing applied in the same way as the previous GAN model stated in the report as refrence 2. The signal gets splitted into ten parts and for each part nine statistical features get extracted + the same amount of features over the whole signals resulting in 99 features.
  2. pre_processing_stft.ipynb the applied preprocessing for comparison in the frequency domain, with a Short time Frequency transformation. The signal got splitted into the same ten parts as before and for each EEG band (Theta, Alpha, Beta, Gamma) the mean got extracted + the same features over the whole signal in frequency domain resulting in 44 features.
  3. pre_processing_fft.ipynb the applied preprocessing using the Fast Fourier Transformation. The whole signal got transformed into the frequency domain and the mean and standard deviation for the four EEG bands (Theta, Alpha, Beta, Gamma) got extracted, resulting in 8 features per signal.
  4. diffusion_bhat.ipynb the diffusion model - training and sampling - for the time domain approach
  5. diffusion_fft.ipynb the diffusion model - training and samping - for the frequency approach
  6. distribution_graphs.ipynb distribution graphs of the real against synthetic data plotted on feature level to compare visually the produced output of the diffusion model.
  7. quality_report_featureDistribution_bhat.ipynb the quality report produced by SDMetrics with quality scores and distribution graphs for the time domain approach
  8. quality_report_featureDistribution_fft.ipynb the quality report produced by SDMetrics with quality scores and distribution graphs for the frequency domain approach
  9. k-fold.ipynb a k-fold evaluation to test the classification results by (1) training on the real data and test on real data (2) training on the real data and test on synthetic data (3) training on the synthetic data and test on real data (4) training on the synthetic data and test on synthetic data
  10. statistical_test.ipynb a Welchs t-test and a t-test for testing statistical significance on the k-fold results and the classification results of the full dataset compared with the reduced dataset approach.
  11. classification_bhat.ipynb classification results for the first approach in time domain with comparison to GAN.
  12. classification_stft.ipynb classification results for the STFT approach without augmentation.
  13. classification_fft.ipynb classification results for the FFT approach.
  14. classification_fft_reduced.ipynb classification results for the reduced FFT approach.

Note that the code here is meant as a reference to see what was done in this study, as not all the data is publically available, one would have to sign an EULA aggreement to get access to the DEAP dataset. If you would like to run this code you would need to get the data and update the paths in the code which reference it.

For the results and more detailes please see the report.

Feel free to contact me in case of questions.