resurfemg.postprocessing.features module

Copyright 2022 Netherlands eScience Center and University of Twente Licensed under the Apache License, version 2.0. See LICENSE for details.

This file contains functions to extract features from preprocessed EMG arrays.

resurfemg.postprocessing.features.amplitude(signal, peak_idxs, baseline=None)

Calculate the peak height of signal and the baseline for the windows at the peak_idxs relative to the baseline. If no baseline is provided, the peak height relative to zero is determined. ————————————————————————— :param signal: signal to determine the peak heights in :type signal: ~numpy.ndarray[float] :param peak_idxs: list of individual peak start indices :type peak_idxs: ~np.ndarray[int] :param baseline: running baseline of the signal :type baseline: ~numpy.ndarray[float]

Returns amplitudes:

list of peak amplitudes

Rtype amplitudes:

~np.ndarray[float]

resurfemg.postprocessing.features.area_under_baseline(signal, fs, peak_idxs, start_idxs, end_idxs, aub_window_s, baseline, ref_signal=None)

Calculate the time product between the baseline and the nadir of the reference signal in the aub_window_s for the windows defined by the start_idx and end_idx sample pairs. ————————————————————————— :param signal: signal to calculate the time product over :type signal: ~numpy.ndarray[float] :param fs: sampling frequency :type fs: ~int :param peak_idxs: list of individual peak indices :type peak_idxs: ~list[int] :param start_idxs: list of individual peak start indices :type start_idxs: ~list[int] :param end_idxs: list of individual peak end indices :type end_idxs: ~list[int] :param aub_window_s: number of samples before and after peak_idxs to look for the nadir :type aub_window_s: ~int :param baseline: running baseline of the signal :type baseline: ~numpy.ndarray[float] :param ref_signal: signal in which the nadir is searched :type ref_signal: ~numpy.ndarray[float]

Returns aubs:

the calculated areas under the baseline

Return type:

numpy.ndarray[float]

Returns y_ref:

the reference signal

Return type:

numpy.ndarray[float]

resurfemg.postprocessing.features.pseudo_slope(emg_env, start_idxs, end_idxs, smoothing=True)

This is a function to get the shape/slope of the take-off angle of the EMG signal. The slope is returned in units/samples (in abs values), not true slope. The true slope will depend on sampling rate and pre- processing. Therefore, only within sample comparison is recommended. ————————————————————————— :param emg_env: an single lead EMG envelope :type emg_env: np.array :param start_idxs: list of individual peak start indices :type start_idxs: ~[int] :param end_idxs: list of individual peak end indices :type end_idxs: ~[int] :param smoothing: smoothing which can or can not run before calculations :type smoothing: bool

Returns pseudoslope:

initial slope of the peak

Rtype pseudoslope:

np.ndarray[float]

resurfemg.postprocessing.features.respiratory_rate(breath_idxs, fs, outlier_percentile=33, outlier_factor=3)

Estimate respiratory rate based from breath indices. Breath-by-breath respiratory rate larger than the outlier_percentile * outlier_factor are excluded. ————————————————————————— :param breath_idxs: breath indices :type breath_idxs: ~numpy.ndarray[int] :param fs: sampling frequency :type fs: ~int :param outlier_percentile: Respiratory rate outlier percentile :type outlier_percentile: ~float :param outlier_percentile: Respiratory rate outlier factor :type outlier_percentile: ~float

Returns rr_median:

median respiratory rate

Return type:

~float

Returns rr_b2b:

breath-to-breath respiratory rate

Rtype rr_b2b:

numpy.ndarray[~float]

resurfemg.postprocessing.features.time_product(signal, fs, start_idxs, end_idxs, baseline=None)

Calculate the time product between the signal and the baseline for the windows defined by the start_idx and end_idx sample pairs. ————————————————————————— :param signal: signal to calculate the time product over :type signal: ~numpy.ndarray[float] :param fs: sampling frequency :type fs: ~int :param start_idxs: list of individual peak start indices :type start_idxs: ~list[int] :param end_idxs: list of individual peak end indices :type end_idxs: ~list[int] :param baseline: running Baseline of the signal :type baseline: ~numpy.ndarray[float]

Returns time_products:

the calculated time products

Rtype time_products:

numpy.ndarray[float]

resurfemg.postprocessing.features.time_to_peak(emg_env, start_idxs, end_idxs)

Calculates the absolute and relative time to peak

param emg_env:

an single lead EMG envelope

type emg_env:

np.array

param start_idxs:

list of individual peak start indices

type start_idxs:

~[int]

param end_idxs:

list of individual peak end indices

type end_idxs:

~[int]

returns abs_times:

absolute time-to_peak

rtype abs_times:

numpy.ndarray[int]

returns percent_times:

relative time-to_peak

rtype percent_times:

numpy.ndarray[float]