sccn / xdf

BSD 2-Clause "Simplified" License
87 stars 34 forks source link

load_xdf.m will not dejitter properly in certain edge-cases #53

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.