def singleAnalysis(cls): # ----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(DATA_PATH, modelledFilenames, None, None, None) # viewer kv = plotViewers.SpatioTemporalPlotViewer(analysisInstance) kv.setNormativeDataset(normativeDatasets.NormalSTP()) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(DATA_PATH, "stp", "pdf") pf.plot() plt.show()
def plot_spatioTemporal(DATA_PATH, analysis, exportPdf=False, outputName=None, show=True, title=None, exportPng=False): """ plot_spatioTemporal : display spatio-temporal parameters as horizontal histogram :param DATA_PATH [str]: path to your data :param analysis [pyCGM2.Processing.analysis.Analysis]: pyCGM2 analysis instance **optional** :param exportPdf [bool]: save as pdf (False[default]) :param outputName [string]: name of your pdf file (None[default] export your pdf with name : Global Analysis) :param show [bool]: enable matplotlib show function :param title [string]: change default title of the plot panel """ if outputName is None: outputName = "pyCGM2-analysis" if exportPdf or exportPng: filenameOut = outputName + "-SpatioTemporal parameters" stpv = plotViewers.SpatioTemporalPlotViewer(analysis) stpv.setNormativeDataset(normativeDatasets.NormalSTP()) # filter stppf = plotFilters.PlottingFilter() stppf.setViewer(stpv) if title is not None: stppf.setTitle(title + "-SpatioTemporal parameters") if exportPdf: stppf.setExport(DATA_PATH, filenameOut, "pdf") fig = stppf.plot() if show: plt.show() if exportPng: fig.savefig(DATA_PATH + filenameOut + ".png") return fig, filenameOut + ".png" else: return fig
def test_singleAnalysis(self): # ----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) # viewer kv = plotViewers.SpatioTemporalPlotViewer(analysisInstance) kv.setNormativeDataset(normativeDatasets.NormalSTP()) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot()
def singleAnalysis(cls): # ----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) # viewer kv = plotViewers.SpatioTemporalPlotViewer(analysis) kv.setNormativeDataset(normativeDatasets.NormalSTP()) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(DATA_PATH, "stp", "pdf") pf.plot() plt.show()
def cgm_gaitPlots(modelVersion, analysis, kineticFlag, outputPath, pdfFilename, pointLabelSuffix="", normativeDataset=None): # filter 0 - stp panel #------------------------------------------- # pstViewer stpv = plotViewers.SpatioTemporalPlotViewer(analysis) stpv.setNormativeDataset(normativeDatasets.NormalSTP()) # filter stppf = plotFilters.PlottingFilter() stppf.setViewer(stpv) stppf.setExport(outputPath, str(pdfFilename + "-stp"), "pdf") stppf.plot() # filter 1 - descriptive kinematic panel #------------------------------------------- # viewer if modelVersion in [ "CGM1.0", "CGM1.1", "CGM2.1", "CGM2.2", "CGM2.2e", "CGM2.3", "CGM2.3e" ]: kv = plotViewers.LowerLimbKinematicsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) elif modelVersion in ["CGM2.4", "CGM2.4e"]: kv = plotViewers.LowerLimbMultiFootKinematicsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) else: raise Exception("[pyCGM2] Model version not known") kv.setConcretePlotFunction(plot.gaitDescriptivePlot) if normativeDataset is not None: kv.setNormativeDataset(normativeDataset) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(outputPath, str(pdfFilename + "-descriptive Kinematics"), "pdf") pf.plot() # filter 2 - consistency kinematic panel #------------------------------------------- # viewer if modelVersion in [ "CGM1.0", "CGM1.1", "CGM2.1", "CGM2.2", "CGM2.2e", "CGM2.3", "CGM2.3e" ]: kv = plotViewers.LowerLimbKinematicsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) elif modelVersion in ["CGM2.4", "CGM2.4e"]: kv = plotViewers.LowerLimbMultiFootKinematicsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) else: raise Exception("[pyCGM2] Model version not known") kv.setConcretePlotFunction(plot.gaitConsistencyPlot) if normativeDataset is not None: kv.setNormativeDataset(normativeDataset) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(outputPath, str(pdfFilename + "-consistency Kinematics"), "pdf") pf.plot() if kineticFlag: # filter 1 - descriptive kinematic panel #------------------------------------------- # viewer if modelVersion in [ "CGM1.0", "CGM1.1", "CGM2.1", "CGM2.2", "CGM2.2e", "CGM2.3", "CGM2.3e", "CGM2.4", "CGM2.4e" ]: kv = plotViewers.LowerLimbKineticsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) if normativeDataset is not None: kv.setNormativeDataset(normativeDataset) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(outputPath, str(pdfFilename + "-descriptive Kinetics"), "pdf") pf.plot() # filter 2 - consistency kinematic panel #------------------------------------------- # viewer if modelVersion in [ "CGM1.0", "CGM1.1", "CGM2.1", "CGM2.2", "CGM2.2e", "CGM2.3", "CGM2.3e", "CGM2.4", "CGM2.4e" ]: kv = plotViewers.LowerLimbKineticsPlotViewer( analysis, pointLabelSuffix=pointLabelSuffix) kv.setConcretePlotFunction(plot.gaitConsistencyPlot) if normativeDataset is not None: kv.setNormativeDataset(normativeDataset) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport(outputPath, str(pdfFilename + "-consistency Kinetics"), "pdf") pf.plot()