Skip to content

Instantly share code, notes, and snippets.

@ajtritt
Created July 29, 2017 05:04
Show Gist options
  • Save ajtritt/ba18f355f46cab7b6b9db8d657c8423a to your computer and use it in GitHub Desktop.
Save ajtritt/ba18f355f46cab7b6b9db8d657c8423a to your computer and use it in GitHub Desktop.
fix of example extension and dynamic class
#fix of https://gist.github.com/nicain/be598d5b7be5f2ffe1fd7e8d27c87ec3
#
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),
bar=3.14,
foo=2.718)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment