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 analysisAdvanced(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"} analysisInstance = pyCGM2.Lib.analysis.makeAnalysis("Gait", DATA_PATH,modelledFilenames,subjectInfo, experimentalInfo, modelInfo) exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysisInstance) exportFilter.export("testAdvanced", path=DATA_PATH,excelFormat = "xls",mode="Advanced")
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"} analysisInstance = pyCGM2.Lib.analysis.makeAnalysis( "Gait", DATA_PATH, modelledFilenames, subjectInfo, experimentalInfo, modelInfo) files.saveAnalysis(analysisInstance, DATA_PATH, "Save_and_openAnalysis") analysis2 = files.loadAnalysis(DATA_PATH, "Save_and_openAnalysis")
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 analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH,modelledFilenames,None, None, None) # viewer kv = plotViewers.LowerLimbKinematicsPlotViewer(analysisInstance) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setNormativeDataset(normativeDatasets.Schwartz2008("Free")) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() 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 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 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 detailedProcess_labelNotInTrial(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() #---- 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() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- # ----INFOS----- modelInfo = {"type": "S01"} subjectInfo = None experimentalInfo = None kinematicLabelsDict = { 'Left': ["LHipAngles", "LKneeAngles", "LAnkleAngles", "LForeFootAngles"], 'Right': ["RHipAngles", "RKneeAngles", "RAnkleAngles"] } kineticLabelsDict = None #{ 'Left': ["LHipMoment","LKneeMoment"], #'Right': ["RHipMoment","RKneeMoment"]} analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.setInfo(model=modelInfo) analysisFilter.build() analysisInstance = analysisFilter.analysis
def consistencyPlot_OneModelOutputPlot(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 = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) analysis2 = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) 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.gaitConsistencyPlot(ax, analysis1.kinematicStats, "LPelvisAngles", "Left", 0, color=colormap_i[0], legendLabel="analysis1", customLimits=None) plot.gaitConsistencyPlot(ax, analysis2.kinematicStats, "LKneeAngles", "Left", 0, color=colormap_i[1], legendLabel="analysis2", customLimits=None) ax.legend() plt.show()
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 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 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 analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) fig = plt.figure() ax = plt.gca() plot.gaitConsistencyPlot(ax, analysisInstance.kinematicStats, "LPelvisAngles", "Left", 0, color="blue", title="", xlabel="", ylabel="", ylim=None, customLimits=None) 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 analysisInstance = analysis.makeAnalysis("Gait", "CGM1.0", DATA_PATH, modelledFilenames, None, None, None) ndp = normativeDatasets.Schwartz2008("Free") gps = scores.CGM1_GPS() scf = scores.ScoreFilter(gps, analysisInstance, ndp) scf.compute() # viewer kv = plotViewers.GpsMapPlotViewer(analysisInstance) # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.setPath(DATA_PATH) pf.setPdfName(str("map")) pf.plot() plt.show()
def standardProcessing(DATA_PATH, modelledFilenames, modelVersion, modelInfo, subjectInfo, experimentalInfo, pointSuffix, outputPath=None, outputFilename="standardProcessing", exportXls=False): 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("LForeFoot") cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT["Right"].append("RForeFoot") analysis = standardSmartFunctions.make_analysis(trialManager, cgm.CGM1LowerLimbs.ANALYSIS_KINEMATIC_LABELS_DICT, cgm.CGM1LowerLimbs.ANALYSIS_KINETIC_LABELS_DICT, modelInfo, subjectInfo, experimentalInfo, pointLabelSuffix=pointSuffix) #---- export #----------------------------------------------------------------------- if exportXls: exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysis) exportFilter.export(outputFilename, path=outputPath,excelFormat = "xls",mode="Advanced")
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 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 analysisInstance = pyCGM2.Lib.analysis.makeAnalysis( "Gait", DATA_PATH, modelledFilenames, None, None, None)
def test_withData(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\gaitDeviations\\gaitPig\\" modelledFilenames = [ "gait Trial 01 - viconName.c3d", "gait Trial 03 - viconName.c3d" ] # ----INFOS----- modelInfo = None subjectInfo = None experimentalInfo = None normativeDataSet = dict() normativeDataSet["Author"] = "Schwartz2008" normativeDataSet["Modality"] = "Free" pointLabelSuffix = "" #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) 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() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- pointLabelSuffixPlus = pointLabelSuffix if pointLabelSuffix == "" else "_" + pointLabelSuffix kinematicLabelsDict = { 'Left': [ str("LHipAngles" + pointLabelSuffixPlus), str("LKneeAngles" + pointLabelSuffixPlus), str("LAnkleAngles" + pointLabelSuffixPlus), str("LFootProgressAngles" + pointLabelSuffixPlus), str("LPelvisAngles" + pointLabelSuffixPlus) ], 'Right': [ str("RHipAngles" + pointLabelSuffixPlus), str("RKneeAngles" + pointLabelSuffixPlus), str("RAnkleAngles" + pointLabelSuffixPlus), str("RFootProgressAngles" + pointLabelSuffixPlus), str("RPelvisAngles" + pointLabelSuffixPlus) ] } kineticLabelsDict = { 'Left': [ str("LHipMoment" + pointLabelSuffixPlus), str("LKneeMoment" + pointLabelSuffixPlus), str("LAnkleMoment" + pointLabelSuffixPlus), str("LHipPower" + pointLabelSuffixPlus), str("LKneePower" + pointLabelSuffixPlus), str("LAnklePower" + pointLabelSuffixPlus) ], 'Right': [ str("RHipMoment" + pointLabelSuffixPlus), str("RKneeMoment" + pointLabelSuffixPlus), str("RAnkleMoment" + pointLabelSuffixPlus), str("RHipPower" + pointLabelSuffixPlus), str("RKneePower" + pointLabelSuffixPlus), str("RAnklePower" + pointLabelSuffixPlus) ] } analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.build() #---- Joint patterns # xls Processing RULES_PATH = pyCGM2.PYCGM2_SETTINGS_FOLDER + "jointPatterns\\" rulesXls = RULES_PATH + "tests.xlsx" jpp = jointPatterns.XlsJointPatternProcedure(rulesXls) dpf = jointPatterns.JointPatternFilter(jpp, analysisFilter.analysis) dataFrameValues = dpf.getValues() dataFramePatterns = dpf.getPatterns()
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 test_envelopGaitPlotPanel(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_envelopGaitPlotPanel.c3d") modelledFilenames = ["test_envelopGaitPlotPanel.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","Right") envnf.setMaxMethod(enums.EmgAmplitudeNormalization.MeanMax) envnf.run() envnf = emgFilters.EmgNormalisationProcessingFilter(analysisInstance,"EMG2","Right") envnf.setMaxMethod(enums.EmgAmplitudeNormalization.MeanMax) envnf.run() data = analysisInstance.emgStats.data # viewer kv = emgPlotViewers.EnvEmgGaitPlotPanelViewer (analysisInstance) kv.setEmgs([["EMG1","Right","rf"],["EMG2","Right","rf"]]) kv.setNormalActivationLabels(["RECFEM","RECFEM"]) kv.setConcretePlotFunction(plot.gaitDescriptivePlot) # # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot()
def GpsCGM1Test(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gps\\" reconstructedFilenameLabelledNoExt = "gait Trial 03 - viconName" reconstructedFilenameLabelled = reconstructedFilenameLabelledNoExt + ".c3d" logging.info("data Path: " + DATA_PATH) logging.info("reconstructed file: " + reconstructedFilenameLabelled) modelledFilenames = [reconstructedFilenameLabelled] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) 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() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- # ----INFOS----- modelInfo = {"type": "S01"} subjectInfo = None experimentalInfo = None pointLabelSuffix = "" pointLabelSuffixPlus = pointLabelSuffix if pointLabelSuffix == "" else "_" + pointLabelSuffix kinematicLabelsDict = { 'Left': [ "LHipAngles" + pointLabelSuffixPlus, "LKneeAngles" + pointLabelSuffixPlus, "LAnkleAngles" + pointLabelSuffixPlus, "LFootProgressAngles" + pointLabelSuffixPlus, "LPelvisAngles" + pointLabelSuffixPlus ], 'Right': [ "RHipAngles" + pointLabelSuffixPlus, "RKneeAngles" + pointLabelSuffixPlus, "RAnkleAngles" + pointLabelSuffixPlus, "RFootProgressAngles" + pointLabelSuffixPlus, "RPelvisAngles" + pointLabelSuffixPlus ] } kineticLabelsDict = { 'Left': [ "LHipMoment" + pointLabelSuffixPlus, "LKneeMoment" + pointLabelSuffixPlus, "LAnkleMoment" + pointLabelSuffixPlus, "LHipPower" + pointLabelSuffixPlus, "LKneePower" + pointLabelSuffixPlus, "LAnklePower" + pointLabelSuffixPlus ], 'Right': [ "RHipMoment" + pointLabelSuffixPlus, "RKneeMoment" + pointLabelSuffixPlus, "RAnkleMoment" + pointLabelSuffixPlus, "RHipPower" + pointLabelSuffixPlus, "RKneePower" + pointLabelSuffixPlus, "RAnklePower" + pointLabelSuffixPlus ] } analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.setInfo(model=modelInfo) analysisFilter.build() analysisInstance = analysisFilter.analysis ## --- GPS ---- ndp = normativeDatasets.Schwartz2008("Free") gps = scores.CGM1_GPS() scf = scores.ScoreFilter(gps, analysisInstance, ndp) scf.compute() xlsExport = exporter.XlsAnalysisExportFilter() xlsExport.setAnalysisInstance(analysisInstance) xlsExport.export("gpsTest2", path=DATA_PATH, mode="Advanced")
def analysisAdvancedAndBasic_nonExistingLabel(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"operations\\analysis\\gait\\" modelledFilenames = ["gait Trial 03 - viconName.c3d","gait Trial 01 - viconName.c3d" ] #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) 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() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- # ----INFOS----- modelInfo={"type":"S01"} subjectInfo=None experimentalInfo=None kinematicLabelsDict ={ 'Left': ["LHipAngles","LKneeAngles","LAnkleAngles","LForeFootAngles"], 'Right': ["RHipAngles","RKneeAngles","RAnkleAngles"] } kineticLabelsDict =None#{ 'Left': ["LHipMoment","LKneeMoment"], #'Right': ["RHipMoment","RKneeMoment"]} analysisBuilder = analysis.GaitAnalysisBuilder(cycles, kinematicLabelsDict = kinematicLabelsDict, kineticLabelsDict = kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.setInfo(model = modelInfo) analysisFilter.build() analysisInstance = analysisFilter.analysis # ----INFOS----- modelInfo={"Type":"cgm2", "hjc":"hara"} subjectInfo={"Id":"1", "Name":"Lecter"} experimentalInfo={"Condition":"Barefoot", "context":"block"} exportFilter = exporter.XlsAnalysisExportFilter() exportFilter.setAnalysisInstance(analysisInstance) exportFilter.export("testAdvancedNan", path=DATA_PATH,excelFormat = "xls",mode="Advanced") exportFilter2 = exporter.XlsAnalysisExportFilter() exportFilter2.setAnalysisInstance(analysisInstance) exportFilter2.export("testBasic2", path=DATA_PATH,excelFormat = "xls",mode="Basic")
def makeEmgAnalysis(DATA_PATH, processedEmgFiles, emgChannels, subjectInfo=None, experimentalInfo=None, type="Gait", openmaTrials=None): """ makeEmgAnalysis : create the pyCGM2.Processing.analysis.Analysis instance with only EMG signals :param DATA_PATH [str]: path to your data :param processedEmgFiles [string list]: c3d files with emg processed outputs :param emgChannels [string list]: label of your emg channels **optional** :param subjectInfo [dict]: dictionnary gathering info about the patient (name,dob...) :param experimentalInfo [dict]: dictionnary gathering info about the data session (orthosis, gait task,... ) :param type [str]: process files with gait events if selected type is Gait :param openmaTrials [bool]: force the use of a list of openma trials """ if openmaTrials is not None: c3dmanagerProcedure = c3dManager.UniqueOpenmaTrialSetProcedure( DATA_PATH, processedEmgFiles, trials=openmaTrials) else: c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, processedEmgFiles) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableSpatioTemporal(False) cmf.enableKinematic(False) cmf.enableKinetic(False) cmf.enableEmg(True) trialManager = cmf.generate() #---- GAIT CYCLES FILTER #-------------------------------------------------------------------------- #----cycles if type == "Gait": cycleBuilder = cycle.GaitCyclesBuilder( spatioTemporalTrials=trialManager.spatioTemporal["Trials"], kinematicTrials=trialManager.kinematic["Trials"], kineticTrials=trialManager.kinetic["Trials"], emgTrials=trialManager.emg["Trials"]) else: cycleBuilder = cycle.CyclesBuilder( 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() emgLabelList = [label + "_Rectify_Env" for label in emgChannels] if type == "Gait": analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=None, kineticLabelsDict=None, emgLabelList=emgLabelList, subjectInfos=subjectInfo, modelInfos=None, experimentalInfos=experimentalInfo) else: analysisBuilder = analysis.AnalysisBuilder( cycles, kinematicLabelsDict=None, kineticLabelsDict=None, emgLabelList=emgLabelList, subjectInfos=subjectInfo, modelInfos=None, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.build() analysisInstance = analysisFilter.analysis return analysisInstance
def makeAnalysis(DATA_PATH, modelledFilenames, type="Gait", subjectInfo=None, experimentalInfo=None, modelInfo=None, pointLabelSuffix=None, kinematicLabelsDict=None, kineticLabelsDict=None, disableKinetics=False, openmaTrials=None): """ makeAnalysis : create the pyCGM2.Processing.analysis.Analysis instance :param DATA_PATH [str]: path to your data :param modelledFilenames [string list]: c3d files with model outputs **optional** :param type [str]: process files with gait events if selected type is Gait :param subjectInfo [dict]: dictionnary gathering info about the patient (name,dob...) :param experimentalInfo [dict]: dictionnary gathering info about the data session (orthosis, gait task,... ) :param modelInfo [dict]: dictionnary gathering info about the used model) :param pointLabelSuffix [string]: suffix previously added to your model outputs :param kinematicLabelsDict [dict]: dictionnary with two entries,Left and Right, pointing to kinematic model outputs you desire processes :param kineticLabelsDict [dict]: dictionnary with two entries,Left and Right, pointing to kinetic model outputs you desire processes :param disableKinetics [bool]: disable kinetics processing :param openmaTrials [bool]: force the use of a list of openma trials .. note:: The dictionnaries (subjectInfo,experimentalInfo,modelInfo) is interesting if you want to find these information within the xls file """ #---- c3d manager if openmaTrials is not None: c3dmanagerProcedure = c3dManager.UniqueOpenmaTrialSetProcedure( DATA_PATH, modelledFilenames, trials=openmaTrials) else: c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) if disableKinetics: cmf.enableKinetic(False) trialManager = cmf.generate() #----cycles if type == "Gait": cycleBuilder = cycle.GaitCyclesBuilder( spatioTemporalTrials=trialManager.spatioTemporal["Trials"], kinematicTrials=trialManager.kinematic["Trials"], kineticTrials=trialManager.kinetic["Trials"], emgTrials=trialManager.emg["Trials"]) else: cycleBuilder = cycle.CyclesBuilder( 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() #----analysis if kinematicLabelsDict is None: kinematicLabelsDict = cgm.CGM.ANALYSIS_KINEMATIC_LABELS_DICT if kineticLabelsDict is None: kineticLabelsDict = cgm.CGM.ANALYSIS_KINETIC_LABELS_DICT if type == "Gait": analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, pointlabelSuffix=pointLabelSuffix) else: analysisBuilder = analysis.AnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, pointlabelSuffix=pointLabelSuffix) analysisFilter = analysis.AnalysisFilter() analysisFilter.setInfo(subject=subjectInfo, model=modelInfo, experimental=experimentalInfo) analysisFilter.setBuilder(analysisBuilder) analysisFilter.build() return analysisFilter.analysis
def cycleAnalysis(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH+"EMG\\SampleNantes\\" gaitTrial = "gait.c3d" restTrial = "repos.c3d" 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+"test.c3d") modelledFilenames = ["test.c3d"] c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure(DATA_PATH,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
def test(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "operations\\analysis\\gait\\" modelledFilenames = [ "gait Trial 01 - viconName.c3d", "gait Trial 03 - viconName.c3d" ] # ----INFOS----- modelInfo = None subjectInfo = None experimentalInfo = None normativeDataSet = dict() normativeDataSet["Author"] = "Schwartz2008" normativeDataSet["Modality"] = "Free" pointLabelSuffix = "" #---- c3d manager #-------------------------------------------------------------------------- c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, modelledFilenames) cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure) cmf.enableEmg(False) 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() #---- GAIT ANALYSIS FILTER #-------------------------------------------------------------------------- pointLabelSuffixPlus = pointLabelSuffix if pointLabelSuffix == "" else "_" + pointLabelSuffix kinematicLabelsDict = { 'Left': [ str("LHipAngles" + pointLabelSuffixPlus), str("LKneeAngles" + pointLabelSuffixPlus), str("LAnkleAngles" + pointLabelSuffixPlus), str("LFootProgressAngles" + pointLabelSuffixPlus), str("LPelvisAngles" + pointLabelSuffixPlus) ], 'Right': [ str("RHipAngles" + pointLabelSuffixPlus), str("RKneeAngles" + pointLabelSuffixPlus), str("RAnkleAngles" + pointLabelSuffixPlus), str("RFootProgressAngles" + pointLabelSuffixPlus), str("RPelvisAngles" + pointLabelSuffixPlus) ] } kineticLabelsDict = { 'Left': [ str("LHipMoment" + pointLabelSuffixPlus), str("LKneeMoment" + pointLabelSuffixPlus), str("LAnkleMoment" + pointLabelSuffixPlus), str("LHipPower" + pointLabelSuffixPlus), str("LKneePower" + pointLabelSuffixPlus), str("LAnklePower" + pointLabelSuffixPlus) ], 'Right': [ str("RHipMoment" + pointLabelSuffixPlus), str("RKneeMoment" + pointLabelSuffixPlus), str("RAnkleMoment" + pointLabelSuffixPlus), str("RHipPower" + pointLabelSuffixPlus), str("RKneePower" + pointLabelSuffixPlus), str("RAnklePower" + pointLabelSuffixPlus) ] } analysisBuilder = analysis.GaitAnalysisBuilder( cycles, kinematicLabelsDict=kinematicLabelsDict, kineticLabelsDict=kineticLabelsDict, subjectInfos=subjectInfo, modelInfos=modelInfo, experimentalInfos=experimentalInfo) analysisFilter = analysis.AnalysisFilter() analysisFilter.setBuilder(analysisBuilder) analysisFilter.build() #---- DISCRETE POINT FILTER #----------------------------------------------------------------------- # Benedetti Processing dpProcedure = discretePoints.GoldbergProcedure() dpf = discretePoints.DiscretePointsFilter(dpProcedure, analysisFilter.analysis) dataFrame = dpf.getOutput() xlsExport = exporter.XlsExportDataFrameFilter() xlsExport.setDataFrames(dataFrame) xlsExport.export("discretePointsGoldberg", path=DATA_PATH)
def EnvelopCoactivationPlot(cls): # ----DATA----- DATA_PATH = pyCGM2.TEST_DATA_PATH + "EMG\\SampleNantes\\" gaitTrial = "gait.c3d" restTrial = "repos.c3d" 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 + "test.c3d") modelledFilenames = ["test.c3d"] c3dmanagerProcedure = c3dManager.UniqueC3dSetProcedure( DATA_PATH, 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() envnf = emgFilters.EmgNormalisationProcessingFilter( analysisInstance, "EMG2", "Left") envnf.setMaxMethod(enums.EmgAmplitudeNormalization.MeanMax) envnf.run() # viewer kv = emgPlotViewers.CoactivationEmgPlotViewer(analysisInstance) kv.setEmgs("EMG1", "EMG2") kv.setMuscles("RF1", "RF2") kv.setConcretePlotFunction(plot.gaitDescriptivePlot) kv.setContext("Left") # # filter pf = plotFilters.PlottingFilter() pf.setViewer(kv) pf.plot() plt.show()