pyCGM_Single.pyCGM.combineDataDict

pyCGM_Single.pyCGM.combineDataDict(values, labels)

Converts two lists of values and labels to a dictionary.

Parameters
valuesarray

Array of motion data values. Indices of values correspond to frames in the trial. Each element is an array of x, y, and z coordinate values.

labelsarray

List of marker names.

Returns
dataarray

Array of dictionaries of motion capture data. Keys are marker names and values are arrays of x, y, and z coordinate values. Array indices correspond to frames of the trial.

Examples

Example for three markers and two frames of trial.

>>> from numpy import array_equal
>>> labels = ['RFHD', 'LFHD', 'LBHD']
>>> values = [[[ 325.83, 402.55, 1722.50],
...            [ 184.55, 409.69, 1721.34],
...            [ 197.86, 251.29, 1696.90]],
...           [[ 326.83, 403.55, 1723.50],
...            [ 185.55, 408.69, 1722.34],
...            [ 198.86, 252.29, 1697.90]]]
>>> result = combineDataDict(values, labels)
>>> expected = [{'RFHD': [325.83, 402.55, 1722.50],
...              'LFHD': [184.55, 409.69, 1721.34],
...              'LBHD': [197.86, 251.29, 1696.90]},
...              {'RFHD': [326.83, 403.55, 1723.50],
...              'LFHD': [185.55, 408.69, 1722.34],
...              'LBHD': [198.86, 252.29, 1697.90]}]
>>> flag = True # False if any values are not equal
>>> for i in range(len(result)):
...     for key in result[i]:
...         if (not array_equal(result[i][key], expected[i][key])):
...             flag = False
>>> flag
True