buzsakilab / buzcode

Code for internal lab sharing - polishing has started but is by no means complete
http://www.buzsakilab.com/
GNU General Public License v3.0
119 stars 128 forks source link

bz_GetLFP interval input, ensure # of samples #232

Closed DavidTingley closed 6 years ago

DavidTingley commented 6 years ago

I've noticed when running bz_getLFP with interval sets that it often returns .data segments of differing sizes even when the intervals provided are exactly the same duration. For intervals of 300 ms, I often get .data segments of either 375 OR 374 samples.

We should add a "check # of samples" condition somewhere to ensure that bz_GetLFP always returns segments of a consistent size (375 for the above case).

What do you guys think? I imagine this is a rounding error that can be fixed with a ceil/floor call.

DavidTingley commented 6 years ago

tracked it to line 169 of bz_LoadBinary

nSamplesPerChannel = floor((duration*frequency));

duration = 0.3000, frequency = 1250; the floor call returns 374 but it should be 375....

changed to below in /dev

nSamplesPerChannel = round((duration*frequency));

raswanson commented 6 years ago

Oi good find.