pyCGM_Single.pycgmCalc.calcAngles¶
-
pyCGM_Single.pycgmCalc.
calcAngles
(data, **kargs)¶ Calculates the joint angles and axis.
By default, the function will calculate all the data and return angles and axis as separate arrays. The values returned by this function currently differ in return type and value depending on the keyword arguments of
**kargs
. The function is currently used directly in pyCGM/pycgm_embed.py.- Parameters
- dataarray
Joint centers in the global coordinate system. List indices correspond to each frame of trial. Dict keys correspond to name of each joint center, dict values are arrays ([],[],[]) of x,y,z coordinates for each joint center.
- ``**kargs``keyword arguments
- startint, optional
Indicates which index in data to start the calculation.
- endint, optional
Indicates which index in data to end the calculation. The data at index end is not included.
- frameint, optional
Frame number if the calculation is only for one frame. Incompatible with start and end.
- vskdict, required
Subject measurement values as a dictionary or labels and data.
- anglesbool, optional
If true, the function will return angles. True by default.
- axisbool, optional
If true, the function will return axis. True by default.
- splitAnglesAxisbool, optional
If true, the function will return angles and axis as separate arrays. If false, it will be the same array. True by default.
- returnjointsbool, optional
If true, the function will return returnjoints. False by default.
- formatDatabool, optional
If true, the function will return angles and axis in one array. True by default.
- Returns
- r, jcsarray_like
r is a list of joint angle values for each frame. jcs is a list of dictionaries, each of which holds joint center locations for each frame. Returned only if returnjoints is True.
- Raises
- Exception
If start is given and is negative. If start is larger than end. If end is larger than the length of data.
Examples
First, we load motion capture data from Sample_Static.c3d and subject measurement values from Sample_SM.vsk in /SampleData/ROM/.
>>> from numpy import around >>> from .pycgmIO import loadC3D, loadVSK >>> from .pycgmStatic import getStatic >>> from .pyCGM_Helpers import getfilenames >>> filenames = getfilenames(x=2) >>> c3dFile = filenames[1] >>> vskFile = filenames[2] >>> result = loadC3D(c3dFile) >>> data = result[0] >>> vskData = loadVSK(vskFile, False) >>> vsk = getStatic(data,vskData,flat_foot=False)
Example of default behavior.
>>> result = calcAngles(data, vsk=vsk) >>> around(result[0], 2) #Array of joint angles array([[[ -0.46, -5.76, 4.81], [ 3.04, -7.02, -17.41], [ -3. , -4.54, -1.74], ..., [ 36.3 , 0. , 0. ], [ 9.92, 15.25, 126.24], [ 6.64, 17.64, 123.81]]]) >>> around(result[1], 2) #Array of axis values array([[[[ 246.15, 353.26, 1031.71], [ 246.24, 354.25, 1031.61], [ 245.16, 353.35, 1031.7 ], [ 246.14, 353.36, 1032.71]], ... [-306.46, 510.14, 1069.26], [-307.13, 509.31, 1068.33], [-305.75, 509.12, 1068.58]]]])
Example of returning as a tuple.
>>> kinematics, joint_centers = calcAngles(data, start=None, end=None, vsk=vsk, splitAnglesAxis=False, formatData=False,returnjoints=True) >>> around(kinematics[0][0], 2) -0.46 >>> around(joint_centers[0]['Pelvis'], 2) array([ 246.15, 353.26, 1031.71])
Example without returning joints.
>>> kinematics = calcAngles(data, vsk=vsk, splitAnglesAxis=False, formatData=False,returnjoints=False) >>> around(kinematics[0][0], 2) -0.46