Skip to content

Instantly share code, notes, and snippets.

@nicain
Last active July 31, 2017 18:53
Show Gist options
  • Save nicain/8965460ebcab2075fb478839843cad9f to your computer and use it in GitHub Desktop.
Save nicain/8965460ebcab2075fb478839843cad9f to your computer and use it in GitHub Desktop.
hackathon
from pynwb import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec
import numpy as np
ns_path = "mylab.namespace.yaml"
ext_source = "mylab.extensions.yaml"
nwb_as = NWBAttributeSpec('unit', 'str', 'the population name', value = 'Hz')
ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab")
ext = NWBGroupSpec('A custom TimeSeries for my lab',
attributes=[nwb_as],
neurodata_type_inc='TimeSeries',
neurodata_type_def='FiringRateSeries')
ns_builder.add_spec(ext_source, ext)
ns_builder.export(ns_path)
from pynwb import get_class, load_namespaces
ns_path = "mylab.namespace.yaml"
load_namespaces(ns_path)
FiringRateSeries = get_class('FiringRateSeries', 'mylab')
fs = FiringRateSeries(data=np.random.rand(5),
name='my_population',
source='acquisition')
@nicain
Copy link
Author

nicain commented Jul 31, 2017

my-lab.extensions.yaml:

groups:

  • attributes:
    • doc: the population name
      dtype: str
      name: unit
      value: Hz
      doc: A custom TimeSeries for my lab
      neurodata_type_def: FiringRateSeries
      neurodata_type_inc: TimeSeries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment