Ejemplo n.º 1
0
    def test_consistencyPlot_OneModelOutputPlot(self):
        """
        Plot only one Model output
        """

        # ----DATA-----
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\"
        modelledFilenames = ["gait Trial 01.c3d", "gait Trial 02.c3d"]

        #---- Analysis
        #--------------------------------------------------------------------------

        modelInfo = None
        subjectInfo = None
        experimentalInfo = None

        analysisInstance = analysis.makeAnalysis(DATA_PATH, modelledFilenames)

        fig = plt.figure()
        ax = plt.gca()
        plot.gaitConsistencyPlot(ax,
                                 analysisInstance.kinematicStats,
                                 "LPelvisAngles",
                                 "Left",
                                 0,
                                 color="blue",
                                 title="",
                                 xlabel="",
                                 ylabel="",
                                 ylim=None,
                                 customLimits=None)
Ejemplo n.º 2
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 = 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.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()
Ejemplo n.º 3
0
    def test_consistencyPlot_OneModelOutputPlot(self):
        """

        """

        # ----DATA-----
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitData\CGM1-NormalGaitData-Events\Hånnibøl Lecter\\"
        modelledFilenames1 = ["gait Trial 01.c3d"]
        modelledFilenames2 = ["gait Trial 02.c3d"]

        #---- Analysis
        #--------------------------------------------------------------------------

        modelInfo = None
        subjectInfo = None
        experimentalInfo = None

        analysis1 = analysis.makeAnalysis(DATA_PATH, modelledFilenames1)
        analysis2 = analysis.makeAnalysis(DATA_PATH, modelledFilenames2)

        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()
Ejemplo n.º 4
0
    def test_gaitConsistencyPlot(self):

        DATA_PATH, analysisInstance = dataTest1()

        fig = plt.figure()
        ax = plt.gca()
        reportPlot.gaitConsistencyPlot(ax,
                                       analysisInstance.kinematicStats,
                                       "LPelvisAngles",
                                       "Left",
                                       0,
                                       color="blue",
                                       title="",
                                       xlabel="",
                                       ylabel="",
                                       ylim=None,
                                       customLimits=None)
        if SHOW: plt.show()
        return fig
Ejemplo n.º 5
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()
Ejemplo n.º 6
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()
Ejemplo n.º 7
0
def compareSelectedEmgEvelops(analyses,
                              legends,
                              emgChannels,
                              contexts,
                              normalized=False,
                              plotType="Descriptive",
                              type="Gait",
                              show=True,
                              title=None):
    """
    compareSelectedEmgEvelops : compare selected emg envelops from  pyCGM2 analysis instances

    :param analysis [pyCGM2.Processing.analysis.Analysis list]: list of pyCGM2 analysis instances
    :param legends [string list]: legend of each analysis instance
    :param emgChannels [string list]: label of your emg channels
    :param contexts [string list]: context associated with your emg channels


    **optional**
    :param normalized [bool]:  display normalized amplitude envelop (false [defaut])
    :param plotType [string]: trace type ( Descriptive [default] or Consistency)
    :param type [string]:  display events (Gait [defaut] or None)
    :param show [bool]: enable matplotlib show function
    :param title [string]: change default title of the plot panel
    :example:

    >>> plot.compareSelectedEmgEvelops([emgAnalysisPre,emgAnalysisPost],["Pre","Post"],["EMG1","EMG1"],["Left","Left"],normalized=False)
    """

    fig = plt.figure()
    ax = plt.gca()

    colormap_i_left = [
        plt.cm.Reds(k) for k in np.linspace(0.2, 1, len(analyses))
    ]
    colormap_i_right = [
        plt.cm.Blues(k) for k in np.linspace(0.2, 1, len(analyses))
    ]

    i = 0
    for analysis in analyses:
        label = emgChannels[
            i] + "_Rectify_Env" if not normalized else emgChannels[
                i] + "_Rectify_Env_Norm"
        title = "EMG Envelop Comparison" if not normalized else "Normalized EMG Envelop Comparison"

        if contexts[i] == "Left":
            color = colormap_i_left[i]
        elif contexts[i] == "Right":
            color = colormap_i_right[i]

        if plotType == "Descriptive":
            if type == "Gait":
                plot.gaitDescriptivePlot(ax,
                                         analysis.emgStats,
                                         label,
                                         contexts[i],
                                         0,
                                         color=color,
                                         title=title,
                                         xlabel="Gait Cycle",
                                         ylabel="emg",
                                         ylim=None,
                                         customLimits=None,
                                         legendLabel=legends[i])
            else:
                plot.descriptivePlot(ax,
                                     analysis.emgStats,
                                     label,
                                     contexts[i],
                                     0,
                                     color=None,
                                     title=title,
                                     xlabel="Gait Cycle",
                                     ylabel="emg",
                                     ylim=None,
                                     customLimits=None,
                                     legendLabel=legends[i])
        elif plotType == "Consistency":
            if type == "Gait":
                plot.gaitConsistencyPlot(ax,
                                         analysis.emgStats,
                                         label,
                                         contexts[i],
                                         0,
                                         color=color,
                                         title=title,
                                         xlabel="Gait Cycle",
                                         ylabel="emg",
                                         ylim=None,
                                         customLimits=None,
                                         legendLabel=legends[i])
            else:
                plot.consistencyPlot(ax,
                                     analysis.emgStats,
                                     label,
                                     contexts[i],
                                     0,
                                     color=None,
                                     title=title,
                                     xlabel="Gait Cycle",
                                     ylabel="emg",
                                     ylim=None,
                                     customLimits=None,
                                     legendLabel=legends[i])
        else:
            raise Exception("[pyCGM2]: plot type does not recongnized")

        i += 1

        ax.legend(fontsize=6)
    if show: plt.show()