resurfemg.preprocessing.envelope 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 extract the envelopes from EMG arrays.

resurfemg.preprocessing.envelope.full_rolling_rms(data_emg, window_length)

This function computes a root mean squared envelope over an array data_emg. To do this it uses number of sample values window_length. It differs from naive_rolling_rms() by that the output is the same length as the input vector.

Parameters:
  • data_emg (ndarray) – Samples from the EMG

  • window_length (int) – Length of the sample use as window for function

Returns:

The root-mean-squared EMG sample data

Return type:

ndarray

resurfemg.preprocessing.envelope.hi_envelope(our_signal, dmax=24)

Takes a 1d signal array, and extracts ‘high’envelope, then makes high envelope, based on connecting peaks dmax: int, size of chunks,

Parameters:
  • our_signal (ndarray) – 1d signal array usually of emg

  • dmax (int) – length of chunk to look for local max in

Returns:

src_signal_gated, the gated result

Return type:

ndarray

resurfemg.preprocessing.envelope.naive_rolling_rms(data_emg, window_length)

This function computes a root mean squared envelope over an array data_emg. To do this it uses number of sample values window_length.

Parameters:
  • data_emg (ndarray) – Samples from the EMG

  • window_length (int) – Length of the sample use as window for function

Returns:

The root-mean-squared EMG sample data

Return type:

ndarray

resurfemg.preprocessing.envelope.running_smoother(array)

This is the smoother to use in time calculations

resurfemg.preprocessing.envelope.smooth_for_baseline(single_filtered_array, start=None, end=None, smooth=100)

This is an adaptive smoothing a series that overvalues closer numbers.

Parameters:
  • single_filtered_array (ndarray) – Array.

  • start (int) – The number of samples to work from

  • end (int) – The number of samples to work until

  • smooth (int) – The number of samples to work over

Returns:

tuple of arrays

Return type:

tuple

resurfemg.preprocessing.envelope.smooth_for_baseline_with_overlay(my_own_array, threshold=10, start=None, end=None, smooth=100)

This is the same as smooth for baseline, but we also get an overlay 0 or 1 mask tagging the baseline.

Parameters:
  • my_own_array (ndarray) – Array

  • threshold (int) – Number where to cut the mask for overlay

  • start (int) – The number of samples to work from

  • end (int) – The number of samples to work until

  • smooth (int) – The number of samples to work over

Returns:

tuple of arrays

Return type:

tuple

resurfemg.preprocessing.envelope.vect_naive_rolling_rms(x, N)

This function computes a root mean squared envelope over an array x. To do this it uses number of sample values N. It differs from naive_rolling_rms() by the way the signal is put in.

Parameters:
  • xc (ndarray) – Samples from the EMG

  • N (int) – Legnth of the sample use as window for function

Returns:

The root-mean-squared EMG sample data

Return type:

ndarray