pecg.ecg package¶
pecg.ecg.FiducialPoints¶

class
pecg.ecg.FiducialPoints.
FiducialPoints
(signal: numpy.array, fs: int)[source]¶ Bases:
object
The purpose of the FiducialPoints class is to calculate the fiducial points.
 Parameters:
signal – the ECG signal as a ndarray, with shape (L, N) when L is the number of channels or leads and N is the number of samples.
fs – The sampling frequency of the signal.[Hz]
import pecg from pecg.Example import load_example from pecg.ecg import FiducialPoints as Fp signal, fs = load_example(ecg_type='Holter') fp = Fp.FiducialPoints(signal, fs)

wavedet
(matlab_pat: str, peaks: numpy.array = array([], dtype=float64))[source]¶ The wavedet function uses the matlab algorithm wavedet which was compiled for Windows OS for its usage in python. The algorithm is described in the the work of Martinez et al. [1]. The function is calculating the fiducial points of the ECG time series using the wavelet transform.
 Parameters:
matlab_pat – path to matlab runtime 2021a directory
peaks – Optional input Annotation of the reference peak detector (Indices of the peaks), as an ndarray of shape (L,N), when L is the number of channels or leads and N is the number of peaks. If peaks are not provided they are calculated using the jqrs detector.
 Returns:
fiducials: Nested dictionary of leads  For every lead there is a dictionary that includes indexes for each one of nine fiducials points.
matlab_pat = '/usr/local/MATLAB/R2021a' fiducials = fp.wavedet(matlab_pat)

epltd
()[source]¶ This function calculates the indexes of the Rpeaks with epltd peak detector algorithm. This algorithm were introduced by [2].
 Returns:
indexes of the Rpeaks in the ECG signal, as an ndarray of shape (L,N), when L is the number of channels or leads and N is the number of peaks.
peaks = fp.epltd()

xqrs
()[source]¶ This function wraps the XQRS function of the WFDB package.
 Returns:
indexes of the Rpeaks in the ECG signal, as an ndarray of shape (L,N), when L is the number of channels or leads and N is the number of peaks.
peaks = fp.xqrs()

jqrs
(thr: float = 0.8, rp: float = 0.25)[source]¶ The function is an Implementation of an energy based qrs detector [3]. The algorithm is an adaptation of the popular Pan & Tompkins algorithm [2]. The function assumes the input ecg is already prefiltered i.e. bandpass filtered and that the powerline interference was removed. Of note, NaN should be represented by the value 32768 in the ecg (WFDB standard).
 Parameters:
thr – threshold, default value is 0.8.
rp – refractory period (sec), default value is 0.25.
 Returns:
indexes of the Rpeaks in the ECG signal, as an ndarray of shape (L,N), when L is the number of channels or leads and N is the number of peaks.
peaks = fp.jqrs()
pecg.ecg.Biomarkers¶

class
pecg.ecg.Biomarkers.
Biomarkers
(signal: numpy.array, fs: int, fiducials: dict)[source]¶ Bases:
object
The purpose of the Biomarkers class is to calculate the biomarkers, we divided the morphological biomarkers into two main groups: intervals and waves.
 Parameters:
signal – The ECG signal as a ndarray.
fs – The sampling frequency of the signal [Hz].
fiducials – Nested dictionary of leads  For every lead there is a dictionary that includes indexes for for each one of nine fiducials points. this nested dictionary can be calculated using the FiducialPoints module.
import pecg from pecg.ecg import Biomarkers as Bm from pecg.ecg import FiducialPoints as Fp from pecg.Example import load_example signal, fs = load_example(ecg_type='12lead') fp = Fp.FiducialPoints(signal, fs) matlab_pat = '/usr/local/MATLAB/R2021a' fiducials = fp.wavedet(matlab_pat) bm = Bm.Biomarkers(signal, fs, fiducials) ints, stat_i = bm.intervals() waves, stat_w = bm.waves()

intervals
()[source]¶  Returns:
intervals_b: Dictionary that includes all the raw data, for the Intervals and segments biomarkers.
intervals_statistics: Dictionary that includes the mean, median, min, max, iqr and std, for every Intervals and segments biomarker.
¶ Biomarker
Description
Pwaveint
Time interval between Pon and Poff.
PRint
Time interval between the Pon to the QRSon.
PRseg
Time interval between the Poff to the QRSon.
PRint2
Time interval between Ppeak and Rpeak as defined by Mao et al.
QRSint
Time interval between the QRSon to the QRSoff.
QTint
Time interval between the QRSon to the Toff.
QTcBint
Corrected QT interval (QTc) using Bazett’s formula.
QTcFriint
QTc using the Fridericia formula.
QTcFraint
QTc using the Framingham formula.
QTcHint
QTc using the Hodges formula.
Twaveint
Time interval between Ton and Toff.
TPseg
Time interval between Toff and Pon.
RRint
Time interval between sequential Rpeaks.
Rdep
Time interval betweem Qon and Rpeak.

waves
()[source]¶  Returns:
waves_b: Dictionary that includes all the raw data, for every Wave characteristic biomarker.
wave_statistics: Dictionary that includes the mean, median, min, max, iqr and std, for every Wave characteristic biomarker.
¶ Biomarker
Description
Pwave
Amplitude difference between Ppeak and Poff.
Twave
Amplitude difference between Tpeak on and Toff.
Rwave:
Rpeak amplitude.
PwaveArea
Pwave interval area defined as integral from the Pon to the Poff.
TwaveArea
Twave interval area defined as integral from the Ton to the Toff.
QRSArea
QRS interval area defined as integral from the QRSon to the QRSoff.
STseg
Amplitude difference between QRSoff and Ton.
Jpoint
Amplitude in 40ms after QRSoff as defined by Hollander et al.