m-beau / NeuroPyxels

NeuroPyxels (npyx) is a python library built for electrophysiologists using Neuropixels electrodes. This package stems from the need of a pythonist who really did not want to transition to MATLAB to work with Neuropixels: it features a suite of core utility functions for loading, processing and plotting Neuropixels data.
GNU General Public License v3.0
112 stars 27 forks source link

Sampling rate from metadata converted to int #352

Closed nazgulfg92 closed 11 months ago

nazgulfg92 commented 11 months ago

Hi all, First of all, thanks for the wonderful package! I was fiddling around with loading some metadata from a recording and realised that the sampling rate returned from the npyx.inout.metadata function is converted to int (line 262 in the code):

            if meta_glx[filt_key]['typeThis'] == 'imec':
                meta[filt_key]['sampling_rate']=int(meta_glx[filt_key]['imSampRate'])

If, by some circumstances, one has more than one event, wouldn't this lead to accumulated error? The calibrated sampling rate from my recording is 30000.352941 (which is the sampling rate .meta file), but from the metadata function I'd get 30000.

Ultimately, I worry that it might make event detection (e.g. from the sync channel) a little bit inaccurate (although the error would be very small, almost negligible).

m-beau commented 11 months ago

Hi there,

You are completely right, this is an error! This line of code casts the string from the metafile into a 'workable quantity', and wasn't using sampling rate calibration at the beginning of my project so I cast it to int. Fixing this asap.

m-beau commented 11 months ago

The master branch is now fixed. Bear in mind that the pip uploaded version of the package is not yet! I will update it soon.

nazgulfg92 commented 11 months ago

Great! Thanks a lot! I noticed something else in the output of the get_npix_sync function; I'll open another issue to let you know in more detail :)