-
Notifications
You must be signed in to change notification settings - Fork 32
Description
I just discovered that using the TimeStamp column in the mocap module was a bad idea. I new that the TimeStamp column had some anomalies (see http://gait-analysis-toolkit.readthedocs.org/en/latest/motek.html#data-column-descriptions) but none of my test data showed the additional anomalies I've just uncovered. Once I used a new differentiation method in PR #128 these anomalies were exposed, where as the previous differentiation method quietly but incorrectly smoothed them over. This issue is that DFlow receives streaming data from Cortex and it is accessible in the from the mocap module. Cortex likely handles the data stream correctly, i.e. within the 0.01 s sampling period it collects data from all cameras and computes the marker coordinates providing a value that was collected at sometime during the sampling period. Each cortex value is delivered along with the sequential frame number and it must have a mechanism to flag a frame number that has missing marker values. DFlow receives this data over ethernet and time stamps it using the DFlow CPU clock. This issue arises because the data flow comes into the DFlow computer serially and likely asynchronously wrt to time. A FIFO flow is likely used to so data is dropped, but this means that data can "stack up" with respect to the DFlow cpu time and if the TimeStamp column is relied upon, there can be issues.
The following plot shows the same graph from (http://gait-analysis-toolkit.readthedocs.org/en/latest/motek.html#data-column-descriptions) except with a data set (trial 31) that doesn't have as clean a time stamp. This plot shows the difference in the current and subsequent time value:

Note that most of the differences are around 0.01 s, but there are some large outliers and notice the values that are close to zero. These correspond to the data stack up wrt to time.
The next plot shows three plots where I've flagged all the values associated with the time stack ups in red. The first plot is TimeStamp vs FrameNumber and the following two show the RGTRO marker coordinate against time and frame number.

Notice that there are a fair amount of time stack ups in the data. We can zoom in to one instance to see what is going on:

This graph plots the same things but we see how the frames get stacked up wrt to time.
The motek.py module parses the data and uses the TimeStamp column as a reliable value. You can see how this will cause issues when trying to differentiate marker positions with respect to time. The real time differentiator does can differentiate these instance without too much error so it wasn't noticed before. But the values are still wrong. The traditional central differencing methods have major issues with this incorrect data.
Note that this issue is in addition to missing marker values. The DFlowData class needs to be reworked to make use of the FrameNumber instead of the TimeStamp column.
The other issue with this is that synchronizing the mocap module and record module data relies on the time stamp values. I assume that the TimeStamp column from each module is generated from the DFlow cpu time. We'll need to look into the synchronization after the time stamp issues are taken care of to ensure that synchronization still works as expected.