NeurodataWithoutBorders / matnwb

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

[Bug]: Unexpected attributes with nwbRead Dandiset 000115 #470

Closed hungtuchen closed 1 year ago

hungtuchen commented 2 years ago

What happened?

Unexpected properties {camera_device 1} when using nwbRead to read data file https://dandiarchive.org/dandiset/000115/0.210914.1732/sub-despereaux/sub-despereaux_ses-despereaux-07_behavior+ecephys.nwb.

Steps to Reproduce

addpath(genpath(pwd));
generateCore();
nwb = nwbRead('pathname_to_file')

And `util.getSchemaVersion('pathname_to_file')` returns '2.3.0'

Error Message

Error using assert
Unexpected properties {camera_device 1}.

Your schema version may be incompatible with the file.  Consider checking the schema version of the
file with `util.getSchemaVersion(filename)` and comparing with the YAML namespace version present in
nwb-schema/core/nwb.namespace.yaml

Error in types.util.checkUnset (line 13)
assert(isempty(dropped),...

Error in types.ndx_franklab_novela.NwbImageSeries (line 11)
            types.util.checkUnset(obj, unique(varargin(1:2:end)));

Error in io.parseGroup (line 85)
    parsed = eval([Type.typename '(kwargs{:})']);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in nwbRead (line 59)
nwb = io.parseGroup(filename, h5info(filename), Blacklist); 


### Operating System

macOS

### Matlab Version

R2022b

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://github.com/neurodatawithoutborders/matnwb/blob/master/.github/CODE_OF_CONDUCT.md)
- [X] Have you ensured this bug was not already [reported](https://github.com/NeurodataWithoutBorders/matnwb/issues)?
bendichter commented 2 years ago

Hey @transedward thanks for opening the issue. This is going to be a bit tricky to reproduce because it's a 90 GB file. In Python I'd just stream it using fsspec, but the tools to do this in MATLAB are not as good. I'm downloading the file but it could take a while.

Looking at the traceback it looks like the issue is with the ndx_franklab_novela extension, not the core schema. Is it possible that you generated the schema for this extension and that it conflicts with the schema in the file? @lawrence-mbf , any thoughts on this?

lawrence-mbf commented 2 years ago

I agree that it's most likely coming from the extension schema and not the main one. I just finished downloading a representative file and it seems to come from the CameraDevice object which does come from the ndx-franklab-novela extension schema.

lawrence-mbf commented 2 years ago

I think see what the issue is. It has to do with the modifications to the device property in the core ImageSeries. The problematic type--NwbImageSeries--has modified the property to expand it to contain multiple Device objects. This causes a subtle breakage where the default value of device is not supposed to be [] as expected by checkUnset.

yarikoptic commented 2 years ago

Is the fix coming?

lawrence-mbf commented 2 years ago

It requires a larger change to class generation where checkUnset is used. But yes, working on it.

lawrence-mbf commented 2 years ago

@transedward @yarikoptic Let me know if #475 fixes this issue.

hungtuchen commented 1 year ago

Hi @lawrence-mbf, thank you for the fix and update. There are some other errors appearing as follows. Let me know what I can do, thanks!

Error using builtin
Incorrect number or types of inputs or outputs for function 'flip'.

Error in flip (line 32)
      [varargout{1:nargout}] = builtin(mfilename, varargin{:});

Error in flipud (line 14)
x = flip(x,1);

Error in types.untyped.DataStub/load_mat_style (line 171)
                    cell2mat(flipud(points)) - 1);

Error in types.untyped.DataStub/load (line 120)
                data = obj.load_mat_style(varargin{1});

Error in indexing (line 369)
                B = builtin('subsref', obj, S);

Error in types.util.checkDtype (line 80)
        val = val.load(1);

Error in types.hdmf_common.DynamicTableRegion/validate_data (line 38)
        val = types.util.checkDtype('data', 'int32', val);

Error in types.hdmf_common.Data/set.data (line 29)
        obj.data = obj.validate_data(val);

Error in types.hdmf_common.Data (line 22)
        obj.data = p.Results.data;

Error in types.hdmf_common.VectorData (line 13)
        obj = obj@types.hdmf_common.Data(varargin{:});

Error in types.hdmf_common.DynamicTableRegion (line 13)
        obj = obj@types.hdmf_common.VectorData(varargin{:});

Error in io.parseDataset (line 81)
    parsed = eval([Type.typename '(kwargs{:})']);

Error in io.parseGroup (line 22)
    dataset = io.parseDataset(filename, datasetInfo, fullPath, Blacklist);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in io.parseGroup (line 38)
    subg = io.parseGroup(filename, group, Blacklist);

Error in nwbRead (line 59)
nwb = io.parseGroup(filename, h5info(filename), Blacklist);
hungtuchen commented 1 year ago

Interestingly, it seems to be working with the file in the draft version (dandiset/000115/draft). Thanks for the fix!

lawrence-mbf commented 1 year ago

Good to hear! I'll check on that error in the original file anyway in the meantime.