Skip to content

Instantly share code, notes, and snippets.

View ajtritt's full-sized avatar

Andrew Tritt ajtritt

View GitHub Profile
@ajtritt
ajtritt / example_table_no_group.py
Created August 16, 2017 04:13
An example of how to create and use a table by itself
import numpy as np
from pynwb import get_class, load_namespaces
from datetime import datetime
from pynwb import NWBFile
import pandas as pd
from form.backends.hdf5 import HDF5IO
from pynwb import get_build_manager
ns_path = "alleninstitute.namespace.yaml"
ext_source = "alleninstitute.extensions.yaml"
@ajtritt
ajtritt / example_table.py
Created August 16, 2017 04:09
An example of how to use NWBDatasetSpec to create a table
import numpy as np
from pynwb import get_class, load_namespaces
from datetime import datetime
from pynwb import NWBFile
import pandas as pd
from form.backends.hdf5 import HDF5IO
from pynwb import get_build_manager
ns_path = "alleninstitute.namespace.yaml"
ext_source = "alleninstitute.extensions.yaml"
@ajtritt
ajtritt / regref_dim_scales.py
Last active August 2, 2017 18:26
Using a slice to label a dimension with HDF5
import os
import h5py
import numpy as np
# Create compound data type
# a table with columns channel ID, xyz-coordinates, and impedence
coord_dt = np.dtype([('x', np.float), ('y', np.float), ('z', np.float)])
ch_dt = np.dtype([("id", np.int), ("coord", coord_dt), ("imp", np.float)])
# Make a fake channel table
@ajtritt
ajtritt / firing_rate_extension.py
Created July 29, 2017 05:04
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