CerebusOSS/CereLink

Loading data in .nsx and .nev files into Python

Closed this issue · 3 comments

It appears there are no versions of openNSx.m and openNEV.m for Python. To load data into Python, the only currently available option seems to be using the n2h5 utility to convert .nsx and .nev files into HDF5 files, and then loading those files into Python (using a package such as h5py or tables).

However, n2h5 saves the datasets corresponding to different channels in different groups (e.g., channel00001, channel00002) within the HDF5 file. Therefore, one can only load data from one channel at a time. Furthermore, you have to load all of the data on that channel (i.e., you can't time-slice). (Please correct me if I'm wrong about this!) E.g., to load spike data from multiple channels, one would have to do something like:

>>> import h5py
>>> f = h5py.File('file1.nev.hdf5', 'r')  // use n2h5 to create file1.nev.hdf5 from file1.nev
>>> chan1_data = f.get('channel/channel00001/spike_set')
>>> chan2_data = f.get('channel/channel00002/spike_set')
>>> // ... etc. etc.

In contrast, with openNEV.m in MATLAB, one can read spike data from all channels at once and even specify a time slice by doing something like:

openNEV('read', t:50:100’, ‘uV’);

Can you tell me if my understanding of the options for reading saved data into Python, and the differences between Python and MATLAB, is correct? If so, does Blackrock have any development plans for a Python version of the NPMK? This is something that other users have expressed interest in as well (e.g., see issue #30).

Update: Nick Halper at Blackrock has informed me that they are currently developing a Python data loader. I would be in favor of Blackrock adding this to the github site (along with the current MATLAB data loader -- although I'm much more interested in the Python version).

From Nick Halper:
The NPMK is just a compilation of Matlab scripts, the newest of which can always be obtained at this link: http://support.blackrockmicro.com/KB/View/166898-matlab-interfacing-and-analysis

hdf5 format is becoming the standard, and it is much faster than loading directly. h5py is just one of many to read hdf format, there should be more optimized versions as well. If Blackrock decides to donate the code for Python loader, I will gladly add it to my repo.