Skip to main content

A CLI tool for seizure detection using interpretable ML

Project description

  • SeizyML uses interpretable machine learning models to detect 🕵️‍♂️ seizures from EEG recordings coupled with manual verification in user-friendly GUI.
  • 📖 To reference SeizyML, or view the manuscript, please refer to the following publication (To be updated soon).
  • You can access the data and code used to reproduce the experiments and figures from the accompanying paper on Zenodo.

Version DOI Generic badge License: Apache 2.0


📚 Contents

📄 Additional Resources


Hardware requirements

  • SeizyML is a lightweight application that utilizes Gaussian Naive Bayes (GNB) models to predict seizure events from EEG data.
  • Any modern CPU with sufficient RAM to load your EEG recordings should work effectively.
  • For example, a quad-core CPU with 16 GB RAM can efficiently handle 24-hour long EEG recordings with 2 channels sampled at 4000 Hz.
  • No GPU is required for SeizyML's operation.

Installation

Conda (Recommended)

  1. Download and install miniconda.

  2. Clone or Download SeizyML on your machine.

  3. Start Anaconda's prompt, navigate to the downloaded /seizy_ml to create the conda environment:

     conda env create -f environment.yml
    
  4. Activate environment

     conda activate seizyml
    
  5. Launch App

     seizyml
    

Pip

  1. Download and install Python 3.9.

  2. In the terminal

     pip install seizyml
    
  3. Launch App

     seizyml
    

If this works you should see the SeizyMl CLI interface.


How To Use

🚀 Quick Start Guide

# 1. Activate environment
conda activate seizyml

# 2. Train the model
seizyml train-model

# 3. Set data path
seizyml set-datapath /path/to/data

# 4. Preprocess EEG data
seizyml preprocess

# 5. Generate predictions
seizyml predict

# 6. Verify predictions via GUI
seizyml verify

# Repeat step 6 until all recordings are verified.

# 7. Extract seizure properties
seizyml extract-properties

📄 Detailed instructions

  1. Launch App.

For conda:

# In anaconda prompt
conda activate seizyml
seizyml

For pip:

# In terminal
seizyml
  1. Train Model (Skip to step 3 if a model was trained).
seizyml train-model
  • You will be prompted to enter the full path to the training directory.
  • This is the folder path where the training data in .h5 format along with the corresponding training labels in .csv format are stored.
  • The training data consist of each recording in .h5 format [Nsegments, 1 segment, Nchannels]. Where a segment is 500 (win*fs).
  • For data conversion check the accompanying app seizy_convert or the h5_conversion script for more help.
  • The training labels consist of a corresponding .csv file containing the ground truth labels (1 for seizure, 0 for non seizure) with length [Nsegments].
  • Training data and labels for each recording need to have a matching name.

  • After this a GUI will be launched to allow editing the settings.
  • The only field that requires editing (given default formatting) is the channels field.
  •     **channels** : List containing the names of LFP/EEG channels, e.g. ["hippocampus", "frontal cortex"]
    
  1. Set DataPath.
seizyml set-datapath <data_path>
  • The first is the full path to the parent directory where the child folder with h5 data resides and where all subsequent folders will be created. Check configuration settings for more information.
  • The h5 data should be added in a child folder called data.
/parent_directory/
└── data/
    ├── file1.h5
    └── file2.h5
  • The data need to be in the same format as the data used to train the model.
  1. Preprocess data.
seizyml preprocess
  • This is the step where the h5 data files will be filtered and large outliers will be removed.
  1. Generate model prections.
seizyml predict
  • Here selected features will be extracted and model predictions will be generated using the selected model (model id can be found in the configuration settings file).
  • For more informtaion check the model pipeline
  1. Verify seizures and adjust seizure boundaries.
seizyml verify
  • This will launch a prompt to allow for file selection for verification.
  • After file selection, a GUI will be launched for seizure verification and boundary adjustment.
  • Repeat this command until all files are verified.
  • 📄 Note: if you choose to re-verify a file, the app will remember which seizures where accepted/rejected/not-verified but not the refined seizure boundaries.

  1. Get seizure properties.
seizyml extract-properties
  • After all files are verified run this command to get seizure properties
  • This step will generate a csv file with seizure properties for each h5 file.
  • Current properties extracted per file are:
'seizure_number'
'avg_seizure_dur_sec'
'total_time_seizing_sec'
'coefficient_of_variation'
'recording_dur_hrs

Other important functions

  1. Select Model.
seizyml select-model <model_path> <user_settings_path>
  • This function allows the user to select a model
  • Before using SeizyML for seizure detection a model should be first trained on ground truth (hand-scored) data.
  1. Feature Contributions
seizyml feature-contribution
  • Features contribution to the GNB model can be visualized using the following command.

App Configuration

All settings are stored in the user_settings.yaml file.

  • This file will be created in the training folder specified by the user when they run seizyml train-model command.
  • To edit the user_settings.yaml use any text editor such as notepad:
  • An explanation of all other settings can be found here.

🤝 Contributions

We welcome all project contributions including raising issues and pull requests!


📬 Support

If you encounter issues, please submit them via the GitHub issue tracker.


-> Back to Top.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

seizyml-2.0.0.tar.gz (501.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seizyml-2.0.0-py3-none-any.whl (501.4 kB view details)

Uploaded Python 3

File details

Details for the file seizyml-2.0.0.tar.gz.

File metadata

  • Download URL: seizyml-2.0.0.tar.gz
  • Upload date:
  • Size: 501.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for seizyml-2.0.0.tar.gz
Algorithm Hash digest
SHA256 1cbd8504c889a44fa7f9dc196a30da8af5130b18eb793794f6003ba42093a652
MD5 6a4b63972045d433e86268aa2c158fc8
BLAKE2b-256 146bba557faa97081bffc310790da321429f14d985382e8501ca00cf95dd2341

See more details on using hashes here.

File details

Details for the file seizyml-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: seizyml-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 501.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for seizyml-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 091c4dbe313553e0785ab3f8988392e414ee480f445108f63d4b5f5297b60c7e
MD5 dc49700c82f4187398aa8af0ab9065c5
BLAKE2b-256 937fcf8c1fa025b6d056d3e22d4a7ab34a307ecedd8b277346d5dc440d38e107

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page