xdf-modules / xdf-Matlab

Matlab code for working with xdf files.
BSD 2-Clause "Simplified" License
11 stars 13 forks source link

Error in dejitter in certain edge-cases #7

Closed dmedine closed 4 years ago

dmedine commented 4 years ago

This line is wrong: https://github.com/xdf-modules/xdf-Matlab/blob/master/load_xdf.m#L530

What can happen is that in the case of a clock reset, the timestamps can go from a very high to a very small range of values. In this case, this line of code will fail to spot the large negative spike in the diff(timestamps) array and the result will be completely wrong. I have a data set where this happens and the effective sampling rate is a negative value. Taking the absolute value of the diff(timestamps) array will stop this from happening.

arnodelorme commented 4 years ago

I think you fixed it right?

dmedine commented 4 years ago

Yes. This is fixed now.