paulhibbing / AGread

Read Accelerometer Files from ActiGraph Accelerometers
Other
15 stars 4 forks source link

Differences between IMU data obtained from `read_gt3x` and `read_AG_IMU` #5

Closed paulhibbing closed 4 years ago

paulhibbing commented 5 years ago

Branch 3x-error was created to address issues with read_gt3x related to USB connection and gaps in the data. That investigation has now revealed that something is not right with the way SENSOR_DATA packets are parsed.

read_gt3x("inst/extdata/example.gt3x")$IMU

gives different values from the reference standard, i.e., the data exported from ActiLife, which are found in inst/extdata/example-IMU.csv.

For example, see inst/extdata/example-IMU.xlsx, particularly the highlighted data (2019-02-14 09:00:34 -- the 155th SENSOR_DATA packet). Columns A-K are the IMU.csv data (i.e., values from ActiLife), columns N-W are the corresponding read_gt3x data, and columns Y-AH are the absolute differences between the two.

A particular concern is the last value for Gyroscope_Y (see cells G121, S121, and AD121). In read_gt3x that value is coming from bytes 413965 and 413966 of log.bin (hex: fd45). The signed big-endian value lands at -699, and the scale factor (from SENSOR_SCHEMA packet) is 16.384, giving a final value of -42.66357, compared to -293.003558 from ActiLife.

Also of note, the first sample for the highlighted packet matches exactly (ActiLife vs read_gt3x) for all variables. I'm having trouble diagnosing all of this.

paulhibbing commented 4 years ago

Interpolation was to blame for this, and all is resolved in v1.0.0. Previously, IMU packets were interpolated using a malformed linear approach. The revised approach is distance-weighted (but not quite IDW interpolation), per correspondence with ActiGraph.