neurogears / vestibular-vr

Closed-loop VR setup for Rancz Lab
2 stars 0 forks source link

Discrepancy between raw analog data and buffer count. #81

Closed RoboDoig closed 2 months ago

RoboDoig commented 2 months ago

For synchronisation between HARP and ONIX in the Bonsai workflow, we index each buffer of analog data and assign it a HARP timestamp (this is the 'old' way of doing things without the hardware HARP timestamping).

@ikharitonov noticed in the data analysis that there was sometimes a discrepancy between the number of timestamped buffers and the total amount of analog data.

I've tracked the source of this down to the method by which the logging works in the Bonsai workflow. A key down combination is used to trigger the start of data logging, which in turn subscribes the loggers to the individual data streams. Because I separated subscription to the raw analog data and the buffer index, I believe that Bonsai was subscribing to the buffer index slightly before the raw analog data. Because the analog data is acquired so fast, this means that some raw analog samples were missed from the logging at the beginning of acquisition.

The solution is to subscribe to these streams simultaneously in Bonsai. For analysis where data has this discrepancy due to this bug, one can assume that missing analog samples are missing from the start of the dataset, so data can still be aligned.

RoboDoig commented 2 months ago

Closing with PR #82