Пример #1
0
    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")
Пример #2
0
    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")
Пример #3
0
    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)
Пример #4
0
    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")
Пример #5
0
    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")
Пример #6
0
    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()
Пример #7
0
    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()
Пример #8
0
    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()
Пример #9
0
    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
Пример #10
0
    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()
Пример #11
0
    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()
Пример #12
0
    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()
Пример #13
0
    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()
Пример #14
0
    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()
Пример #15
0
    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()
Пример #16
0
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")
Пример #17
0
    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()
Пример #18
0
    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()
Пример #19
0
    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()
Пример #20
0
    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)
Пример #21
0
    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()
Пример #22
0
    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")
Пример #23
0
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
Пример #24
0
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
Пример #25
0
    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()
Пример #26
0
def makeCGMGaitAnalysis(DATA_PATH,
                        modelledFilenames,
                        emgFilenames,
                        emgChannels,
                        subjectInfo=None,
                        experimentalInfo=None,
                        modelInfo=None,
                        pointLabelSuffix=None):
    """
    makeCGMGaitAnalysis : create the pyCGM2.Processing.analysis.Analysis instance with modelled c3d and  EMG c3d



    """

    if modelledFilenames == []: modelledFilenames = None
    if emgFilenames == []: emgFilenames = None

    c3dmanagerProcedure = c3dManager.DistinctC3dSetProcedure(
        DATA_PATH, modelledFilenames, modelledFilenames, modelledFilenames,
        emgFilenames)

    cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure)
    cmf.enableSpatioTemporal(
        True) if modelledFilenames is not None else cmf.enableSpatioTemporal(
            False)
    cmf.enableKinematic(
        True) if modelledFilenames is not None else cmf.enableKinematic(False)
    cmf.enableKinetic(
        True) if modelledFilenames is not None else cmf.enableKinetic(False)
    cmf.enableEmg(True) if emgFilenames is not None else cmf.enableEmg(False)
    trialManager = cmf.generate()

    #----cycles
    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()

    #----analysis
    kinematicLabelsDict = cgm.CGM.ANALYSIS_KINEMATIC_LABELS_DICT
    kineticLabelsDict = cgm.CGM.ANALYSIS_KINETIC_LABELS_DICT
    emgLabelList = [label + "_Rectify_Env" for label in emgChannels]

    analysisBuilder = analysis.GaitAnalysisBuilder(
        cycles,
        kinematicLabelsDict=kinematicLabelsDict,
        kineticLabelsDict=kineticLabelsDict,
        pointlabelSuffix=pointLabelSuffix,
        emgLabelList=emgLabelList)

    analysisFilter = analysis.AnalysisFilter()
    analysisFilter.setInfo(subject=subjectInfo,
                           model=modelInfo,
                           experimental=experimentalInfo)
    analysisFilter.setBuilder(analysisBuilder)
    analysisFilter.build()

    return analysisFilter.analysis
Пример #27
0
    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)
Пример #28
0
    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)
Пример #29
0
def makeAnalysis(
    DATA_PATH,
    filenames,
    type="Gait",
    kinematicLabelsDict=cgm.CGM.ANALYSIS_KINEMATIC_LABELS_DICT,
    kineticLabelsDict=cgm.CGM.ANALYSIS_KINETIC_LABELS_DICT,
    emgChannels=[
        "Voltage.EMG1", "Voltage.EMG2", "Voltage.EMG3", "Voltage.EMG4",
        "Voltage.EMG5", "Voltage.EMG6", "Voltage.EMG7", "Voltage.EMG8",
        "Voltage.EMG9", "Voltage.EMG10", "Voltage.EMG11", "Voltage.EMG12",
        "Voltage.EMG13", "Voltage.EMG14", "Voltage.EMG15", "Voltage.EMG16"
    ],
    pointLabelSuffix=None,
    btkAcqs=None,
    subjectInfo=None,
    experimentalInfo=None,
    modelInfo=None,
    pstfilenames=None,
    kinematicfilenames=None,
    kineticfilenames=None,
    emgfilenames=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**





    """
    if filenames == [] or filenames is None: filenames = None

    #---- c3d manager

    if btkAcqs is not None:
        c3dmanagerProcedure = c3dManager.UniqueBtkAcqSetProcedure(DATA_PATH,
                                                                  filenames,
                                                                  acqs=btkAcqs)

    else:
        iPstFilenames = filenames if pstfilenames is None else pstfilenames
        iKinematicFilenames = filenames if kinematicfilenames is None else kinematicfilenames
        iKineticFilenames = filenames if kineticfilenames is None else kineticfilenames
        iEmgFilenames = filenames if emgfilenames is None else emgfilenames

        c3dmanagerProcedure = c3dManager.DistinctC3dSetProcedure(
            DATA_PATH, iPstFilenames, iKinematicFilenames, iKineticFilenames,
            iEmgFilenames)

    cmf = c3dManager.C3dManagerFilter(c3dmanagerProcedure)

    cmf.enableKinematic(
        True) if kinematicLabelsDict is not None else cmf.enableKinematic(
            False)
    cmf.enableKinetic(
        True) if kineticLabelsDict is not None else cmf.enableKinetic(False)
    cmf.enableEmg(True) if emgChannels is not None else cmf.enableEmg(False)

    trialManager = cmf.generate()

    #----cycles
    if type == "Gait":
        cycleBuilder = cycle.GaitCyclesBuilder(
            spatioTemporalAcqs=trialManager.spatioTemporal["Acqs"],
            kinematicAcqs=trialManager.kinematic["Acqs"],
            kineticAcqs=trialManager.kinetic["Acqs"],
            emgAcqs=trialManager.emg["Acqs"])

    else:
        cycleBuilder = cycle.CyclesBuilder(
            spatioTemporalAcqs=trialManager.spatioTemporal["Acqs"],
            kinematicAcqs=trialManager.kinematic["Acqs"],
            kineticAcqs=trialManager.kinetic["Acqs"],
            emgAcqs=trialManager.emg["Acqs"])

    cyclefilter = cycle.CyclesFilter()
    cyclefilter.setBuilder(cycleBuilder)
    cycles = cyclefilter.build()

    if emgChannels is not None:
        emgLabelList = [label + "_Rectify_Env" for label in emgChannels]
    else:
        emgLabelList = None

    if type == "Gait":
        analysisBuilder = analysis.GaitAnalysisBuilder(
            cycles,
            kinematicLabelsDict=kinematicLabelsDict,
            kineticLabelsDict=kineticLabelsDict,
            pointlabelSuffix=pointLabelSuffix,
            emgLabelList=emgLabelList)
    else:
        analysisBuilder = analysis.AnalysisBuilder(
            cycles,
            kinematicLabelsDict=kinematicLabelsDict,
            kineticLabelsDict=kineticLabelsDict,
            pointlabelSuffix=pointLabelSuffix,
            emgLabelList=emgLabelList)

    analysisFilter = analysis.AnalysisFilter()
    analysisFilter.setInfo(subject=subjectInfo,
                           model=modelInfo,
                           experimental=experimentalInfo)
    analysisFilter.setBuilder(analysisBuilder)
    analysisFilter.build()

    return analysisFilter.analysis
Пример #30
0
    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()