python-neo icon indicating copy to clipboard operation
python-neo copied to clipboard

Spike2IO: Wrong sampling_rate value of the read analogsignal

Open ajkswamy opened this issue 10 years ago • 6 comments

Dear Neo development team

I am trying to import an SMR file using neo.Spike2IO. The sampling rate of one of the read analog signals is different from what is shown when I open the file with Spike2.

Here is an example file: https://copy.com/g4rSBq4hTBl0kjqD The issue is with the signal in channel 1.

The code to reproduce the issue:

from neo import Spike2IO fName = '130605-1LY.smr' blk = Spike2IO(fName).read()[0] volt = blk.segments[0].analogsignals[0] print(volt.sampling_rate)

Thanks

Sincerely, Ajay

ajkswamy avatar Aug 03 '15 10:08 ajkswamy

Hi, sorry for very long delay. I notice something very weird (like a bug) in SMR files. This depends on system version.

In short there are 2 ways: 1- The rate written in the header which is not the real one. I guess it is the one wanted by user. 2- The real computed from the ADC sampling interval. This 2 float differs (at least in some files)!!!! See line 210 to 218 in the Spike2IO. The 2 is prefered but it is sometimes buggy. So you can try the other one. You can try Spike2IO.read_segment(take_ideal_sampling_rate = True).

I wrote this IO but I never use spike2 files. So maybe I am missing something.

Could you try Spike2IO.read_segment(take_ideal_sampling_rate = True). The file you send give: 0.0373989256635 Hz for take_ideal_sampling_rate = False 20000.0 Hz for take_ideal_sampling_rate = True

samuelgarcia avatar Aug 20 '15 10:08 samuelgarcia

Hi Samuel

Thanks for the reply. I tried with take_ideal_sampling_rate = True and take_ideal_sampling_rate = False and the sampling rates are as you say.

Unfortunately, the actual sampling rate of the signal is 20.833kHz and my collaborator says it is properly displayed when he opens it with Spike2.

At the moment, I am just reinitializing the sampling rate of the analogsignal with the problem. Do you think I would face problems down the line doing this? I check the length of the signal with other simultaneously recorded signals and the lengths are equal.

Anyways, thanks again for the reply.

Sincerely Ajay

ajkswamy avatar Aug 25 '15 11:08 ajkswamy

Maybe the formula used in lines 210 to 218 in Spike2IO are wrong for some version of CED. The best would be to check directly in the dcoumentation provided with the CED system and patch theses lines.

samuelgarcia avatar Aug 25 '15 11:08 samuelgarcia

SamuelGarcia, would you still have the documentation of the .smr files?

cafalchio avatar Dec 19 '24 21:12 cafalchio

@cafalchio : unfortunatly not! I think I never get it. I am sorry. I wrote this reader long time ago by reading others code and this code are not longer open apparently... Having a format specification is challenging here.

samuelgarcia avatar Jan 06 '25 16:01 samuelgarcia

Thank you, I am going to automate some scripts for a friend and I was looking to get the file specification to try to implement a rust loader, but I will just use yours and email the cambridge guys.

cafalchio avatar Jan 06 '25 16:01 cafalchio