Skip to content

A Python Library for Calculating Seizure Quality Indices in Electroconvulsive Therapy

License

Notifications You must be signed in to change notification settings

maxkayser/ectmetrics

Repository files navigation

ECTMetrics

ECTMetrics is a Python library for analyzing EEG signals, particularly focusing on electroconvulsive therapy (ECT) seizure metrics. It provides functionalities to generate synthetic EEG signals, visualize them, and calculate various metrics related to seizure activity.

Features

  • Generate synthetic ECT specific EEG signals with customizable parameters.

  • Visualize EEG signals for better understanding and analysis.

  • Import EEG data from GPD (Elektrika Inc®).

  • Calculate various ECT seizure metrics, including:

    • Seizure Energy Index (SEI)
    • Average Seizure Energy Index (ASEI)
    • Postictal Suppression Index (PSI)
    • Earlyictal Amplitude (EIA)
    • Midictal Amplitude (MIA)
    • Maximum Sustained Power (MSP)
    • Time to Peak Power (TTPP)
    • Maximum Sustained Coherence (COH)
    • Time to Peak Coherence (TTPC)

Documentation

The code documentation is available at: https://maxkayser.github.io/ectmetrics/

Installation

To install the ectmetrics library, clone the repository and use pip to install the library and it's dependencies:

git clone https://github.com/maxkayser/ectmetrics
cd ectmetrics
pip install .

Usage

Usage examples

This section lists various usage examples for the ectmetrics library as demonstrated in Jupyter Notebook.

Quick start

Here’s a short example of generating an EEG signal and calculating the ECT seizure metrics.

# Import the ectmetrics library and it's modules
import ectmetrics
from ectmetrics.eeg import generate, plot
from ectmetrics.metrics import metric

# Generate a synthetic EEG signal
eeg_data = generate(
    signal_duration=28,      # in seconds
    seizure_duration=21,     # in seconds
    sampling_frequency=200,  # in Hz
    eeg_name='ECT EEG'
)

# Calculate all default ECT seizure quality metrics
metrics_results = metric(eeg_data)

metrics_results

ECT Seizure Quality Metrics

Contact Information

For more details, please refer to the contact information file.

Citing ECTMetrics

For citation information, please refer to the citations file.

Acknowledgements

The authors sincerely acknowledge the access granted to the Bonna computing cluster hosted by the University of Bonn and the support provided by its High-Performance Computing & Analytics Lab. We extend special thanks to Ralf Berninger for his invaluable technical insights and assistance regarding the Thymatron® System IV stimulation device. We also express our deep gratitude to Jesse Pavel for the development and ongoing enhancement of the ECT data collection tool, GPD.

All acknowledgments are associated with research that was partially funded by the BONFOR and the FKS study support program [2021-FKS-12] of the University Hospital Bonn. This research did not receive any additional grants from funding agencies in the public, commercial, or not-for-profit sectors.

Running Tests

To run the tests, you will need pytest. Install it via pip if you haven’t already:

pip install pytest

Then run the tests with:

pytest tests/