def automaticCPdeviations(DATA_PATH, analysis, pointLabelSuffix=None, filterTrue=False, export=True, outputname="Nieuwenhuys2017"): """ Detect gait deviation for CP according a Delphi Consensus (Nieuwenhuys2017 et al 2017) :param analysis [pyCGM2.Processing.analysis.Analysis]: pyCGM2 analysis instance """ RULES_PATH = pyCGM2.PYCGM2_SETTINGS_FOLDER + "jointPatterns\\" rulesXls = RULES_PATH + "Nieuwenhuys2017.xlsx" jpp = jointPatterns.XlsJointPatternProcedure(rulesXls, pointSuffix=pointLabelSuffix) dpf = jointPatterns.JointPatternFilter(jpp, analysis) dataFrameValues = dpf.getValues() dataFramePatterns = dpf.getPatterns(filter=filterTrue) if export: xlsExport = exporter.XlsExportDataFrameFilter() xlsExport.setDataFrames([dataFrameValues]) xlsExport.export(str(outputname + "_Data"), path=DATA_PATH) xlsExport = exporter.XlsExportDataFrameFilter() xlsExport.setDataFrames([dataFramePatterns]) xlsExport.export(str(outputname + "_Patterns"), path=DATA_PATH) return dataFramePatterns
def kinematicsOnly_bothSide(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 + "Nieuwenhuys2017.xlsx" jpp = jointPatterns.XlsJointPatternProcedure(rulesXls) dpf = jointPatterns.JointPatternFilter(jpp, analysisFilter.analysis) dataFrameValues = dpf.getValues() dataFramePatterns = dpf.getPatterns() xlsExport = exporter.XlsExportDataFrameFilter() xlsExport.setDataFrames([dataFrameValues]) xlsExport.export("TestsPointData", path=DATA_PATH) xlsExport = exporter.XlsExportDataFrameFilter() xlsExport.setDataFrames([dataFramePatterns]) xlsExport.export("TestsPatternsData", path=DATA_PATH)
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)