ltbio.biosignals.modalities.ECG#
Overview#
Classes#
Contents#
- class ltbio.biosignals.modalities.ECG.ECG(timeseries, source=None, patient=None, acquisition_location=None, name=None)#
Bases:
ltbio.biosignals.modalities.Biosignal.Biosignal- DEFAULT_UNIT#
- basSQI(by_segment: bool = False)#
Computes the ration between [0, 1] Hz and [0, 40] Hz frequency power bands. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
Adequate to evaluate the presence of baseline drift. Values between [0.95, 1] mean ECG shows optimal quality.
- Returns:
A dictionary of the computed ratio for each channel.
- bsSQI(by_segment: bool = False)#
Checks baseline wander in time domain. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
Meant to evaluate the presence of baseline wander. Ref: https://www.sciencedirect.com/science/article/pii/S0169260714003241?via%3Dihub#bib0040
- Returns:
A dictionary of the computed ratio for each channel.
- flatline_percentage(by_segment: bool = False)#
Computes the % of flatline of each channel. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
- Returns:
A dictionary of % of flatline value(s) for each channel.
- heartbeats(before=0.2, after=0.4)#
Segment the signal by heartbeats. Works like a Segmenter, except output Timeseries is not necessarily equally segmented.
- beforefloat, optional
Window size to include before the R peak (seconds).
- afterint, optional
Window size to include after the R peak (seconds).
- heartbeatsECG
Biosignal segmented where each Segment is a heartbeat.
If filtered, the raw samples are not recoverable by ‘undo_filters’.
- hr(smooth_length: float = None)#
Transform ECG signal to instantaneous heart rate.
- smooth_lengthfloat, optional
Length of smoothing window. If not given, no smoothing is performed on the instantaneous heart rate.
- hrHR
Pseudo-Biosignal where samples are the instantaneous heart rate at each timepoint.
- invert_if_necessary()#
Investigates which ECG channels need to be inverted, and, the ones that do, get inverted just like method ‘invert’. Based on the median of the R-peaks amplitudes. Works preferably with leads I and II.
None
None
- kurtosis(by_segment: bool = False)#
Computes the kurtosis of each channel. If by_segment is True, a list of kurtosis values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
If kurtosis <= 5, it means there’s a great amount of noise present.
- Returns:
A dictionary of kurtosis value(s) for each channel.
- nni()#
Transform ECG signal to an evenly-sampled R-R peak interval (RRI/NNI) signal. Interpolation is used. It is assumed the ECG only has one channel.
- nniECG
Pseudo-Biosignal where each sample is the interval of the R peak ‘occured there’ and the previous R peak.
- pSQI(by_segment: bool = False)#
Computes the ration between [5, 15] Hz and [5, 40] Hz frequency power bands. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
Values between [0.5, 0.8] mean QRS complexes show high quality.
- Returns:
A dictionary of the computed ratio for each channel.
- plot_rpeaks(show: bool = True, save_to: str = None)#
- plot_summary(show: bool = True, save_to: str = None)#
- qSQI(by_segment: bool = False)#
Evaluates agreement between two R detectors. If by_segment is True, a list of values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment.
Values > 90% mean optimal R-peak consensus.
- Returns:
A dictionary of the computed qSQI for each channel.
- r_timepoints(algorithm='hamilton', _by_segment=False) tuple#
Finds the timepoints of the R peaks.
@param algoritm (optional): The algorithm used to compute the R peaks. Default: Hamilton segmenter. @param _by_segment (optional): Return timepoints grouped by uninterrptuned segments.
@returns: The ordered sequence of timepoints of the R peaks. @rtype: np.array
Note: Index one channel first.
- skewness(by_segment: bool = False) dict[str:float | list[float]]#
Computes the skweness of each channel. If by_segment is True, a list of skweness values is returned for each contiguous uninterrupted segment, otherwise the weighted average is returned. Weighted by duration of each segment. :return: A dictionary of skewness value(s) for each channel.
- zhaoSQI(by_segment: bool = False)#
- class ltbio.biosignals.modalities.ECG.RRI(timeseries, source=None, patient=None, acquisition_location=None, name=None, original=None)#
Bases:
ltbio.biosignals.modalities.Biosignal.DerivedBiosignal- plot_summary(show: bool = True, save_to: str = None)#