def main(): ns_builder = NWBNamespaceBuilder(doc='data type for holding power or phase spectra for a signal', name='ndx-spectrum', version='0.2.2', author='Ben Dichter', contact='*****@*****.**') ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('TimeSeries', namespace='core') ns_builder.include_type('DynamicTableRegion', namespace='core') Spectrum = NWBGroupSpec( neurodata_type_def='Spectrum', neurodata_type_inc='NWBDataInterface', doc='type for storing power or phase of spectrum') for data_name in ('power', 'phase'): Spectrum.add_dataset( name=data_name, doc='spectrum values', dims=(('frequency',), ('frequency', 'channel')), shape=((None,), (None, None)), dtype='float', quantity='?') Spectrum.add_dataset(name='frequencies', doc='frequencies of spectrum', dims=('frequency',), shape=(None,), dtype='float') Spectrum.add_link(target_type='TimeSeries', doc='timeseries that this spectrum describes', quantity='?', name='source_timeseries') Spectrum.add_dataset(name='electrodes', doc='the electrodes that this series was generated from', neurodata_type_inc='DynamicTableRegion', quantity='?') new_data_types = [Spectrum] # 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= """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)
def main(): ns_builder = NWBNamespaceBuilder( doc='type for storing metadata for Tank lab', name='ndx-tank-metadata', version='0.1.0', author=['Szonja Weigl', 'Luiz Tauffer', 'Ben Dichter'], contact=['*****@*****.**']) ns_builder.include_type('LabMetaData', namespace='core') ns_builder.include_type('DynamicTable', namespace='core') LabMetaDataExtension = NWBGroupSpec( doc='type for storing metadata for Tank lab', neurodata_type_def='LabMetaDataExtension', neurodata_type_inc='LabMetaData', ) LabMetaDataExtension.add_attribute( name='experiment_name', doc='name of experiment run', dtype='text', ) LabMetaDataExtension.add_attribute( name='world_file_name', doc='name of world file run', dtype='text', ) LabMetaDataExtension.add_attribute( name='protocol_name', doc='name of protocol run', dtype='text', ) LabMetaDataExtension.add_attribute( name='stimulus_bank_path', doc='path of stimulus bank file', dtype='text', ) LabMetaDataExtension.add_attribute( name='commit_id', doc='Commit id for session run', dtype='text', ) LabMetaDataExtension.add_attribute( name='location', doc='Name of rig where session was run', dtype='text', ) LabMetaDataExtension.add_attribute( name='session_performance', doc='Performance of correct responses in %', dtype='float', required=False) LabMetaDataExtension.add_attribute( name='session_end_time', doc='Datetime when session ended', dtype='text', # temporary solution until datetime is fixed ) LabMetaDataExtension.add_attribute( name='num_trials', doc='Number of trials during the session', dtype='int', ) RigExtension = NWBGroupSpec( doc='type for storing rig information', neurodata_type_def='RigExtension', neurodata_type_inc='LabMetaData', ) rig_attr = [('rig', 'text'), ('simulationMode', 'int'), ('hasDAQ', 'int'), ('hasSyncComm', 'int'), ('minIterationDT', 'float'), ('arduinoPort', 'text'), ('sensorDotsPerRev', 'float'), ('ballCircumference', 'float'), ('toroidXFormP1', 'float'), ('toroidXFormP2', 'float'), ('colorAdjustment', 'float'), ('soundAdjustment', 'float'), ('nidaqDevice', 'int'), ('nidaqPort', 'int'), ('nidaqLines', 'int'), ('syncClockChannel', 'int'), ('syncDataChannel', 'int'), ('rewardChannel', 'int'), ('rewardSize', 'float'), ('rewardDuration', 'float'), ('laserChannel', 'int'), ('rightPuffChannel', 'int'), ('leftPuffChannel', 'int'), ('webcam_name', 'text')] for attr in rig_attr: if attr[0] in ['sensorDotsPerRev', 'colorAdjustment', 'nidaqLines']: RigExtension.add_attribute(name=attr[0], doc='rig information', dtype=attr[1], shape=(None, ), required=False) else: RigExtension.add_attribute(name=attr[0], doc='rig information', dtype=attr[1], required=False) LabMetaDataExtension.add_group( name='rig', neurodata_type_inc='RigExtension', doc='type for storing rig information', ) MazeExtension = NWBGroupSpec( doc='type for storing maze information', neurodata_type_def='MazeExtension', neurodata_type_inc='DynamicTable', ) LabMetaDataExtension.add_group( name='mazes', neurodata_type_inc='MazeExtension', doc='type for storing maze information', ) # export the extension to yaml files in the spec folder output_dir = os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..', 'spec')) export_spec(ns_builder, [LabMetaDataExtension, RigExtension, MazeExtension], output_dir)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""NovelaNeurotechnologies Namespaces""", name="""ndx-franklab-novela""", version="""0.0.011.36""", author=list(map(str.strip, """NovelaDevops""".split(','))), contact=list(map(str.strip, """*****@*****.**""".split(',')))) # # 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('ElectrodeGroup', namespace='core') ns_builder.include_type('Device', namespace='core') ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('ImageSeries', namespace='core') # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information shanks_electrode = NWBGroupSpec( neurodata_type_def='ShanksElectrode', neurodata_type_inc='NWBDataInterface', doc='electrode in the probe', attributes=[ NWBAttributeSpec(name='name', doc='name of the electrode', dtype='text'), NWBAttributeSpec(name='rel_x', doc='the rel_x value of the electrode', dtype='float'), NWBAttributeSpec(name='rel_y', doc='the rel_y value of the electrode', dtype='float'), NWBAttributeSpec(name='rel_z', doc='the rel_z value of the electrode', dtype='float'), ]) shanks = NWBGroupSpec(neurodata_type_def='Shank', neurodata_type_inc='NWBDataInterface', doc='shank in the probe', groups=[ NWBGroupSpec( neurodata_type_inc='ShanksElectrode', doc='electrode in the probe', quantity='*') ], attributes=[ NWBAttributeSpec(name='name', doc='name of the shank', dtype='text'), ]) probe = NWBGroupSpec( doc='A custom Probes interface', neurodata_type_def='Probe', neurodata_type_inc='Device', groups=[ NWBGroupSpec(neurodata_type_inc='Shank', doc='shank in the probe', quantity='*') ], attributes=[ NWBAttributeSpec(name='id', doc='unique id of the probe', dtype='int'), NWBAttributeSpec(name='probe_type', doc='type of the probe', dtype='text'), NWBAttributeSpec(name='units', doc='units in probe, acceptable values um or mm', dtype='text'), NWBAttributeSpec(name='probe_description', doc='description of the probe', dtype='text'), NWBAttributeSpec(name='contact_side_numbering', doc='is contact_side_numbering enabled', dtype='bool'), NWBAttributeSpec(name='contact_size', doc='value of contact size in float', dtype='float'), ]) data_acq_device = NWBGroupSpec(doc='A custom Device interface', neurodata_type_def='DataAcqDevice', neurodata_type_inc='Device', attributes=[ NWBAttributeSpec(name='system', doc='system of device', dtype='text'), NWBAttributeSpec(name='amplifier', doc='amplifier', dtype='text'), NWBAttributeSpec(name='adc_circuit', doc='adc_circuit', dtype='text'), ]) camera_device = NWBGroupSpec(neurodata_type_def='CameraDevice', neurodata_type_inc='Device', doc='A custom Device interface', attributes=[ NWBAttributeSpec(name='meters_per_pixel', doc='meters per pixel', dtype='float'), NWBAttributeSpec(name='camera_name', doc='name of the camera', dtype='text'), NWBAttributeSpec( name='model', doc='model of this camera device', dtype='text'), NWBAttributeSpec(name='lens', doc='lens info', dtype='text') ]) associated_files = NWBGroupSpec( neurodata_type_def='AssociatedFiles', neurodata_type_inc='NWBDataInterface', doc='content of files linked with nwb', attributes=[ NWBAttributeSpec(name='description', doc='description of file', dtype='text'), NWBAttributeSpec(name='content', doc='content of file', dtype='text'), NWBAttributeSpec(name='task_epochs', doc='epochs this task belongs to', dtype='text') ]) nwb_image_series = NWBGroupSpec( neurodata_type_def='NwbImageSeries', neurodata_type_inc='ImageSeries', doc='Extension of ImageSeries object in NWB', groups=[ NWBGroupSpec(neurodata_type_inc='Device', doc='devices used to record video', quantity='*') ], ) header_device = NWBGroupSpec( doc='metadata from global configuration from header', neurodata_type_def='HeaderDevice', neurodata_type_inc='Device', attributes=[ NWBAttributeSpec(name='headstage_serial', doc='headstage_serial from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_smart_ref_on', doc='headstage_smart_ref_on from global configuration', dtype='text'), NWBAttributeSpec(name='realtime_mode', doc='realtime_mode from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_auto_settle_on', doc='headstage_auto_settle_on from global configuration', dtype='text'), NWBAttributeSpec( name='timestamp_at_creation', doc='timestamp_at_creation from global configuration', dtype='text'), NWBAttributeSpec( name='controller_firmware_version', doc='conntroller_firmware_version from global configuration', dtype='text'), NWBAttributeSpec(name='controller_serial', doc='controller_serial from global configuration', dtype='text'), NWBAttributeSpec( name='save_displayed_chan_only', doc='save_displayed_chan_only from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_firmware_version', doc='headstage_firmware_version from global configuration', dtype='text'), NWBAttributeSpec( name='qt_version', doc='qt_version_version from global configuration', dtype='text'), NWBAttributeSpec( name='compile_date', doc='compile_date_version from global configuration', dtype='text'), NWBAttributeSpec( name='compile_time', doc='compile_time_version from global configuration', dtype='text'), NWBAttributeSpec( name='file_prefix', doc='file_prefix_version from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_gyro_sensor_on', doc= 'headstage_gyro_sensor_on_version from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_mag_sensor_on', doc='headstage_mag_sensor_on_version from global configuration', dtype='text'), NWBAttributeSpec( name='trodes_version', doc='trodes_versionversion from global configuration', dtype='text'), NWBAttributeSpec( name='headstage_accel_sensor_on', doc='headstage_accel_sensor_on from global configuration', dtype='text'), NWBAttributeSpec(name='commit_head', doc='commit_head from global configuration', dtype='text'), NWBAttributeSpec( name='system_time_at_creation', doc='system_time_at_creation from global configuration', dtype='text'), NWBAttributeSpec(name='file_path', doc='file_path from global configuration', dtype='text'), ]) nwb_electrode_group = NWBGroupSpec( neurodata_type_def='NwbElectrodeGroup', neurodata_type_inc='ElectrodeGroup', doc='Custom nwb ElectrodeGroup', attributes=[ NWBAttributeSpec(name='targeted_location', doc='predicted location', dtype='text'), NWBAttributeSpec(name='targeted_x', doc='predicted x coordinates', dtype='float'), NWBAttributeSpec(name='targeted_y', doc='predicted y coordinates', dtype='float'), NWBAttributeSpec(name='targeted_z', doc='predicted z coordinates', dtype='float'), NWBAttributeSpec( name='units', doc='units of fields, acceptable values: um or mm', dtype='text'), ]) new_data_types = [ shanks_electrode, shanks, probe, data_acq_device, camera_device, nwb_image_series, header_device, associated_files, nwb_electrode_group ] # 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='An NWB:N extension for storing bipolar schema', name='ndx-bipolar-scheme', version='0.3.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'): ns_builder.include_type(type_name, namespace='core') ecephys_ext = NWBGroupSpec( doc= 'Group that holds proposed extracellular electrophysiology extensions.', neurodata_type_def='EcephysExt', neurodata_type_inc='LabMetaData', default_name='ecephys_ext', groups=[ NWBGroupSpec(name='bipolar_scheme_table', neurodata_type_inc='BipolarSchemeTable', doc='Bipolar referencing scheme used', quantity='?') ]) bipolar_scheme = NWBGroupSpec( doc='Table that holds information about the bipolar scheme used', neurodata_type_def='BipolarSchemeTable', neurodata_type_inc='DynamicTable', default_name='bipolar_scheme') bipolar_scheme.add_dataset(name='anodes', neurodata_type_inc='DynamicTableRegion', doc='references the electrodes table', dims=('num_electrodes', ), shape=(None, ), dtype='int') bipolar_scheme.add_dataset(name='cathodes', neurodata_type_inc='DynamicTableRegion', doc='references the electrodes table', dims=('num_electrodes', ), shape=(None, ), dtype='int') bipolar_scheme.add_dataset(name='anodes_index', neurodata_type_inc='VectorIndex', doc='Indices for the anode table', dims=('num_electrode_grp', ), shape=(None, )) bipolar_scheme.add_dataset(name='cathodes_index', neurodata_type_inc='VectorIndex', doc='Indices for the cathode table', dims=('num_electrode_grp', ), shape=(None, )) new_data_types = [ecephys_ext, bipolar_scheme] # 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='type for storing time-varying FRET data', name='ndx-fret', version='0.2.1', author=['Luiz Tauffer', 'Ben Dichter'], contact=['*****@*****.**', '*****@*****.**']) ns_builder.include_type('NWBDataInterface', namespace='core') ns_builder.include_type('ImageSeries', namespace='core') ns_builder.include_type('OpticalChannel', namespace='core') ns_builder.include_type('Device', namespace='core') # Define FRETSeries, type that stores Donor/Acceptor specific information FRETSeries = NWBGroupSpec( neurodata_type_def='FRETSeries', neurodata_type_inc='ImageSeries', doc='Donor/Acceptor specific information.', ) FRETSeries.add_attribute( name='fluorophore', doc='Fluorophore name.', dtype='text', shape=None, ) FRETSeries.add_group( name='optical_channel', doc='Group storing channel specific data', neurodata_type_inc='OpticalChannel', ) FRETSeries.add_link( name='device', doc='The device that was used to record.', target_type='Device', ) # Defines FRET, DataInterface that holds metadata and data for FRET experiments FRET = NWBGroupSpec( doc='type for storing time-varying FRET data', neurodata_type_def='FRET', neurodata_type_inc='NWBDataInterface', ) FRET.add_attribute( name='excitation_lambda', doc='Excitation wavelength in nm.', dtype='float', shape=None, ) FRET.add_attribute( name='location', doc='Location of imaging field.', dtype='text', shape=None, required=False, ) FRET.add_group( name='donor', doc='Group storing donor data', neurodata_type_inc='FRETSeries', ) FRET.add_group( name='acceptor', doc='Group storing acceptor data', neurodata_type_inc='FRETSeries', ) new_data_types = [FRET, FRETSeries] # 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(): 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)
def generate_extended_schema(): # set up silverlab namespace ns_builder = NWBNamespaceBuilder( 'Extensions for acousto-optic lens data', 'silverlab_extended_schema', 'Silver lab data extension to NWB format for acousto-optic lens experiments', version='0.4') ns_builder.include_type('LabMetaData', namespace='core') ns_builder.include_type('TwoPhotonSeries', namespace='core') # define attributes Silver lab extension cycle_time_attr = NWBAttributeSpec( name='cycle_time', doc='time in seconds for the microscope to acquire all ROIs once ' 'and return to its starting position', dtype='float') cycles_per_trial_attr = NWBAttributeSpec( name='cycles_per_trial', doc='how many microscope cycles occur in each experimental trial', dtype="int") imaging_mode_attr = NWBAttributeSpec( name='imaging_mode', doc='the acquisition mode for the experiment; ' 'pointing = single-voxel ROIs, ' 'miniscan = 2d rectangular ROIs, ' 'volume = 3d cuboid ROIs', dtype='text') frame_size_attr = NWBAttributeSpec( name='frame_size', doc='the 2d imaging frame size in voxels', shape=(2, ), dtype='int') silverlab_api_version_attr = NWBAttributeSpec( name='silverlab_api_version', doc='For potential future backwards compatibility, ' 'store the \'version\' of this API that created the file.', dtype='text') labview_version_attr = NWBAttributeSpec( name='labview_version', doc='The version of LabVIEW the data came from', dtype='text', required=False) pockels_column_names_attr = NWBAttributeSpec( name='columns', doc='column names for the zplane pockels dataset', shape=(4, ), dtype='text') # define datasets for Silver lab extensions zplane_pockels_ds = NWBDatasetSpec( doc='pockels data set, recording calibration data ' 'for focusing at different z-planes in four columns: ' 'Z offset from focal plane (micrometres), ' 'normalised Z, ' '\'Pockels\' i.e. laser power in %, ' 'and z offset for drive motors', name='pockels', shape=(None, 4), attributes=[pockels_column_names_attr], neurodata_type_def='ZplanePockelsDataset') # define groups for Silver lab extensions silverlab_optophys_specs = NWBGroupSpec( doc='A place to store Silver lab specific optophysiology data', attributes=[ cycle_time_attr, cycles_per_trial_attr, frame_size_attr, imaging_mode_attr ], datasets=[zplane_pockels_ds], neurodata_type_def='SilverLabOptophysiology', neurodata_type_inc='LabMetaData') silverlab_metadata_specs = NWBGroupSpec( doc='A place to store Silver lab specific metadata', attributes=[silverlab_api_version_attr, labview_version_attr], neurodata_type_def='SilverLabMetaData', neurodata_type_inc='LabMetaData', ) # dimensions ordered as t, x, y [, z], like the TimeSeries data itself silverlab_pixel_time_offset_data = NWBDatasetSpec( doc='A datastructure to hold time offsets for pixels. The' 'time offsets are the acquisition time of each pixel ' 'relative to a starting time. The starting time is the ' 'start of the cycle for pre-2018 LabView versions, ' 'and the start of the trial for new versions.', name='pixel_time_offsets', shape=[(None, None), (None, None, None), (None, None, None, None)], neurodata_type_def='PixelTimeOffsets') silverlab_roi_image_specs = NWBGroupSpec( doc='An extension to PyNWB\'s TwoPhotonSeries class, designed to hold ' 'pixels from an ROI as well as the PixelTimeOffsets for them.', datasets=[silverlab_pixel_time_offset_data], neurodata_type_def='ROISeriesWithPixelTimeOffsets', neurodata_type_inc='TwoPhotonSeries') # export as schema extension ext_source = 'silverlab.ophys.yaml' ns_builder.add_spec(ext_source, silverlab_optophys_specs) ext_source = 'silverlab.metadata.yaml' ns_builder.add_spec(ext_source, silverlab_metadata_specs) ext_source = 'silverlab.roi.yaml' ns_builder.add_spec(ext_source, silverlab_roi_image_specs) ns_builder.export('silverlab.namespace.yaml')
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.1.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')] ) survey_data.add_dataset( name='nrs_pain_intensity_rating', neurodata_type_inc=question_response, doc='NRS Pain Intensity Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='nrs_pain_relief_rating', neurodata_type_inc=question_response, doc='NRS Pain Relief Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='nrs_relative_pain_intensity_rating', neurodata_type_inc=question_response, doc='NRS Relative Pain Intensity Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='nrs_pain_unpleasantness', neurodata_type_inc=question_response, doc='NRS Pain Unpleasantness', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='vas_pain_intensity_rating', neurodata_type_inc=question_response, doc='VAS Pain Intensity Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='vas_pain_relief_rating', neurodata_type_inc=question_response, doc='VAS Pain Relief Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='vas_relative_pain_intensity_rating', neurodata_type_inc=question_response, doc='VAS Relative Pain Intensity Rating', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='vas_pain_unpleasantness', neurodata_type_inc=question_response, doc='VAS Pain Unpleasantness', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='throbbing', neurodata_type_inc=question_response, doc='Throbbing', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='shooting', neurodata_type_inc=question_response, doc='Shooting', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='stabbing', neurodata_type_inc=question_response, doc='Stabbing', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='sharp', neurodata_type_inc=question_response, doc='Sharp', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='cramping', neurodata_type_inc=question_response, doc='Cramping', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='gnawing', neurodata_type_inc=question_response, doc='Gnawing', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='hot_burning', neurodata_type_inc=question_response, doc='Hot-burning', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='aching', neurodata_type_inc=question_response, doc='Aching', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='heavy', neurodata_type_inc=question_response, doc='Heavy', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='tender', neurodata_type_inc=question_response, doc='Tender', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='splitting', neurodata_type_inc=question_response, doc='Splitting', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='tiring_exhausting', neurodata_type_inc=question_response, doc='Tiring-Exhausting', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='sickening', neurodata_type_inc=question_response, doc='Sickening', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='fearful', neurodata_type_inc=question_response, doc='Fearful', dims=('num_samples',), shape=(None,), dtype='text' ) survey_data.add_dataset( name='cruel_punishing', neurodata_type_inc=question_response, doc='Cruel-Punishing', dims=('num_samples',), shape=(None,), dtype='text' ) 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(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder(doc='Data types for recording data from multiple compartments of multiple ' 'neurons in a single TimeSeries.', name='ndx-simulation-output', version='0.2.6', author='Ben Dichter', contact='*****@*****.**') types_to_include = ['TimeSeries', 'VectorData', 'VectorIndex', 'DynamicTable', 'LabMetaData'] for ndtype in types_to_include: ns_builder.include_type(ndtype, namespace='core') Compartments = NWBGroupSpec(default_name='compartments', neurodata_type_def='Compartments', neurodata_type_inc='DynamicTable', doc='Table that holds information about what places are being recorded.') Compartments.add_dataset(name='number', neurodata_type_inc='VectorData', dtype='int', doc='Cell compartment ids corresponding to a each column in the data.') Compartments.add_dataset(name='number_index', neurodata_type_inc='VectorIndex', doc='Index that maps cell to compartments.', quantity='?') Compartments.add_dataset(name='position', neurodata_type_inc='VectorData', dtype='float', quantity='?', doc='Position of recording within a compartment. 0 is close to soma, 1 is other end.') Compartments.add_dataset(name='position_index', neurodata_type_inc='VectorIndex', doc='Index for position.', quantity='?') Compartments.add_dataset(name='label', neurodata_type_inc='VectorData', doc='Labels for compartments.', dtype='text', quantity='?') Compartments.add_dataset(name='label_index', neurodata_type_inc='VectorIndex', doc='indexes label', quantity='?') CompartmentsSeries = NWBGroupSpec(neurodata_type_def='CompartmentSeries', neurodata_type_inc='TimeSeries', doc='Stores continuous data from cell compartments') CompartmentsSeries.add_link(name='compartments', target_type='Compartments', quantity='?', doc='Metadata about compartments in this CompartmentSeries.') SimulationMetaData = NWBGroupSpec(name='simulation', neurodata_type_def='SimulationMetaData', neurodata_type_inc='LabMetaData', doc='Group that holds metadata for simulations.') SimulationMetaData.add_group(name='compartments', neurodata_type_inc='Compartments', doc='Table that holds information about what places are being recorded.') new_data_types = [Compartments, CompartmentsSeries, SimulationMetaData] # 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='stores electrical stimulation waveforms', name='ndx-electrical-stim', version='0.1.0', author=list(map(str.strip, 'Jessie R. Liu'.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('TimeSeries', namespace='core') ns_builder.include_type('TimeIntervals', namespace='core') ns_builder.include_type('DynamicTableRegion', namespace='hdmf-common') ns_builder.include_type('VectorData', namespace='hdmf-common') # TODO: define your new data types # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information stim_series = NWBGroupSpec( neurodata_type_def='StimSeries', neurodata_type_inc='TimeSeries', doc=('An extension of TimeSeries to include stimulation waveforms ' 'used during electrical stimulation.'), ) stim_series.add_dataset(name='bipolar_electrodes', neurodata_type_inc='DynamicTableRegion', doc='DynamicTableRegion pointer to the ' 'bipolar electrode pairs corresponding to the ' 'stimulation waveforms.') stim_table = NWBGroupSpec( neurodata_type_def='StimTable', neurodata_type_inc='TimeIntervals', doc=('An extension of TimeIntervals to hold parameters used for ' 'various stimulation events.'), ) stim_table.add_dataset(name='bipolar_pair', neurodata_type_inc='DynamicTableRegion', doc='DynamicTableRegion pointer to the ' 'bipolar electrode pair used for this ' 'stimulation event.') stim_table.add_dataset(name='frequency', neurodata_type_inc='VectorData', doc='Frequency of stimulation waveform, in Hz.') stim_table.add_dataset(name='amplitude', neurodata_type_inc='VectorData', doc='Amplitude of stimulation waveform, in Amps.') stim_table.add_dataset(name='pulse_width', neurodata_type_inc='VectorData', doc='Pulse width of stimulation waveform, ' 'in seconds/phase') new_data_types = [stim_series, stim_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)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc='NWB extension to store pose estimation data', name='ndx-pose', version='0.1.1', author=['Ryan Ly', 'Ben Dichter', 'Alexander Mathis'], contact=[ '*****@*****.**', '*****@*****.**', '*****@*****.**' ], ) ns_builder.include_type('SpatialSeries', namespace='core') ns_builder.include_type('NWBDataInterface', 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_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='*', ), ], 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 PoseEstimationSeries 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='Cameras used to record the videos.', # quantity='*', # ), # ], ) new_data_types = [pose_estimation_series, pose_estimation] # 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) print( 'Spec files generated. Please make sure to rerun `pip install .` to load the changes.' )
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(): 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)
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 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(): ns_builder = NWBNamespaceBuilder( doc= 'Holds structures for recording data from multiple compartments of multiple ' 'neurons in a single TimeSeries', name='ndx-simulation-output', version='0.2.2', author='Ben Dichter', contact='*****@*****.**') Compartments = NWBGroupSpec( default_name='compartments', neurodata_type_def='Compartments', neurodata_type_inc='DynamicTable', doc='table that holds information about what places are being recorded' ) Compartments.add_dataset( name='number', neurodata_type_inc='VectorData', dtype='int', doc='cell compartment ids corresponding to a each column in the data') Compartments.add_dataset(name='number_index', neurodata_type_inc='VectorIndex', doc='maps cell to compartments', quantity='?') Compartments.add_dataset( name='position', neurodata_type_inc='VectorData', dtype='float', quantity='?', doc= 'position of recording within a compartment. 0 is close to soma, 1 is other end' ) Compartments.add_dataset(name='position_index', neurodata_type_inc='VectorIndex', doc='indexes position', quantity='?') Compartments.add_dataset(name='label', neurodata_type_inc='VectorData', doc='labels for compartments', dtype='text', quantity='?') Compartments.add_dataset(name='label_index', neurodata_type_inc='VectorIndex', doc='indexes label', quantity='?') CompartmentsSeries = NWBGroupSpec( neurodata_type_def='CompartmentSeries', neurodata_type_inc='TimeSeries', doc='Stores continuous data from cell compartments') CompartmentsSeries.add_link( name='compartments', target_type='Compartments', quantity='?', doc='meta-data about compartments in this CompartmentSeries') SimulationMetaData = NWBGroupSpec( name='simulation', neurodata_type_def='SimulationMetaData', neurodata_type_inc='LabMetaData', doc='group that holds metadata for simulation') SimulationMetaData.add_group( name='compartments', neurodata_type_inc='Compartments', doc='table that holds information about what places are being recorded' ) SimulationMetaData.add_attribute( name='help', dtype='text', doc='help', value='container for simulation meta-data that goes in /general') new_data_types = [Compartments, CompartmentsSeries, SimulationMetaData] types_to_include = [ 'TimeSeries', 'VectorData', 'VectorIndex', 'DynamicTable', 'LabMetaData' ] for ndtype in types_to_include: ns_builder.include_type(ndtype, namespace='core') export_spec(ns_builder, new_data_types)
# # The following block of code demonstrates how to create a new namespace, and then add a new `neurodata_type` # to this namespace. Finally, # it calls :py:meth:`~hdmf.spec.write.NamespaceBuilder.export` to save the extensions to disk for downstream use. # sphinx_gallery_thumbnail_path = 'figures/gallery_thumbnails_extensions.png' from pynwb.spec import NWBNamespaceBuilder, NWBGroupSpec, NWBAttributeSpec ns_path = "mylab.namespace.yaml" ext_source = "mylab.extensions.yaml" ns_builder = NWBNamespaceBuilder('Extension for use in my Lab', "mylab", version='0.1.0') ns_builder.include_type('ElectricalSeries', namespace='core') ext = NWBGroupSpec( 'A custom ElectricalSeries for my lab', attributes=[NWBAttributeSpec('trode_id', 'the tetrode id', 'int')], neurodata_type_inc='ElectricalSeries', neurodata_type_def='TetrodeSeries') ns_builder.add_spec(ext_source, ext) ns_builder.export(ns_path) #################### # Running this block will produce two YAML files. # # The first file, mylab.namespace.yaml, contains the specification of the namespace. #
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)
LabMetaData_ext.add_attribute( name='auditory_stim_association', doc='Descriptor of auditory stimulus-lick port association.', dtype='text', shape=None, ) LabMetaData_ext.add_attribute( name='visual_stim_association', doc='Descriptor of auditory stimulus-lick port association.', dtype='text', shape=None, ) LabMetaData_ext.add_attribute( name='behavior_version', doc='Version of schema used to translate LabView data to NWB.', dtype='text', shape=None, ) # Add the extension ext_source = 'uobrainflex.specs.yaml' ns_builder.include_type('LabMetaData', namespace='core') ns_builder.add_spec(ext_source, LabMetaData_ext) # Save the namespace and extensions ns_path = 'uobrainflex.namespace.yaml' ns_builder.export(ns_path)
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='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)
def main(): # these arguments were auto-generated from your cookiecutter inputs ns_builder = NWBNamespaceBuilder( doc="""extension for fiber photometry data""", name="""ndx-photometry""", version="""0.1.0""", author=list(map(str.strip, """Akshay Jaggi""".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("TimeSeries", namespace="core") ns_builder.include_type("NWBDataInterface", namespace="core") ns_builder.include_type("NWBContainer", namespace="core") ns_builder.include_type("RoiResponseSeries", namespace="core") ns_builder.include_type("LabMetaData", namespace="core") ns_builder.include_type("DynamicTable", namespace="hdmf-common") ns_builder.include_type("DynamicTableRegion", namespace="hdmf-common") ns_builder.include_type("VectorData", namespace="hdmf-common") ns_builder.include_type("VectorIndex", namespace="hdmf-common") ns_builder.include_type("Data", namespace="hdmf-common") ns_builder.include_type("ElementIdentifiers", namespace="hdmf-common") # TODO: define your new data types # see https://pynwb.readthedocs.io/en/latest/extensions.html#extending-nwb # for more information fibers_table = NWBGroupSpec( neurodata_type_def="FibersTable", neurodata_type_inc="DynamicTable", name='fibers', doc="Extends DynamicTable to hold various Fibers", datasets=[ NWBDatasetSpec( name="location", doc="location of fiber", dtype="text", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="excitation_source", doc="references rows of ExcitationSourcesTable", dtype="int", shape=(None,), neurodata_type_inc="DynamicTableRegion", ), NWBDatasetSpec( name="photodetector", doc="references rows of PhotodetectorsTable", dtype="int", shape=(None,), neurodata_type_inc="DynamicTableRegion", ), NWBDatasetSpec( name="fluorophores", doc="references rows of FluorophoresTable", shape=(None,), neurodata_type_inc="DynamicTableRegion", ), # NWBDatasetSpec( # name="fluorophores_index", # doc="indexes fluorophores of FluorophoresTable", # shape=(None,), # neurodata_type_inc="VectorIndex", # ), NWBDatasetSpec( name="notes", doc="description of fiber", dtype="text", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="fiber_model_number", doc="fiber model number", dtype="text", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), NWBDatasetSpec( name="dichroic_model_number", doc="dichroic model number", dtype="text", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), ], ) photodetectors_table = NWBGroupSpec( neurodata_type_def="PhotodetectorsTable", neurodata_type_inc="DynamicTable", name='photodetectors', doc="Extends DynamicTable to hold various Photodetectors", datasets=[ NWBDatasetSpec( name="peak_wavelength", doc="peak wavelength of photodetector", dtype="float", shape=(None,), neurodata_type_inc="VectorData", attributes=[ NWBAttributeSpec( name="unit", doc="wavelength unit", value="nanometers", dtype="text" ) ], ), NWBDatasetSpec( name="type", doc='"PMT" or "photodiode"', dtype="text", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="gain", doc="gain on the photodetector", dtype="float", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="model_number", doc="model number of the photodector", dtype="text", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), ], ) excitationsources_table = NWBGroupSpec( neurodata_type_def="ExcitationSourcesTable", neurodata_type_inc="DynamicTable", name="excitation_sources", doc="Extends DynamicTable to hold various Excitation Sources", datasets=[ NWBDatasetSpec( name="peak_wavelength", doc="peak wavelength of the excitation source", dtype="float", shape=(None,), neurodata_type_inc="VectorData", attributes=[ NWBAttributeSpec( name="unit", doc="wavelength unit", value="nanometers", dtype="text" ) ], ), NWBDatasetSpec( name="source_type", doc='"LED" or "laser"', dtype="text", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="commanded_voltage", doc="references CommandedVoltageSeries", dtype=NWBRefSpec( target_type="CommandedVoltageSeries", reftype="object" ), shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="output", doc="excitation output, references TimeSeries", dtype="float", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), NWBDatasetSpec( name="model_number", doc="model number of the excitation source", dtype="text", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), ], ) commandedvoltage_series = NWBGroupSpec( neurodata_type_def="CommandedVoltageSeries", neurodata_type_inc="TimeSeries", doc="Extends TimeSeries to hold a Commanded Voltage", datasets=[ NWBDatasetSpec( name="data", doc="voltages (length number timesteps) in unit volts", dtype="float", shape=(None,), attributes=[ NWBAttributeSpec( name="unit", doc="data unit", value="volts", dtype="text" ) ], ), NWBDatasetSpec( name="frequency", doc="voltage frequency in unit hertz", dtype="float", attributes=[ NWBAttributeSpec( name="unit", doc="frequency unit", value="hertz", dtype="text" ) ], ), NWBDatasetSpec( name="power", doc="voltage power in unit volts", dtype="float", attributes=[ NWBAttributeSpec( name="unit", doc="power unit", value="volts", dtype="text" ) ], ), ], ) multi_commanded_voltage = NWBGroupSpec( name='commanded_voltages', neurodata_type_def="MultiCommandedVoltage", neurodata_type_inc="NWBDataInterface", doc="holds CommandedVoltageSeries objects", groups=[ NWBGroupSpec( neurodata_type_inc="CommandedVoltageSeries", quantity="*", doc="commanded voltage series", ) ], ) deconvolvedroiresponse_series = NWBGroupSpec( neurodata_type_def="DeconvolvedRoiResponseSeries", neurodata_type_inc="RoiResponseSeries", doc="Extends RoiResponseSeries to hold deconvolved data", links=[ NWBLinkSpec( name="raw", target_type="RoiResponseSeries", doc="ref to roi response series", ) ], datasets=[ NWBDatasetSpec( name="deconvolution_filter", doc="description of deconvolution filter used", dtype="text", neurodata_type_inc="VectorData", quantity="?", ), NWBDatasetSpec( name="downsampling_filter", doc="description of downsampling filter used", dtype="text", neurodata_type_inc="VectorData", quantity="?", ), ], ) fluorophores_table = NWBGroupSpec( neurodata_type_def="FluorophoresTable", neurodata_type_inc="DynamicTable", name='fluorophores', doc="Extends DynamicTable to hold various Fluorophores", datasets=[ NWBDatasetSpec( name="label", doc="name of fluorophore", dtype="text", shape=(None,), neurodata_type_inc="VectorData", ), NWBDatasetSpec( name="location", doc='injection brain region name', dtype="text", shape=(None,), neurodata_type_inc="VectorData", quantity="?", ), NWBDatasetSpec( name="coordinates", doc="injection taxonomical coordinates in (AP, ML, Z) in mm relative to Bregma", dtype="float", shape=(None,3), neurodata_type_inc="VectorData", quantity="?", ), ], ) fiber_photometry = NWBGroupSpec( neurodata_type_def='FiberPhotometry', neurodata_type_inc='LabMetaData', name='fiber_photometry', doc='all Fiber Photometry metadata', groups=[ NWBGroupSpec( name='fibers', neurodata_type_inc='FibersTable', doc='table of fibers used' ), NWBGroupSpec( name='excitation_sources', neurodata_type_inc='ExcitationSourcesTable', doc='table of excitation sources used' ), NWBGroupSpec( name='photodetectors', neurodata_type_inc='PhotodetectorsTable', doc='table of photodetectors used' ), NWBGroupSpec( name='fluorophores', neurodata_type_inc='FluorophoresTable', doc='table of fluorophores used' ), NWBGroupSpec( name='commanded_voltages', neurodata_type_inc='MultiCommandedVoltage', doc='multiple commanded voltage container' ) ] ) # TODO: add all of your new data types to this list new_data_types = [ fibers_table, photodetectors_table, excitationsources_table, commandedvoltage_series, deconvolvedroiresponse_series, multi_commanded_voltage, fiber_photometry, fluorophores_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)