def basicCGM1_manualTibialTorsion(cls): MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\KAD-basic\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() 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, } optional_mp={ 'InterAsisDistance' : 0, 'LeftAsisTrocanterDistance' : 0, 'LeftThighRotation' : 0, 'LeftShankRotation' : 0 , 'LeftTibialTorsion' : -10, 'RightAsisTrocanterDistance' : 0, 'RightThighRotation' : 0, 'RightShankRotation' : 0, 'RightTibialTorsion' : 15 } model.addAnthropoInputParameters(mp,optional=optional_mp) # -----------CGM STATIC CALIBRATION-------------------- scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() #TESTS np.testing.assert_equal(model.m_useRightTibialTorsion,True ) np.testing.assert_equal(model.m_useLeftTibialTorsion,True ) # np.testing.assert_almost_equal(model.mp["InterAsisDistance"],model.mp_computed["InterAsisDistance"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["LeftAsisTrocanterDistance"],model.mp_computed["LeftAsisTrocanterDistance"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["LeftThighRotation"],-1.0*model.mp_computed["LeftThighRotationOffset"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["LeftShankRotation"],-1.0*model.mp_computed["LeftShankRotationOffset"] , decimal = 3) np.testing.assert_almost_equal(model.mp["LeftTibialTorsion"],-1.0*model.mp_computed["LeftTibialTorsionOffset"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["RightAsisTrocanterDistance"],model.mp_computed["RightAsisTrocanterDistance"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["RightThighRotation"],model.mp_computed["RightThighRotationOffset"] , decimal = 3) # np.testing.assert_almost_equal(model.mp["RightShankRotation"],model.mp_computed["RightShankRotationOffset"] , decimal = 3) np.testing.assert_almost_equal(model.mp["RightTibialTorsion"],model.mp_computed["RightTibialTorsionOffset"] , decimal = 3)
def basicCGM1_bodyBuilderFoot(cls): """ goal : know effet on Foot kinematics of a foot referential built according ta sequence metionned in some bodybuilder code: LFoot = [LTOE,LAJC-LTOE,LAJC-LKJC,zyx] """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\basic\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() model.configure() 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) scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model, useBodyBuilderFoot=True).compute() # ------ Test 1 Motion Axe X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 14.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel 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","LPSI","RASI","RPSI"]) modelFilters.ModelAbsoluteAnglesFilter(model,acqGait, segmentLabels=["Left Foot","Right Foot","Pelvis"], angleLabels=["LFootProgress", "RFootProgress","Pelvis"], eulerSequences=["TOR","TOR", "TOR"], globalFrameOrientation = globalFrame, forwardProgression = forwardProgression).compute(pointLabelSuffix="cgm1_6dof") btkTools.smartWriter(acqGait, "testuseBodyBuilderFoot.c3d")
def advancedCGM11_KneeMedKad_TrueEquinus(cls): """ """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\kad-med-TrueEquinus\\" staticFilename = "static.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() model.configure() markerDiameter=14 mp={ 'Bodymass' : 36.9, 'LeftLegLength' : 665.0, 'RightLegLength' : 655.0 , 'LeftKneeWidth' : 102.7, 'RightKneeWidth' : 100.2, 'LeftAnkleWidth' : 64.5, 'RightAnkleWidth' : 63.0, 'LeftSoleDelta' : 0, 'RightSoleDelta' : 0, } optional_mp={ 'InterAsisDistance' : 0, 'LeftAsisTrocanterDistance' : 0, 'LeftThighRotation' : 0, 'LeftShankRotation' : 0 , 'LeftTibialTorsion' : 0, 'RightAsisTrocanterDistance' : 0, 'RightThighRotation' : 0, 'RightShankRotation' : 0, 'RightTibialTorsion' : 0 } model.addAnthropoInputParameters(mp,optional=optional_mp) # -----------CGM STATIC CALIBRATION-------------------- scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # cgm decorator modelDecorator.Kad(model,acqStatic).compute() modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, side="both") modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() btkTools.smartWriter(acqStatic,"Kad-med-TrueEquinus.c3d")
def cgm1(cls): """ GOAL : compare Joint centres and foot Offset """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "operations\\markerDecomposition\\CGM1decomposeTracking\\" # staticFilename = "static.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model = cgm.CGM1LowerLimbs() model.configure() markerDiameter = 14 mp = { 'Bodymass': 36.9, 'LeftLegLength': 665, 'RightLegLength': 655.0, 'LeftKneeWidth': 102.7, 'RightKneeWidth': 100.2, 'LeftAnkleWidth': 64.5, 'RightAnkleWidth': 63.4, 'LeftSoleDelta': 0, 'RightSoleDelta': 0, } model.addAnthropoInputParameters(mp) # CALIBRATION scp = modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute() print model.m_useRightTibialTorsion # --- Test 1 Motion Axe X ------- gaitFilename = "gait trial 01.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) modMotion = modelFilters.ModelMotionFilter( scp, acqGait, model, pyCGM2Enums.motionMethod.Determinist, useForMotionTest=True) modMotion.compute() mtf = modelFilters.TrackingMarkerDecompositionFilter(model, acqGait) mtf.decompose() btkTools.smartWriter(acqGait, "cgm1-decompose.c3d")
def advancedCGM11_KneeMedOnly(cls): """ """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\CGM1.1\medial\\" staticFilename = "static-all.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() 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, } optional_mp={ 'InterAsisDistance' : 0, 'LeftAsisTrocanterDistance' : 0, 'LeftThighRotation' : 0, 'LeftShankRotation' : 0 , 'LeftTibialTorsion' : -10, 'RightAsisTrocanterDistance' : 0, 'RightThighRotation' : 0, 'RightShankRotation' : 0, 'RightTibialTorsion' : 15 } model.addAnthropoInputParameters(mp,optional=optional_mp) # -----------CGM STATIC CALIBRATION-------------------- scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # cgm decorator modelDecorator.KneeCalibrationDecorator(model).midCondyles(acqStatic) #modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, side="both") modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() btkTools.smartWriter(acqStatic,"advancedCGM11_KneeMedOnly.c3d")
def GeneralScoreTest(cls): """ GOAL : compare Joint centres and foot Offset """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\basic\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model = cgm.CGM1LowerLimbs() 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) scp = modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute() # ------ Test 1 Motion Axe X ------- gaitFilename = "MRI-US-01, 2008-08-08, 3DGA 14.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion = modelFilters.ModelMotionFilter( scp, acqGait, model, enums.motionMethod.Determinist) modMotion.compute() # score msrp = modelQualityFilter.GeneralScoreResidualProcedure(model) msrp.setDefinition("LHJC", "Pelvis", "Left Thigh") srf = modelQualityFilter.ScoreResidualFilter(acqGait, msrp) srf.compute()
def advancedCGM1_kadMed_manualTibialTorsion(cls): """ - constraints on both tibial Torsion But application of a KAD-med calibration => tibial Torsion has to be udpated """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\KAD-Med\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() 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, } optional_mp={ 'InterAsisDistance' : 0, 'LeftAsisTrocanterDistance' : 0, 'LeftThighRotation' : 0, 'LeftShankRotation' : 0 , 'LeftTibialTorsion' : -10, 'RightAsisTrocanterDistance' : 0, 'RightThighRotation' : 0, 'RightShankRotation' : 0, 'RightTibialTorsion' : 15 } model.addAnthropoInputParameters(mp,optional=optional_mp) # -----------CGM STATIC CALIBRATION-------------------- scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # cgm decorator modelDecorator.Kad(model,acqStatic).compute() modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, side="both") modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() np.testing.assert_equal(model.m_useRightTibialTorsion,True ) np.testing.assert_equal(model.m_useLeftTibialTorsion,True ) np.testing.assert_equal(model.mp["LeftTibialTorsion"],0 ) # cancel by the decorator np.testing.assert_equal(model.mp["RightTibialTorsion"],0) ltt_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LTibialTorsion").value().GetInfo().ToDouble()[0]) rtt_vicon =np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RTibialTorsion").value().GetInfo().ToDouble()[0]) np.testing.assert_almost_equal(-1.0*model.mp_computed["LeftTibialTorsionOffset"],ltt_vicon, decimal = 3) np.testing.assert_almost_equal(model.mp_computed["RightTibialTorsionOffset"],rtt_vicon, decimal = 3)
def basicCGM1_distal(cls,plotFlag=False): MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\basic-filtered\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() 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) scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # ------ Test 1 Motion Axe X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 13.distal.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,pyCGM2Enums.motionMethod.Determinist) modMotion.compute() # Joint kinematics modelFilters.ModelJCSFilter(model,acqGait).compute(description="vectoriel", pointLabelSuffix="cgm1_6dof") # BSP model bspModel = bodySegmentParameters.Bsp(model) bspModel.compute() # force plate -- construction du wrench attribue au pied forceplates.appendForcePlateCornerAsMarker(acqGait) mappedForcePlate = forceplates.matchingFootSideOnForceplate(acqGait) modelFilters.ForcePlateAssemblyFilter(model,acqGait,"LR", leftSegmentLabel="Left Foot", rightSegmentLabel="Right Foot").compute() idp = modelFilters.CGMLowerlimbInverseDynamicProcedure() modelFilters.InverseDynamicFilter(model, acqGait, procedure = idp, projection = pyCGM2Enums.MomentProjection.Distal, viconCGM1compatible=True ).compute(pointLabelSuffix="cgm1_6dof") modelFilters.JointPowerFilter(model,acqGait).compute(pointLabelSuffix="cgm1_6dof") # writer #btkTools.smartWriter(acqGait,"testInvDyn.c3d") if plotFlag: plotMoment(acqGait,"LHipMoment","LHipMoment_cgm1_6dof") plotMoment(acqGait,"LKneeMoment","LKneeMoment_cgm1_6dof") plotMoment(acqGait,"LAnkleMoment","LAnkleMoment_cgm1_6dof") plotMoment(acqGait,"RHipMoment","RHipMoment_cgm1_6dof") plotMoment(acqGait,"RKneeMoment","RKneeMoment_cgm1_6dof") plotMoment(acqGait,"RAnkleMoment","RAnkleMoment_cgm1_6dof") plt.show()
def basicCGM1_global(cls): MAIN_PATH = pyCGM2.TEST_DATA_PATH+"CGM1\\CGM1-TESTS\\basic_pathologicalSubject\\" staticFilename = "BOVE Vincent Cal 01.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() model.configure() markerDiameter=14 mp={ 'Bodymass' : 72.0, 'LeftLegLength' : 840.0, 'RightLegLength' : 850.0 , 'LeftKneeWidth' : 105.0, 'RightKneeWidth' : 110.4, 'LeftAnkleWidth' : 74.0, 'RightAnkleWidth' : 74.0, } model.addAnthropoInputParameters(mp) scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # ------ Travelling Axis Y ------- gaitFilename="20120213_BV-PRE-S-NNNN-I-dyn 04.global2.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,pyCGM2Enums.motionMethod.Determinist) modMotion.compute() # Joint kinematics modelFilters.ModelJCSFilter(model,acqGait).compute(description="vectoriel", pointLabelSuffix="cgm1_6dof") # BSP model bspModel = bodySegmentParameters.Bsp(model) bspModel.compute() # force plate -- construction du wrench attribue au pied forceplates.appendForcePlateCornerAsMarker(acqGait) mappedForcePlate = forceplates.matchingFootSideOnForceplate(acqGait) modelFilters.ForcePlateAssemblyFilter(model,acqGait,mappedForcePlate, leftSegmentLabel="Left Foot", rightSegmentLabel="Right Foot").compute() idp = modelFilters.CGMLowerlimbInverseDynamicProcedure() modelFilters.InverseDynamicFilter(model, acqGait, procedure = idp, projection = pyCGM2Enums.MomentProjection.Global ).compute(pointLabelSuffix="cgm1_6dof") modelFilters.JointPowerFilter(model,acqGait).compute(pointLabelSuffix="cgm1_6dof") btkTools.smartWriter(acqGait,"testInvDynPatho.c3d") # TEST ------ compareKinetics(acqGait, 5, -5, 0.2, 40.0, 0.1 )
# pyCGM2 from pyCGM2.Tools import btkTools from pyCGM2.Model import modelFilters, modelDecorator, frame from pyCGM2.Model.CGM2 import cgm from pyCGM2 import enums if __name__ == "__main__": MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\PIG advanced\\dynaKAD\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model = cgm.CGM1LowerLimbs() 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)
def basicCGM1_absoluteAngles_pelikin(cls): """ """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\Pelikin\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() 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) scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # ------ Test 1 Motion Axe X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 14.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,pyCGM2Enums.motionMethod.Determinist) modMotion.compute() longitudinalAxis,forwardProgression,globalFrame = btkTools.findProgressionAxisFromPelvicMarkers(acqGait,["LASI","LPSI","RASI","RPSI"]) 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") #btkTools.smartWriter(acqGait, "verifX.c3d") # --- tests on angles np.testing.assert_almost_equal( acqGait.GetPoint("RNewPelAngles").GetValues(), acqGait.GetPoint("RPelvisAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LNewPelAngles").GetValues(), acqGait.GetPoint("LPelvisAngles_cgm1_6dof").GetValues(), decimal =3) # ------ Test 2 Motion Axe -X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 12.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion=modelFilters.ModelMotionFilter(scp,acqGait,model,pyCGM2Enums.motionMethod.Determinist) modMotion.compute() longitudinalAxis,forwardProgression,globalFrame = btkTools.findProgressionAxisFromPelvicMarkers(acqGait,["LASI","LPSI","RASI","RPSI"]) 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") # --- tests on angles np.testing.assert_almost_equal( acqGait.GetPoint("RNewPelAngles").GetValues(), acqGait.GetPoint("RPelvisAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LNewPelAngles").GetValues(), acqGait.GetPoint("LPelvisAngles_cgm1_6dof").GetValues(), decimal =3)
def advancedCGM11_KadMed_TrueEquinus(cls): """ """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\kad-med-TrueEquinus\\" staticFilename = "static.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() model.configure() markerDiameter=14 mp={ 'Bodymass' : 36.9, 'LeftLegLength' : 665.0, 'RightLegLength' : 655.0 , 'LeftKneeWidth' : 102.7, 'RightKneeWidth' : 100.2, 'LeftAnkleWidth' : 64.5, 'RightAnkleWidth' : 63.0, 'LeftSoleDelta' : 0, 'RightSoleDelta' : 0, } optional_mp={ 'InterAsisDistance' : 0, 'LeftAsisTrocanterDistance' : 0, 'LeftThighRotation' : 0, 'LeftShankRotation' : 0 , 'LeftTibialTorsion' : 0, 'RightAsisTrocanterDistance' : 0, 'RightThighRotation' : 0, 'RightShankRotation' : 0, 'RightTibialTorsion' : 0 } model.addAnthropoInputParameters(mp,optional=optional_mp) # -----------CGM STATIC CALIBRATION-------------------- scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # cgm decorator modelDecorator.Kad(model,acqStatic).compute() modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, side="both") modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # tibial torsion ltt_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LTibialTorsion").value().GetInfo().ToDouble()[0]) rtt_vicon =np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RTibialTorsion").value().GetInfo().ToDouble()[0]) logging.info(" LTibialTorsion : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(ltt_vicon,model.mp_computed["LeftTibialTorsionOffset"])) logging.info(" RTibialTorsion : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rtt_vicon,model.mp_computed["RightTibialTorsionOffset"])) # thigh and shank Offsets lto = model.getViconThighOffset("Left") lso = model.getViconShankOffset("Left") rto = model.getViconThighOffset("Right") rso = model.getViconShankOffset("Right") lto_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LThighRotation").value().GetInfo().ToDouble()[0]) lso_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LShankRotation").value().GetInfo().ToDouble()[0]) rto_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RThighRotation").value().GetInfo().ToDouble()[0]) rso_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RShankRotation").value().GetInfo().ToDouble()[0]) logging.info(" LThighRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(lto_vicon,lto)) logging.info(" LShankRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(lso_vicon,lso)) logging.info(" RThighRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rto_vicon,rto)) logging.info(" RShankRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rso_vicon,rso)) btkTools.smartWriter(acqStatic,"Kad-med-TrueEquinus.c3d") gaitFilename="gait trial 01.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel 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","LPSI","RASI","RPSI"]) modelFilters.ModelAbsoluteAnglesFilter(model,acqGait, segmentLabels=["Left Foot","Right Foot","Pelvis"], angleLabels=["LFootProgress", "RFootProgress","Pelvis"], eulerSequences=["TOR","TOR", "TOR"], globalFrameOrientation = globalFrame, forwardProgression = forwardProgression).compute(pointLabelSuffix="cgm1_6dof") btkTools.smartWriter(acqGait, "Kad-med-TrueEquinus-angles.c3d")
def kad_midMaleolus(cls): """ """ MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\KAD-Med\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model=cgm.CGM1LowerLimbs() model.configure() 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) scp=modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # cgm decorator modelDecorator.Kad(model,acqStatic).compute() modelDecorator.AnkleCalibrationDecorator(model).midMaleolus(acqStatic, side="both") modelFilters.ModelCalibrationFilter(scp,acqStatic,model).compute() # tibial torsion ltt_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LTibialTorsion").value().GetInfo().ToDouble()[0]) rtt_vicon =np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RTibialTorsion").value().GetInfo().ToDouble()[0]) logging.info(" LTibialTorsion : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(ltt_vicon,model.mp_computed["LeftTibialTorsionOffset"])) logging.info(" RTibialTorsion : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rtt_vicon,model.mp_computed["RightTibialTorsionOffset"])) # foot offsets spf_l,sro_l = model.getViconFootOffset("Left") spf_r,sro_r = model.getViconFootOffset("Right") vicon_spf_l = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LStaticPlantFlex").value().GetInfo().ToDouble()[0]) vicon_spf_r = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RStaticPlantFlex").value().GetInfo().ToDouble()[0]) vicon_sro_l = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LStaticRotOff").value().GetInfo().ToDouble()[0]) vicon_sro_r = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RStaticRotOff").value().GetInfo().ToDouble()[0]) logging.info(" LStaticPlantFlex : Vicon (%.6f) Vs bodyBuilderFoot (%.6f)" %(spf_l,vicon_spf_l)) logging.info(" RStaticPlantFlex : Vicon (%.6f) Vs bodyBuilderFoot (%.6f)" %(spf_r,vicon_spf_r)) logging.info(" LStaticRotOff : Vicon (%.6f) Vs bodyBuilderFoot (%.6f)" %(sro_l,vicon_sro_l)) logging.info(" RStaticRotOff : Vicon (%.6f) Vs bodyBuilderFoot (%.6f)" %(sro_r,vicon_sro_r)) # thigh and shank Offsets lto = model.getViconThighOffset("Left") lso = model.getViconShankOffset("Left") rto = model.getViconThighOffset("Right") rso = model.getViconShankOffset("Right") lto_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LThighRotation").value().GetInfo().ToDouble()[0]) lso_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("LShankRotation").value().GetInfo().ToDouble()[0]) rto_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RThighRotation").value().GetInfo().ToDouble()[0]) rso_vicon = np.rad2deg(acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild("RShankRotation").value().GetInfo().ToDouble()[0]) logging.info(" LThighRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(lto_vicon,lto)) logging.info(" LShankRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(lso_vicon,lso)) logging.info(" RThighRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rto_vicon,rto)) logging.info(" RShankRotation : Vicon (%.6f) Vs pyCGM2 (%.6f)" %(rso_vicon,rso)) # ------ Test 1 Motion Axe X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 14.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel 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","LPSI","RASI","RPSI"]) modelFilters.ModelAbsoluteAnglesFilter(model,acqGait, segmentLabels=["Left Foot","Right Foot","Pelvis"], angleLabels=["LFootProgress", "RFootProgress","Pelvis"], eulerSequences=["TOR","TOR", "TOR"], globalFrameOrientation = globalFrame, forwardProgression = forwardProgression).compute(pointLabelSuffix="cgm1_6dof") btkTools.smartWriter(acqGait, "advancedCGM1_kad_midMaleolus-14.c3d") # tests on joint angles np.testing.assert_almost_equal( acqGait.GetPoint("RHipAngles").GetValues(), acqGait.GetPoint("RHipAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LHipAngles").GetValues(), acqGait.GetPoint("LHipAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("RKneeAngles").GetValues(), acqGait.GetPoint("RKneeAngles_cgm1_6dof").GetValues(), decimal =2) np.testing.assert_almost_equal( acqGait.GetPoint("LKneeAngles").GetValues(), acqGait.GetPoint("LKneeAngles_cgm1_6dof").GetValues(), decimal =2) np.testing.assert_almost_equal( acqGait.GetPoint("RPelvisAngles").GetValues(), acqGait.GetPoint("RPelvisAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LPelvisAngles").GetValues(), acqGait.GetPoint("LPelvisAngles_cgm1_6dof").GetValues(), decimal =3) # # tests on angles influence by Vicon error # np.testing.assert_almost_equal( acqGait.GetPoint("RAnkleAngles").GetValues(), # acqGait.GetPoint("RAnkleAngles_cgm1_6dof").GetValues(), decimal =3) # np.testing.assert_almost_equal( acqGait.GetPoint("LAnkleAngles").GetValues(), # acqGait.GetPoint("LAnkleAngles_cgm1_6dof").GetValues(), decimal =3) # # np.testing.assert_almost_equal( acqGait.GetPoint("LFootProgressAngles").GetValues(), # acqGait.GetPoint("LFootProgressAngles_cgm1_6dof").GetValues(), decimal =3) # np.testing.assert_almost_equal( acqGait.GetPoint("RFootProgressAngles").GetValues(), # acqGait.GetPoint("RFootProgressAngles_cgm1_6dof").GetValues(), decimal =3) # ------ Test 2 Motion Axe -X ------- gaitFilename="MRI-US-01, 2008-08-08, 3DGA 12.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # Motion FILTER # optimisation segmentaire et calibration fonctionnel 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","LPSI","RASI","RPSI"]) modelFilters.ModelAbsoluteAnglesFilter(model,acqGait, segmentLabels=["Left Foot","Right Foot","Pelvis"], angleLabels=["LFootProgress", "RFootProgress","Pelvis"], globalFrameOrientation = globalFrame, eulerSequences=["TOR","TOR", "TOR"], forwardProgression = forwardProgression).compute(pointLabelSuffix="cgm1_6dof") #btkTools.smartWriter(acqGait, "test.c3d") # tests on joint angles np.testing.assert_almost_equal( acqGait.GetPoint("RHipAngles").GetValues(), acqGait.GetPoint("RHipAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LHipAngles").GetValues(), acqGait.GetPoint("LHipAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("RKneeAngles").GetValues(), acqGait.GetPoint("RKneeAngles_cgm1_6dof").GetValues(), decimal =2) np.testing.assert_almost_equal( acqGait.GetPoint("LKneeAngles").GetValues(), acqGait.GetPoint("LKneeAngles_cgm1_6dof").GetValues(), decimal =2) np.testing.assert_almost_equal( acqGait.GetPoint("RPelvisAngles").GetValues(), acqGait.GetPoint("RPelvisAngles_cgm1_6dof").GetValues(), decimal =3) np.testing.assert_almost_equal( acqGait.GetPoint("LPelvisAngles").GetValues(), acqGait.GetPoint("LPelvisAngles_cgm1_6dof").GetValues(), decimal =3)
def basicCGM1(cls): MAIN_PATH = pyCGM2.TEST_DATA_PATH + "CGM1\\CGM1-TESTS\\basic_static_StaticVsDynamicAngles\\" staticFilename = "MRI-US-01, 2008-08-08, 3DGA 02.c3d" acqStatic = btkTools.smartReader(str(MAIN_PATH + staticFilename)) model = cgm.CGM1LowerLimbs() 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-------------------- scp = modelFilters.StaticCalibrationProcedure(model) modelFilters.ModelCalibrationFilter(scp, acqStatic, model).compute() spf_l, sro_l = model.getViconFootOffset("Left") spf_r, sro_r = model.getViconFootOffset("Right") # TESTS ------------------------------------------------ np.testing.assert_equal(model.m_useRightTibialTorsion, False) np.testing.assert_equal(model.m_useLeftTibialTorsion, False) # joint centres np.testing.assert_almost_equal( acqStatic.GetPoint("LFEP").GetValues().mean(axis=0), acqStatic.GetPoint("LHJC").GetValues().mean(axis=0), decimal=3) np.testing.assert_almost_equal( acqStatic.GetPoint("RFEP").GetValues().mean(axis=0), acqStatic.GetPoint("RHJC").GetValues().mean(axis=0), decimal=3) np.testing.assert_almost_equal( acqStatic.GetPoint("LFEO").GetValues().mean(axis=0), acqStatic.GetPoint("LKJC").GetValues().mean(axis=0), decimal=3) np.testing.assert_almost_equal( acqStatic.GetPoint("RFEO").GetValues().mean(axis=0), acqStatic.GetPoint("RKJC").GetValues().mean(axis=0), decimal=3) np.testing.assert_almost_equal( acqStatic.GetPoint("LTIO").GetValues().mean(axis=0), acqStatic.GetPoint("LAJC").GetValues().mean(axis=0), decimal=3) np.testing.assert_almost_equal( acqStatic.GetPoint("RTIO").GetValues().mean(axis=0), acqStatic.GetPoint("RAJC").GetValues().mean(axis=0), decimal=3) # foot offsets vicon_spf_l = np.rad2deg( acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild( "LStaticPlantFlex").value().GetInfo().ToDouble()[0]) vicon_spf_r = np.rad2deg( acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild( "RStaticPlantFlex").value().GetInfo().ToDouble()[0]) vicon_sro_l = np.rad2deg( acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild( "LStaticRotOff").value().GetInfo().ToDouble()[0]) vicon_sro_r = np.rad2deg( acqStatic.GetMetaData().FindChild("PROCESSING").value().FindChild( "RStaticRotOff").value().GetInfo().ToDouble()[0]) logging.info(" LStaticPlantFlex : Vicon (%.6f) Vs pyCGM2 (%.6f)" % (spf_l, vicon_spf_l)) logging.info(" RStaticPlantFlex : Vicon (%.6f) Vs pyCGM2 (%.6f)" % (spf_r, vicon_spf_r)) logging.info(" LStaticRotOff : Vicon (%.6f) Vs pyCGM2 (%.6f)" % (sro_l, vicon_sro_l)) logging.info(" RStaticRotOff : Vicon (%.6f) Vs pyCGM2 (%.6f)" % (sro_r, vicon_sro_r)) np.testing.assert_almost_equal(spf_l, vicon_spf_l, decimal=3) np.testing.assert_almost_equal(spf_r, vicon_spf_r, decimal=3) np.testing.assert_almost_equal(sro_l, vicon_sro_l, decimal=3) np.testing.assert_almost_equal(sro_r, vicon_sro_r, decimal=3) # -------- CGM FITTING ------------------------------------------------- # ---- on c3d processed vicon static-pig operation # Motion FILTER # optimisation segmentaire et calibration fonctionnel modMotion = modelFilters.ModelMotionFilter( scp, acqStatic, model, pyCGM2Enums.motionMethod.Determinist, markerDiameter=markerDiameter, pigStatic=True, viconCGM1compatible=False) modMotion.compute() # relative angles modelFilters.ModelJCSFilter(model, acqStatic).compute( description="vectoriel", pointLabelSuffix="cgm1_6dof") btkTools.smartWriter(acqStatic, "test_basicCGM1_staticAngles.c3d") # ---- on c3d processed vicon dynamic-pig operation gaitFilename = "MRI-US-01, 2008-08-08, 3DGA 02-dynamics.c3d" #"staticComparisonPipelines.c3d" acqGait = btkTools.smartReader(str(MAIN_PATH + gaitFilename)) # # output and plot #btkTools.smartWriter(acqGait, "test_basicCGM1_staticAngles.c3d") plotComparison(acqGait, acqStatic, "LHipAngles") plotComparison(acqGait, acqStatic, "LKneeAngles") plotComparison(acqGait, acqStatic, "LAnkleAngles") plt.figure() plt.plot( acqStatic.GetPoint("LAnkleAngles").GetValues()[:, 0] - acqStatic.GetPoint("LAnkleAngles" + "_cgm1_6dof").GetValues()[:, 0]) plt.figure() plt.plot( acqStatic.GetPoint("LAnkleAngles").GetValues()[:, 2] - acqStatic.GetPoint("LAnkleAngles" + "_cgm1_6dof").GetValues()[:, 2])
def calibrate(DATA_PATH,calibrateFilenameLabelled,translators, required_mp,optional_mp, leftFlatFoot,rightFlatFoot,markerDiameter, pointSuffix): # --------------------------ACQUISITION ------------------------------------ # ---btk acquisition--- acqStatic = btkTools.smartReader(str(DATA_PATH+calibrateFilenameLabelled)) btkTools.checkMultipleSubject(acqStatic) acqStatic = btkTools.applyTranslators(acqStatic,translators) # ---definition--- model=cgm.CGM1LowerLimbs() model.setVersion("CGM1.1") model.configure() model.addAnthropoInputParameters(required_mp,optional=optional_mp) # --store calibration parameters-- model.setStaticFilename(calibrateFilenameLabelled) model.setCalibrationProperty("leftFlatFoot",leftFlatFoot) model.setCalibrationProperty("rightFlatFoot",rightFlatFoot) model.setCalibrationProperty("markerDiameter",markerDiameter) # ---check marker set used---- smc= cgm.CGM.checkCGM1_StaticMarkerConfig(acqStatic) # --------------------------STATIC CALBRATION-------------------------- scp=modelFilters.StaticCalibrationProcedure(model) # load calibration procedure # ---initial calibration filter---- modelFilters.ModelCalibrationFilter(scp,acqStatic,model, leftFlatFoot = leftFlatFoot, rightFlatFoot = rightFlatFoot, markerDiameter = markerDiameter, ).compute() # ---- Decorators ----- decorators.applyDecorators_CGM(smc, model,acqStatic,optional_mp,markerDiameter) # ----Final Calibration filter if model previously decorated ----- if model.decoratedModel: # initial static filter modelFilters.ModelCalibrationFilter(scp,acqStatic,model, leftFlatFoot = leftFlatFoot, rightFlatFoot = rightFlatFoot, markerDiameter=markerDiameter).compute() # ----------------------CGM MODELLING---------------------------------- # ----motion filter---- # notice : viconCGM1compatible option duplicate error on Construction of the foot coordinate system modMotion=modelFilters.ModelMotionFilter(scp,acqStatic,model,enums.motionMethod.Determinist, markerDiameter=markerDiameter) modMotion.compute() #---- Joint kinematics---- # relative angles modelFilters.ModelJCSFilter(model,acqStatic).compute(description="vectoriel", pointLabelSuffix=pointSuffix) # detection of traveling axis longitudinalAxis,forwardProgression,globalFrame = btkTools.findProgressionAxisFromPelvicMarkers(acqStatic,["LASI","RASI","RPSI","LPSI"]) # absolute angles modelFilters.ModelAbsoluteAnglesFilter(model,acqStatic, segmentLabels=["Left Foot","Right Foot","Pelvis"], angleLabels=["LFootProgress", "RFootProgress","Pelvis"], eulerSequences=["TOR","TOR", "ROT"], globalFrameOrientation = globalFrame, forwardProgression = forwardProgression).compute(pointLabelSuffix=pointSuffix) return model, acqStatic