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.
-
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)
The code documentation is available at: https://maxkayser.github.io/ectmetrics/
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 .
This section lists various usage examples for the ectmetrics
library as demonstrated in Jupyter Notebook.
- Simple usage example
- EEG signal generation
- EEG signal import
- ECT seizure quality metrics calculation
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
For more details, please refer to the contact information file.
For citation information, please refer to the citations file.
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.
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/