Work with emg

Before running following code, the analyst must define the emg configuration of his data collection. As default, pyCGM2 considers the content of the file emg.settingscopy, located in the folder pyCGM2/Settingscopy.

Here is a part of emg.settingscopy

CHANNELS:
    Voltage.EMG1 :
        Muscle : RECFEM
        Context : Left
        NormalActivity : RECFEM

    Voltage.EMG2 :
        Muscle : RECFEM
        Context : Right
        NormalActivity : RECFEM
    ...
    Voltage.EMG16 :
        Muscle :
        Context :
        NormalActivity :

copy
  • 16 channels are predefined.
  • Channels are named Voltage.EMG1copy to Voltage.EMG16copy and matched with analog label of your c3d.
  • for each channel, the label of the muscle (musclecopy) is given as well as its side location (Contextcopy)
  • the item NormalActivitycopy is the muscle label used for displaying the instant of normal activity in the background of the plot. Unlike, the musclecopy item, user must select a NormalActivitycopy label in the list:
ADDBRE , ADDLON, ADDMAG, BICFEM, CALF, EXTDIGLON, EXTHALLON, FLEDIGLON, FLEHALLON,
GASTRO, GLUMAX, GLUMED, GLUMIN, GRACIL, HAMSTR, HIPABD, HIPADD, HIPEXT, HIPFLE,
ILIACU, ILIOPS, LATHAM, LATQUA, MEDHAM, MEDQUA, PERBRE, PERLON, POPLIT, RECFEM,
SARTOR, SEMIME, SEMITE, SOLEUS, TENFACLAT, TIBANT, TIBPOS, VASINT, VASLAT,
VASMEDLON, VASMEDOBL
copy

Alter the emg.settingscopy located in the folder pyCGM2/Settingscopy if you want to configure your emg routine.

Exceptionally, if your gait data collection does not match with your routine, you can copy/paste the emg.settingscopy in the data folder, then edit it.

plot rectify emg

The code shows how you can create plot panel reporting temporal traces of the emg.

import pyCGM2
from pyCGM2.Lib import plot
from pyCGM2.Lib import emg

# data
DATA_PATH = "C:\\myPATH\\"
trialNames = ["03367_05136_20200604-GBNNN-VDEF-01.c3d"]

# load emg manager
emgManager = emg.loadEmg(DATA_PATH)

# process emg channels
emg.processEMG(DATA_PATH, trialNames, emgManager.getChannels(),
    highPassFrequencies=[20,200],
    envelopFrequency=6.0)

# plot
plot.plotTemporalEMG(DATA_PATH, trialNames[0],
        rectify = True)
copy

plot time-normalized emg envelops

Instead of plotting temporal EMG traces, we show how to report the emg envelops normalized on gait event. This requires the construction of an analysis Instancecopy.

import pyCGM2
from pyCGM2.Lib import plot
from pyCGM2.Lib import emg
from pyCGM2.Lib import analysis

# data
DATA_PATH = "C:\\myPATH\\"
trialNames = ["03367_05136_20200604-GBNNN-VDEF-01.c3d", "03367_05136_20200604-GBNNN-VDEF-02.c3d"]

# emg manager
emgManager = emg.loadEmg(DATA_PATH)

# process emg analog channels
emg.processEMG(DATA_PATH, trialNames, emgManager.getChannels(),
    highPassFrequencies=[20,200],
    envelopFrequency=6.0)

# construct the analysis instance
analysisInstance = analysis.makeAnalysis(DATA_PATH,
                    trialNames,
                    emgChannels = emgManager.getChannels()                )

# plot descriptive and consistancy plot panels
plot.plotDescriptiveEnvelopEMGpanel(DATA_PATH,analysisInstance)
plot.plotConsistencyEnvelopEMGpanel(DATA_PATH,analysisInstance)
copy