-
Notifications
You must be signed in to change notification settings - Fork 32
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
failing validation of matnwb-generated files with extension in cached namespace #351
Comments
Doing some printing. It looks like pynwb is trying to use key 'NWBFile' to access an entry in a dictionary that has the relevant subset of classes as keys (e.g., |
Issue seems to be in how matnwb caches the namespace of the extension. Compare how the namespace cached by matnwb: import h5py
import json
from pprint import pprint
f = h5py.File('ndx-ecog_file_test_matnwb.nwb', "r")
pprint(json.loads(f["/specifications/ndx-ecog/0.3.1/namespace"][()]))
{'namespaces': [{'author': ['Ben Dichter'],
'contact': ['ben.dichter@catalystneuro.com'],
'doc': 'An NWB extension for storing the cortical surface of '
'subjects in ECoG experiments.',
'name': 'ndx-ecog',
'schema': [{'namespace': 'core',
'neurodata_types': ['NWBDataInterface',
'Subject',
'Images',
'NWBData']},
{'source': 'ndx-ecog.extensions'}],
'version': '0.3.1'}]} with how the namespace is cached by pynwb f = h5py.File('ndx-ecog_file_test_pynwb.nwb', "r")
pprint(json.loads(f["/specifications/ndx-ecog/0.3.1/namespace"][()]))
{'namespaces': [{'author': ['Ben Dichter'],
'contact': ['ben.dichter@catalystneuro.com'],
'doc': 'An NWB extension for storing the cortical surface of '
'subjects in ECoG experiments.',
'name': 'ndx-ecog',
'schema': [{'namespace': 'core'},
{'source': 'ndx-ecog.extensions'}],
'version': '0.3.1'}]} Note that pynwb does not cache the |
@rly can you clarify why caching the neurodata_types key is a problem and why PyNWB does not cache it? |
This may be a bug in the PyNWB/HDMF validator. I thought this was resolved in hdmf-dev/hdmf#613 . @cechava can you share that test file that you created? |
Separately, PyNWB/HDMF should cache the |
Sure. The code to generate both files is below. They both make sure of the ndx-ecog extension python from pynwb import load_namespaces, get_class, NWBHDF5IO, NWBFile
from datetime import datetime
import numpy as np
from ndx_ecog import CorticalSurfaces, ECoGSubject, Surface, Parcellations
nwbfile = NWBFile('my first synthetic recording', 'EXAMPLE_ID', datetime.now())
cortex_module = nwbfile.create_processing_module(name='cortex',
description='description')
with NWBHDF5IO('ndx-ecog_file_test_pynwb.nwb', 'w') as io:
io.write(nwbfile) MATLAB generateExtension('/Users/cesar/Repositories/ndx-ecog/spec/ndx-ecog.namespace.yaml');
nwb = NwbFile( ...
'session_description', 'mouse in open exploration', ...
'identifier', 'Mouse5_Day3', ...
'session_start_time', datetime(2018, 4, 25, 2, 30, 3) ...
);
cortical_surfaces = types.ndx_ecog.CorticalSurfaces;
parcellations = types.ndx_ecog.Parcellations();
parcellation = types.ndx_ecog.Parcellation( ...
'data', randi(5, 1, 20), ...
'labels', {'a','b', 'c', 'd', 'e'} ...
);
parcellations.parcellation.set('my_map', parcellation);
nwbExport(nwb, 'ndx-ecog_file_test_matnwb.nwb'); |
@rly Just realized you were asking for the actual files. To make life easy here are links to download: |
@rly Could you help me understand if this is a bug with the way matnwb embeds an extension. Or was this a bug in pynwb? If the latter, do you know if it was resolved? |
pynwb validation of matnwb-generated files fails when an extension is in the cached namespace.
This is and independent issue from issue #349 and is not fixed by PR #350
To replicate:
No issue when cached namespace is not used:
$ python -m pynwb.validate ndx-ecog_file_test_matnwb.nwb --no-cached-namespace Validating ndx-ecog_file_test_matnwb.nwb against pynwb namespace information using namespace 'core'. - no errors found.
The text was updated successfully, but these errors were encountered: