pyCGM_Single.pycgmCalc.Calc

pyCGM_Single.pycgmCalc.Calc(start, end, data, vsk)

Calculates angles and joint values for marker data in a given range

This function is a wrapper around calcFrames. It calls calcFrames with the given data and vsk inputs starting at index start and ending at index end in data.

Parameters
startint

Start index for the range of frames in data to calculate

endint

End index for the range of frames in data to calculate. The data at index end is not included.

dataarray of dict or array

List of xyz coordinates of marker positions in a frame. Each coordinate is a dict where the key is the marker name and the value is a 3 element array of its xyz coordinate. Can also pass as an array of [labels, data], where labels is a list of marker names and data is list of corresponding xyz coordinates.

vskdict or array

Dictionary containing subject measurement values, or array of labels and data [labels, data].

Returns
angles, jcstuple

angles is an array of the joint angle values. jcs is an array of joint center locations. Indices correspond to frames in the trial.

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) #x=2 loads sample data from Sample_Data/ROM
>>> c3dFile = filenames[1]
>>> vskFile = filenames[2]
>>> result = loadC3D(c3dFile)
>>> data = result[0]
>>> vskData = loadVSK(vskFile, False)
>>> vsk = getStatic(data,vskData,flat_foot=False)

A start value of 0 and an end value of 3 indicates that we want to calculate angles for frames 0-2.

>>> start = 0
>>> end = 3
>>> angles, jcs = Calc(start, end, data, vsk)
>>> around(angles[0][0], 2) #Frame 0
-0.46
>>> around(angles[1][0], 2) #Frame 1
-0.46
>>> around(angles[2][0], 2) #Frame 2
-0.46
>>> around(jcs[0]['Pelvis'], 2)
array([ 246.15,  353.26, 1031.71])
>>> around(jcs[1]['Pelvis'], 2)
array([ 246.16,  353.27, 1031.72])