def test_descriptivePlot_OneModelOutputPlot(self): """ Plot only one Model output """ # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\" modelledFilenames = ["gait Trial 01.c3d", "gait Trial 02.c3d"] #---- Analysis #-------------------------------------------------------------------------- modelInfo = None subjectInfo = None experimentalInfo = None analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledFilenames) fig = plt.figure() ax = plt.gca() plot.gaitDescriptivePlot(ax, analysisInstance.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None)
def test_gaitDescriptivePlot(self): DATA_PATH, analysisInstance = dataTest1() fig = plt.figure() ax = plt.gca() reportPlot.gaitDescriptivePlot(ax, analysisInstance.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None) if SHOW: plt.show() return fig
def descriptivePlot_OneModelOutputPlot(cls): """ Plot only one Model output """ # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo = None subjectInfo = None experimentalInfo = None analysis = gaitSmartFunctions.make_analysis( trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo) fig = plt.figure() ax = plt.gca() plot.gaitDescriptivePlot(ax, analysis.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None) plt.show()
def descriptivePlot_OneModelOutputPlot(cls): """ Plot only one Model output """ # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\plot\\gaitPlot\\" modelledFilenames = ["gait Trial 03 - viconName.c3d"] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- Analysis #-------------------------------------------------------------------------- modelInfo = None subjectInfo = None experimentalInfo = None analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) fig = plt.figure() ax = plt.gca() plot.gaitDescriptivePlot(ax, analysisInstance.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None) plt.show()
def test_envelopPlotSingleEmg(self): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"GaitData\\EMG\\Hånnibøl Lecter-nerve block\\" gaitTrial = "PRE-gait trial 01.c3d" restTrial = "PRE-repos.c3d" DATA_PATH_OUT = pyCGM2.TEST_DATA_PATH_OUT+"GaitData\\EMG\\Hånnibøl Lecter-nerve block\\" files.createDir(DATA_PATH_OUT) EMG_LABELS=['EMG1','EMG2'] acq = btkTools.smartReader(DATA_PATH +gaitTrial) bf = emgFilters.BasicEmgProcessingFilter(acq,EMG_LABELS) bf.setHighPassFrequencies(20.0,200.0) bf.run() envf = emgFilters.EmgEnvelopProcessingFilter(acq,EMG_LABELS) envf.setCutoffFrequency(180.0) envf.run() btkTools.smartWriter(acq,DATA_PATH_OUT+"test_envelopPlotSingleEmg.c3d") modelledFilenames = ["test_envelopPlotSingleEmg.c3d"] c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH_OUT,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableSpatioTemporal(False) cmf.enableKinematic(False) cmf.enableKinetic(False) cmf.enableEmg(True) trialManager = cmf.generate() #---- GAIT CYCLES FILTER #-------------------------------------------------------------------------- cycleBuilder = cycle.GaitCyclesBuilder(spatioTemporalTrials=trialManager.spatioTemporal["Trials"], kinematicTrials = trialManager.kinematic["Trials"], kineticTrials = trialManager.kinetic["Trials"], emgTrials=trialManager.emg["Trials"]) cyclefilter = cycle.CyclesFilter() cyclefilter.setBuilder(cycleBuilder) cycles = cyclefilter.build() modelInfo=None subjectInfo=None experimentalInfo=None analysisBuilder = analysis.GaitAnalysisBuilder(cycles, kinematicLabelsDict = None, kineticLabelsDict = None, emgLabelList = ['EMG1_Rectify_Env','EMG2_Rectify_Env'], subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.setInfo(model = modelInfo) analysisFilter.build() analysisInstance = analysisFilter.analysis envnf = emgFilters.EmgNormalisationProcessingFilter(analysisInstance,"EMG1","Left") envnf.setMaxMethod(enums.EmgAmplitudeNormalization.MeanMax) envnf.run() fig = plt.figure() ax = plt.gca() plot.gaitDescriptivePlot(ax,analysisInstance.emgStats, "EMG1_Rectify_Env","Left",0, color=None, title="title", xlabel=None, ylabel=None,ylim=None,legendLabel=None, customLimits=None) footOff = analysisInstance.emgStats.pst['stancePhase', "Left"]["mean"] plot.addNormalActivationLayer(ax,"RECFEM", footOff)
def compareSelectedEmgEvelops(analyses, legends, emgChannels, contexts, normalized=False, plotType="Descriptive", type="Gait", show=True, title=None): """ compareSelectedEmgEvelops : compare selected emg envelops from pyCGM2 analysis instances :param analysis [pyCGM2.Processing.analysis.Analysis list]: list of pyCGM2 analysis instances :param legends [string list]: legend of each analysis instance :param emgChannels [string list]: label of your emg channels :param contexts [string list]: context associated with your emg channels **optional** :param normalized [bool]: display normalized amplitude envelop (false [defaut]) :param plotType [string]: trace type ( Descriptive [default] or Consistency) :param type [string]: display events (Gait [defaut] or None) :param show [bool]: enable matplotlib show function :param title [string]: change default title of the plot panel :example: >>> plot.compareSelectedEmgEvelops([emgAnalysisPre,emgAnalysisPost],["Pre","Post"],["EMG1","EMG1"],["Left","Left"],normalized=False) """ fig = plt.figure() ax = plt.gca() colormap_i_left = [ plt.cm.Reds(k) for k in np.linspace(0.2, 1, len(analyses)) ] colormap_i_right = [ plt.cm.Blues(k) for k in np.linspace(0.2, 1, len(analyses)) ] i = 0 for analysis in analyses: label = emgChannels[ i] + "_Rectify_Env" if not normalized else emgChannels[ i] + "_Rectify_Env_Norm" title = "EMG Envelop Comparison" if not normalized else "Normalized EMG Envelop Comparison" if contexts[i] == "Left": color = colormap_i_left[i] elif contexts[i] == "Right": color = colormap_i_right[i] if plotType == "Descriptive": if type == "Gait": plot.gaitDescriptivePlot(ax, analysis.emgStats, label, contexts[i], 0, color=color, title=title, xlabel="Gait Cycle", ylabel="emg", ylim=None, customLimits=None, legendLabel=legends[i]) else: plot.descriptivePlot(ax, analysis.emgStats, label, contexts[i], 0, color=None, title=title, xlabel="Gait Cycle", ylabel="emg", ylim=None, customLimits=None, legendLabel=legends[i]) elif plotType == "Consistency": if type == "Gait": plot.gaitConsistencyPlot(ax, analysis.emgStats, label, contexts[i], 0, color=color, title=title, xlabel="Gait Cycle", ylabel="emg", ylim=None, customLimits=None, legendLabel=legends[i]) else: plot.consistencyPlot(ax, analysis.emgStats, label, contexts[i], 0, color=None, title=title, xlabel="Gait Cycle", ylabel="emg", ylim=None, customLimits=None, legendLabel=legends[i]) else: raise Exception("[pyCGM2]: plot type does not recongnized") i += 1 ax.legend(fontsize=6) if show: plt.show()