NeurodataWithoutBorders / matnwb

A Matlab interface for reading and writing NWB files
BSD 2-Clause "Simplified" License
50 stars 32 forks source link

cannot read UnitTimes #36

Closed bendichter closed 6 years ago

bendichter commented 6 years ago

I am having trouble reading the UnitTimes datatype. Specifically, when I try to import data with UnitTimes, I get the following error:

>> nwb=nwbRead('/Users/bendichter/Desktop/Buzsaki/SenzaiBuzsaki2017/test.nwb');
Error using hdf5lib2
Incorrect number of uint8 values passed in
reference parameter.

Error in H5R.get_name (line 34)
name = H5ML.hdf5lib2('H5Rget_name', loc_id,
ref_type, ref, useUtf8);

Error in io.parseReference (line 7)
target = H5R.get_name(did, reftype, data);

Error in io.parseDataset (line 24)
    data = io.parseReference(did, tid,
    H5D.read(did));

Error in io.parseGroup (line 14)
    ds = io.parseDataset(filename, ds_info,
    fp);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename, g_info);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename, g_info);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename, g_info);

Error in nwbRead (line 20)
nwb = io.parseGroup(filename, info);

I have tracked this down to an error building the spike_times_index component of UnitTimes, which is a list of range references. This is data written using pynwb. Could this be due to the switch of dimensions mentioned in the README? I'll try to replicate the error using a file written in matnwb as well.

lawrence-mbf commented 6 years ago

Is this using the schema currently in the repo?

lawrence-mbf commented 6 years ago

9fda8e07f91faa0c2f44e7471403b268094935d4 added a new test for UnitTimes. Roundtrip seems to work with just matnwb (schema may need to be update to nwb-schema current). Will look at pynwb interop.

bendichter commented 6 years ago
Error using hdf5lib2
Incorrect number of uint8 values passed
in reference parameter.

Error in H5R.get_name (line 34)
name = H5ML.hdf5lib2('H5Rget_name',
loc_id, ref_type, ref, useUtf8);

Error in io.parseReference (line 7)
target = H5R.get_name(did, reftype,
data);

Error in io.parseDataset (line 25)
    data = io.parseReference(did, tid,
    H5D.read(did));

Error in io.parseGroup (line 14)
    ds = io.parseDataset(filename,
    ds_info, fp);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename,
    g_info);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename,
    g_info);

Error in io.parseGroup (line 26)
    subg = io.parseGroup(filename,
    g_info);

Error in nwbRead (line 25)
nwb = io.parseGroup(filename, info);

loading this file

It looks like this could possibly be another int8 vs int16 type issue

lawrence-mbf commented 6 years ago

It's because it's an array of References, which I don't think is actually read in properly yet. I'll get this done by tomorrow.

bendichter commented 6 years ago

sounds good. It's been great plowing through these issues with you!

lawrence-mbf commented 6 years ago

See if this commit works actually: 944998ae980ebd352a1da28d184638ecb6a34808

bendichter commented 6 years ago

Works!

>> nwb=nwbRead('test.nwb')
>> spikes = nwb.processing.get('cellular').nwbdatainterface.get('UnitTimes').spike_times_index.data(1).refresh(nwb);
>> spikes(1:10)

ans =

    2.7670
    4.6878
    5.0803
    5.3623
    5.6367
    5.7636
    5.7712
    5.9959
    6.6608
    7.0330