biosppy.signals.emg

biosppy.signals.emg

This module provides methods to process Electromyographic (EMG) signals.

copyright:
  1. 2015-2026 by Instituto de Telecomunicacoes

license:

BSD 3-clause, see LICENSE for more details.

Functions

abbink_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

bonato_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

emg([signal, sampling_rate, units, path, show])

Process a raw EMG signal and extract relevant signal features using default parameters.

find_onsets([signal, sampling_rate, size, ...])

Determine onsets of EMG pulses.

hodges_bui_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

lidierth_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

londral_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

silva_onset_detector([signal, ...])

Determine onsets of EMG pulses.

solnik_onset_detector([signal, rest, ...])

Determine onsets of EMG pulses.

biosppy.signals.emg.abbink_onset_detector(signal=None, rest=None, sampling_rate=1000.0, size=None, alarm_size=None, threshold=None, transition_threshold=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Abbink et al.. [Abb98].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (int) – Detection window size (seconds).

  • alarm_size (int) – Number of amplitudes searched in the calculation of the transition index.

  • threshold (int, float) – Detection threshold.

  • transition_threshold (int, float) – Threshold used in the calculation of the transition index.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Abb98]

Abbink JH, van der Bilt A, van der Glas HW, “Detection of onset and termination of muscle activity in surface electromyograms”, Journal of Oral Rehabilitation, vol. 25, pp. 365–369, 1998

biosppy.signals.emg.bonato_onset_detector(signal=None, rest=None, sampling_rate=1000.0, threshold=None, active_state_duration=None, samples_above_fail=None, fail_size=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Bonato et al. [Bo98].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • threshold (int, float) – Detection threshold.

  • active_state_duration (int) – Minimum duration of the active state.

  • samples_above_fail (int) – Number of samples above the threshold level in a group of successive samples.

  • fail_size (int) – Number of successive samples.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Bo98]

Bonato P, D’Alessio T, Knaflitz M, “A statistical method for the measurement of muscle activation intervals from surface myoelectric signal during gait”, IEEE Transactions on Biomedical Engineering, vol. 45:3, pp. 287–299, 1998

biosppy.signals.emg.emg(signal=None, sampling_rate=1000.0, units=None, path=None, show=True)[source]

Process a raw EMG signal and extract relevant signal features using default parameters.

Parameters:
  • signal (array) – Raw EMG signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • units (str, optional) – The units of the input signal. If specified, the plot will have the y-axis labeled with the corresponding units.

  • path (str, optional) – If provided, the plot will be saved to the specified file.

  • show (bool, optional) – If True, show a summary plot.

Returns:

  • ts (array) – Signal time axis reference (seconds).

  • filtered (array) – Filtered EMG signal.

  • onsets (array) – Indices of EMG pulse onsets.

biosppy.signals.emg.find_onsets(signal=None, sampling_rate=1000.0, size=0.05, threshold=None)[source]

Determine onsets of EMG pulses.

Skips corrupted signal parts.

Parameters:
  • signal (array) – Input filtered EMG signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (float, optional) – Detection window size (seconds).

  • threshold (float, optional) – Detection threshold.

Returns:

onsets (array) – Indices of EMG pulse onsets.

biosppy.signals.emg.hodges_bui_onset_detector(signal=None, rest=None, sampling_rate=1000.0, size=None, threshold=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Hodges and Bui [HoBu96].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (int) – Detection window size (seconds).

  • threshold (int, float) – Detection threshold.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[HoBu96]

Hodges PW, Bui BH, “A comparison of computer-based methods for the determination of onset of muscle contraction using electromyography”, Electroencephalography and Clinical Neurophysiology - Electromyography and Motor Control, vol. 101:6, pp. 511-519, 1996

biosppy.signals.emg.lidierth_onset_detector(signal=None, rest=None, sampling_rate=1000.0, size=None, threshold=None, active_state_duration=None, fail_size=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Lidierth. [Li86].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (int) – Detection window size (seconds).

  • threshold (int, float) – Detection threshold.

  • active_state_duration (int) – Minimum duration of the active state.

  • fail_size (int) – Number of successive samples.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Li86]

Lidierth M, “A computer based method for automated measurement of the periods of muscular activity from an EMG and its application to locomotor EMGs”, ElectroencephClin Neurophysiol, vol. 64:4, pp. 378–380, 1986

biosppy.signals.emg.londral_onset_detector(signal=None, rest=None, sampling_rate=1000.0, size=None, threshold=None, active_state_duration=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Londral et al. [Lon13].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (int) – Detection window size (seconds).

  • threshold (int, float) – Scale factor for calculating the detection threshold.

  • active_state_duration (int) – Minimum duration of the active state.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Lon13]

Londral A, Silva H, Nunes N, Carvalho M, Azevedo L, “A wireless user-computer interface to explore various sources of biosignals and visual biofeedback for severe motor impairment”, Journal of Accessibility and Design for All, vol. 3:2, pp. 118–134, 2013

biosppy.signals.emg.silva_onset_detector(signal=None, sampling_rate=1000.0, size=None, threshold_size=None, threshold=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Silva et al. [Sil12].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • size (int) – Detection window size (seconds).

  • threshold_size (int) – Window size for calculation of the adaptive threshold; must be bigger than the detection window size.

  • threshold (int, float) – Fixed threshold for the double criteria.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Sil12]

Silva H, Scherer R, Sousa J, Londral A , “Towards improving the usability of electromyographic interfacess”, Journal of Oral Rehabilitation, pp. 1–2, 2012

biosppy.signals.emg.solnik_onset_detector(signal=None, rest=None, sampling_rate=1000.0, threshold=None, active_state_duration=None)[source]

Determine onsets of EMG pulses.

Follows the approach by Solnik et al. [Sol10].

Parameters:
  • signal (array) – Input filtered EMG signal.

  • rest (array, list, dict) – One of the following 3 options: * N-dimensional array with filtered samples corresponding to a rest period; * 2D array or list with the beginning and end indices of a segment of the signal corresponding to a rest period; * Dictionary with {‘mean’: mean value, ‘std_dev’: standard variation}.

  • sampling_rate (int, float, optional) – Sampling frequency (Hz).

  • threshold (int, float) – Scale factor for calculating the detection threshold.

  • active_state_duration (int) – Minimum duration of the active state.

Returns:

  • onsets (array) – Indices of EMG pulse onsets.

  • processed (array) – Processed EMG signal.

References

[Sol10]

Solnik S, Rider P, Steinweg K, DeVita P, Hortobágyi T, “Teager-Kaiser energy operator signal conditioning improves EMG onset detection”, European Journal of Applied Physiology, vol 110:3, pp. 489-498, 2010