Exemple #1
0
    def twoPF_FP1left_FP2right(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "operations\\forceplates\\FootAssignementAutoamticGeneralEvent\\"

        # --- Motion 1
        gaitFilename = "MRI-US-01, 2008-08-08, 3DGA 13.c3d"
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))
        #forceplates.appendForcePlateCornerAsMarker(acqGait)
        mappedForcePlate = forceplates.matchingFootSideOnForceplate(acqGait)
        forceplates.addForcePlateGeneralEvents(acqGait, "LR")

        btkTools.smartWriter(acqGait,
                             str(MAIN_PATH + "twoPF_FP1left_FP2right.c3d"))

        modelledFilenames = ["twoPF_FP1left_FP2right.c3d"]

        #---- GAIT CYCLES FILTER PRELIMARIES
        #--------------------------------------------------------------------------
        # distinguishing trials for kinematic and kinetic processing

        # - kinematic Trials
        kinematicTrials = []
        kinematicFilenames = []
        for kinematicFilename in modelledFilenames:
            kinematicFileNode = ma.io.read(str(MAIN_PATH + kinematicFilename))
            kinematicTrial = kinematicFileNode.findChild(ma.T_Trial)
            trialTools.sortedEvents(kinematicTrial)

            longitudinalAxis, forwardProgression, globalFrame = trialTools.findProgression(
                kinematicTrial, "LHEE")

            kinematicTrials.append(kinematicTrial)
            kinematicFilenames.append(kinematicFilename)

        # - kinetic Trials ( check if kinetic events)
        kineticTrials, kineticFilenames, flag_kinetics = trialTools.automaticKineticDetection(
            MAIN_PATH, modelledFilenames)

        #---- GAIT CYCLES FILTER
        #--------------------------------------------------------------------------
        cycleBuilder = cycle.GaitCyclesBuilder(
            spatioTemporalTrials=kinematicTrials,
            kinematicTrials=kinematicTrials,
            kineticTrials=kineticTrials,
            emgTrials=None)

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

        # TESTING

        np.testing.assert_equal(len(cycles.kineticCycles), 2)
        np.testing.assert_equal(cycles.kineticCycles[0].context, "Left")
        np.testing.assert_equal(cycles.kineticCycles[0].begin, 253)
        np.testing.assert_equal(cycles.kineticCycles[1].context, "Right")
        np.testing.assert_equal(cycles.kineticCycles[1].begin, 201)
Exemple #2
0
    def build(self):
        self.appendEvents()
        self.appendMarkers()
        if self.m_nexusForcePlates != []: self.appendForcePlates()
        if self.m_nexusAnalogDevices != []: self.appendAnalogs()
        self.appendModelOutputs()

        trialTools.sortedEvents(self.m_trial)

        return self.m_trial
Exemple #3
0
def plotTemporalKinetic(DATA_PATH,
                        modelledFilenames,
                        bodyPart,
                        pointLabelSuffix=None,
                        exportPdf=False,
                        outputName=None,
                        show=True,
                        title=None,
                        openmaTrial=None):
    """
    plotTemporalKinetic : display temporal trace of the Kinetics


    :param DATA_PATH [str]: path to your data
    :param modelledFilenames [string list]: c3d files
    :param bodyPart [str]: body part (choice : LowerLimb, Trunk, UpperLimb)

    **optional**

    :param pointLabelSuffix [string]: suffix previously added to your model outputs
    :param exportPdf [bool]: save as pdf (False[default])
    :param outputName [string]: name of the output filed
    :param show [bool]: enable matplotlib show function
    :param title [string]: change default title of the plot panel
    :param openmaTrial [openma::Trial]: force use of an openma trial instance

    Examples:

    """

    if bodyPart == "LowerLimb":
        bodyPart = enums.BodyPartPlot.LowerLimb
    elif bodyPart == "Trunk":
        bodyPart = enums.BodyPartPlot.Trunk
    elif bodyPart == "UpperLimb":
        bodyPart = enums.BodyPartPlot.UpperLimb
    else:
        raise Exception(
            "[pyCGM2] - bodyPart argument not recognized ( must be LowerLimb, Trunk or UpperLimb) "
        )

    if exportPdf:
        if outputName is None:
            filenameOut = str(modelledFilenames + "-Temporal Kinetics[" +
                              bodyPart.name + "]")
        else:
            filenameOut = str(outputName + "-Temporal Kinetics [" +
                              bodyPart.name + "]")

    if openmaTrial is not None:
        trial = openmaTrial
        trialTools.sortedEvents(trial)

    else:
        trial = trialTools.smartTrialReader(DATA_PATH, modelledFilenames)

    kv = plotViewers.TemporalKineticsPlotViewer(
        trial, pointLabelSuffix=pointLabelSuffix, bodyPart=bodyPart)
    # # filter
    pf = plotFilters.PlottingFilter()
    pf.setViewer(kv)
    if title is not None:
        pf.setTitle(str(title + "-Temporal Kinetics [" + bodyPart.name + "]"))
    if exportPdf: pf.setExport(DATA_PATH, filenameOut, "pdf")
    pf.plot()

    if show: plt.show()