pyCGM_Single.pycgmCalc.createMotionDataDict¶
-
pyCGM_Single.pycgmCalc.
createMotionDataDict
(labels, data)¶ Creates an array of motion capture data given labels and data.
- Parameters
- labelsarray
List of marker position names.
- dataarray
List of x, y, and z coordinate values corresponding to the marker names in labels. Indices of data correspond to frames in the trial.
- Returns
- motiondataarray
List of dict. Indices of motiondata correspond to frames in the trial. Keys in the dictionary are marker names and values are x, y, and z coordinates of the corresponding marker.
Examples
This example uses a loop and
numpy.array_equal
to test the equality of individual dictionary elements since python does not guarantee the order of dictionary elements.Example for three markers and two frames of trial.
>>> from numpy import array, array_equal >>> labels = ['LFHD', 'RFHD', 'LBHD'] >>> data = [[array([184.55, 409.69, 1721.34]), ... array([325.83, 402.55, 1722.50]), ... array([197.86, 251.29, 1696.90])], ... [array([185.55, 408.69, 1722.34]), ... array([326.83, 403.55, 1723.50]), ... array([198.86, 252.29, 1697.90])]] >>> result = createMotionDataDict(labels, data) >>> expected = [{'LFHD': array([184.55, 409.69, 1721.34]), ... 'RFHD': array([325.83, 402.55, 1722.50]), ... 'LBHD': array([197.86, 251.29, 1696.90])}, ... {'LFHD': array([185.55, 408.69, 1722.34]), ... 'RFHD': array([326.83, 403.55, 1723.50]), ... 'LBHD': array([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