streamsim.src.sources.ecg module
ECG Data Processing Module
This module provides utilities for loading, modifying, and streaming electrocardiogram (ECG) signals from the MIT-BIH Arrhythmia Database. It includes functionality for creating synthetic anomalies (e.g., temporary heart rate acceleration). The ECG_DataSource, implements a callable interface that yields (sample, timestamp) pairs sequentially, allowing for streaming of signal data without loading the entire signalstream into memory at once.
- Dependencies:
wfdb: Waveform database access for MIT-BIH records
Author: F.Feenstra
Example
>>> data_source = create_ecg_data_source()
>>> modified_source = create_ecg_with_temporary_anomaly(start=5, stop=10)
- class streamsim.src.sources.ecg.ECG_DataSource(signal, fs)[source]
Bases:
objectGenerator-based wrapper for ECG data.
- streamsim.src.sources.ecg.create_ecg_data_source()[source]
Create an ECG data source with fallback to mock data.
Attempts to load real ECG data from the MIT-BIH Arrhythmia Database (record ‘100’). If the wfdb library is unavailable or the record cannot be loaded, generates a synthetic ECG-like signal for testing purposes.
- Returns:
A data source containing either real or mock ECG data.
- Return type:
- streamsim.src.sources.ecg.create_ecg_with_temporary_anomaly(start, stop)[source]
Create an ECG data source with a temporary heart rate acceleration.
Generates a modified ECG signal where the segment between ‘start’ and ‘stop’ seconds is accelerated (compressed in time) to simulate increased heart rate. The rest of the signal remains unchanged.
- Parameters:
start (float) – Start time in seconds where acceleration begins.
stop (float) – End time in seconds where acceleration ends.
- Returns:
A data source containing the modified ECG signal.
- Return type: