open-ephys / analysis-tools

Archived code for reading data saved by the Open Ephys GUI
59 stars 176 forks source link

OpenEphys.py does not load .spikes #70

Closed dieKrone closed 5 years ago

dieKrone commented 5 years ago

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.

jsiegle commented 5 years ago

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?

dieKrone commented 5 years ago

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.

jsiegle commented 5 years ago

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?

dieKrone commented 5 years ago

The new version works! Thank you very much!