EEG-PK / schizophrenia-classification

Classification of schizophrenia by EEG signals using CNN network
GNU General Public License v3.0
0 stars 0 forks source link

schizophrenia-classification

Classification of schizophrenia by EEG signals using CNN network

Introduction

This study aims to classify schizophrenia using convolutional neural networks (CNN). One method of detecting schizophrenia is the use of electroencephalography (EEG), which records the brain's electrical activity and provides information about differences in brain function between affected and healthy individuals. EEG data will be transformed into the time-frequency domain using the Margenau-Hill distribution (MH-TFD), which allows for the analysis of nonlinear and non-stationary signals. The resulting two-dimensional array data will be fed into a CNN model capable of autonomously detecting brain activity features. It is also worth mentioning that deep neural networks are also resistant to computational errors during feature extraction compared to traditional learning methods. The convolutional network will be trained and tested on three publicly available datasets. The final solution will be applicable to data from other studies with different characteristics, thanks to methods that minimize the influence of the reference electrode selection.

Datasets

Dataset "number 1":

Dataset "number 2":

Dataset "number 3":

Code

The model was trained on Debian 12 on the GPU. The code was tested on Python3.11 and CUDA 12.2.
CUDA and cudnn are installed in the conda environment. All you need is NVIDIA drivers compatible with at least CUDA 12.2 and the Linux environment.

Setup

1) Create environment

Conda
conda env create --file ml_eeg_gpu_tf215_ver.yml
conda activate ml_eeg_gpu_tf215_ver

2) Set the LD_LIBRARY_PATH environment variable

chmod +x env_create.sh
./env_create.sh
conda deactivate
conda activate ml_eeg_gpu_tf215_ver

3) Fix tftb library compatibility

python tftb_repair.py

Tasks

Task 1: EEG signal preparation/preprocessing

  1. Go to the preprocessing folder.
    cd preprocessing

  2. Download all datasets using command:
    python dataset_setup.py
    This command will automatically download and unzip all datasets into appropriate folders

  3. After that run
    python main.py -m {mode} -ps {patient_state} -i {folder_path}
    or move all files to one folder and run
    python main.py -m all -ps {patient_state} -i {folder_path}

    For example, for 'number 3' (.eea) dataset:
    python main.py -m Eea -ps health -i Datasets/EeaHealthy
    python main.py -m Eea -ps ill -i Datasets/EeaIll

    By default all file should be contained folder called Data in root of preprocessing folder.
    What is important that in one folder there can only one state of patients (either healthy or ill).

Task 2: Schizophrenia prediction

  1. Prepare data according to preprocessing step.
  2. Go to the model folder.
    cd model
  3. Search for optimal hyperparameters
    python main.py
  4. Check out the results
    optuna-dashboard sqlite:///schizo_model.db
    Open Optuna's dashboard:
    http://localhost:8080