open-ephys/analysis-tools

OpenEphys.py does not load .spikes

Closed this issue · 4 comments

When I import the OpenEphys module I can load the .continous data without issues.
But when I try to load the spikes it gives me the following error:

data = OpenEphys.load(r"T:\Dokumente\Data\test_2019-01-08_13-57-09\STp105.0n5.spikes")
loading spikes...
Traceback (most recent call last):

File "", line 1, in
data = OpenEphys.load(r"T:\Dokumente\Data\test_2019-01-08_13-57-09\STp105.0n5.spikes")

File "c:\anaconda3\lib\OpenEphys.py", line 37, in load
data = loadSpikes(filepath)

File "c:\anaconda3\lib\OpenEphys.py", line 208, in loadSpikes
waveforms = np.fromfile(f, np.dtype('<u2'), numChannels*numSamples)

TypeError: only integer scalar arrays can be converted to a scalar index

Does anybody know what I am doing wrong here? Any help would be appreciated.

It looks like there might be a problem with OpenEphys.py.

Try changing that last line to:

waveforms = np.fromfile(f, np.dtype('<u2'), int(numChannels*numSamples))

Also, do you know what version of Python are you using?

Yes I tried that already. The outcome is the same issue, but in the next line... and so on. So that is why I think there is some systematic problem. I copied the exact code that is available here on GitHub in the Python 3 folder.

I am using Python 3.6.4

Thank you for your response.

It looks like numSamples and numChannels were being loaded as length-1 arrays, rather than integers. I just pushed a fix that should solve your problem. Can you try loading the .spikes file with the latest version of OpenEphys.py?

The new version works! Thank you very much!