NeurodataWithoutBorders / matnwb

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

nwbRead with ignorecache fails #279

Closed ageorgou closed 3 years ago

ageorgou commented 3 years ago

I've tried the 'ignorecache' option for nwbRead (as a way around #220) but it always fails due to not expecting the specifications group (sure enough, it does not appear in the schema for NWBFile).

It seems that the specifications group is normally "blacklisted" (excluded from comparisons against the spec), but only when 'ignorecache' is not passed. Should it should always be excluded?

If this is not intended behaviour, I'm happy to try a PR changing the logic ofreadNwb so that the location of namespaces is excluded even when they are not checked/retrieved due to 'ignorecache'.

Tried with current matnwb master (96bbb7e).

Steps to reproduce:

nwb = NwbFile;
nwb.session_start_time = datetime('now');
nwb.identifier = 'EMPTY';
nwb.session_description = 'empty test file';
nwbExport(nwb, 'empty.nwb');
n = nwbRead('empty.nwb', 'ignorecache')

Output:

Error using types.util.checkUnset (line 13)
Unexpected properties {specifications}.

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 NwbFile (line 18)
                types.util.checkUnset(obj, unique(varargin(1:2:end)));

Error in io.parseGroup (line 76)
            parsed = NwbFile(kwargs{:});

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

Thanks!

EDIT: If it helps, this may have been changed in cd8dda1.

lawrence-mbf commented 3 years ago

Ah I think I see the issue. So technically specifications is not in the NWB schema as it is used to cache the schema of whoever exported the file. However, the name of the group is not as important as its reference in .specloc which points to a Group which houses the cached schema.

What we'd need to do is always ignore both .specloc as well as whatever specloc is pointing to. Thanks for catching this!

lawrence-mbf commented 3 years ago

@ageorgou Does #280 work for you?

ageorgou commented 3 years ago

That seems to do it, yes! I can read in a file with or without custom spec (as long as the extension has been previously generated under matnwb's +types). Thanks!