Coder Social home page Coder Social logo

cys3165 / eeg_real_time_seizure_detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aitrics/eeg_real_time_seizure_detection

0.0 0.0 0.0 7.08 MB

Real-Time Seizure Detection using EEG: A Comprehensive Comparison of Recent Approaches under a Realistic Setting

License: MIT License

Python 100.00%

eeg_real_time_seizure_detection's Introduction

Real-Time Seizure Detection using Electroencephalogram (EEG)

This is the repository for "Real-Time Seizure Detection using EEG: A Comprehensive Comparison of Recent Approaches under a Realistic Setting". You can checkout pdf file of our paper in our github repo.

  • If you have used our code or referred to our result in your research, please cite:
@inproceedings{lee2022real,
  title={Real-Time Seizure Detection using EEG: A Comprehensive Comparison of Recent Approaches under a Realistic Setting},
  author={Lee, Kwanhyung and Jeong, Hyewon and Kim, Seyun and Yang, Donghwa and Kang, Hoon-Chul and Choi, Edward},
  booktitle={Conference on Health, Inference, and Learning},
  pages={311--337},
  year={2022},
  organization={PMLR}
}

Real-Time EEG Detection

We downsample the EEG signal and extract features. The models detect whether ictal / non-ictal signal appears within the 4-second sliding window input. We present an example case with Raw EEG signal but other signal feature extractors can also be applied in the pipeline. concpet

Requirements

To install all the requirements of this repository in your environment, run:

pip install -r requirements.txt

Preprocessing

To construct dataset with TUH EEG dataset, you can download EEG Seizure Corpus in the website and save it to $PATH_TO_EEG and run:

python preproces.py --data_type train --cpu_num *available cpu numbers* --label_type  *tse or tse_bi* --save_directory *path to save preprocessed files* --samplerate *sample rate that you want to re-sample all files*

Before running the code, please change $PATH_TO_EEG/ to your own path to EEG raw dataset.

Model Training

Check our builder/models/detection_models or builder/models/multiclassification repository to see available models for each task. To train the model in default setting, run a command in a format as shown below :

CUDA_VISIBLE_DEVICES=*device number* python ./2_train.py --project-name *folder name to store trained model* --model *name of model to run* --task-type *task*

For sincnet settin, add --sincnet-bandnum 7

Example run for binary seizure detection:

CUDA_VISIBLE_DEVICES=7 python3 ./2_train.py --project-name alexnet_v4_raw --model alexnet_v4 --task-type binary --optim adam --window-size 4 --window-shift 1 --eeg-type bipolar --enc-model raw --binary-sampler-type 6types --binary-target-groups 2 --epoch 8 --batch-size 32 --seizure-wise-eval-for-binary True
CUDA_VISIBLE_DEVICES=7 python3 ./2_train.py --project-name cnn2d_lstm_raw --model cnn2d_lstm_v8 --task-type binary --optim adam --window-size 4 --window-shift 1 --eeg-type bipolar --enc-model raw --binary-sampler-type 6types --binary-target-groups 2 --epoch 8 --batch-size 32 --seizure-wise-eval-for-binary True

Example run for SincNet signal feature extraction :

CUDA_VISIBLE_DEVICES=7 python3 ./2_train.py --project-name alexnet_v4_raw_sincnet --model alexnet_v4 --task-type binary --optim adam --window-size 4 --window-shift 1 --eeg-type bipolar --enc-model sincnet --sincnet-bandnum 7 --binary-sampler-type 6types --binary-target-groups 2 --epoch 8 --batch-size 32 --seizure-wise-eval-for-binary True

Other arguments you can add :

  1. enc-model : preprocessing method to extract features from raw EEG data (options: raw, sincnet, LFCC, stft2, psd2, downsampled) psd2 is for Frequency bands described in our paper stft2 is for short-time fourier transform
  2. seizure-wise-eval-for-binary : perform seizure-wise evaluation for binary task at the end of training if True
  3. ignore-model-summary : does not print model summary and size information if True model summary is measured with torchinfo Please refer to /control/config.py for other arguments and brief explanations.

Model Evaluation

We provide multiple evaluation methods to measure model performance in different perspectives. This command will measure the model's inference time in seconds for one window.

python ./3_test.py --project-name *folder where model is stored* --model *name of model to test* --task-type *task*
python ./4_seiz_test.py --project-name *folder where model is stored* --model *name of model to test* --task-type *task*

Test and measure model speed

To evaluate the model and measure model speed per window using cpu, run the following command :

CUDA_VISIBLE_DEVICES="" python ./3_test.py --project-name *folder where model is stored* --model *name of model to test* --cpu 1 --batch-size 1

For sincnet setting, add --sincnet-bandnum 7 4_seiz_test.py is for evaluation metrics of OVLP, TAES, average latency, and MARGIN

Other arguments you can add :

  1. ignore-model-speed : does not calculate model's inference time per sliding window if True

eeg_real_time_seizure_detection's People

Contributors

mandiehyewon avatar rhksgud92 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.