EMG: Removing Background Noise

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

Introduction

The purpose is to offset trial data to accommodate for any DC shift. Quantifying the EMG background noise based on a "Resting Trial" using the following algorithm:

Find overall mean of trial:

if positive, subtract mean from all values to offset overall average to zero
if negative, add mean to all values to offset overall average to zero.

Rectify trial around the zero baselines

Calculate threshold values for each channel of EMG (level of digitized baseline noise).

Determine noise threshold (i.e., the value determined from the resting EMG values fall below; calculated by passing a ceiling through data at successively higher levels until all data values for the 5 second duration fall below the ceiling.

EMG_Resting_Background

You can remove the background using a Meta-Command (as described below), or you can see here for an example implementing this in a script.

EMG_Resting_Background Meta-Command

The following Meta Command can be Cut-and-Paste into a file named EMG_Resting_Background.v3m

! BEGIN_META
! META_CMD_NAME=EMG_Resting_Background
! META_PARAM= SIGNAL_NAMES:string::yes
! META_PARAM= SIGNAL_FOLDER:string::yes
! META_PARAM= RESULT_FOLDER:string::yes
! END_META

Set_Pipeline_Parameter
/PARAMETER_NAME=FOLDER
/PARAMETER_VALUE=::SIGNAL_FOLDER
! /PARAMETER_VALUE_SEARCH_FOR=
! /PARAMETER_VALUE_REPLACE_WITH=
! /PARAMETER_VALUE_PREFIX=
! /PARAMETER_VALUE_APPEND=
;

Set_Pipeline_Parameter
/PARAMETER_NAME=RESULT
/PARAMETER_VALUE=::RESULT_FOLDER
! /PARAMETER_VALUE_SEARCH_FOR=
! /PARAMETER_VALUE_REPLACE_WITH=
! /PARAMETER_VALUE_PREFIX=
! /PARAMETER_VALUE_APPEND=
;

! ---------------------------------------------------------------
! Offset trial data to accommodate for any DC shift
! (find overall mean of trial&ldots;if positive,
! subtract mean from all values to offset overall average to zero&ldots;
! if negative, add mean to all values to offset overall average to zero).
! Rectify trial around the zero baselines
! (all values set to absolute values).
! ---------------------------------------------------------------

For_Each
/ITERATION_PARAMETER_NAME=INDEX
/ITEMS=::SIGNAL_NAMES
;

Metric_Mean
/RESULT_METRIC_NAME=_MEAN
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
! /RESULT_METRIC_FOLDER=PROCESSED
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=::INDEX
/SIGNAL_FOLDER=::FOLDER
! /SIGNAL_COMPONENTS=X
/EVENT_SEQUENCE=
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
;

Evaluate_Expression
/EXPRESSION=ABS(ANALOG&:&:&::FOLDER&:&:&::INDEX&-&METRIC::PROCESSED&:&:&::INDEX&_MEAN)
/RESULT_NAME=::INDEX
/RESULT_TYPE=ANALOG
/RESULT_FOLDER=::RESULT
;

End_For_Each
/ITERATION_PARAMETER_NAME=INDEX
;

! ---------------------------------------------------------------
! Calculated threshold values for each channel of EMG
! (level of digitized baseline noise).
! Apply noise threshold (i.e., the value determined from the
! resting EMG values fall below).  Calculated by passing a
! ceiling through data at successively higher levels until
! all data values for the 5 second duration fall below the ceiling.
! ---------------------------------------------------------------

Metric_Maximum
/RESULT_METRIC_NAME=_REST
/APPLY_AS_SUFFIX_TO_SIGNAL_NAME=TRUE
/RESULT_METRIC_FOLDER=::RESULT
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=
/SIGNAL_FOLDER=::RESULT
/SIGNAL_COMPONENTS=X
/EVENT_SEQUENCE=
/EXCLUDE_EVENTS=
/GENERATE_MEAN_AND_STDDEV=FALSE
! /APPEND_TO_EXISTING_VALUES=FALSE
/CREATE_GLOBAL_MAXIMUM=TRUE
;

Madonna EMG Remove Background Meta-Command

The following Meta Command removes the background noise from the EMG signals and can be Cut-and-Paste into a file named Madonna_EMG_Remove_Background.v3m

! BEGIN_META
! META_CMD_NAME=Madonna EMG Remove Background
! META_PARAM= SIGNAL_NAMES:string::yes
! META_PARAM= SIGNAL_FOLDER:string::yes
! META_PARAM= RESULT_FOLDER:string::yes
! META_PARAM= BACKGROUND_FOLDER:string::yes
! END_META

Set_Pipeline_Parameter
/PARAMETER_NAME=FOLDER
/PARAMETER_VALUE=::SIGNAL_FOLDER
; 

Set_Pipeline_Parameter
/PARAMETER_NAME=RESULT
/PARAMETER_VALUE=::RESULT_FOLDER
; 

! ---------------------------------------------------------------
! Remove the EMG background noise
! --------------------------------------------------------------- 

For_Each
/ITERATION_PARAMETER_NAME=INDEX
/ITEMS=::SIGNAL_NAMES
; 

Evaluate_Expression
/EXPRESSION=ABS(ANALOG&:&:&::FOLDER&:&:&::INDEX&& - GLOBAL::METRIC&:&:&::BACKGROUND_FOLDER&:&:&::INDEX&_REST_MAX)
/RESULT_NAME=::INDEX
/RESULT_TYPE=ANALOG
/RESULT_FOLDER=::RESULT
; 

Set_Data_To_New_Values
/SIGNAL_TYPES=ANALOG
/SIGNAL_NAMES=::INDEX
/SIGNAL_FOLDER=::RESULT
! /SIGNAL_COMPONENTS=ALL_COMPONENTS
! /RESULT_SUFFIX=
/RESULT_FOLDER=::RESULT
! /EVENT_SEQUENCE=
! /EXCLUDE_EVENTS=
/START_FRAME=1
/END_FRAME=EOF
! /USE_POINT_RATE=TRUE
/REPLACEMENT_VALUES=0
/THRESHOLD_HIGH=DATA_NOT_FOUND
/THRESHOLD_LOW=GLOBAL::METRIC&:&:&::BACKGROUND_FOLDER&:&:&::INDEX&_REST_MAX
; 

End_For_Each
/ITERATION_PARAMETER_NAME=INDEX
;

An example Visual3D Pipeline Command to call these Meta-Commands

In this example, some files are TAGGED as REST, EMG, and GAIT.

!Make the Resting Trial the Active File.

For_Each
/ITERATION_PARAMETER_NAME=TAGS
/ITEMS=REST
;

Select_Active_File
/FILE_NAME=::TAGS
!/QUERY=
;

! Calculates resting background by calling the EMG_Resting_Background Meta-Command.
EMG_Resting_Background
/SIGNAL_NAMES=LGAS+LGLU+LMED+LTIB+LVAS+RGAS+RGLU+RMED+RTIB+RVAS
/SIGNAL_FOLDER=EMG_FILTERED
/RESULT_FOLDER=EMG_BACKGROUND
;

End_For_Each
/ITERATION_PARAMETER_NAME=TAGS
;

! This loop will remove the resting background from the signals.
For_Each
/ITERATION_PARAMETER_NAME=TAGS
/ITEMS=EMG+GAIT
;

Select_Active_File
/FILE_NAME=::TAGS
!/QUERY=
;

! Call the EMG_Remove_Background Meta-Command
EMG_Remove_Background
/SIGNAL_NAMES=LGAS+LGLU+LMED+LTIB+LVAS+RGAS+RGLU+RMED+RTIB+RVAS
/SIGNAL_FOLDER=EMG_FILTERED
/BACKGROUND_FOLDER=EMG_BACKGROUND
/RESULT_FOLDER=EMG_PROCESSED
;

End_For_Each
/ITERATION_PARAMETER_NAME=TAGS
;
Retrieved from ""