Beispiel #1
0
    def cgm24(cls):
        """

        """
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "operations\\markerDecomposition\\CGM24decomposeTracking\\"
    #

        staticFilename = "PN01OP01S01STAT.c3d"

        acqStatic = btkTools.smartReader(str(MAIN_PATH +  staticFilename))

        model=cgm2.CGM2_4LowerLimbs()
        model.setVersion("CGM2.4e")
        model.configure()

        markerDiameter=14
        mp={
        'Bodymass'   : 83.0,
        'LeftLegLength' : 874.0,
        'RightLegLength' : 876.0 ,
        'LeftKneeWidth' : 106.0,
        'RightKneeWidth' : 103.0,
        'LeftAnkleWidth' : 74.0,
        'RightAnkleWidth' : 72.0,
        'LeftSoleDelta' : 0,
        'RightSoleDelta' : 0,
        }
        model.addAnthropoInputParameters(mp)

        # CALIBRATION
        scp=modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model,
                                            leftFlatFoot = 1, rightFlatFoot = 1,
                                            markerDiameter=markerDiameter,
                                            ).compute()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(acqStatic, markerDiameter=markerDiameter, side="left")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, markerDiameter=markerDiameter, side="left")
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(acqStatic, markerDiameter=markerDiameter, side="right")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, markerDiameter=markerDiameter, side="right")

        modelDecorator.HipJointCenterDecorator(model).hara(side = "Both")

        scp=modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model,
                                            leftFlatFoot = 1, rightFlatFoot = 1,
                                            markerDiameter=markerDiameter,
                                            ).compute()

        # --- Test 1 Motion Axe X -------
        gaitFilename="PN01OP01S01SS01.c3d"
        acqGait = btkTools.smartReader(str(MAIN_PATH +  gaitFilename))

        modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,pyCGM2Enums.motionMethod.Sodervisk                                             )
        modMotion.compute()


        mtf = modelFilters.TrackingMarkerDecompositionFilter(model,acqGait)
        mtf.decompose()

        btkTools.smartWriter(acqGait, "cgm24-decompose.c3d")
Beispiel #2
0
    def noIK_6dof(cls):
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.4\\fullBody\\"
        staticFilename = "PN01OP01S01STAT.c3d"
        gaitFilename = "PN01OP01S01STAT.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 83.0,
            'LeftLegLength': 874.0,
            'RightLegLength': 876.0,
            'LeftKneeWidth': 106.0,
            'RightKneeWidth': 103.0,
            'LeftAnkleWidth': 74.0,
            'RightAnkleWidth': 72.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        translators = files.getTranslators(MAIN_PATH, "CGM2_4.translators")
        acqStatic = btkTools.applyTranslators(acqStatic, translators)

        model = cgm2.CGM2_4()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        print "----"
        print model.getSegment("Left Shank").getReferential(
            "TF").relativeMatrixAnatomic
        print "----"

        # # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")
        #
        # # final
        modelFilters.ModelCalibrationFilter(
            scp, acqStatic, model, markerDiameter=markerDiameter).compute()

        # ------ Fitting -------
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))
        acqGait = btkTools.applyTranslators(acqGait, translators)

        # Motion FILTER
        modMotion = modelFilters.ModelMotionFilter(
            scp, acqGait, model, enums.motionMethod.Sodervisk)
        modMotion.compute()

        btkTools.smartWriter(acqGait, "cgm24_noIK6dof_staticMotion.c3d")
Beispiel #3
0
def applyHJCDecorators(model,method):

    if method["Left"] == "Hara":
        logging.info("[pyCGM2] Left HJC : Hara")
        modelDecorator.HipJointCenterDecorator(model).hara(side = "left")
    elif len(method["Left"]) == 3:
        logging.info("[pyCGM2] Left HJC : Custom")
        logging.warning(method["Left"])
        modelDecorator.HipJointCenterDecorator(model).custom(position_Left =  np.array(method["Left"]), methodDesc = "custom",side="left")

    if method["Right"] == "Hara":
        logging.info("[pyCGM2] Right HJC : Hara")
        modelDecorator.HipJointCenterDecorator(model).hara(side = "right")
    elif len(method["Right"]) == 3:
        logging.info("[pyCGM2] Right HJC : Custom")
        logging.warning(method["Right"])
        modelDecorator.HipJointCenterDecorator(model).custom(position_Right =  np.array(method["Right"]), methodDesc = "custom",side="right")
Beispiel #4
0
    def noIK_6dof_Garches(cls):
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "Datasets Tests\\didier\\08_02_18_Vincent Pere\\"
        staticFilename = "08_02_18_Vincent_Pere_Statique_000_MOKKA.c3d"
        gaitFilename = "08_02_18_Vincent_Pere_Statique_000_MOKKA.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 70.0,
            'LeftLegLength': 890.0,
            'RightLegLength': 890.0,
            'LeftKneeWidth': 150.0,
            'RightKneeWidth': 150.0,
            'LeftAnkleWidth': 88.0,
            'RightAnkleWidth': 99.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        print "----"
        print model.getSegment("Left Shank").getReferential(
            "TF").relativeMatrixAnatomic
        print "----"

        # # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")
        #
        # # final
        modelFilters.ModelCalibrationFilter(
            scp, acqStatic, model, markerDiameter=markerDiameter).compute()

        # ------ Fitting -------
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))

        # Motion FILTER
        modMotion = modelFilters.ModelMotionFilter(
            scp, acqGait, model, enums.motionMethod.Sodervisk)
        modMotion.compute()

        btkTools.smartWriter(acqGait,
                             "cgm24_noIK6dof_staticMotion_Garches.c3d")
Beispiel #5
0
    def calibration_FlatFoot(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.4\\medial\\"
        staticFilename = "static.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 69.0,
            'LeftLegLength': 930.0,
            'RightLegLength': 930.0,
            'LeftKneeWidth': 94.0,
            'RightKneeWidth': 64.0,
            'LeftAnkleWidth': 67.0,
            'RightAnkleWidth': 62.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
            "LeftToeOffset": 0,
            "RightToeOffset": 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(scp,
                                            acqStatic,
                                            model,
                                            markerDiameter=markerDiameter,
                                            leftFlatFoot=True,
                                            rightFlatFoot=True).compute()

        # display CS
        csp = modelFilters.ModelCoordinateSystemProcedure(model)
        csf = modelFilters.CoordinateSystemDisplayFilter(csp, model, acqStatic)
        csf.setStatic(True)
        csf.display()

        btkTools.smartWriter(acqStatic, "cgm2.4_FlatFoot.c3d")
Beispiel #6
0
    def calibration_GarchesFlatFoot(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "Datasets Tests\\didier\\08_02_18_Vincent Pere\\"
        staticFilename = "08_02_18_Vincent_Pere_Statique_000_MOKKA.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 70.0,
            'LeftLegLength': 890.0,
            'RightLegLength': 890.0,
            'LeftKneeWidth': 150.0,
            'RightKneeWidth': 150.0,
            'LeftAnkleWidth': 88.0,
            'RightAnkleWidth': 99.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
            "LeftToeOffset": 0,
            "RightToeOffset": 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(scp,
                                            acqStatic,
                                            model,
                                            markerDiameter=markerDiameter,
                                            leftFlatFoot=True,
                                            rightFlatFoot=True).compute()

        # display CS
        csp = modelFilters.ModelCoordinateSystemProcedure(model)
        csf = modelFilters.CoordinateSystemDisplayFilter(csp, model, acqStatic)
        csf.setStatic(True)
        csf.display()

        btkTools.smartWriter(acqStatic, "cgm2.4_GarchesFlatFoot.c3d")
Beispiel #7
0
    def customLocalPosition(cls):
        """
        GOAL : compare Joint centres and foot Offset

        """
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.1\\native\\"
        staticFilename = "static.c3d"

        acqStatic = btkTools.smartReader(str(MAIN_PATH +  staticFilename))

        model=cgm2.CGM2_1LowerLimbs()
        model.configure()

        markerDiameter=14
        mp={
        'Bodymass'   : 71.0,
        'LeftLegLength' : 860.0,
        'RightLegLength' : 865.0 ,
        'LeftKneeWidth' : 102.0,
        'RightKneeWidth' : 103.4,
        'LeftAnkleWidth' : 75.3,
        'RightAnkleWidth' : 72.9,
        'LeftSoleDelta' : 0,
        'RightSoleDelta' : 0,
        }
        model.addAnthropoInputParameters(mp)

        # -----------CGM STATIC CALIBRATION--------------------
        # initial
        scp=modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute()

        pos0_L = model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("LHJC").getLocal()
        pos0_R = model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("RHJC").getLocal()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).custom(position_Left = np.array([1,2,3]),
                                                  position_Right = np.array([1,2,3]), methodDesc = "us") # add node to pelvis

        # final
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute()


        pos_L = model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("LHJC").getLocal()
        pos_R = model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("RHJC").getLocal()

        # ---- tests ----
        np.testing.assert_equal(model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("LHJC").getDescription() ,"us")
        np.testing.assert_equal(model.getSegment("Left Thigh").getReferential("TF").static.getNode_byLabel("LHJC").getDescription() ,"us")

        np.testing.assert_equal(model.getSegment("Pelvis").getReferential("TF").static.getNode_byLabel("RHJC").getDescription() ,"us")
        np.testing.assert_equal(model.getSegment("Right Thigh").getReferential("TF").static.getNode_byLabel("RHJC").getDescription() ,"us")

        np.testing.assert_equal(np.all(pos_L == pos0_L) == False, True)
        np.testing.assert_equal(np.all(pos_R == pos0_R) ==False, True)
Beispiel #8
0
def applyHJCDecorators(model, method):
    if model.getBodyPart() != enums.BodyPart.UpperLimb:
        if method["Left"] == "Hara":
            LOGGER.logger.info("[pyCGM2] Left HJC : Hara")
            modelDecorator.HipJointCenterDecorator(model).hara(side="left")
        elif len(method["Left"]) == 3:
            LOGGER.logger.info("[pyCGM2] Left HJC : Custom")
            LOGGER.logger.debug(method["Left"])
            modelDecorator.HipJointCenterDecorator(model).custom(
                position_Left=np.array(method["Left"]),
                methodDesc="custom",
                side="left")

        if method["Right"] == "Hara":
            LOGGER.logger.info("[pyCGM2] Right HJC : Hara")
            modelDecorator.HipJointCenterDecorator(model).hara(side="right")
        elif len(method["Right"]) == 3:
            LOGGER.logger.info("[pyCGM2] Right HJC : Custom")
            LOGGER.logger.debug(method["Right"])
            modelDecorator.HipJointCenterDecorator(model).custom(
                position_Right=np.array(method["Right"]),
                methodDesc="custom",
                side="right")
Beispiel #9
0
    def CGM2_4_SARA_test(cls):
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.4\\Knee Calibration\\"
        staticFilename = "static.c3d"

        funcFilename = "functional.c3d"
        gaitFilename = "gait trial 01.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 69.0,
            'LeftLegLength': 930.0,
            'RightLegLength': 930.0,
            'LeftKneeWidth': 94.0,
            'RightKneeWidth': 64.0,
            'LeftAnkleWidth': 67.0,
            'RightAnkleWidth': 62.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
            "LeftToeOffset": 0,
            "RightToeOffset": 0,
        }

        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4LowerLimbs()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # --- INITIAL  CALIBRATION ---
        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic,
            markerDiameter=markerDiameter,
            side="both",
            cgm1Behaviour=True)
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            seLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="LKJC_mid",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="RKJC_mid",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter).compute()

        # ------ LEFT KNEE CALIBRATION -------
        acqFunc = btkTools.smartReader(str(MAIN_PATH + funcFilename))

        # Motion of only left
        modMotionLeftKnee = modelFilters.ModelMotionFilter(
            scp, acqFunc, model, pyCGM2Enums.motionMethod.Sodervisk)
        modMotionLeftKnee.segmentalCompute(["Left Thigh", "Left Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).sara(
            "Left", indexFirstFrame=831, indexLastFrame=1280)

        # ----add Point into the c3d----
        Or_inThigh = model.getSegment("Left Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionOri")
        axis_inThigh = model.getSegment("Left Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionAxis")
        btkTools.smartAppendPoint(acqFunc, "Left" + "_KneeFlexionOri",
                                  Or_inThigh)
        btkTools.smartAppendPoint(acqFunc, "Left" + "_KneeFlexionAxis",
                                  axis_inThigh)

        # ------ RIGHT KNEE CALIBRATION -------

        # Motion of only left
        modMotionRightKnee = modelFilters.ModelMotionFilter(
            scp, acqFunc, model, pyCGM2Enums.motionMethod.Sodervisk)
        modMotionRightKnee.segmentalCompute(["Right Thigh", "Right Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).sara("Right",
                                                            indexFirstFrame=61,
                                                            indexLastFrame=551)

        # ----add Point into the c3d----
        Or_inThigh = model.getSegment("Right Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionOri")
        axis_inThigh = model.getSegment("Right Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionAxis")
        btkTools.smartAppendPoint(acqFunc, "Right" + "_KneeFlexionOri",
                                  Or_inThigh)
        btkTools.smartAppendPoint(acqFunc, "Right" + "_KneeFlexionAxis",
                                  axis_inThigh)

        btkTools.smartWriter(acqFunc, "acqFunc-Sara.c3d")

        #--- FINAL  CALIBRATION ---
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            useLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="KJC_Sara",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="KJC_Sara",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter,
            RotateLeftThighFlag=True,
            RotateRightThighFlag=True).compute()

        #  save static c3d with update KJC
        btkTools.smartWriter(acqStatic, "Static-SARA.c3d")

        # ------ Fitting -------
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))

        # Motion FILTER

        modMotion = modelFilters.ModelMotionFilter(
            scp, acqGait, model, pyCGM2Enums.motionMethod.Determinist)
        modMotion.compute()

        # relative angles
        modelFilters.ModelJCSFilter(model, acqGait).compute(
            description="vectoriel", pointLabelSuffix="cgm1_6dof")

        # absolute angles
        longitudinalAxis, forwardProgression, globalFrame = btkTools.findProgressionAxisFromPelvicMarkers(
            acqGait, ["LASI", "RASI", "RPSI", "LPSI"])
        modelFilters.ModelAbsoluteAnglesFilter(
            model,
            acqGait,
            segmentLabels=["Left HindFoot", "Right HindFoot", "Pelvis"],
            angleLabels=["LFootProgress", "RFootProgress", "Pelvis"],
            eulerSequences=["TOR", "TOR", "ROT"],
            globalFrameOrientation=globalFrame,
            forwardProgression=forwardProgression).compute(
                pointLabelSuffix="cgm1_6dof")

        # ------- OPENSIM IK --------------------------------------

        # --- osim builder ---
        cgmCalibrationprocedure = opensimFilters.CgmOpensimCalibrationProcedures(
            model)
        markersetFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_4\\cgm2_4-markerset.xml"

        osimfile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\osim\\lowerLimb_ballsJoints.osim"

        oscf = opensimFilters.opensimCalibrationFilter(
            osimfile, model, cgmCalibrationprocedure)
        oscf.addMarkerSet(markersetFile)
        scalingOsim = oscf.build(exportOsim=False)

        # --- fitting ---
        #procedure
        cgmFittingProcedure = opensimFilters.CgmOpensimFittingProcedure(model)
        iksetupFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_4\\cgm2_4-ikSetUp_template.xml"

        osrf = opensimFilters.opensimFittingFilter(iksetupFile, scalingOsim,
                                                   cgmFittingProcedure,
                                                   MAIN_PATH)
        acqIK = osrf.run(acqGait,
                         str(MAIN_PATH + gaitFilename),
                         exportSetUp=False)

        # -------- NEW MOTION FILTER ON IK MARKERS ------------------

        modMotion_ik = modelFilters.ModelMotionFilter(
            scp,
            acqIK,
            model,
            pyCGM2Enums.motionMethod.Sodervisk,
            useForMotionTest=True)
        modMotion_ik.compute()

        finalJcs = modelFilters.ModelJCSFilter(model, acqIK)
        finalJcs.setFilterBool(False)
        finalJcs.compute(description="ik", pointLabelSuffix="2_ik")  #

        btkTools.smartWriter(acqIK, "gait trial 01 - Fitting.c3d")
Beispiel #10
0
    def calibrate(self, aquiStatic, dictRef, dictAnatomic, options=None):

        # add markers
        valSACR = (aquiStatic.GetPoint("LPSI").GetValues() +
                   aquiStatic.GetPoint("RPSI").GetValues()) / 2.0
        btkTools.smartAppendPoint(aquiStatic, "SACR", valSACR, desc="")
        valMidAsis = (aquiStatic.GetPoint("LASI").GetValues() +
                      aquiStatic.GetPoint("RASI").GetValues()) / 2.0
        btkTools.smartAppendPoint(aquiStatic, "midASIS", valMidAsis, desc="")
        valLMET = (aquiStatic.GetPoint("LFMH").GetValues() +
                   aquiStatic.GetPoint("LVMH").GetValues()) / 2.0
        btkTools.smartAppendPoint(aquiStatic, "LMET", valLMET, desc="")
        valRMET = (aquiStatic.GetPoint("RFMH").GetValues() +
                   aquiStatic.GetPoint("RVMH").GetValues()) / 2.0
        btkTools.smartAppendPoint(aquiStatic, "RMET", valRMET, desc="")

        ff = aquiStatic.GetFirstFrame()
        lf = aquiStatic.GetLastFrame()
        frameInit = ff - ff
        frameEnd = lf - ff + 1

        # calibrate technical
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Pelvis",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Left Thigh",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Right Thigh",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Left Shank",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Right Shank",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Left Foot",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)
        self._calibrateTechnicalSegment(aquiStatic,
                                        "Right Foot",
                                        dictRef,
                                        frameInit,
                                        frameEnd,
                                        options=options)

        # # ---- decorator ----
        modelDecorator.HipJointCenterDecorator(self).greatTrochanterOffset(
            aquiStatic)
        modelDecorator.KneeCalibrationDecorator(self).midCondyles(aquiStatic)
        modelDecorator.AnkleCalibrationDecorator(self).midMaleolus(aquiStatic)

        # calibrate anatomic
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Pelvis",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Left Thigh",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Right Thigh",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Left Shank",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Right Shank",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Left Foot",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
        self._calibrateAnatomicalSegment(aquiStatic,
                                         "Right Foot",
                                         dictAnatomic,
                                         frameInit,
                                         frameEnd,
                                         options=options)
Beispiel #11
0
    def full_IK(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.4\\medial\\"
        staticFilename = "static.c3d"
        gaitFilename = "gait Trial 01.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 69.0,
            'LeftLegLength': 930.0,
            'RightLegLength': 930.0,
            'LeftKneeWidth': 94.0,
            'RightKneeWidth': 64.0,
            'LeftAnkleWidth': 67.0,
            'RightAnkleWidth': 62.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
            "LeftToeOffset": 0,
            "RightToeOffset": 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4LowerLimbs()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(
            scp, acqStatic, model, markerDiameter=markerDiameter).compute()

        # ------ Fitting -------
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))

        # Motion FILTER
        modMotion = modelFilters.ModelMotionFilter(
            scp, acqGait, model, pyCGM2Enums.motionMethod.Sodervisk)
        modMotion.compute()

        # relative angles
        modelFilters.ModelJCSFilter(model, acqGait).compute(
            description="vectoriel", pointLabelSuffix="cgm1_6dof")

        # absolute angles
        longitudinalAxis, forwardProgression, globalFrame = btkTools.findProgressionAxisFromPelvicMarkers(
            acqGait, ["LASI", "RASI", "RPSI", "LPSI"])
        modelFilters.ModelAbsoluteAnglesFilter(
            model,
            acqGait,
            segmentLabels=["Left Foot", "Right Foot", "Pelvis"],
            angleLabels=["LFootProgress", "RFootProgress", "Pelvis"],
            eulerSequences=["TOR", "TOR", "ROT"],
            globalFrameOrientation=globalFrame,
            forwardProgression=forwardProgression).compute(
                pointLabelSuffix="cgm1_6dof")

        # ---Marker decomp filter----
        mtf = modelFilters.TrackingMarkerDecompositionFilter(model, acqGait)
        mtf.decompose()
        # ------- OPENSIM IK --------------------------------------

        # --- osim builder ---
        cgmCalibrationprocedure = opensimFilters.CgmOpensimCalibrationProcedures(
            model)
        markersetFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_4\\cgm2_4-markerset - expert.xml"

        osimfile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\osim\\lowerLimb_ballsJoints.osim"

        oscf = opensimFilters.opensimCalibrationFilter(
            osimfile, model, cgmCalibrationprocedure, MAIN_PATH)
        oscf.addMarkerSet(markersetFile)
        scalingOsim = oscf.build(exportOsim=False)

        # --- fitting ---
        #procedure
        cgmFittingProcedure = opensimFilters.CgmOpensimFittingProcedure(
            model, expertMode=True)

        iksetupFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_4\\cgm2_4-expert-ikSetUp_template.xml"

        osrf = opensimFilters.opensimFittingFilter(iksetupFile, scalingOsim,
                                                   cgmFittingProcedure,
                                                   MAIN_PATH)

        acqIK = osrf.run(acqGait,
                         str(MAIN_PATH + gaitFilename),
                         exportSetUp=False)

        # -------- NEW MOTION FILTER ON IK MARKERS ------------------

        modMotion_ik = modelFilters.ModelMotionFilter(
            scp,
            acqIK,
            model,
            pyCGM2Enums.motionMethod.Sodervisk,
            useForMotionTest=True)
        modMotion_ik.compute()

        finalJcs = modelFilters.ModelJCSFilter(model, acqIK)
        finalJcs.setFilterBool(False)
        finalJcs.compute(description="ik", pointLabelSuffix="2_ik")  #

        btkTools.smartWriter(acqIK, "cgm24e_fullIK.c3d")
Beispiel #12
0
                      pointLabelOrigin="LHEE")
    gcp.setDefinition("Right Foot",
                      "TF",
                      sequence="ZXY",
                      pointLabel1="RSMH",
                      pointLabel2="RHEE",
                      pointLabel3="RVMH",
                      pointLabelOrigin="RHEE")

    #---Initial Calibration Filter---
    smf0 = modelFilters.ModelCalibrationFilter(gcp, acqStatic, bioMechModel)
    smf0.setBoolOption("technicalReferentialOnly")
    smf0.compute()

    # ---- decorator ----
    modelDecorator.HipJointCenterDecorator(bioMechModel).greatTrochanterOffset(
        acqStatic)
    modelDecorator.KneeCalibrationDecorator(bioMechModel).midCondyles(
        acqStatic)
    modelDecorator.AnkleCalibrationDecorator(bioMechModel).midMaleolus(
        acqStatic)

    gcp.setAnatomicalDefinition("Pelvis",
                                sequence="YZX",
                                nodeLabel1="RASI",
                                nodeLabel2="LASI",
                                nodeLabel3="SACR",
                                nodeLabelOrigin="midASIS")
    gcp.setAnatomicalDefinition("Left Thigh",
                                sequence="ZXiY",
                                nodeLabel1="LKJC_mid",
                                nodeLabel2="LHJC_gt",
Beispiel #13
0
    }

    # --- Calibration ---
    acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

    model = cgm2.CGM2_2LowerLimbs()
    model.configure()

    model.addAnthropoInputParameters(mp)

    # ------ calibration -------
    scp = modelFilters.StaticCalibrationProcedure(model)
    modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

    # cgm decorator
    modelDecorator.HipJointCenterDecorator(model).hara()
    modelDecorator.KneeCalibrationDecorator(model).midCondyles(
        acqStatic, markerDiameter=markerDiameter, side="both")
    modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
        acqStatic, markerDiameter=markerDiameter, side="both")

    # final
    modelFilters.ModelCalibrationFilter(
        scp, acqStatic, model, markerDiameter=markerDiameter).compute()

    # ------ Fitting -------
    acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))

    # Motion FILTER
    modMotion = modelFilters.ModelMotionFilter(
        scp, acqGait, model, pyCGM2Enums.motionMethod.Determinist)
Beispiel #14
0
    def test_lowLevel(self):
        DATA_PATH = pyCGM2.TEST_DATA_PATH + "GaitModels\CGM2.3\\Hannibal-medial\\"

        staticFilename = "static.c3d"
        gaitFilename= "gait1.c3d"

        markerDiameter=14
        required_mp={
        'Bodymass'   : 71.0,
        'LeftLegLength' : 860.0,
        'RightLegLength' : 865.0 ,
        'LeftKneeWidth' : 102.0,
        'RightKneeWidth' : 103.4,
        'LeftAnkleWidth' : 75.3,
        'RightAnkleWidth' : 72.9,
        'LeftSoleDelta' : 0,
        'RightSoleDelta' : 0,
        'LeftShoulderOffset' : 0,
        'RightShoulderOffset' : 0,
        'LeftElbowWidth' : 0,
        'LeftWristWidth' : 0,
        'LeftHandThickness' : 0,
        'RightElbowWidth' : 0,
        'RightWristWidth' : 0,
        'RightHandThickness' : 0
        }
        optional_mp = {
            'LeftTibialTorsion' : 0,
            'LeftThighRotation' : 0,
            'LeftShankRotation' : 0,
            'RightTibialTorsion' : 0,
            'RightThighRotation' : 0,
            'RightShankRotation' : 0
            }

        # --- Calibration ---
        # ---check marker set used----
        acqStatic = btkTools.smartReader(DATA_PATH +  staticFilename)

        dcm = cgm.CGM.detectCalibrationMethods(acqStatic)
        model=cgm2.CGM2_3()
        model.configure(detectedCalibrationMethods=dcm)
        model.addAnthropoInputParameters(required_mp,optional=optional_mp)

        # ---- Calibration ----

        scp=modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(scp,acqStatic,model,
                           markerDiameter=markerDiameter).compute()


        # ------ Fitting -------
        acqGait = btkTools.smartReader(DATA_PATH +  gaitFilename)


        # Motion FILTER
        modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,enums.motionMethod.Sodervisk)
        modMotion.compute()



        # ------- OPENSIM IK --------------------------------------
        # --- osim builder ---
        cgmCalibrationprocedure = opensimFilters.CgmOpensimCalibrationProcedures(model)
        markersetFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_3\\cgm2_3-markerset.xml"

        osimfile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\osim\\lowerLimb_ballsJoints.osim"


        oscf = opensimFilters.opensimCalibrationFilter(osimfile,
                                                model,
                                                cgmCalibrationprocedure,
                                                DATA_PATH)
        oscf.addMarkerSet(markersetFile)
        scalingOsim = oscf.build(exportOsim=False)


        # --- fitting ---
        #procedure
        cgmFittingProcedure = opensimFilters.CgmOpensimFittingProcedure(model)

        iksetupFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_3\\cgm2_3-ikSetUp_template.xml"

        osrf = opensimFilters.opensimFittingFilter(iksetupFile,
                                                          scalingOsim,
                                                          cgmFittingProcedure,
                                                          DATA_PATH,
                                                          acqGait )


        acqIK = osrf.run(str(DATA_PATH + gaitFilename ),exportSetUp=False)

        # -------- NEW MOTION FILTER ON IK MARKERS ------------------

        modMotion_ik=modelFilters.ModelMotionFilter(scp,acqIK,model,enums.motionMethod.Sodervisk,
                                                    useForMotionTest=True)
        modMotion_ik.compute()

        finalJcs =modelFilters.ModelJCSFilter(model,acqIK)
        finalJcs.compute(description="ik", pointLabelSuffix = "2_ik")#

        btkTools.smartWriter(acqIK,"cgm23_fullIK_Motion.c3d")
Beispiel #15
0
    def full_IK(cls):

        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.3\\fullBody\\"
        staticFilename = "PN01OP01S01STAT.c3d"
        gaitFilename = "PN01OP01S01SS01.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 83.0,
            'LeftLegLength': 874.0,
            'RightLegLength': 876.0,
            'LeftKneeWidth': 106.0,
            'RightKneeWidth': 103.0,
            'LeftAnkleWidth': 74.0,
            'RightAnkleWidth': 72.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
        }

        # --- Calibration ---
        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))
        translators = files.getTranslators(MAIN_PATH, "CGM2_3.translators")
        acqStatic = btkTools.applyTranslators(acqStatic, translators)

        model = cgm2.CGM2_3LowerLimbs()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # ---- Calibration ----

        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(
            scp, acqStatic, model, markerDiameter=markerDiameter).compute()

        # ------ Fitting -------
        acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename))
        acqGait = btkTools.applyTranslators(acqGait, translators)

        # Motion FILTER
        modMotion = modelFilters.ModelMotionFilter(
            scp, acqGait, model, enums.motionMethod.Sodervisk)
        modMotion.compute()

        # ------- OPENSIM IK --------------------------------------
        # --- osim builder ---
        cgmCalibrationprocedure = opensimFilters.CgmOpensimCalibrationProcedures(
            model)
        markersetFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_3\\cgm2_3-markerset.xml"

        osimfile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\osim\\lowerLimb_ballsJoints.osim"

        oscf = opensimFilters.opensimCalibrationFilter(
            osimfile, model, cgmCalibrationprocedure, MAIN_PATH)
        oscf.addMarkerSet(markersetFile)
        scalingOsim = oscf.build(exportOsim=False)

        # --- fitting ---
        #procedure
        cgmFittingProcedure = opensimFilters.CgmOpensimFittingProcedure(model)

        iksetupFile = pyCGM2.OPENSIM_PREBUILD_MODEL_PATH + "models\\settings\\cgm2_3\\cgm2_3-ikSetUp_template.xml"

        osrf = opensimFilters.opensimFittingFilter(iksetupFile, scalingOsim,
                                                   cgmFittingProcedure,
                                                   MAIN_PATH)

        acqIK = osrf.run(acqGait,
                         str(MAIN_PATH + gaitFilename),
                         exportSetUp=False)

        # -------- NEW MOTION FILTER ON IK MARKERS ------------------

        modMotion_ik = modelFilters.ModelMotionFilter(
            scp,
            acqIK,
            model,
            enums.motionMethod.Sodervisk,
            useForMotionTest=True)
        modMotion_ik.compute()

        finalJcs = modelFilters.ModelJCSFilter(model, acqIK)
        finalJcs.setFilterBool(False)
        finalJcs.compute(description="ik", pointLabelSuffix="2_ik")  #

        btkTools.smartWriter(acqIK, "cgm23_fullIK_Motion.c3d")
Beispiel #16
0
    def CGM2_4_SARA_test(cls):
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.4\\Knee Calibration\\"
        staticFilename = "static.c3d"

        funcFilename = "functional.c3d"
        gaitFilename = "gait trial 01.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 69.0,
            'LeftLegLength': 930.0,
            'RightLegLength': 930.0,
            'LeftKneeWidth': 94.0,
            'RightKneeWidth': 64.0,
            'LeftAnkleWidth': 67.0,
            'RightAnkleWidth': 62.0,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
            "LeftToeOffset": 0,
            "RightToeOffset": 0,
        }

        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_4()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # --- INITIAL  CALIBRATION ---
        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            seLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="LKJC_mid",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="RKJC_mid",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter).compute()

        # ------ LEFT KNEE CALIBRATION -------
        acqFunc = btkTools.smartReader(str(MAIN_PATH + funcFilename))

        # Motion of only left
        modMotionLeftKnee = modelFilters.ModelMotionFilter(
            scp, acqFunc, model, enums.motionMethod.Sodervisk)
        modMotionLeftKnee.segmentalCompute(["Left Thigh", "Left Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).sara(
            "Left", indexFirstFrame=831, indexLastFrame=1280)

        # ----add Point into the c3d----
        Or_inThigh = model.getSegment("Left Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionOri")
        axis_inThigh = model.getSegment("Left Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionAxis")
        btkTools.smartAppendPoint(acqFunc, "Left" + "_KneeFlexionOri",
                                  Or_inThigh)
        btkTools.smartAppendPoint(acqFunc, "Left" + "_KneeFlexionAxis",
                                  axis_inThigh)

        # ------ RIGHT KNEE CALIBRATION -------

        # Motion of only left
        modMotionRightKnee = modelFilters.ModelMotionFilter(
            scp, acqFunc, model, enums.motionMethod.Sodervisk)
        modMotionRightKnee.segmentalCompute(["Right Thigh", "Right Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).sara("Right",
                                                            indexFirstFrame=61,
                                                            indexLastFrame=551)

        # ----add Point into the c3d----
        Or_inThigh = model.getSegment("Right Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionOri")
        axis_inThigh = model.getSegment("Right Thigh").getReferential(
            "TF").getNodeTrajectory("KneeFlexionAxis")
        btkTools.smartAppendPoint(acqFunc, "Right" + "_KneeFlexionOri",
                                  Or_inThigh)
        btkTools.smartAppendPoint(acqFunc, "Right" + "_KneeFlexionAxis",
                                  axis_inThigh)

        btkTools.smartWriter(acqFunc, "acqFunc-Sara.c3d")

        #--- FINAL  CALIBRATION ---
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            useLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="KJC_Sara",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="KJC_Sara",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter).compute()

        #  save static c3d with update KJC
        btkTools.smartWriter(acqStatic, "Static-SARA.c3d")

        # print functional Offsets
        print model.mp_computed["LeftKneeFuncCalibrationOffset"]
        print model.mp_computed["RightKneeFuncCalibrationOffset"]
Beispiel #17
0
    def CGM23_2DOF_test(cls):
        MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM2\\cgm2.3\\Knee Calibration\\"
        staticFilename = "Static.c3d"

        leftKneeFilename = "Left Knee.c3d"
        rightKneeFilename = "Right Knee.c3d"
        gaitFilename = "gait trial 01.c3d"

        markerDiameter = 14
        mp = {
            'Bodymass': 71.0,
            'LeftLegLength': 860.0,
            'RightLegLength': 865.0,
            'LeftKneeWidth': 102.0,
            'RightKneeWidth': 103.4,
            'LeftAnkleWidth': 75.3,
            'RightAnkleWidth': 72.9,
            'LeftSoleDelta': 0,
            'RightSoleDelta': 0,
        }

        acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename))

        model = cgm2.CGM2_3()
        model.configure()

        model.addAnthropoInputParameters(mp)

        # --- INITIAL  CALIBRATION ---
        scp = modelFilters.StaticCalibrationProcedure(model)
        modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute()

        # cgm decorator
        modelDecorator.HipJointCenterDecorator(model).hara()
        modelDecorator.KneeCalibrationDecorator(model).midCondyles(
            acqStatic, markerDiameter=markerDiameter, side="both")
        modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(
            acqStatic, markerDiameter=markerDiameter, side="both")

        # final
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            seLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="LKJC_mid",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="RKJC_mid",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter).compute()

        # ------ LEFT KNEE CALIBRATION -------
        acqLeftKnee = btkTools.smartReader(str(MAIN_PATH + leftKneeFilename))

        # Motion of only left
        modMotionLeftKnee = modelFilters.ModelMotionFilter(
            scp, acqLeftKnee, model, enums.motionMethod.Sodervisk)
        modMotionLeftKnee.segmentalCompute(["Left Thigh", "Left Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).calibrate2dof(
            "Left", indexFirstFrame=489, indexLastFrame=1451)

        # ----add Point into the c3d----
        btkTools.smartWriter(acqLeftKnee, "Left Knee-2dof.c3d")

        # ------ RIGHT KNEE CALIBRATION -------
        acqRightKnee = btkTools.smartReader(str(MAIN_PATH + rightKneeFilename))

        # Motion of only left
        modMotionRightKnee = modelFilters.ModelMotionFilter(
            scp, acqRightKnee, model, enums.motionMethod.Sodervisk)
        modMotionRightKnee.segmentalCompute(["Right Thigh", "Right Shank"])

        # decorator
        modelDecorator.KneeCalibrationDecorator(model).calibrate2dof(
            "Right", indexFirstFrame=25, indexLastFrame=1060)

        # ----add Point into the c3d----
        btkTools.smartWriter(acqRightKnee, "Right Knee-2dof.c3d")

        #--- FINAL  CALIBRATION ---
        modelFilters.ModelCalibrationFilter(
            scp,
            acqStatic,
            model,
            useLeftHJCnode="LHJC_Hara",
            useRightHJCnode="RHJC_Hara",
            useLeftKJCnode="KJC_Sara",
            useLeftAJCnode="LAJC_mid",
            useRightKJCnode="KJC_Sara",
            useRightAJCnode="RAJC_mid",
            markerDiameter=markerDiameter).compute()

        #  save static c3d with update KJC
        btkTools.smartWriter(acqStatic, "Static-2DOF.c3d")