Here, we show how you can work with c3d files incorporating CGM#i model outputs and gait events.
The code introduces the analysiscopy object which contain time-normalized results under
specific conditions ( ie, barefoot spontaneous gait, fast gait with shoes…. )
Basic process
import pyCGM2
from pyCGM2.Report import normativeDatasets
from pyCGM2.Lib import analysis
from pyCGM2.Lib import plot
# data
DATA_PATH = "c:\\pathTomydata\\"
modelledFilenames = ["gait Trial 01.c3d", "gait Trial 02.c3d"] # two gait trials with both gait event and CGMi model ouptuts
analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledFilenames,
emgChannels=None) # construction of the analysis instance.
normativeDataset = normativeDatasets.NormativeData("Schwartz2008","Free") # selected normative dataset
# plots
plot.plot_DescriptiveKinematic(DATA_PATH,analysisInstance,"LowerLimb",normativeDataset)
plot.plot_DescriptiveKinetic(DATA_PATH,analysisInstance,"LowerLimb",normativeDataset)
plot.plot_spatioTemporal(DATA_PATH,analysisInstance)
# export as spreadsheet
analysis.exportAnalysis(analysisInstance,DATA_PATH,"spreadsheet")
copyThe code
- returns plot panels of the kinematics, kinetics and spatio-temporal parameters.
- export your result in a excel spreadsheet
The central object is the analysisInstancecopy built from the function makeAnalysiscopy.
This function time-normalizes all model ouptuts (ie kinematic and kinetic model outputs, plus all emg analog channels), then return an analysiscopy instance
Advanced use
Add metadata information
We input information relative to the subject, the experiment itself or the model as basic dictionaries
This metadata information will appear in each sheet of the exported xlsx spreasheet as column
analysisInstance = analysis.makeAnalysis(DATA_PATH,
modelledFilenames,
emgChannels= None,
subjectInfo={"Name":"Hannibal"},
experimentalInfo={"Context":"Post-Toxin"},
modelInfo={"model":"CGM"},
)
copyProcess specific model outputs
Instead of to time-normalized all CGM model outputs, the code below deals with specific kinematic or kinetic parameters
analysisInstance = analysis.makeAnalysis(DATA_PATH,
modelledFilenames,
kinematicLabelsDict = {"Left":["LHipAngles","LKneeAngles"],"Right":["RHipAngles","RKneeAngles"]},
kineticLabelsDict = {"Left":["LHipMoment","LKneePower"],"Right":["RHipMoment","RKneePower"]},
emgChannels = None,
subjectInfo={"Name":"Hannibal"},
experimentalInfo={"Context":"Post-Toxin"},
modelInfo={"model":"CGM"},
)
copykinematicLabelsDictcopy is a dictionary with two entries (ie Leftcopy and rightcopy) which defined the event context used for time-normalized a CGM ouptut.
In the above case, the LHipAnglescopy and LKneeAnglescopy are time-normalized with Leftcopy gait events and RHipAnglescopy and RKneeAnglescopy with Rightcopy gait events.
The process is similar for kinetic outputs kineticLabelsDictcopy. LHipMomentcopy and LKneePowercopy are time-normalized with Leftcopy gait events and RHipMomentcopy and RKneePowercopy with Rightcopy gait events.
work with different set of c3d
This is an particular case a gait analyst might encounter.
In this example, the spatio-temporal parameters , kinematic results and kinetics results are computed for different c3d files.
analysisInstance = analysis.makeAnalysis(DATA_PATH,
None,
kinematicLabelsDict = {"Left":["LHipAngles","LKneeAngles"],"Right":["RHipAngles","RKneeAngles"]},
kineticLabelsDict = {"Left":["LHipMoment","LKneePower"],"Right":["RHipMoment","RKneePower"]},
emgChannels = None,
subjectInfo={"Name":"Hannibal"},
experimentalInfo={"Context":"Post-Toxin"},
modelInfo={"model":"CGM"},
pstfilenames = ["Gait1.c3d","Gait2.c3d"],
kinematicfilenames = ["Gait3.c3d","Gait4.c3d"],
kineticfilenames = ["Gait5.c3d","Gait6.c3d"]
)
copyThis process is enable from the presence of the keyword arguments:
pstfilenamescopykinematicfilenamescopykineticfilenamescopyemgfilenamescopy
In the above code :
- the spatio-temporal parameters are calculated from
["Gait1.c3d","Gait2.c3d"]copy - the kinematic results are calculated from
["Gait3.c3d","Gait4.c3d"]copy - the kinetic results are calculated from
["Gait5.c3d","Gait6.c3d"]copy