EMG Detecting Muscle Onset

From Software Product Documentation
Jump to navigation Jump to search
Language:  English  • français • italiano • português • español 

Introduction

To determine when a muscle is activated a threshold needs to be chosen from a period of inactivity. When the signal surpasses the threshold, the muscle is turned on. There are three different ways to do so.

  1. EMG Onset using Event_Threshold
  2. EMG Onset based on TKEO
  3. EMG Onset based on automatic detection

EMG Onset using Event_Threshold

Computing the onset of an EMG signal can be quite tricky. In this example, we describe a pipeline for a straightforward estimation of EMG onset based on the EMG envelope and Event Threshold. This is not a definitive definition, but simply a starting point for the user. Two events should be created at the start and beginning of the rest period. Three event labels are identified on this figure. The yellow and red events specify the "rest period". This is arbitrary and is specified by the user explicitly. The blue event label is the first threshold crossing above the "median + 3*standard deviation".

Pipeline

The following pipeline first includes a low pass filter, a high pass filter and a moving RMS. The first event named REST1 is created by selecting the first frame indicating the start of the rest. The second event named REST2 is created by selecting the frame number at the end of the rest. A typical threshold is median + 3*standard deviation. The median and standard deviation are then calculated by using the Metric_Median and Metric_StdDev functions. The Event_Threshold pipeline command is then used to compute the threshold by computing the median + 3*standard deviation.

!Apply a high pass and low pass filter assuming that the surface emg signal contains information
!from 20 to 500 Hz

Highpass_Filter
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG2
! /SIGNAL_FOLDER=ORIGINAL
! /RESULT_SUFFIX=
/RESULT_FOLDER=RMS
! /FILTER_CLASS=BUTTERWORTH
/FREQUENCY_CUTOFF=20
/NUM_REFLECTED=0
/TOTAL_BUFFER_SIZE=100
! /NUM_BIDIRECTIONAL_PASSES=1
;

Lowpass_Filter
/SIGNAL_TYPES=ANALOG
! /SIGNAL_NAMES=
/SIGNAL_FOLDER=RMS
! /RESULT_SUFFIX=
/RESULT_FOLDER=RMS
! /FILTER_CLASS=BUTTERWORTH
/FREQUENCY_CUTOFF=500
/NUM_REFLECTED=0
/TOTAL_BUFFER_SIZE=100
! /NUM_BIDIRECTIONAL_PASSES=1
;

!Compute the RMS of the emg signal based on a 100 ms window

Moving_RMS
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG2
/SIGNAL_FOLDER=RMS
! /RESULT_SUFFIX=
/RESULT_FOLDER=RMS
/NUM_WINDOW_FRAMES=1+0.1*PARAMETER::ANALOG::RATE
;

!Create events that define the resting baseline of the muscle

Event_Explicit
/EVENT_NAME=REST1
/FRAME=1
! /TIME=
;

Event_Explicit
/EVENT_NAME=REST2
/FRAME=150
! /TIME=
;

!Compute the median and standard deviation of the EMG envelope during rest

Metric_Median
/RESULT_METRIC_NAME=_MED
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/RESULT_METRIC_FOLDER=EMG
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG2
/SIGNAL_FOLDER=RMS
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
/EVENT_SEQUENCE=REST1+REST2
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

Metric_StdDev
/RESULT_METRIC_NAME=_SD
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/RESULT_METRIC_FOLDER=EMG
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG2
/SIGNAL_FOLDER=RMS
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
/EVENT_SEQUENCE=REST1+REST2
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

!Identify the event EMG2_ON based on a threshold crossing
!of the median + 3 * standard deviation

Event_Threshold
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG2
/SIGNAL_FOLDER=RMS
/EVENT_NAME=EMG2_ON
/SELECT_X=TRUE
! /SELECT_Y=FALSE
! /SELECT_Z=FALSE
! /SELECT_RESIDUAL=FALSE
/THRESHOLD=METRIC::EMG::EMG2_MED+3*METRIC::EMG::EMG2_SD
! /FRAME_WINDOW=8
! /FRAME_OFFSET=0
/ASCENDING=TRUE
! /DESCENDING=FALSE
! /ENSURE_RANGE_FRAMES_BEFORE_THRESHOLD_CROSSING=FALSE
/ENSURE_RANGE_FRAMES_AFTER_THRESHOLD_CROSSING=TRUE
! /START_AT_EVENT=
! /END_AT_EVENT=
/EVENT_INSTANCE=1
;

Pipeline for computing the number of frames the signal is on

To calculate how long a signal is on or how long a muscle is active, a signal will be created to be set as zero when below the threshold, and one when the signal is above the threshold.

! Create a signal that is zero when the EMG is off, and one when it is ON

! Start with creating a signal that is zero at all frames
Evaluate_Expression
/EXPRESSION=FRAME_NUMBERS::ORIGINAL::FRAMES * 0
! /SIGNAL_TYPES=
! /SIGNAL_FOLDER=ORIGINAL
! /SIGNAL_NAMES=
/RESULT_TYPES=DERIVED
/RESULT_FOLDERS=EMG_COUNT
/RESULT_NAME=EMG2
! /APPLY_AS_SUFFIX_TO_SIGNAL_NAME=FALSE
;

! Set all frames between the ON/OFF events to one
Set_Data_To_New_Values
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=EMG_COUNT
/SIGNAL_NAMES=EMG2
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
/RESULT_TYPES=DERIVED
/RESULT_FOLDERS=EMG_COUNT
/RESULT_SUFFIX=
/EVENT_SEQUENCE=EMG2_ON+EMG2_OFF
! /EXCLUDE_EVENTS=
! /EVENT_INSTANCE=0
! /START_FRAME=
! /END_FRAME=
! /USE_POINT_RATE=TRUE
/REPLACEMENT_VALUES=1
! /THRESHOLD_HIGH=NO_DATA
! /THRESHOLD_LOW=NO_DATA
! /SET_DATA_AT_SINGLE_EVENT=FALSE
;

! Add the signal during the gait cycle 
! The result will be the number of frames the signal is ON during the gait cycle
Metric_Sum
/RESULT_METRIC_FOLDER=EMG_COUNT
/RESULT_METRIC_NAME=
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/SIGNAL_TYPES=DERIVED
/SIGNAL_FOLDER=EMG_COUNT
/SIGNAL_NAMES=EMG2
/COMPONENT_SEQUENCE=ALL
/EVENT_SEQUENCE=RHS+RHS
/EXCLUDE_EVENTS=
/SEQUENCE_PERCENT_START=
/SEQUENCE_PERCENT_END=
! /GENERATE_MEAN_AND_STDDEV=TRUE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

EMG Onset based on TKEO

Computing the onset of an EMG signal can be quite tricky. In this example, we describe a pipeline for a straightforward estimation of EMG onset based on the the Teager-Kaiser Energy Operator and Event_Threshold. This is not a definitive definition, but simply a starting point for the user. The following figure shows an EMG signal before and after the Teager Kaiser Energy Operator is implemented.

Pipeline

The following pipeline follows the same general format as above, yet at the beginning there is a Highpass Filter and a Teager Kaiser Energy Operator instead of a Lowpass filter and a HighPass Filter.

!Apply a high pass and low pass filter assuming that the surface emg signal contains information
!from 20 to 500 Hz

Highpass_Filter
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG_C
! /SIGNAL_FOLDER=ORIGINAL
! /RESULT_SUFFIX=
/RESULT_FOLDER=PROCESSED
! /FILTER_CLASS=BUTTERWORTH
/FREQUENCY_CUTOFF=20
/NUM_REFLECTED=0
/TOTAL_BUFFER_SIZE=100
! /NUM_BIDIRECTIONAL_PASSES=1
;

!Apply the Teager-Kaiser Operator

Teager_Kaiser_Energy
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG_C
/SIGNAL_FOLDER=PROCESSED
! /SIGNAL_COMPONENTS=
! /RESULT_FOLDER=PROCESSED
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
;

!Create events that define the resting baseline of the muscle

Event_Explicit
/EVENT_NAME=REST1
/FRAME=1
! /TIME=
;

Event_Explicit
/EVENT_NAME=REST2
/FRAME=150
! /TIME=
;

!Compute the median and standard deviation of the TKO envelope during rest

Metric_Median
/RESULT_METRIC_NAME=_MED
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/RESULT_METRIC_FOLDER=EMG
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG_C
/SIGNAL_FOLDER=PROCESSED
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
/EVENT_SEQUENCE=REST1+REST2
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

Metric_StdDev
/RESULT_METRIC_NAME=_SD
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/RESULT_METRIC_FOLDER=EMG
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG_C
/SIGNAL_FOLDER=PROCESSED
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
/EVENT_SEQUENCE=REST1+REST2
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

!Identify the event EMG_C_ON based on a threshold crossing
!of the median + 3 * standard deviation

Event_Threshold
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=EMG_C
/SIGNAL_FOLDER=PROCESED
/EVENT_NAME=EMG_C_ON
/SELECT_X=TRUE
! /SELECT_Y=FALSE
! /SELECT_Z=FALSE
! /SELECT_RESIDUAL=FALSE
/THRESHOLD=METRIC::EMG::EMG2_MED+3*METRIC::EMG::EMG2_SD
! /FRAME_WINDOW=8
! /FRAME_OFFSET=0
/ASCENDING=TRUE
! /DESCENDING=FALSE
! /ENSURE_RANGE_FRAMES_BEFORE_THRESHOLD_CROSSING=FALSE
/ENSURE_RANGE_FRAMES_AFTER_THRESHOLD_CROSSING=TRUE
! /START_AT_EVENT=
! /END_AT_EVENT=
/EVENT_INSTANCE=1
;

EMG Onset based on Automatic Detection

The following meta-command may be used to process EMG analog signals to find "resting" thresholds automatically, without using a reference file. Processing motion files with multiple EMG signals can become tedious when manually extracting events and identifying points of “rest”. We can manually detect sections of minimal activity within a motion trial to set as a reference threshold. The pipeline to compute this automated detection has been provided as a meta-command, and you may copy and paste it into your Visual3D x64 > Plugins > Meta-Commands folder. For more information on Meta-Commands and how they work, see Pipeline Commands:Meta Commands. For a detailed tutorial on how to use Automatic_EMG_Events, head to the tutorial page:

Meta-Command:

Tutorial page: Tutorial: Automatic EMG Events

Retrieved from ""