electrocardiogram#
- detkit.electrocardiogram(start=0.0, end=10.0, bw_window=0.5, freq_cut=45, plot=False, plot_bw=False, verbose=False)#
Load an electrocardiogram signal as an example for a 1D signal.
- Parameters:
- startfloat, default=0.0
Start of the signal in seconds.
- endfloat, default=10.0
End of the signal in seconds.
- bw_windowdefault=1.0
Length of moving average filter (in seconds) to remove baseline wander (bw). If zero, BW is not removed. If set to zero, baseline is not removed.
- freq_cutfloat, default=45
Frequencies (in Hz) above this limit will be cut by low-pass filter. If numpy.inf, no filtering is performed.
- plotbool or str, default=False
If True, the ECG signal and its autocorrelation function, the covariance (or correlation) matrix and its eigenvalues are plotted. If
plot
is a string, the plot is not shown, rather saved with a filename as the given string. If the filename does not contain file extension, the plot is saved in bothsvg
andpdf
formats. If the filename does not have directory path, the plot is saved in the current directory.- plot_bwbool, default=False
If True, plots the baseline wander and the original signal along with the filtered signal. This option is effective only if
plot
is not False.- verbosebool, default=False
if True, the saved plot filename is printed.
- Returns:
- ecgnumpy.array
ECG signal.
- timenumpy.array
Time axis corresponding to the ECG signal.
See also
Notes
The signal is sampled at 360 Hz.
Two filters are applied on the original ECG signal:
Removing baseline wander (BW) by moving average filter. BW is the trend of the signal caused by respiration and movements of the person. Usually, BW is on the frequency range of 0.1 HZ to 0.5 Hz. Unfortunately, a high-pass filter above 0.5 Hz does not cleanly remove the BW. The best approach so far was a moving average filter with the kernel duration of about 1 seconds.
Removing noise by low-pass filter with critical frequency of 45 Hz. This also removes the 60 Hz power-line frequency that interferes with the measurement device.
References
[1]Moody GB, Mark RG. The impact of the MIT-BIH Arrhythmia Database. IEEE Eng in Med and Biol 20(3):45-50 (May-June 2001). (PMID: 11446209); DOI: 10.13026/C2F305
[2]Goldberger AL, Amaral LAN, Glass L, Hausdorff JM, Ivanov PCh, Mark RG, Mietus JE, Moody GB, Peng C-K, Stanley HE. PhysioBank, PhysioToolkit, and PhysioNet: Components of a New Research Resource for Complex Physiologic Signals. Circulation 101(23):e215-e220; DOI: 10.1161/01.CIR.101.23.e215
Examples
>>> from detkit.datasets import electrocardiogram >>> time, ecg = electrocardiogram(plot=True, plot_bw=True)