def build_ext(): datasets = [ NWBDatasetSpec(doc='list of cell ids', dtype='uint32', shape=(None, 1), name='gid', quantity='?'), NWBDatasetSpec(doc='index pointer', dtype='uint64', shape=(None, 1), name='index_pointer'), NWBDatasetSpec( doc= 'cell compartment ids corresponding to a given column in the data', dtype='uint32', shape=(None, 1), name='element_id'), NWBDatasetSpec( doc='relative position of recording within a given compartment', dtype='float', shape=(None, None), name='element_pos') ] cont_data = NWBGroupSpec(doc='A spec for storing cell recording variables', datasets=datasets, neurodata_type_inc='TimeSeries', neurodata_type_def='CompartmentSeries') ns_builder.add_spec(ext_source, cont_data) ns_builder.export(ns_path)
def test_load_namespace_with_reftype_attribute_check_autoclass_const(self): ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', self.prefix) test_ds_ext = NWBDatasetSpec( doc='test dataset to add an attr', name='test_data', shape=(None, ), attributes=[ NWBAttributeSpec(name='target_ds', doc='the target the dataset applies to', dtype=RefSpec('TimeSeries', 'object')) ], neurodata_type_def='my_new_type') ns_builder.add_spec(self.ext_source, test_ds_ext) ns_builder.export(self.ns_path, outdir=self.tempdir) type_map = get_type_map( extensions=os.path.join(self.tempdir, self.ns_path)) my_new_type = type_map.get_container_cls(self.prefix, 'my_new_type') docval = None for tmp in get_docval(my_new_type.__init__): if tmp['name'] == 'target_ds': docval = tmp break self.assertIsNotNone(docval) self.assertEqual(docval['type'], TimeSeries)
def test_load_namespace_with_reftype_attribute(self): ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', self.prefix, version='0.1.0') test_ds_ext = NWBDatasetSpec(doc='test dataset to add an attr', name='test_data', shape=(None,), attributes=[NWBAttributeSpec(name='target_ds', doc='the target the dataset applies to', dtype=RefSpec('TimeSeries', 'object'))], neurodata_type_def='my_new_type') ns_builder.add_spec(self.ext_source, test_ds_ext) ns_builder.export(self.ns_path, outdir=self.tempdir) get_type_map(extensions=os.path.join(self.tempdir, self.ns_path))
def main(): ns_builder = NWBNamespaceBuilder( doc="Detected events from optical physiology ROI fluorescence traces", name=f"""{NAMESPACE}""", version="""0.1.0""", author="""Allen Institute for Brain Science""", contact="""*****@*****.**""" ) ns_builder.include_type('RoiResponseSeries', namespace='core') ns_builder.include_type('DynamicTableRegion', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') ophys_events_spec = NWBGroupSpec( neurodata_type_def='OphysEventDetection', neurodata_type_inc='RoiResponseSeries', name='event_detection', doc='Stores event detection output', datasets=[ NWBDatasetSpec( name='lambdas', dtype='float', doc='calculated regularization weights', shape=(None,) ), NWBDatasetSpec( name='noise_stds', dtype='float', doc='calculated noise std deviations', shape=(None,) ) ] ) new_data_types = [ophys_events_spec] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) export_spec(ns_builder, new_data_types, output_dir)
def build_dataset(name, d): kwargs = remap_keys(name, d) if 'name' in kwargs: if kwargs['name'] in dataset_ndt: tmpname = kwargs.pop('name') kwargs['neurodata_type_def'] = dataset_ndt[tmpname] #kwargs['neurodata_type_inc'] = 'NWBData' if 'neurodata_type_def' in kwargs or 'neurodata_type_inc' in kwargs: kwargs['namespace'] = CORE_NAMESPACE dset_spec = NWBDatasetSpec(kwargs.pop('doc'), kwargs.pop('dtype'), **kwargs) if 'attributes' in d: add_attributes(dset_spec, d['attributes']) return dset_spec
def _extract_dataset(val): if val.many: raise NotImplementedError('many not supported') if 'values' not in val.schema.fields: raise ValueError('A dataset must contain an attribute called "values"') values = val.schema.fields['values'] attributes = _extract_attributes(attributes=val.schema.fields, fields_to_skip=['values']) return NWBDatasetSpec( name=val.name, attributes=attributes, doc=val.metadata['doc'], dtype=STYPE_DICT[type(values)], dims=values.metadata['shape'] )
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc='NWB extension for survey/behavioral data', name='ndx-survey-data', version='0.2.0', author=list(map(str.strip, 'Ben Dichter, Armin Najarpour Foroushani'.split(','))), contact=list(map(str.strip, '*****@*****.**'.split(','))) ) for type_name in ('DynamicTable', 'VectorData'): ns_builder.include_type(type_name, namespace='core') survey_data = NWBGroupSpec( doc='Table that holds information about the survey/behavior', neurodata_type_def='SurveyTable', neurodata_type_inc='DynamicTable', default_name='survey_data' ) question_response = NWBDatasetSpec( doc='Column that holds information about a question', neurodata_type_def='QuestionResponse', neurodata_type_inc='VectorData', default_name='question_response', attributes=[NWBAttributeSpec(name='options', doc='Response Options', dtype='text', shape=(None,), dims=('num_options',))] ) survey_data.add_dataset( neurodata_type_inc='VectorData', doc='UNIX time of survey response', name='unix_timestamp', dtype='int', shape=(None,), dims=('num_responses',) ) new_data_types = [survey_data, question_response] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
def main(): ns_builder = NWBNamespaceBuilder( doc="Stimulus images", name=f"""{NAMESPACE}""", version="""0.1.0""", author="""Allen Institute for Brain Science""", contact="""*****@*****.**""" ) ns_builder.include_type('ImageSeries', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') stimulus_template_spec = NWBGroupSpec( neurodata_type_def='StimulusTemplate', neurodata_type_inc='ImageSeries', doc='Note: image names in control_description are referenced by ' 'stimulus/presentation table as well as intervals ' '\n' 'Each image shown to the animals is warped to account for ' 'distance and eye position relative to the monitor. This ' 'extension stores the warped images that were shown to the animal ' 'as well as an unwarped version of each image in which a mask has ' 'been applied such that only the pixels visible after warping are ' 'included', datasets=[ NWBDatasetSpec( name='unwarped', dtype='float', doc='Original image with mask applied such that only the ' 'pixels visible after warping are included', shape=(None, None, None) ) ] ) new_data_types = [stimulus_template_spec] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) export_spec(ns_builder, new_data_types, output_dir)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""DANDI project extension""", name="""ndx-dandi""", version="""0.1.0""", author=list(map(str.strip, """Yaroslav O Halchenko""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(',')))) # TODO: specify the neurodata_types that are used by the extension as well # as in which namespace they are found # this is similar to specifying the Python modules that need to be imported # to use your new data types #ns_builder.include_type('Subject', namespace='core') ns_builder.include_namespace('core') # TODO: define your new data types # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information dandi_subject = NWBGroupSpec( neurodata_type_def='Subject', neurodata_type_inc='Subject', doc="TODO: somehow inherit", datasets=[ NWBDatasetSpec( name='subject_id', quantity=1, # 'zero_or_one', doc="TODO: somehow inherit") ]) # TODO: add all of your new data types to this list new_data_types = [dandi_subject] # export the spec to yaml files in the spec folder output_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
from pynwb.spec import NWBDatasetSpec, NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec, RefSpec namespace = 'template [CHANGE TO NAME]' ns_path = namespace + ".namespace.yaml" ext_source = namespace + ".extensions.yaml" spec = NWBGroupSpec( neurodata_type_def='', neurodata_type_inc='NWBDataInterface', quantity='?', doc='', groups=[], attributes=[ NWBAttributeSpec(name='', doc='', dtype='', required=False), NWBAttributeSpec(name='help', doc='help', dtype='text', value='ENTER HELP INFO HERE') ], datasets=[NWBDatasetSpec(name='', doc='', dtype='', shape=())]) ns_builder = NWBNamespaceBuilder(doc=namespace + ' extensions', name=namespace, version='1.0', author='Ben Dichter', contact='*****@*****.**') specs = (spec, ) for spec in specs: ns_builder.add_spec(ext_source, spec) ns_builder.export(ns_path)
name = 'ecog' ns_path = name + ".namespace.yaml" ext_source = name + ".extensions.yaml" # Now we define the data structures. We use `NWBDataInterface` as the base type, # which is the most primitive type you are likely to use as a base. The name of the # class is `CorticalSurface`, and it requires two matrices, `vertices` and # `faces`. surface = NWBGroupSpec( doc='brain cortical surface', datasets=[ NWBDatasetSpec(doc='faces for surface, indexes vertices', shape=(None, 3), name='faces', dtype='uint', dims=('face_number', 'vertex_index')), NWBDatasetSpec(doc='vertices for surface, points in 3D space', shape=(None, 3), name='vertices', dtype='float', dims=('vertex_number', 'xyz')) ], neurodata_type_def='CorticalSurface', neurodata_type_inc='NWBDataInterface') # Now we set up the builder and add this object ns_builder = NWBNamespaceBuilder(name + ' extensions', name, version='0.1.0') ns_builder.add_spec(ext_source, surface)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc='An extension to hold metadata about a multi-electrode probe.', name='ndx-probe', version='0.1.0', author=list(map(str.strip, 'Ryan Ly'.split(','))), contact=list(map(str.strip, '*****@*****.**'.split(','))) ) ns_builder.include_type('ElectrodeGroup', namespace='core') stereotrode = NWBGroupSpec( neurodata_type_def='Stereotrode', neurodata_type_inc='ElectrodeGroup', doc=('A subtype of ElectrodeGroup to include metadata about a single stereotrode (group of 2 closely spaced ' 'electrodes) on a shank of a probe.'), attributes=[ NWBAttributeSpec( name='location', doc=('Location of the stereotrode in the brain (optional). Specify the area, layer, comments on ' 'estimation of area/layer, etc. Use standard atlas names for anatomical regions when ' 'possible.'), dtype='text', required=False ) ] ) tetrode = NWBGroupSpec( neurodata_type_def='Tetrode', neurodata_type_inc='ElectrodeGroup', doc=('A subtype of ElectrodeGroup to include metadata about a single tetrode (group of 4 closely spaced ' 'electrodes) on a shank of a probe.'), attributes=[ NWBAttributeSpec( name='location', doc=('Location of the tetrode in the brain (optional). Specify the area, layer, comments on ' 'estimation of area/layer, etc. Use standard atlas names for anatomical regions when ' 'possible.'), dtype='text', required=False ) ] ) shank = NWBGroupSpec( neurodata_type_def='Shank', neurodata_type_inc='ElectrodeGroup', doc=('A subtype of ElectrodeGroup to include metadata about a single shank of a probe.') ) entry_point_ap_dtype = NWBDtypeSpec(name='ap', dtype='float', doc='Anterior-Posterior coordinate, in mm.') entry_point_lr_dtype = NWBDtypeSpec(name='lr', dtype='float', doc='Left-Right coordinate, in mm.') entry_point_dv_dtype = NWBDtypeSpec(name='dv', dtype='float', doc='Dorsal-Ventral coordinate, in mm.') entry_point = NWBDatasetSpec( name='entry_point', doc='The coordinates of the entry point.', dtype=[entry_point_ap_dtype, entry_point_lr_dtype, entry_point_dv_dtype], # compound dtype attributes=[ NWBAttributeSpec( name='reference', doc=('Description of the reference atlas used for the coordinates, e.g., Allen Institute Common ' 'Coordinate Framework v3, or stereotaxic coordinates with zero point at ear-bar zero.'), dtype='text' ), NWBAttributeSpec( name='unit', doc='Unit of measurement for the coordinates.', dtype='text', value='millimeters' ) ], quantity='?' ) angle_coronal_dtype = NWBDtypeSpec( name='coronal', dtype='float', doc='Coronal angle, in degrees' ) angle_sagittal_dtype = NWBDtypeSpec( name='sagittal', dtype='float', doc='Sagittal angle, in degrees' ) angle_axial_dtype = NWBDtypeSpec( name='axial', dtype='float', doc='Axial angle, in degrees' ) angle = NWBDatasetSpec( name='angle', doc='The angle of the probe.', dtype=[angle_coronal_dtype, angle_sagittal_dtype, angle_axial_dtype], # compound dtype attributes=[ NWBAttributeSpec( name='reference', doc='Description of the reference frame used for the angles, e.g., which direction is angle zero.', dtype='text' ), NWBAttributeSpec( name='unit', doc='Unit of measurement for the angles.', dtype='text', value='degrees' ) ], quantity='?' ) distance_advanced = NWBDatasetSpec( name='distance_advanced', doc='The distance that the probe was advanced from the surface of the brain, in mm.', dtype='float', attributes=[ NWBAttributeSpec( name='unit', doc='Unit of measurement for the distance.', dtype='text', value='millimeters' ) ], quantity='?' ) probe = NWBGroupSpec( neurodata_type_def='Probe', neurodata_type_inc='Device', doc=('Metadata about a multi-electrode probe (or array), which contains one or many shanks. ' 'Each shank should be represented as an ElectrodeGroup. Sub-groupings within a shank ' 'should also be represented as ElectrodeGroups.'), attributes=[ NWBAttributeSpec( name='description', doc='Description of the probe as free-form text.', dtype='text', ), NWBAttributeSpec( name='model', doc='Model name of the probe.', dtype='text', ), NWBAttributeSpec( name='manufacturer', doc='Manufacturer name of the probe.', dtype='text', ), NWBAttributeSpec( name='id', doc='Serial number or other unique identifier of the probe.', dtype='text', required=False ), ], datasets=[ entry_point, angle, distance_advanced, ] ) new_data_types = [stereotrode, tetrode, shank, probe] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
def main(): ns_builder = NWBNamespaceBuilder(doc='describe a maze of arbitrary shape', name='ndx-maze', version='0.1.0', author='Ben Dichter', contact='*****@*****.**') node = NWBGroupSpec( neurodata_type_def='Node', neurodata_type_inc='NWBDataInterface', doc= "Abstract representation for any kind of node in the topological graph We won't actually" " implement abstract nodes. Rather this is a parent group from which our more specific " "types of nodes will inherit. Note that NWB specifications have inheritance. The quantity " "'*' means that we can have any number (0 or more) nodes.", quantity='*', attributes=[ NWBAttributeSpec('name', 'the name of this node', 'text'), NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Apparatus Node') ]) edge = NWBGroupSpec( neurodata_type_def='Edge', neurodata_type_inc='NWBDataInterface', doc= "Edges between any two nodes in the graph. An edge's only dataset is the name (string) of " "the two nodes that the edge connects Note that we don't actually include the nodes " "themselves, just their names, in an edge.", quantity='*', datasets=[ NWBDatasetSpec(doc='names of the nodes this edge connects', name='edge_nodes', dtype='text', dims=['first_node_name|second_node_name'], shape=[2]) ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Apparatus Edge') ]) point_node = NWBGroupSpec( neurodata_type_def='PointNode', neurodata_type_inc='Node', doc= 'A node that represents a single 2D point in space (e.g. reward well, novel object' ' location)', quantity='*', datasets=[ NWBDatasetSpec(doc='x/y coordinate of this 2D point', name='coords', dtype='float', dims=['num_coords', 'x_vals|y_vals'], shape=[1, 2]) ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Apparatus Point') ]) segment_node = NWBGroupSpec( neurodata_type_def='SegmentNode', neurodata_type_inc='Node', doc= 'A node that represents a linear segment in 2D space, defined by its start and end' ' points (e.g. a single arm of W-track maze)', quantity='*', datasets=[ NWBDatasetSpec( doc= 'x/y coordinates of the start and end points of this segment', name='coords', dtype='float', dims=['num_coords', 'x_vals|y_vals'], shape=[None, 2]) ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Apparatus Segment') ]) polygon_node = NWBGroupSpec( neurodata_type_def='PolygonNode', neurodata_type_inc='Node', doc= 'A node that represents a polygon area (e.g. open field, sleep box). A polygon is' ' defined by its external vertices and, optionally, by any interior points of ' 'interest (e.g. interior wells, objects)', quantity='*', datasets=[ NWBDatasetSpec( doc='x/y coordinates of the exterior points of this polygon', name='coords', dtype='float', dims=['num_coords', 'x_vals|y_vals'], shape=[None, 2]), NWBDatasetSpec( doc='x/y coordinates of interior points inside this polygon', name='interior_coords', dtype='float', quantity='?', dims=['num_coords', 'x_vals|y_vals'], shape=[None, 2]) ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Apparatus Polygon') ]) environment = NWBGroupSpec(neurodata_type_def='Environment', neurodata_type_inc='NWBDataInterface', default_name='Environment', doc='a graph of nodes and edges', quantity='*', groups=[ NWBGroupSpec(neurodata_type_inc='Node', doc='nodes in the graph', quantity='*'), NWBGroupSpec(neurodata_type_inc='Edge', doc='edges in the graph', quantity='*') ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='Environment') ]) environments = NWBGroupSpec(neurodata_type_def='Environments', neurodata_type_inc='LabMetaData', default_name='environments', doc='holds environments', quantity='?', groups=[ NWBGroupSpec( neurodata_type_inc='Environment', doc='holds structure of environment', quantity='*') ], attributes=[ NWBAttributeSpec(name='help', doc='help doc', dtype='text', value='help') ]) new_data_types = [ node, edge, point_node, segment_node, polygon_node, environment, environments ] # TODO: include the types that are used and their namespaces (where to find them) ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('LabMetaData', namespace='core') export_spec(ns_builder, new_data_types)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""Store the elliptical eye tracking output of DeepLabCut""", name=f"""{NAMESPACE}""", version="""0.1.0""", author=list(map(str.strip, """Ben Dichter""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(',')))) ns_builder.include_type('SpatialSeries', namespace='core') ns_builder.include_type('EyeTracking', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ellipse_series_spec = NWBGroupSpec( neurodata_type_def='EllipseSeries', neurodata_type_inc='SpatialSeries', doc='Information about an ellipse moving over time', datasets=[ NWBDatasetSpec( name= 'data', # override SpatialSeries 'data' dataset to be more explicit dtype='numeric', doc= 'The (x, y) coordinates of the center of the ellipse at each time point.', dims=('num_times', 'x, y'), shape=(None, 2), ), NWBDatasetSpec( name='area', dtype='float', doc='ellipse area, with nan values in likely blink times', shape=(None, )), NWBDatasetSpec( name='area_raw', dtype='float', doc='ellipse area, with no regard to likely blink times', shape=(None, )), NWBDatasetSpec(name='width', dtype='float', doc='width of ellipse', shape=(None, )), NWBDatasetSpec(name='height', dtype='float', doc='height of ellipse', shape=(None, )), NWBDatasetSpec(name='angle', dtype='float', doc='angle that ellipse is rotated by (phi)', shape=(None, )) ]) ellipse_eye_tracking_spec = NWBGroupSpec( neurodata_type_def='EllipseEyeTracking', neurodata_type_inc='EyeTracking', name=None, default_name='EyeTracking', doc='Stores detailed eye tracking information output from DeepLabCut', groups=[ NWBGroupSpec(neurodata_type_inc=ellipse_series_spec, name=x, doc=x.replace('_', ' ')) for x in ('eye_tracking', 'pupil_tracking', 'corneal_reflection_tracking') ] + [ NWBGroupSpec( neurodata_type_inc='TimeSeries', name='likely_blink', doc= 'Indicator of whether there was a probable blink for this frame' ) ]) new_data_types = [ellipse_series_spec, ellipse_eye_tracking_spec] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__))) export_spec(ns_builder, new_data_types, output_dir)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""labels for behavior or neural data""", name="""ndx-labels""", version="""0.1.0""", author=list(map(str.strip, """Akshay Jaggi, Kanishk Jain, Jim Robinson-Bohnslav""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(','))) ) # TODO: specify the neurodata_types that are used by the extension as well # as in which namespace they are found # this is similar to specifying the Python modules that need to be imported # to use your new data types # as of HDMF 1.6.1, the full ancestry of the neurodata_types that are used by # the extension should be included, i.e., the neurodata_type and its parent # type and its parent type and so on. this will be addressed in a future # release of HDMF. ns_builder.include_type('ElectricalSeries', namespace='core') ns_builder.include_type('ImageSeries', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('NWBContainer', namespace='core') ns_builder.include_type('DynamicTableRegion', namespace='hdmf-common') ns_builder.include_type('VectorData', namespace='hdmf-common') ns_builder.include_type('Data', namespace='hdmf-common') # TODO: define your new data types # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information representation_series = NWBGroupSpec( neurodata_type_def='RepresentationSeries', neurodata_type_inc='TimeSeries', doc=('Extends TimeSeries to include abstract representations of raw data (e.g. PCs, tSNE)'), attributes=[ NWBAttributeSpec( name='method', doc='a description of the method used to derive the representation', dtype='text' ), NWBAttributeSpec( name='unit', doc='required unit for RepresentationSeries, default to "a.u."', default_value="a.u.", dtype='text', required=False ), ], links=[ NWBLinkSpec( name="video", target_type="ImageSeries", doc="ref to video that's being labeled", quantity="?" ) ], datasets=[ NWBDatasetSpec( name='data', doc='float array of the value of m factors for n time steps', dtype='float64', dims=['num_frames', 'num_factors'], shape=(None, None), ), ] ) label_series = NWBGroupSpec( neurodata_type_def='LabelSeries', neurodata_type_inc='TimeSeries', doc=('Extends TimeSeries to capture labels encoded'), attributes=[ NWBAttributeSpec( name='exclusive', doc='whether the labels are exclusive or not', dtype='bool' ), NWBAttributeSpec( name='method', doc='a description of the method used to derive the labels (e.g. DeepEthogram v0.1.0)', dtype='text' ), NWBAttributeSpec( name='unit', doc='required unit for LabelSeries, default to "label"', default_value="label", dtype='text', required=False ), ], links=[ NWBLinkSpec( name="representation", target_type="RepresentationSeries", doc="ref to representation series", quantity="?" ), NWBLinkSpec( name="video", target_type="ImageSeries", doc="ref to video that's being labeled", quantity="?" ) ], datasets=[ NWBDatasetSpec( name='data', doc='Binary array of k labels for all n time steps', dtype='int32', dims=['num_frames', 'num_labels'], shape=(None, None), ), NWBDatasetSpec( name='scores', doc='Float array of the probabilities of each of the k labels for all n time steps', dtype='float64', dims=['num_frames', 'num_labels'], shape=(None, None), quantity="?" ), NWBDatasetSpec( name="vocabulary", doc="list of k labels for the behaviors", dtype="text", dims=['num_labels'], shape=(None,), quantity="?" ) ] ) # TODO: add all of your new data types to this list new_data_types = [label_series, representation_series] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc='NWB extension to store single or multi-animal pose tracking.', name='ndx-pose', version='0.2.0', author=['Ryan Ly', 'Ben Dichter', 'Alexander Mathis', 'Talmo Pereira'], contact=['*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'], ) ns_builder.include_type('SpatialSeries', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('NWBContainer', namespace='core') pose_estimation_series = NWBGroupSpec( neurodata_type_def='PoseEstimationSeries', neurodata_type_inc='SpatialSeries', doc='Estimated position (x, y) or (x, y, z) of a body part over time.', datasets=[ NWBDatasetSpec( name='data', doc='Estimated position (x, y) or (x, y, z).', dtype='float32', dims=[['num_frames', 'x, y'], ['num_frames', 'x, y, z']], shape=[[None, 2], [None, 3]], attributes=[ NWBAttributeSpec( name='unit', dtype='text', default_value='pixels', doc=("Base unit of measurement for working with the data. The default value " "is 'pixels'. Actual stored values are not necessarily stored in these units. " "To access the data in these units, multiply 'data' by 'conversion'."), required=True, ), ], ), NWBDatasetSpec( name='confidence', doc='Confidence or likelihood of the estimated positions, scaled to be between 0 and 1.', dtype='float32', dims=['num_frames'], shape=[None], attributes=[ NWBAttributeSpec( name='definition', dtype='text', doc=("Description of how the confidence was computed, e.g., " "'Softmax output of the deep neural network'."), required=False, ), ], ), ], ) pose_grouping_series = NWBGroupSpec( neurodata_type_def='PoseGroupingSeries', neurodata_type_inc='TimeSeries', doc='Instance-level part grouping timeseries for the individual animal. This contains metadata of the part grouping procedure for multi-animal pose trackers.', datasets=[ NWBDatasetSpec( name='name', doc="Description of the type of localization, e.g., 'Centroid' or 'Bounding box'.", dtype='text' ), NWBDatasetSpec( name='data', doc='Score of the grouping approach that associated all of the keypoints to the same animal within the frame.', dtype='float32', dims=['num_frames'], shape=[None] ), NWBDatasetSpec( name='location', doc='Animal location for two-stage (top-down) multi-animal models, e.g., centroid or bounding box.', dtype='float32', dims=[['num_frames', 'x, y'], ['num_frames', 'x, y, z'], ['num_frames', 'x1, y1, x2, y2'], ['num_frames', 'x1, y1, z1, x2, y2, z2']], shape=[[None, 2], [None, 3], [None, 4], [None, 6]], quantity="?" ), ], ) animal_identity_series = NWBGroupSpec( neurodata_type_def='AnimalIdentitySeries', neurodata_type_inc='TimeSeries', doc='Identity of the animal predicted by a tracking or re-ID algorithm in multi-animal experiments.', datasets=[ NWBDatasetSpec( name='data', doc='Score of the identity assignment approach that associated all of the keypoints to the same animal over frames, e.g., MOT tracking score or ID classification probability.', dtype='float32', dims=['num_frames'], shape=[None], ), NWBDatasetSpec( name='name', doc='Unique animal identifier, track label, or class name used to identify this animal in the experiment.', dtype='text' ), ], ) pose_estimation = NWBGroupSpec( neurodata_type_def='PoseEstimation', neurodata_type_inc='NWBDataInterface', doc=('Group that holds estimated position data for multiple body parts, computed from the same video with ' 'the same tool/algorithm. The timestamps of each child PoseEstimationSeries type should be the same.'), default_name='PoseEstimation', groups=[ NWBGroupSpec( neurodata_type_inc='PoseEstimationSeries', doc='Estimated position data for each body part.', quantity='*', ), NWBGroupSpec( neurodata_type_inc='PoseGroupingSeries', doc='Part grouping metadata for the individual in multi-animal experiments.', quantity='?', ), NWBGroupSpec( neurodata_type_inc='AnimalIdentitySeries', doc='Predicted identity of the individual in multi-animal experiments.', quantity='?', ), ], datasets=[ NWBDatasetSpec( name='description', doc='Description of the pose estimation procedure and output.', dtype='text', quantity='?', ), NWBDatasetSpec( name='original_videos', doc='Paths to the original video files. The number of files should equal the number of camera devices.', dtype='text', dims=['num_files'], shape=[None], quantity='?', ), NWBDatasetSpec( name='labeled_videos', doc='Paths to the labeled video files. The number of files should equal the number of camera devices.', dtype='text', dims=['num_files'], shape=[None], quantity='?', ), NWBDatasetSpec( name='dimensions', doc='Dimensions of each labeled video file.', dtype='uint8', dims=['num_files', 'width, height'], shape=[None, 2], quantity='?', ), NWBDatasetSpec( name='scorer', doc='Name of the scorer / algorithm used.', dtype='text', quantity='?', ), NWBDatasetSpec( name='source_software', doc='Name of the software tool used. Specifying the version attribute is strongly encouraged.', dtype='text', quantity='?', attributes=[ NWBAttributeSpec( name='version', doc='Version string of the software tool used.', dtype='text', required=False, ), ], ), NWBDatasetSpec( name='nodes', doc=('Array of body part names corresponding to the names of the SpatialSeries objects within this ' 'group.'), dtype='text', dims=['num_body_parts'], shape=[None], quantity='?', ), NWBDatasetSpec( name='edges', doc=("Array of pairs of indices corresponding to edges between nodes. Index values correspond to row " "indices of the 'nodes' dataset. Index values use 0-indexing."), dtype='uint8', dims=['num_edges', 'nodes_index, nodes_index'], shape=[None, 2], quantity='?', ), ], # TODO: collections of multiple links is currently buggy in PyNWB/HDMF # links=[ # NWBLinkSpec( # target_type='Device', # doc='Camera(s) used to record the videos.', # quantity='*', # ), # ], ) new_data_types = [pose_estimation_series, pose_estimation, pose_grouping_series, animal_identity_series] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
'ElectrodeGroup': NWBGroupSpec( 'One of possibly many groups, one for each electrode group.', neurodata_type_def='ElectrodeGroup', neurodata_type_inc='NWBContainer', namespace=CORE_NAMESPACE, attributes=[ AttributeSpec('help', 'str', "Value is '%s'" % eg_help, value=eg_help) ], datasets=[ NWBDatasetSpec('array with description for each channel', 'text', name='channel_description', shape=(None, ), dims=('num_channels', )), NWBDatasetSpec( 'array with location description for each channel e.g. "CA1"', 'text', name='channel_location', shape=(None, ), dims=('num_channels', )), NWBDatasetSpec( 'array with description of filtering applied to each channel', 'text', name='channel_filtering', shape=(None, ), dims=('num_channels', )), NWBDatasetSpec(
def main(): ns_builder = NWBNamespaceBuilder( doc='NWB extension for hierarchical behavioral data', name='ndx-hierarchical-behavioral-data', version='0.1.0', author=['Ben Dichter', 'Armin Najarpour Foroushani'], contact=['*****@*****.**']) # Add the type we want to include from core to this list include_core_types = ['DynamicTable', 'DynamicTableRegion', 'VectorIndex'] # Include the types that are used by the extension and their namespaces (where to find them) for type_name in include_core_types: ns_builder.include_type(type_name, namespace='core') # Create our table to store phonemes phonemes_table_spec = NWBGroupSpec( name='phonemes', neurodata_type_def='PhonemesTable', neurodata_type_inc='DynamicTable', doc='A table to store different phonemes', attributes=[ NWBAttributeSpec( name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing phonemes related data') ], datasets=[ NWBDatasetSpec( name='label', neurodata_type_inc='DynamicTableRegion', doc= 'Column for storing phonemes. Each row in this DynamicTableRegion is a phoneme.', dims=('num_phonemes', ), shape=(None, ), dtype='text') ]) # Create our table to store syllables syllables_table_spec = NWBGroupSpec( name='syllables', neurodata_type_def='SyllablesTable', neurodata_type_inc='DynamicTable', doc='A table to store different syllables', attributes=[ NWBAttributeSpec( name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing syllables related data') ], datasets=[ NWBDatasetSpec( name='label', neurodata_type_inc='DynamicTableRegion', doc= 'Column for storing syllables. Each row in this DynamicTableRegion is a syllable ' 'consisting of phonemes.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='PhonemesTable', reftype='object'), doc='Reference to the PhonemesTable table that ' 'this table region applies to. This specializes the ' 'attribute inherited from DynamicTableRegion to fix ' 'the type of table that can be referenced here.') ], dims=('num_syllables', ), shape=(None, ), dtype='text'), NWBDatasetSpec( name='phonemes_index', neurodata_type_inc='VectorIndex', doc= 'Column for storing a link to the constituting phonemes (rows)', dims=('num_syllables', ), shape=(None, )) ]) # Create our table to store words words_table_spec = NWBGroupSpec( name='words', neurodata_type_def='WordsTable', neurodata_type_inc='DynamicTable', doc='A table to store different words', attributes=[ NWBAttributeSpec( name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing word related data') ], datasets=[ NWBDatasetSpec( name='label', neurodata_type_inc='DynamicTableRegion', doc= 'Column for storing words. Each row in this DynamicTableRegion is a word ' 'consisting of syllables.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='SyllablesTable', reftype='object'), doc='Reference to the SyllablesTable table that ' 'this table region applies to. This specializes the ' 'attribute inherited from DynamicTableRegion to fix ' 'the type of table that can be referenced here.') ], dims=('num_words', ), shape=(None, ), dtype='text'), NWBDatasetSpec( name='syllables_index', neurodata_type_inc='VectorIndex', doc= 'Column for storing a link to the constituting syllables (rows)', dims=('num_words', ), shape=(None, )) ]) # Create our table to store sentences sentences_table_spec = NWBGroupSpec( name='sentences', neurodata_type_def='SentencesTable', neurodata_type_inc='DynamicTable', doc='A table to store different sentences', attributes=[ NWBAttributeSpec( name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing sentence related data') ], datasets=[ NWBDatasetSpec( name='label', neurodata_type_inc='DynamicTableRegion', doc= 'Column for storing sentences. Each row in this DynamicTableRegion is a sentence ' 'consisting of words.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='WordsTable', reftype='object'), doc='Reference to the WordsTable table that ' 'this table region applies to. This specializes the ' 'attribute inherited from DynamicTableRegion to fix ' 'the type of table that can be referenced here.') ], dims=('num_sentences', ), shape=(None, ), dtype='text'), NWBDatasetSpec( name='words_index', neurodata_type_inc='VectorIndex', doc= 'Column for storing a link to the constituting words (rows)', dims=('num_sentences', ), shape=(None, )) ]) # Create a table to group together all the above groups transcription_table_spec = NWBGroupSpec( name='transcription', neurodata_type_def='TranscriptionTable', neurodata_type_inc='DynamicTable', doc= 'This DynamicTable is intended to group together a collection of sub-tables. Each sub-table is a ' 'DynamicTable itself. This type effectively defines a 2-level table in which the main data is stored in ' 'the main table implemented by this type and additional columns of the table are grouped into categories, ' 'with each category being represented by a separate DynamicTable stored within the group.' 'Here, sub-tables are: sentence table which stores different sentences; words table which stores ' 'constituting words; syllables table for storing syllables of each word; and phonemes table for storing ' 'consisting of phonemes.', attributes=[ NWBAttributeSpec( name='categories', dtype='text', dims=['num_categories'], doc= 'The names of the categories in this TranscriptionTable. Each ' 'category is represented by one DynamicTable stored in the parent group.' 'This attribute should be used to specify an order of categories.', shape=[None]) ], groups=[ NWBGroupSpec( neurodata_type_inc='DynamicTable', doc= 'A DynamicTable representing a particular category for columns in the ' 'TranscriptionTable parent container. The name of the category is given by ' 'the name of the DynamicTable and its description by the description attribute ' 'of the DynamicTable.', quantity='*') ]) # Add all of our new data types to this list new_data_types = [ sentences_table_spec, words_table_spec, syllables_table_spec, phonemes_table_spec, transcription_table_spec ] # export the spec to yaml files in the spec folder output_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
from pynwb.spec import NWBDatasetSpec, NWBNamespaceBuilder, NWBGroupSpec name = 'general' ns_path = name + '.namespace.yaml' ext_source = name + '.extensions.yaml' gid_spec = NWBDatasetSpec(doc='global id for neuron', shape=(None, 1), name='cell_index', dtype='int') data_val_spec = NWBDatasetSpec(doc='Data values indexed by pointer', shape=(None, 1), name='value', dtype='float') data_pointer_spec = NWBDatasetSpec(doc='Pointers that index data values', shape=(None, 1), name='pointer', dtype='RefSpec') gid_pointer_value_spec = [gid_spec, data_val_spec, data_pointer_spec] cat_cell_info = NWBGroupSpec( neurodata_type_def='CatCellInfo', doc='Categorical Cell Info', datasets=[ gid_spec, NWBDatasetSpec(name='indices', doc='indices into values for each gid in order', shape=(None, 1), dtype='RefSpec'), NWBDatasetSpec(name='values',
def main(): # the values for ns_builder are auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder(doc='Implement proposal for hierarchical metadata structure ' 'for intracellular electrophysiology data ', name='ndx-icephys-meta', version='0.2.0', author=['Oliver Ruebel', 'Ryan Ly', 'Benjamin Dichter', 'Thomas Braun', 'Andrew Tritt'], contact=['*****@*****.**', '*****@*****.**', '*****@*****.**', 'None', '*****@*****.**']) # Create a vector-data column that references a range in a time series. I/e., a VectorData column # with a compound data type storing the start_index, count, and TimeSeries reference reference_timeseries_vectordata = NWBDatasetSpec( neurodata_type_inc='VectorData', neurodata_type_def='TimeSeriesReferenceVectorData', doc='Column storing references to a TimeSeries (rows). For each TimeSeries this VectorData ' 'column stores the start_index and count to indicate the range in time to be selected ' 'as well as an object reference to the TimeSeries.', dtype=[ NWBDtypeSpec(name='idx_start', dtype='int32', doc="Start index into the TimeSeries 'data' and 'timestamp' datasets of the " "referenced TimeSeries. The first dimension of those arrays is always time."), NWBDtypeSpec(name='count', dtype='int32', doc="Number of data samples available in this time series, during this epoch"), NWBDtypeSpec(name='timeseries', dtype=NWBRefSpec(target_type='TimeSeries', reftype='object'), doc='The TimeSeries that this index applies to') ] ) # Create a collection of aligned dynamic tables aligned_dynamic_tables_spec = NWBGroupSpec( neurodata_type_inc='DynamicTable', neurodata_type_def='AlignedDynamicTable', doc='DynamicTable container that subports storing a collection of subtables. Each sub-table is a ' 'DynamicTable itself that is aligned with the main table by row index. I.e., all ' 'DynamicTables stored in this group MUST have the same number of rows. This type effectively ' 'defines a 2-level table in which the main data is stored in the main table implemented by this type ' 'and additional columns of the table are grouped into categories, with each category being ' 'represented by a separate DynamicTable stored within the group.', attributes=[NWBAttributeSpec(name='categories', dtype='text', dims=['num_categories'], doc='The names of the categories in this AlignedDynamicTable. Each ' 'category is represented by one DynamicTable stored in the parent group. ' 'This attribute should be used to specify an order of categories.', shape=[None]) ], groups=[NWBGroupSpec(neurodata_type_inc='DynamicTable', doc='A DynamicTable representing a particular category for columns in the ' 'AlignedDynamicTable parent container. The table MUST be aligned ' 'with (i.e., have the same number of rows) as all other DynamicTables ' 'stored in the AlignedDynamicTable parent container. The name of ' 'the category is given by the name of the DynamicTable and its description ' 'by the description attribute of the DynamicTable.', quantity='*') ] ) electrodes_table_spec = NWBGroupSpec( neurodata_type_inc='DynamicTable', neurodata_type_def='IntracellularElectrodesTable', doc='Table for storing intracellular electrode related metadata.', attributes=[NWBAttributeSpec(name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing intracellular electrode related metadata.')], datasets=[NWBDatasetSpec( name='electrode', neurodata_type_inc='VectorData', doc='Column for storing the reference to the intracellular electrode.', dtype=NWBRefSpec(target_type='IntracellularElectrode', reftype='object') ), ] ) stimuli_table_spec = NWBGroupSpec( neurodata_type_inc='DynamicTable', neurodata_type_def='IntracellularStimuliTable', doc='Table for storing intracellular stimulus related metadata.', attributes=[NWBAttributeSpec(name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing intracellular stimulus related metadata.')], datasets=[NWBDatasetSpec( name='stimulus', neurodata_type_inc='TimeSeriesReferenceVectorData', doc='Column storing the reference to the recorded stimulus for the recording (rows).'), ] ) responses_table_spec = NWBGroupSpec( neurodata_type_inc='DynamicTable', neurodata_type_def='IntracellularResponsesTable', doc='Table for storing intracellular response related metadata.', attributes=[NWBAttributeSpec(name='description', dtype='text', doc='Description of what is in this dynamic table.', value='Table for storing intracellular response related metadata.')], datasets=[NWBDatasetSpec( name='response', neurodata_type_inc='TimeSeriesReferenceVectorData', doc='Column storing the reference to the recorded response for the recording (rows)'), ] ) # Create our table to group stimulus and response for Intracellular Electrophysiology Recordings icephys_recordings_table_spec = NWBGroupSpec( name='intracellular_recordings', neurodata_type_def='IntracellularRecordingsTable', neurodata_type_inc='AlignedDynamicTable', doc='A table to group together a stimulus and response from a single electrode and a single simultaneous ' 'recording. Each row in the table represents a single recording consisting typically of a stimulus and a ' 'corresponding response. In some cases, however, only a stimulus or a response are recorded as ' 'as part of an experiment. In this case both, the stimulus and response will point to the same ' 'TimeSeries while the idx_start and count of the invalid column will be set to -1, thus, ' 'indicating that no values have been recorded for the stimulus or response, respectively. Note, ' 'a recording MUST contain at least a stimulus or a response. Typically the stimulus and response ' 'are PatchClampSeries. However, the use of AD/DA channels that are not associated to an electrode ' 'is also common in intracellular electrophysiology, in which case other TimeSeries may be used.', attributes=[NWBAttributeSpec( name='description', dtype='text', doc='Description of the contents of this table. Inherited from AlignedDynamicTable ' 'and overwritten here to fix the value of the attribute', value='A table to group together a stimulus and response from a single electrode ' 'and a single simultaneous recording and for storing metadata about the ' 'intracellular recording.'), ], groups=[ NWBGroupSpec( name='electrodes', neurodata_type_inc='IntracellularElectrodesTable', doc='Table for storing intracellular electrode related metadata.', ), NWBGroupSpec( name='stimuli', neurodata_type_inc='IntracellularStimuliTable', doc='Table for storing intracellular stimulus related metadata.' ), NWBGroupSpec( name='responses', neurodata_type_inc='IntracellularResponsesTable', doc='Table for storing intracellular response related metadata.' ), ] ) # Create a SimultaneousRecordingsTable (similar to trials) table to group # intracellular electrophysiology recording that were # recorded at the same time and belong together simultaneous_recordings_table_spec = NWBGroupSpec( name='simultaneous_recordings', neurodata_type_def='SimultaneousRecordingsTable', neurodata_type_inc='DynamicTable', doc='A table for grouping different intracellular recordings from the ' 'IntracellularRecordingsTable table together that were recorded simultaneously ' 'from different electrodes', datasets=[NWBDatasetSpec(name='recordings', neurodata_type_inc='DynamicTableRegion', doc='A reference to one or more rows in the IntracellularRecordingsTable table.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='IntracellularRecordingsTable', reftype='object'), doc='Reference to the IntracellularRecordingsTable table that ' 'this table region applies to. This specializes the ' 'attribute inherited from DynamicTableRegion to fix ' 'the type of table that can be referenced here.' )]), NWBDatasetSpec(name='recordings_index', neurodata_type_inc='VectorIndex', doc='Index dataset for the recordings column.') ] ) # Create the SequentialRecordingsTable table to group different SimultaneousRecordingsTable together sequentialrecordings_table_spec = NWBGroupSpec( name='sequential_recordings', neurodata_type_def='SequentialRecordingsTable', neurodata_type_inc='DynamicTable', doc='A table for grouping different sequential recordings from the ' 'SimultaneousRecordingsTable table together. This is typically ' 'used to group together sequential recordings where the a sequence ' 'of stimuli of the same type with varying parameters ' 'have been presented in a sequence.', datasets=[NWBDatasetSpec(name='simultaneous_recordings', neurodata_type_inc='DynamicTableRegion', doc='A reference to one or more rows in the SimultaneousRecordingsTable table.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='SimultaneousRecordingsTable', reftype='object'), doc='Reference to the SimultaneousRecordingsTable table that this table region ' 'applies to. This specializes the attribute inherited ' 'from DynamicTableRegion to fix the type of table that ' 'can be referenced here.' ) ]), NWBDatasetSpec(name='simultaneous_recordings_index', neurodata_type_inc='VectorIndex', doc='Index dataset for the simultaneous_recordings column.'), NWBDatasetSpec(name='stimulus_type', neurodata_type_inc='VectorData', doc='The type of stimulus used for the sequential recording.', dtype='text') ] ) # Create the RepetitionsTable table to group different SequentialRecordingsTable together repetitions_table_spec = NWBGroupSpec( name='repetitions', neurodata_type_def='RepetitionsTable', neurodata_type_inc='DynamicTable', doc='A table for grouping different sequential intracellular recordings together. ' 'With each SequentialRecording typically representing a particular type of stimulus, the ' 'RepetitionsTable table is typically used to group sets of stimuli applied in sequence.', datasets=[NWBDatasetSpec(name='sequential_recordings', neurodata_type_inc='DynamicTableRegion', doc='A reference to one or more rows in the SequentialRecordingsTable table.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='SequentialRecordingsTable', reftype='object'), doc='Reference to the SequentialRecordingsTable table that this table region ' 'applies to. This specializes the attribute inherited ' 'from DynamicTableRegion to fix the type of table that ' 'can be referenced here.' ) ]), NWBDatasetSpec(name='sequential_recordings_index', neurodata_type_inc='VectorIndex', doc='Index dataset for the sequential_recordings column.') ] ) # Create ExperimentalConditionsTable tbale for grouping different RepetitionsTable together experimental_conditions_table_spec = NWBGroupSpec( name='experimental_conditions', neurodata_type_def='ExperimentalConditionsTable', neurodata_type_inc='DynamicTable', doc='A table for grouping different intracellular recording repetitions together that ' 'belong to the same experimental experimental_conditions.', datasets=[NWBDatasetSpec(name='repetitions', neurodata_type_inc='DynamicTableRegion', doc='A reference to one or more rows in the RepetitionsTable table.', attributes=[ NWBAttributeSpec( name='table', dtype=NWBRefSpec(target_type='RepetitionsTable', reftype='object'), doc='Reference to the RepetitionsTable table that this table region ' 'applies to. This specializes the attribute inherited ' 'from DynamicTableRegion to fix the type of table that ' 'can be referenced here.' ) ]), NWBDatasetSpec(name='repetitions_index', neurodata_type_inc='VectorIndex', doc='Index dataset for the repetitions column.') ] ) # Update NWBFile to modify /general/intracellular_ephys in NWB to support adding the new structure there # NOTE: If this proposal for extension to NWB gets merged with the core schema the new NWBFile type would # need to be removed and the NWBFile schema updated instead icephys_file_spec = NWBGroupSpec( neurodata_type_inc='NWBFile', neurodata_type_def='ICEphysFile', doc='Extension of the NWBFile class to allow placing the new icephys ' 'metadata types in /general/intracellular_ephys in the NWBFile ' 'NOTE: If this proposal for extension to NWB gets merged with ' 'the core schema, then this type would be removed and the ' 'NWBFile specification updated instead.', groups=[NWBGroupSpec( name='general', doc='expand definition of general from NWBFile', groups=[NWBGroupSpec(name='intracellular_ephys', doc='expand definition from NWBFile', groups=[NWBGroupSpec(neurodata_type_inc='IntracellularRecordingsTable', doc=icephys_recordings_table_spec.doc, name='intracellular_recordings', quantity='?'), NWBGroupSpec(neurodata_type_inc='SimultaneousRecordingsTable', doc=simultaneous_recordings_table_spec.doc, name='simultaneous_recordings', quantity='?'), NWBGroupSpec(neurodata_type_inc='SequentialRecordingsTable', doc=sequentialrecordings_table_spec.doc, name='sequential_recordings', quantity='?'), NWBGroupSpec(neurodata_type_inc='RepetitionsTable', doc=repetitions_table_spec.doc, name='repetitions', quantity='?'), NWBGroupSpec(neurodata_type_inc='ExperimentalConditionsTable', doc=experimental_conditions_table_spec.doc, name='experimental_conditions', quantity='?'), # Update doc on SweepTable to declare it as deprecated NWBGroupSpec(neurodata_type_inc='SweepTable', doc='[DEPRACATED] Table used to group different PatchClampSeries.' 'SweepTable is being replaced by IntracellularRecordingsTable ' 'and SimultaneousRecordingsTable tabels (and corresponding ' 'SequentialRecordingsTable, RepetitionsTable and ' 'ExperimentalConditions tables.', name='sweep_table', quantity='?') ], datasets=[NWBDatasetSpec(name='filtering', doc='[DEPRECATED] Use IntracellularElectrode.filtering instead. ' 'Description of filtering used. Includes filtering type ' 'and parameters, frequency fall-off, etc. If this changes ' 'between TimeSeries, filter description should be stored ' 'as a text attribute for each TimeSeries.', dtype='text', quantity='?')] ) ] ) ] ) # Add the type we want to include from core to this list include_core_types = ['Container', 'DynamicTable', 'DynamicTableRegion', 'VectorData', 'VectorIndex', 'PatchClampSeries', 'IntracellularElectrode', 'NWBFile'] # Include the types that are used by the extension and their namespaces (where to find them) for type_name in include_core_types: ns_builder.include_type(type_name, namespace='core') # Add our new data types to this list new_data_types = [aligned_dynamic_tables_spec, reference_timeseries_vectordata, icephys_recordings_table_spec, simultaneous_recordings_table_spec, sequentialrecordings_table_spec, repetitions_table_spec, experimental_conditions_table_spec, icephys_file_spec, electrodes_table_spec, stimuli_table_spec, responses_table_spec] # Export the spec project_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')) output_dir = os.path.join(project_dir, 'spec') export_spec(ns_builder=ns_builder, new_data_types=new_data_types, output_dir=output_dir) print("Exported specification to: %s" % output_dir)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc= """An NWB extension to describe the detailed genotype of an experimental subject""", name="""ndx-genotype""", version="""0.1.0""", author=list( map(str.strip, """Ryan Ly, Oliver Ruebel, Pam Baker, Lydia Ng""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(',')))) ns_builder.include_type('Subject', namespace='core') ns_builder.include_type('NWBFile', namespace='core') ns_builder.include_type('NWBContainer', namespace='core') ns_builder.include_type('DynamicTable', namespace='core') ns_builder.include_type('VectorData', namespace='core') ns_builder.include_type('Data', namespace='core') ns_builder.include_type('Container', namespace='core') genotypes_table_spec = NWBGroupSpec( neurodata_type_def='GenotypesTable', neurodata_type_inc='DynamicTable', doc='A table to hold structured genotype information.', attributes=[ NWBAttributeSpec( name='process', doc= 'Description of the process or assay used to determine the genotype, e.g., PCR.', dtype='text', required=False, ), NWBAttributeSpec( name='process_url', doc= ('URL to online document that provides further details of the protocol used, e.g., ' 'https://dx.doi.org/10.17504/protocols.io.yjifuke'), dtype='text', required=False, ), NWBAttributeSpec( name='assembly', doc= 'Description of the assembly of the reference genome, e.g., GRCm38.p6.', dtype='text', required=False, ), NWBAttributeSpec( name='annotation', doc=('Description of the annotation of the reference genome, ' 'e.g., NCBI Mus musculus Annotation Release 108.'), dtype='text', required=False, ), ], datasets=[ NWBDatasetSpec( name='locus_symbol', neurodata_type_inc='VectorData', doc='Symbol/name of the locus, e.g., Rorb.', dtype='text', ), NWBDatasetSpec( name='locus_type', neurodata_type_inc='VectorData', doc= 'Type of the locus, e.g., Gene, Transgene, Unclassified other.', dtype='text', quantity='?', ), NWBDatasetSpec( name='allele1_symbol', neurodata_type_inc='VectorData', doc=('Symbol/name of the first allele, e.g., Rorb-IRES2-Cre. ' '"wt" should be used to represent wild-type.'), dtype='text', ), NWBDatasetSpec( name='allele1_type', neurodata_type_inc='VectorData', doc= ('Type of the first allele, e.g., Targeted (Recombinase), ' 'Transgenic (Null/knockout, Transactivator), Targeted (Conditional ready, Inducible, Reporter).' '"Wild Type" should be used to represent wild-type. Allele types can be found at: ' 'http://www.informatics.jax.org/userhelp/ALLELE_phenotypic_categories_help.shtml#method' ), dtype='text', quantity='?', ), NWBDatasetSpec( name='allele2_symbol', neurodata_type_inc='VectorData', doc=('Smybol/name of the second allele, e.g., Rorb-IRES2-Cre. ' '"wt" should be used to represent wild-type.'), dtype='text', ), NWBDatasetSpec( name='allele2_type', neurodata_type_inc='VectorData', doc= ('Type of the second allele, e.g., Targeted (Recombinase), ' 'Transgenic (Null/knockout, Transactivator), Targeted (Conditional ready, Inducible, Reporter).' '"Wild Type" should be used to represent wild-type. Allele types can be found at: ' 'http://www.informatics.jax.org/userhelp/ALLELE_phenotypic_categories_help.shtml#method' ), dtype='text', quantity='?', ), NWBDatasetSpec( name='allele3_symbol', neurodata_type_inc='VectorData', doc=('Symbol/name of the third allele, e.g., Rorb-IRES2-Cre. ' '"wt" should be used to represent wild-type.'), dtype='text', quantity='?', ), NWBDatasetSpec( name='allele3_type', neurodata_type_inc='VectorData', doc= ('Type of the third allele, e.g., Targeted (Recombinase), ' 'Transgenic (Null/knockout, Transactivator), Targeted (Conditional ready, Inducible, Reporter).' '"Wild Type" should be used to represent wild-type. Allele types can be found at: ' 'http://www.informatics.jax.org/userhelp/ALLELE_phenotypic_categories_help.shtml#method' ), dtype='text', quantity='?', ), ], ) genotype_subject_spec = NWBGroupSpec( neurodata_type_def='GenotypeSubject', neurodata_type_inc='Subject', doc= ('An enhanced Subject type that has an additional field for a genotype table. ' 'NOTE: If this proposal for extension ' 'to NWB gets merged with the core schema, then this type would be removed and the' 'Subject specification updated instead.'), groups=[ NWBGroupSpec( name='genotypes_table', neurodata_type_inc='GenotypeTable', doc='Structured genotype information for the subject.', quantity='?', ), ], ) genotype_nwbfile_spec = NWBGroupSpec( neurodata_type_def='GenotypeNWBFile', neurodata_type_inc='NWBFile', doc= ('Extension of the NWBFile class to allow 1) placing the new GenotypeSubject type ' 'in /general/subject in the NWBFile and 2) placing the new ontologies group containing an ' 'ontology table and ontology map. NOTE: If this proposal for extension ' 'to NWB gets merged with the core schema, then this type would be removed and the ' 'NWBFile specification updated instead. The ontologies types will be incorporated from HDMF ' 'when they are finalized.'), groups=[ NWBGroupSpec( name='general', # override existing general group doc='Expanded definition of general from NWBFile.', groups=[ NWBGroupSpec( name='subject', # override existing subject type neurodata_type_inc='GenotypeSubject', doc= 'Subject information with structured genotype information.', quantity='?', ), ], ), NWBGroupSpec( name='.ontologies', doc='Information about ontological terms used in this file.', quantity='?', datasets=[ NWBDatasetSpec( name='objects', neurodata_type_inc='OntologyTable', doc='The objects that conform to an ontology.', ), NWBDatasetSpec( name='terms', neurodata_type_inc='OntologyMap', doc='The ontological terms that get used in this file.', ), ], ), ], ) ontology_table_spec = NWBDatasetSpec( neurodata_type_def='OntologyTable', doc= ('A table for identifying which objects in a file contain values that correspond to ontology terms or ' 'centrally registered IDs (CRIDs)'), dtype=[ NWBDtypeSpec(name='id', dtype='uint64', doc='The unique identifier in this table.'), NWBDtypeSpec( name='object_id', dtype='text', doc='The UUID for the object that uses this ontology term.'), NWBDtypeSpec( name='field', dtype='text', doc= 'The field from the object (specified by object_id) that uses this ontological term.' ), NWBDtypeSpec( name='item', dtype='uint64', doc='An index into the OntologyMap that contains the term.'), ], shape=[None], ) ontology_map_spec = NWBDatasetSpec( neurodata_type_def='OntologyMap', doc= ('A table for mapping user terms (i.e., keys) to ontology terms / registry symbols / ' 'centrally registered IDs (CRIDs)'), dtype=[ NWBDtypeSpec(name='id', dtype='uint64', doc='The unique identifier in this table.'), NWBDtypeSpec( name='key', dtype='text', doc= 'The user key that maps to the ontology term / registry symbol.' ), NWBDtypeSpec( name='ontology', dtype='text', doc='The ontology/registry that the term/symbol comes from.'), NWBDtypeSpec( name='uri', dtype='text', doc= 'The unique resource identifier for the ontology term / registry symbol.' ), ], shape=[None], ) new_data_types = [ genotypes_table_spec, genotype_subject_spec, genotype_nwbfile_spec, ontology_table_spec, ontology_map_spec ] # export the spec to yaml files in the spec folder output_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
from pynwb.spec import NWBDatasetSpec, NWBNamespaceBuilder, NWBGroupSpec, AttributeSpec from pynwb import get_class, load_namespaces ## spec for name = 'simulation_output' ns_path = name + '.namespace.yaml' ext_source = name + '.extensions.yaml' gid_spec = NWBDatasetSpec(doc='global id for neuron', shape=(None, 1), name='cell_index', dtype='int', quantity='?') values = AttributeSpec(shape=(None, 1), name='labels', dtype='str', required=True, doc='these are the values') cat_data_spec = NWBDatasetSpec(name='data', shape=(None, 1), dtype='int', doc='indices into values for each gid in order', attributes=[values]) cat_cell_info = NWBGroupSpec(neurodata_type_def='CatCellInfo', doc='Categorical Cell Info', datasets=[gid_spec, cat_data_spec], neurodata_type_inc='NWBDataInterface') # export ns_builder = NWBNamespaceBuilder(name + ' extensions', name) for spec in [cat_cell_info]: ns_builder.add_spec(ext_source, spec) ns_builder.export(ns_path)
quantity='+', doc='manipulation', attributes=[ NWBAttributeSpec(name='brain_region_target', dtype='text', doc='Allan Institute Acronym') ]) virus_injection = NWBGroupSpec( neurodata_type_inc='NWBDataInterface', neurodata_type_def='VirusInjection', quantity='+', doc='notes about surgery that includes virus injection', datasets=[ NWBDatasetSpec(name='coordinates', doc='(AP, ML, DV) of virus injection', dtype='float', shape=(3, )) ], attributes=[ NWBAttributeSpec(name='virus', doc='type of virus', dtype='text'), NWBAttributeSpec(name='volume', doc='volume of injecting in nL', dtype='float'), NWBAttributeSpec(name='rate', doc='rate of injection (nL/s)', dtype='float', required=False), NWBAttributeSpec(name='scheme', doc='scheme of injection', dtype='text', required=False),
cat_cell_info = NWBGroupSpec( neurodata_type_def='CatCellInfo', doc='Categorical Cell Info', attributes=[ NWBAttributeSpec( name='help', doc='help', dtype='text', value= 'Categorical information about cells. For most cases the units tables is more appropriate. This ' 'structure can be used if you need multiple entries per cell') ], datasets=[ NWBDatasetSpec(doc='global id for neuron', shape=(None, ), name='cell_index', dtype='int', quantity='?'), NWBDatasetSpec(name='indices', doc='list of indices for values', shape=(None, ), dtype='int', attributes=[values]) ], neurodata_type_inc='NWBDataInterface') cat_timeseries = NWBGroupSpec(neurodata_type_def='CatTimeSeries', neurodata_type_inc='TimeSeries', doc='Categorical data through time', datasets=[ NWBDatasetSpec(
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""Store the elliptical eye tracking output of DeepLabCut""", name="""ndx-ellipse-eye-tracking""", version="""0.1.0""", author=list(map(str.strip, """Ben Dichter""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(',')))) # TODO: specify the neurodata_types that are used by the extension as well # as in which namespace they are found # this is similar to specifying the Python modules that need to be imported # to use your new data types # as of HDMF 1.6.1, the full ancestry of the neurodata_types that are used by # the extension should be included, i.e., the neurodata_type and its parent # type and its parent type and so on. this will be addressed in a future # release of HDMF. ns_builder.include_type('SpatialSeries', namespace='core') ns_builder.include_type('EyeTracking', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') # TODO: define your new data types # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information ellipse_series_spec = NWBGroupSpec( neurodata_type_def='EllipseSeries', neurodata_type_inc='SpatialSeries', doc='Information about an ellipse moving over time', datasets=[ NWBDatasetSpec( name= 'data', # override SpatialSeries 'data' dataset to be more explicit dtype='numeric', doc= 'The (x, y) coordinates of the center of the ellipse at each time point.', dims=('num_times', 'x, y'), shape=(None, 2), ), NWBDatasetSpec(name='area', dtype='float', doc='ellipse area', shape=(None, )), NWBDatasetSpec(name='width', dtype='float', doc='width of ellipse', shape=(None, )), NWBDatasetSpec(name='height', dtype='float', doc='height of ellipse', shape=(None, )), NWBDatasetSpec(name='angle', dtype='float', doc='angle that ellipse is rotated by (phi)', shape=(None, )) ]) ellipse_eye_tracking_spec = NWBGroupSpec( neurodata_type_def='EllipseEyeTracking', neurodata_type_inc='EyeTracking', name=None, default_name='EyeTracking', doc='Stores detailed eye tracking information output from DeepLabCut', groups=[ NWBGroupSpec(neurodata_type_inc=ellipse_series_spec, name=x, doc=x.replace('_', ' ')) for x in ('eye_tracking', 'pupil_tracking', 'corneal_reflection_tracking') ] + [ NWBGroupSpec( neurodata_type_inc='TimeSeries', name='likely_blink', doc= 'Indicator of whether there was a probable blink for this frame' ) ], ) # TODO: add all of your new data types to this list new_data_types = [ellipse_series_spec, ellipse_eye_tracking_spec] # export the spec to yaml files in the spec folder output_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
def main(): # these arguments were auto-generated from your cookie-cutter inputs ns_builder = NWBNamespaceBuilder( doc='An NWB extension for storing bipolar schema', name='ndx-bipolar-scheme', version='0.4.0', author=list(map(str.strip, 'Ben Dichter,Armin Najarpour,Ryan Ly'.split(','))), contact=list(map(str.strip, '*****@*****.**'.split(','))) ) for type_name in ('LabMetaData', 'DynamicTableRegion', 'DynamicTable', 'VectorIndex', 'ElectricalSeries'): ns_builder.include_type(type_name, namespace='core') ndx_bipolar_scheme = NWBGroupSpec( doc='Group that holds proposed extracellular electrophysiology extensions.', neurodata_type_def='NdxBipolarScheme', neurodata_type_inc='LabMetaData', name='ndx_bipolar_scheme', groups=[NWBGroupSpec( neurodata_type_inc='BipolarSchemeTable', doc='Bipolar referencing scheme used', quantity='*' )], links=[NWBLinkSpec( name='source', doc='input to re-referencing scheme', target_type='ElectricalSeries', quantity='?', )] ) bipolar_scheme_table = NWBGroupSpec( default_name='bipolar_scheme', doc='Table that holds information about the bipolar scheme used', neurodata_type_def='BipolarSchemeTable', neurodata_type_inc='DynamicTable', datasets=[ NWBDatasetSpec( name='anodes', neurodata_type_inc='DynamicTableRegion', doc='references the electrodes table', dims=('num_electrodes',), shape=(None,), dtype='int' ), NWBDatasetSpec( name='cathodes', neurodata_type_inc='DynamicTableRegion', doc='references the electrodes table', dims=('num_electrodes',), shape=(None,), dtype='int' ), NWBDatasetSpec( name='anodes_index', neurodata_type_inc='VectorIndex', doc='Indices for the anode table', dims=('num_electrode_grp',), shape=(None,), quantity='?', ), NWBDatasetSpec( name='cathodes_index', neurodata_type_inc='VectorIndex', doc='Indices for the cathode table', dims=('num_electrode_grp',), shape=(None,), quantity='?', ) ] ) new_data_types = [ndx_bipolar_scheme, bipolar_scheme_table] # export the spec to yaml files in the spec folder output_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, new_data_types, output_dir)
name = 'simulation_output' ns_path = name + '.namespace.yaml' ext_source = name + '.extensions.yaml' # Continuous data for cell compartments Compartments = NWBGroupSpec( default_name='compartments', neurodata_type_def='Compartments', neurodata_type_inc='DynamicTable', doc='table that holds information about what places are being recorded', datasets=[ NWBDatasetSpec( name='number', neurodata_type_inc='VectorData', doc= 'cell compartment ids corresponding to a each column in the data', dtype='int'), NWBDatasetSpec(name='number_index', neurodata_type_inc='VectorIndex', doc='maps cell to compartments', quantity='?'), NWBDatasetSpec( name='position', neurodata_type_inc='VectorData', doc= 'position of recording within a compartment. 0 is close to soma, 1 is other end', dtype='float', quantity='?'), NWBDatasetSpec(name='position_index', neurodata_type_inc='VectorIndex',
ecephys_specimen_ext = NWBGroupSpec(doc="Metadata for ecephys specimen", attributes=ecephys_specimen_attributes, neurodata_type_def="EcephysSpecimen", neurodata_type_inc="Subject") # Ecephys eye tracking rig metadata extension (inherits from `NWBDataInterface`) rig_equipment_attr = NWBAttributeSpec(name="equipment", doc="Description of rig", dtype="text") unit_attr = NWBAttributeSpec('unit', 'Unit of measurement for the data', 'text') rig_monitor_position_dset = NWBDatasetSpec(name="monitor_position", doc="position of monitor (x, y, z)", attributes=[unit_attr], dtype='float32', dims=(3,)) rig_camera_position_dset = NWBDatasetSpec(name="camera_position", doc="position of camera (x, y, z)", attributes=[unit_attr], dtype='float32', dims=(3,)) rig_led_position_dset = NWBDatasetSpec(name="led_position", doc="position of LED (x, y, z)", attributes=[unit_attr], dtype='float32', dims=(3,))
value='settings parameters stored by MWorks') ], ) sound_play = NWBGroupSpec( neurodata_type_def='SoundPlay', neurodata_type_inc='TimeSeries', doc= 'contains information for sounds played to subject during task. Data represents amplitude', datasets=[ NWBDatasetSpec(name='data', dtype='int', shape=(None, ), doc='indexes sound_files and sound_names in attributes', attributes=[ NWBAttributeSpec(name='sound_files', doc='indexed by data', dtype='text'), NWBAttributeSpec(name='sound_names', doc='indexed by data', dtype='text') ]), NWBDatasetSpec(name='amplitude', dtype='double', shape=(None, ), doc='amplitude of sound') ], ) eye_calibrator = NWBGroupSpec(neurodata_type_def='EyeCalibration', neurodata_type_inc='NWBDataInterface', doc='Eye Calibration parameters',
def main(): ns_builder = NWBNamespaceBuilder( doc='nwb extention for voltage imaging technique called TEMPO', name=name, version='0.1.0', author=list(map(str.strip, 'Saksham Sharda'.split(','))), contact=list(map(str.strip, '*****@*****.**'.split(','))) ) ns_builder.include_type('VectorData', namespace='hdmf-common') ns_builder.include_type('DynamicTable', namespace='hdmf-common') ns_builder.include_type('Subject', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('NWBContainer', namespace='core') ns_builder.include_type('Device', namespace='core') measurement = NWBDatasetSpec('Flexible vectordataset with a custom unit/conversion/resolution' ' field similar to timeseries.data', attributes=[ NWBAttributeSpec('unit', 'The base unit of measure used to store data. This should be in the SI unit.' 'COMMENT: This is the SI unit (when appropriate) of the stored data, such as ' 'Volts. If the actual data is stored in millivolts, the field ''conversion'' ' 'below describes how to convert the data to the specified SI unit.', 'text'), NWBAttributeSpec('conversion', 'Scalar to multiply each element in ' 'data to convert it to the specified unit', 'float32', required=False, default_value=1.0), NWBAttributeSpec('resolution', 'Smallest meaningful difference between values in data, stored in the specified ' 'by unit. COMMENT: E.g., the change in value of the least significant bit, or ' 'a larger number if signal noise is known to be present. If unknown, use -1.0', 'float32', required=False, default_value=0.0) ], neurodata_type_def='Measurement', neurodata_type_inc='VectorData', ) # Typedef for laserline laserline_device = NWBGroupSpec(neurodata_type_def='LaserLine', neurodata_type_inc='Device', doc='description of laserline device, part for a TEMPO device', attributes=[ NWBAttributeSpec('reference', 'reference of the laserline module', dtype='text', required=False) ], quantity='*') laserline_device.add_dataset( name='analog_modulation_frequency', neurodata_type_inc=measurement, doc='analog_modulation_frequency of the laserline module', shape=(1,), dtype='text', quantity='?' ) laserline_device.add_dataset( name='power', neurodata_type_inc=measurement, doc='power of the laserline module', shape=(1,), dtype='float', quantity='?' ) laserline_devices = NWBGroupSpec(neurodata_type_def='LaserLineDevices', neurodata_type_inc='NWBDataInterface', name='laserline_devices', doc='A container for dynamic addition of LaserLine devices', quantity='?', groups=[laserline_device]) # Typedef for PhotoDetector photodetector_device = NWBGroupSpec(neurodata_type_def='PhotoDetector', neurodata_type_inc='Device', doc='description of photodetector device, part for a TEMPO device', attributes=[ NWBAttributeSpec('reference', 'reference of the photodetector module', dtype='text', required=False) ], quantity='*') photodetector_device.add_dataset( name='gain', neurodata_type_inc=measurement, doc='gain of the photodetector module', shape=(1,), dtype='float', quantity='?' ) photodetector_device.add_dataset( name='bandwidth', neurodata_type_inc=measurement, doc='bandwidth metadata of the photodetector module', shape=(1,), dtype='float', quantity='?' ) photodetector_devices = NWBGroupSpec(neurodata_type_def='PhotoDetectorDevices', neurodata_type_inc='NWBDataInterface', name='photodetector_devices', doc='A container for dynamic addition of PhotoDetector devices', quantity='?', groups=[photodetector_device]) # Typedef for LockInAmplifier lockinamp_device = NWBGroupSpec(neurodata_type_def='LockInAmplifier', neurodata_type_inc='DynamicTable', doc='description of lock_in_amp device, part for a TEMPO device', attributes=[ NWBAttributeSpec('demodulation_filter_order', 'demodulation_filter_order of the lockinamp_device module', dtype='float', required=False, default_value=-1), NWBAttributeSpec('reference', 'reference of the lockinamp_device module', dtype='text', required=False) ], quantity='*') lockinamp_device.add_dataset( name='demod_bandwidth', neurodata_type_inc=measurement, doc='demod_bandwidth of lock_in_amp', shape=(1,), dtype='float', quantity='?' ) lockinamp_device.add_dataset( name='channel_name', neurodata_type_inc='VectorData', doc='name of the channel of lock_in_amp', dims=('no_of_channels',), shape=(None,), dtype='text', quantity='?' ) lockinamp_device.add_dataset( name='offset', neurodata_type_inc=measurement, doc='offset for channel of lock_in_amp', dims=('no_of_channels',), shape=(None,), dtype='float', quantity='?' ) lockinamp_device.add_dataset( name='gain', neurodata_type_inc='VectorData', doc='gain for channel of lock_in_amp', dims=('no_of_channels',), shape=(None,), dtype='float', quantity='?' ) lockinamp_devices = NWBGroupSpec(neurodata_type_def='LockInAmplifierDevices', neurodata_type_inc='NWBDataInterface', name='lockinamp_devices', doc='A container for dynamic addition of LockInAmplifier devices', quantity='?', groups=[lockinamp_device]) tempo_device = NWBGroupSpec(neurodata_type_def='TEMPO', neurodata_type_inc='Device', doc='datatype for a TEMPO device', attributes=[NWBAttributeSpec( name='no_of_modules', doc='the number of electronic modules with this acquisition system', dtype='int', required=False, default_value=3)], groups=[laserline_devices, photodetector_devices, lockinamp_devices] ) # surgical meta-data specification: surgery = NWBGroupSpec(neurodata_type_def='Surgery', neurodata_type_inc='Subject', doc='Surgery related meta-data of subject', name='surgery_data', attributes=[NWBAttributeSpec( name='surgery_date', doc='date of surgery', dtype='text', required=False), NWBAttributeSpec( name='surgery_notes', doc='surgery notes', dtype='text', required=False), NWBAttributeSpec( name='surgery_pharmacology', doc='pharmacology data', dtype='text', required=False), NWBAttributeSpec( name='surgery_arget_anatomy', doc='target anatomy of the surgery', dtype='text', required=False)], groups=[ NWBGroupSpec( name='implantation', doc='implantation related data', links=[NWBLinkSpec(name='implantation_device', doc='device implanted during surgery', target_type='Device')], attributes=[NWBAttributeSpec( name='ophys_implant_name', doc='optical physiology implant name', dtype='text', required=False), NWBAttributeSpec( name='ephys_implant_name', doc='electrophysiology implant name', dtype='text', required=False)], quantity='?'), NWBGroupSpec( name='virus_injection', doc='virus injection related data', attributes=[NWBAttributeSpec( name='virus_injection_id', doc='id of virus injected', dtype='text', required=False), NWBAttributeSpec( name='virus_injection_opsin', doc='opsin/protein used', dtype='text', required=False), NWBAttributeSpec( name='virus_injection_opsin_l_r', doc='opsin/protein left/right description' 'enter \'L\' or \'R\'', dtype='text', required=False, default_value='L/R'), NWBAttributeSpec( name='virus_injection_scheme', doc='description of injection scheme eg.' '\'single_bolus\'', dtype='text', required=False), NWBAttributeSpec( name='virus_injection_tag', doc='tag for the virus injected', dtype='text', required=False), NWBAttributeSpec( name='virus_injection_coordinates_description', doc='description of coordinates' '\'AP\'/\'ML\'/\'DV\'', dtype='text', required=False), NWBAttributeSpec( name='virus_injection_volume', doc='volume of virus injected in ml', dtype='float', required=False, default_value=-1.0)], datasets=[NWBDatasetSpec( name='virus_injection_coordinates', doc='coordinates of virus injection', dtype='text', quantity='?')], quantity='?'), NWBGroupSpec( name='ophys_injection', doc='optical physiology fluorescence injection metadata', attributes=[NWBAttributeSpec( name='ophys_injection_date', doc='date of fluorscent protein injection', dtype='text', required=False), NWBAttributeSpec( name='ophys_injection_volume', doc='volume of fluorscent protein injected', dtype='float', required=False), NWBAttributeSpec( name='ophys_injection_brain_area', doc='brain area of fluorscent protein injection', dtype='text', required=False) ], datasets=[NWBDatasetSpec( name='ophys_injection_flr_protein_data', doc='fluorescence protein name and concentration table', neurodata_type_inc='DynamicTable') ], quantity='?') ], quantity='?') subject = NWBGroupSpec( neurodata_type_def='SubjectComplete', neurodata_type_inc='Surgery', doc='Mouse metadata used with the TEMPO device', attributes=[NWBAttributeSpec( name='sacrificial_date', doc='sacrificial date of the animal ', dtype='text', required=False), NWBAttributeSpec( name='strain', doc='strain of the animal', dtype='text', required=False)], ) new_data_types = [measurement, tempo_device, surgery, subject] export_spec(ns_builder, new_data_types)