Skip to content

signals

cls_ = getattr(signal_annotation, annotation_cls) module-attribute

Signals

Bases: PropertyMixin

annotations = {} class-attribute instance-attribute

averaging_mode = 'same' instance-attribute

averaging_window_length = 5 instance-attribute

corr_threshold = 0.1 instance-attribute

correlations = None instance-attribute

delays = None instance-attribute

envelope_filter = False instance-attribute

f_band = (40, 250) instance-attribute

f_low = 10 instance-attribute

ff_a = None instance-attribute

ff_b = None instance-attribute

filters = {} class-attribute instance-attribute

fs = fs instance-attribute

harmonic_frequency = 40 instance-attribute

lags = None instance-attribute

min_peak_distance = None instance-attribute

offsets = None instance-attribute

onsets = None instance-attribute

peaks = None instance-attribute

peaks_correlations = None instance-attribute

peaks_distance_scale = 0.9 instance-attribute

qrs_offset_window = None instance-attribute

qrs_onset_window = None instance-attribute

quality_factor = 25 instance-attribute

r_peak_distance = None instance-attribute

r_peak_height = None instance-attribute

shape property

signals = np.atleast_2d(signals) instance-attribute

smoothing_window = None instance-attribute

t_offset_window = None instance-attribute

threshold = None instance-attribute

tukey_alpha = 0.05 instance-attribute

unipolar = True instance-attribute

__init__(signals, fs=1000)

Parameters:

Name Type Description Default
signals ndarray[N, M] or [M]

N signals with length M or 1D signal with length M.

required
fs Number

sampling frequency.

1000

add_annotation(annotation) classmethod

Manually register an annotation.

Parameters:

Name Type Description Default
annotation Type[SignalAnnotation]

Filter name.

required

add_filter(filter_, name='') classmethod

Manually register a filter.

Parameters:

Name Type Description Default
filter_ Type[SignalFilter]

Filter name.

required

annotate(annotation)

Apply annotation.

Parameters:

Name Type Description Default
annotation str

Key of the annotation to apply.

required

Returns:

Name Type Description
idx ndarray

Indices of the annotated points.

apply_filter(filter_name)

Apply filter.

Parameters:

Name Type Description Default
filter_name str

Key of the filter to apply.

required

Returns:

Type Description
Self

self

apply_filters(filters)

Apply multiple filters consecutively

copy_from_signal(signals, fs) classmethod

get_correlations(pairs=None)

Get the cross-correlation between pairs of signals.

Parameters:

Name Type Description Default
pairs ndarray[K, 2]

K pairs of signals' indexes to which correlation will be applied.

None

get_delays(min_distance=None, min_height=None, reverse_sign=False)

Find the delays between signals Correlations must always be computed first before computing delays.

Parameters:

Name Type Description Default
min_distance float

Minimal time distance between EGM peaks (ms).

None
min_height float

Minimum peak height. Defaults to 0.1.

None
reverse_sign bool

If True, sign of delays is multiplied by -1 for consistency across other dgm modules. Defaults to True.

False

Returns:

Name Type Description
list list

List of time delays between each pair (ms). Positive delays means that the second signal shifted forward in time.

get_dominant_maximum_frequency(f_low=0, f_high=np.inf)

get_dominant_median_frequency()

get_lags()

Calculates the lags between pairs of signals.

get_peaks_correlations()

Find the cross correlation between peaks in the signals.

Returns:

Name Type Description
list list

cross correlation values for all peaks.

get_spectral_density()

get_window(times, start, end)

reset_correlations()

set_averaging_mode(averaging_mode)

A string indicating the size of the output. See scipy.signal.fftconvolve for more information.

set_averaging_window_length(averaging_window_length)

Size of averaging window length. Used for the Moving Average filter & Remove Baseline Filter. If used for remove baseline filter, if the averaging_window_length is None, a normal mean of the signals is used as a baseline. Otherwise, the baseline is the moving average with said window length. Defaults to 5.

set_corr_threshold(threshold)

Threshold for finding complexes in signals.

set_correlations(pairs)

Calculates the cross-correlation between pairs of signals.

Parameters:

Name Type Description Default
pairs ndarray[K, 2]

K pairs of signals' indexes to which correlation will be applied.

required

set_delays(min_distance=0, min_height=0.1, reverse_sign=False)

Find the delays between signals Correlations must always be computed first before computing delays.

Parameters:

Name Type Description Default
min_distance float

Minimal time distance between EGM peaks (ms).

0
min_height float

Minimum peak height. Defaults to 0.1.

0.1
reverse_sign bool

If True, sign of delays is multiplied by -1 for consistency across other dgm modules. Defaults to True.

False

Returns:

Type Description
Self

self

set_envelope_filter(envelope_filter=True)

If set to True, an envelope filter is applied.

set_f_band(f_band)

Used for the RoneyFilter.

set_f_low(f_low)

Low-pass filter frequency. Used for the RoneyFilter.

set_ff_a(ff_a)

The denominator coefficient vector of the FiltFilt filter.

set_ff_b(ff_b)

The numerator coefficient vector of the FiltFilt filter.

set_fs(fs)

set_harmonic_frequency(harmonic_frequency)

Frequency whose harmonics will be removed. Used for the Remove Harmonics Filter.

set_min_peak_distance(min_peak_distance)

Sets the minimum periodic distance between peaks. If fs is not set, the minimum distance is an index i.e. the minimum number of elements between peaks. If fs is set, the minimum distance is in milliseconds.

Parameters:

Name Type Description Default
min_peak_distance number

minimum periodic distance between peaks

required

set_offsets(offsets)

List of QRS (or T-wave) offsets.

set_onsets(onsets)

List of QRS onset indexes.

set_peaks(peaks)

Used for the Farfield Filter. List of R peak indexes.

set_peaks_distance_scale(peaks_distance_scale)

The value to adjust distance between peaks. Used for the Hermit Spline Normalization Filter. Used for the Moving Average filter. Defaults to 0.9.

set_qrs_offset_window(qrs_offset_window)

QRS complex offset search window length (ms).

set_qrs_onset_window(qrs_onset_window)

QRS complex onset search windowlength (ms).

set_quality_factor(quality_factor)

Quality factor of the notch filter. Higher Q means narrower band around the harmonics. Used for the Remove Harmonics Filter.

set_r_peak_distance(r_peak_distance)

Minimal distance between R-peaks of the signals (ms).

set_r_peak_height(r_peak_height)

Minimal R-peak amplitude. Value between [0, 1].

set_smoothing_window(smoothing_window)

Window length. Used for ECG smoothing in T-wave detection.

set_t_offset_window(t_offset_window)

T-wave offset search window length (ms). If None empty list will be returned.

set_threshold(threshold)

Used for the Upper Threshold filter & threshold annotation. In the threshold filter, signal values above this threshold will be set to the threshold value. In the threshold annotation, the locations in a signal where a threshold value is crossed are annotated.

set_tukey_alpha(tukey_alpha)

See docs for scipy.signal.windows.tukey. Used for the envelope filter.

set_unipolar(unipolar)

If the data is unipolar. Used for the RoneyFilter.

to_df()

window(times, start, end)