Created
July 21, 2017 20:54
-
-
Save nicain/be598d5b7be5f2ffe1fd7e8d27c87ec3 to your computer and use it in GitHub Desktop.
Example to help debug require=True not getting enforced on NWBGroupSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pynwb.spec import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec | |
import numpy as np | |
from pynwb import get_class, load_namespaces | |
mylab = 'alleninstitute' | |
ns_path = "%s.namespace.yaml" % mylab | |
ext_source = "%s.extensions.yaml" % mylab | |
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', mylab) | |
ext = NWBGroupSpec('A custom FiringRate for my lab', | |
attributes=[NWBAttributeSpec('foo', 'float', 'name of population', required=True), | |
NWBAttributeSpec('bar', 'float', 'name of population', required=True)], | |
neurodata_type_inc='TimeSeries', | |
neurodata_type_def='FiringRateSeries') | |
ns_builder.add_spec(ext_source, ext) | |
ns_builder.export(ns_path) | |
ns_path = "%s.namespace.yaml" % mylab | |
load_namespaces(ns_path) | |
FiringRateSeries = get_class('FiringRateSeries', mylab) | |
ts = FiringRateSeries('firing_rate', | |
'None', | |
np.array([.01,.05,.1]), | |
'Hertz', | |
timestamps=np.linspace(0,1,3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment