Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a Silver Lab specific Matlab API for NWB2 #1

Open
jonc125 opened this issue Dec 9, 2019 · 8 comments
Open

Create a Silver Lab specific Matlab API for NWB2 #1

jonc125 opened this issue Dec 9, 2019 · 8 comments

Comments

@jonc125
Copy link
Collaborator

jonc125 commented Dec 9, 2019

See https://github.com/SilverLabUCL/AnalysisPipeline/issues/12 for background

@alessandrofelder
Copy link

As of now, we have managed to write an NWB file (schema version 2.1.0) using the python API (pynwb-1.1.2) and then read that file using MatLab (cloned from NeurodataWithoutBorders/matnwb@3353784) but for this to work we had to (hackily) change the namespace hdmf-common to hdmf_common in schema->core->nwb.namespace.yaml and then run generateCore.m again.

@ageorgou
Copy link

Just a bit more information. matnwb is not completely in sync with pynwb, and they suggest changing the namespace definitions to match those from pynwb if a file has been created using the latter.

We did also try commit NeurodataWithoutBorders/matnwb@2c0a852 as suggested by NeurodataWithoutBorders/matnwb#170, which should help.

@bendichter
Copy link

bendichter commented Dec 23, 2019

Thanks for cross-linking the issue. We just pushed some changes to matnwb for reading nwb-schema 1.2.0 files, which should work for current files created by pynwb. Could you test read/write now?

Also, the link to the background in the first post of this thread is dead.

@alessandrofelder
Copy link

alessandrofelder commented Jan 6, 2020

The test data I used was written using pynwb 1.1.2, h5py 2.9.0 and python 3.6.9

Reading from MatLab works for me, only using the 'ignorecache' option of nwbRead, but without hacky modification from commit NeurodataWithoutBorders/matnwb@2c0a852 until NeurodataWithoutBorders/matnwb@ea9c25a (including both these commits) but fails for later commits with 'Property id must be a types.core.ElementIdentifiers.'

Without the ignorecache option, nwbRead works the first time I run it on my test data, but fails the second time with 'Property vectordata.angle_deg should be one of type(s) {types.hdmf-common.VectorData}.' I think this is due to the generateSpec method affecting +types\+core\PlaneSegmentation.m based on some metadata in my nwb file (?).

After generateSpec is called, PlaneSegmentation.m changes and newly contains

%% VALIDATORS

[...]
function val = validate_pixel_mask(obj, val)
    val = types.util.checkDtype('pixel_mask', 'types.hdmf_common.VectorData', val);
end
function val = validate_pixel_mask_index(obj, val)
    val = types.util.checkDtype('pixel_mask_index', 'types.hdmf_common.VectorIndex', val);
end

[...]

function val = validate_vectordata(obj, val)
    constrained = { 'types.hdmf-common.VectorData' };
    types.util.checkSet('vectordata', struct(), constrained, val);
end
function val = validate_vectorindex(obj, val)
    constrained = { 'types.hdmf-common.VectorIndex' };
    types.util.checkSet('vectorindex', struct(), constrained, val);
end

[...]
``

where not all dashes in occurrences of 'hdmf-common' are corrected to 'hdmf_common'...

Currently trying to make sense of this, so any pointers welcome :)

@bendichter
Copy link

@alessandrofelder thanks for this report. I'll let the matnwb team know. If you could provide the files that produce this error or the scripts to produce them, that would be helpful.

@bendichter
Copy link

It looks like you are writing in pynwb and reading in matnwb. Is that right?

@lawrence-mbf
Copy link

@alessandrofelder When you nwbRead, are there still NwbFile objects present? You may need to clear those objects before reading again.

@alessandrofelder
Copy link

alessandrofelder commented Jan 7, 2020

@bendichter and @ln-vidrio - thanks a lot for your help!
The latest merge into master seems to have fixed all my issues!

Yes, that is right - I am writing from pynwb and reading in matnwb.
Don't think any NwbFile objects are still present when I nwbRead - I always tried to read onto the same variable in MatLab. Again, all seems to work for me, now.

For your and future reference, I was using this python class to write a test NWB file.

Again, many many thanks for fixing this so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants