Source code for allensdk.brain_observatory.behavior.write_nwb.extensions.stimulus_template.extension_builder
import os.path
from pynwb.spec import NWBNamespaceBuilder, export_spec, NWBGroupSpec, \
NWBDatasetSpec
NAMESPACE = 'ndx-aibs-stimulus-template'
[docs]def main():
ns_builder = NWBNamespaceBuilder(
doc="Stimulus images",
name=f"""{NAMESPACE}""",
version="""0.1.0""",
author="""Allen Institute for Brain Science""",
contact="""waynew@alleninstitute.org"""
)
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)
if __name__ == "__main__":
# usage: python create_extension_spec.py
main()