def meanPlot_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 analysis1 = gaitSmartFunctions.make_analysis( trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo) analysis2 = gaitSmartFunctions.make_analysis( trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo) analyses = [analysis1, analysis2] fig = plt.figure() ax = plt.gca() colormap = plt.cm.Reds colormap_i = [colormap(i) for i in np.linspace(0.2, 1, len(analyses))] plot.gaitMeanPlot(ax, analysis1.kinematicStats, "LPelvisAngles", "Left", 0, color=colormap_i[0], legendLabel="analysis1", customLimits=None) plot.gaitMeanPlot(ax, analysis2.kinematicStats, "LKneeAngles", "Left", 0, color=colormap_i[1], legendLabel="analysis2", customLimits=None) ax.legend() plt.show()
def Save_and_openAnalysis(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gait\\" 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 #-------------------------------------------------------------------------- # ----INFOS----- modelInfo = {"Type": "cgm2", "hjc": "hara"} subjectInfo = {"Id": "1", "Name": "Lecter"} experimentalInfo = {"Condition": "Barefoot", "context": "block"} analysis = gaitSmartFunctions.make_analysis( trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo) files.saveAnalysis(analysis, DATA_PATH, "Save_and_openAnalysis") analysis2 = files.loadAnalysis(DATA_PATH, "Save_and_openAnalysis")
def makeAnalysis_oneFile_noInfo(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gait\\" 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)
def analysisBasic(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gait\\" 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 #-------------------------------------------------------------------------- # ----INFOS----- modelInfo = {"Type": "cgm2", "hjc": "hara"} subjectInfo = {"Id": "1", "Name": "Lecter"} experimentalInfo = {"Condition": "Barefoot", "context": "block"} analysis = gaitSmartFunctions.make_analysis( trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo) exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysis) exportFilter.export("test", path=DATA_PATH, excelFormat="xls", mode="Basic")
def gaitMeanOnlyKineticPlotPanel(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 analysis1 = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) analysis2 = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo,subjectInfo,experimentalInfo) kv = plotViewers.multipleAnalyses_LowerLimbKineticsPlotViewer([analysis1,analysis2],"Right", ["ana1","ana2"]) kv.setConcretePlotFunction(plot.gaitMeanPlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() plt.show()
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) ndp = normativeDatasets.Schwartz2008("Free") gps =scores.CGM1_GPS() scf = scores.ScoreFilter(gps,analysis, ndp) scf.compute() # viewer kv = plotViewers.GpsMapPlotViewer(analysis) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setPath(DATA_PATH) pf.setPdfName(str("map")) pf.plot() plt.show()
def gaitDescriptiveKinematicPlotPanel(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.LowerLimbKinematicsPlotViewer(analysis) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() ka = annotator.Annotator(pf.fig) ka.IncreasedRange(0,40,10,40, "Context", timing="Throughout Cycle") print(ka.getAnnotations()) plt.show()
def consistencyPlot_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.gaitConsistencyPlot(ax, analysis.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None) plt.show()
def gaitDescriptiveKinematicPlotPanel_recorded(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.LowerLimbKinematicsPlotViewer(analysis) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setExport("C:\\Users\\HLS501\\Desktop\\","test","png") pf.plot() plt.show()
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 gaitProcessing(DATA_PATH, modelledFilenames, modelVersion, modelInfo, subjectInfo, experimentalInfo, normativeData, pointSuffix, outputPath=None, outputFilename="gaitProcessing", exportXls=False, plot=True, plotDisplay=True): if outputPath is None: outputPath= DATA_PATH if isinstance(modelledFilenames,str) or isinstance(modelledFilenames,unicode): modelledFilenames = [modelledFilenames] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() #---- make analysis #----------------------------------------------------------------------- # pycgm2-filter pipeline are gathered in a single function if modelVersion in["CGM1.0","CGM1.1","CGM2.1","CGM2.2","CGM2.2e","CGM2.3","CGM2.3e","CGM2.4","CGM2.4e"]: if modelVersion in ["CGM2.4","CGM2.4e"]: cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT["Left"].append("LForeFootAngles") cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT["Right"].append("RForeFootAngles") analysis = gaitSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo, pointLabelSuffix=pointSuffix) #---- normative dataset #----------------------------------------------------------------------- if normativeData["Author"] == "Schwartz2008": chosenModality = normativeData["Modality"] nds = normativeDatasets.Schwartz2008(chosenModality) # modalites : "Very Slow" ,"Slow", "Free", "Fast", "Very Fast" elif normativeData["Author"] == "Pinzone2014": chosenModality = normativeData["Modality"] nds = normativeDatasets.Pinzone2014(chosenModality) # modalites : "Center One" ,"Center Two" #---- GPS gps =scores.CGM1_GPS(pointSuffix= pointSuffix) scf = scores.ScoreFilter(gps,analysis, nds) scf.compute() #---- export #----------------------------------------------------------------------- files.saveAnalysis(analysis,outputPath,outputFilename) if exportXls: exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysis) exportFilter.export(outputFilename, path=outputPath,excelFormat = "xls",mode="Advanced") #---- plot panels #----------------------------------------------------------------------- if plot: gaitSmartFunctions.cgm_gaitPlots(modelVersion,analysis,trialManager.kineticFlag, outputPath,outputFilename, pointLabelSuffix=pointSuffix, normativeDataset=nds ) if plotDisplay: plt.show() return analysis
subjectInfo = None experimentalInfo = None modelVersion = "CGM2.4" pointSuffix = "" # analysis constructor------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH, modelledFiles) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) trialManager = cmf.generate() analysis = gaitSmartFunctions.make_analysis(trialManager, None, None, modelInfo, subjectInfo, experimentalInfo, modelVersion="CGM2.4", pointLabelSuffix=pointSuffix) # end analysis ------- normativeDataset = normativeDatasets.Schwartz2008("Free") kv = plotViewers.LowerLimbMultiFootKinematicsPlotViewer( analysis, pointLabelSuffix=pointSuffix) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDataset) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv)