From 9dd7304334fdd88c2e5dc80babed4939ca59d681 Mon Sep 17 00:00:00 2001 From: sneakers-the-rat Date: Thu, 31 Aug 2023 20:56:21 -0700 Subject: [PATCH] Working recursion! and also handling multiple array shapes, and properly handling unnamed classes --- nwb_linkml/adapters/adapter.py | 29 +- nwb_linkml/adapters/classes.py | 23 +- nwb_linkml/adapters/dataset.py | 48 ++ nwb_linkml/adapters/group.py | 121 ++++- nwb_linkml/adapters/namespaces.py | 16 +- nwb_linkml/adapters/schema.py | 33 +- nwb_linkml/generators/pydantic.py | 42 +- nwb_linkml/maps/dtype.py | 2 +- nwb_linkml/models/core.py | 13 +- nwb_linkml/models/core_nwb_base.py | 147 +++--- nwb_linkml/models/core_nwb_base_include.py | 89 ++-- nwb_linkml/models/core_nwb_behavior.py | 65 +-- .../models/core_nwb_behavior_include.py | 25 +- nwb_linkml/models/core_nwb_device.py | 16 +- nwb_linkml/models/core_nwb_device_include.py | 33 -- nwb_linkml/models/core_nwb_ecephys.py | 108 ++--- nwb_linkml/models/core_nwb_ecephys_include.py | 159 ++---- nwb_linkml/models/core_nwb_epoch.py | 30 +- nwb_linkml/models/core_nwb_epoch_include.py | 51 +- nwb_linkml/models/core_nwb_file.py | 74 +-- nwb_linkml/models/core_nwb_file_include.py | 423 +++------------- nwb_linkml/models/core_nwb_icephys.py | 183 +++---- nwb_linkml/models/core_nwb_icephys_include.py | 218 +++++---- nwb_linkml/models/core_nwb_image.py | 201 ++++---- nwb_linkml/models/core_nwb_image_include.py | 94 ++-- nwb_linkml/models/core_nwb_misc.py | 95 ++-- nwb_linkml/models/core_nwb_misc_include.py | 237 +++++---- nwb_linkml/models/core_nwb_ogen.py | 31 +- nwb_linkml/models/core_nwb_ogen_include.py | 15 +- nwb_linkml/models/core_nwb_ophys.py | 121 ++--- nwb_linkml/models/core_nwb_ophys_include.py | 156 +++--- nwb_linkml/models/core_nwb_retinotopy.py | 31 +- .../models/core_nwb_retinotopy_include.py | 84 ++-- nwb_linkml/models/hdmf_common.py | 13 +- nwb_linkml/models/hdmf_common_base.py | 26 +- nwb_linkml/models/hdmf_common_base_include.py | 33 -- nwb_linkml/models/hdmf_common_sparse.py | 28 +- .../models/hdmf_common_sparse_include.py | 57 --- nwb_linkml/models/hdmf_common_table.py | 121 +++-- .../models/hdmf_common_table_include.py | 30 +- nwb_linkml/models/hdmf_experimental.py | 13 +- .../models/hdmf_experimental_experimental.py | 23 +- .../hdmf_experimental_experimental_include.py | 33 -- .../models/hdmf_experimental_resources.py | 37 +- .../hdmf_experimental_resources_include.py | 85 ---- nwb_linkml/models/nwb_language.py | 15 +- nwb_linkml/namespaces.py | 2 +- nwb_linkml/schema/core.nwb.base.include.yaml | 74 +-- nwb_linkml/schema/core.nwb.base.yaml | 69 ++- .../schema/core.nwb.behavior.include.yaml | 6 + nwb_linkml/schema/core.nwb.behavior.yaml | 68 ++- .../schema/core.nwb.device.include.yaml | 8 - nwb_linkml/schema/core.nwb.device.yaml | 6 +- .../schema/core.nwb.ecephys.include.yaml | 188 ++----- nwb_linkml/schema/core.nwb.ecephys.yaml | 98 +++- nwb_linkml/schema/core.nwb.epoch.include.yaml | 21 + nwb_linkml/schema/core.nwb.epoch.yaml | 5 + nwb_linkml/schema/core.nwb.file.include.yaml | 458 ++++-------------- nwb_linkml/schema/core.nwb.file.yaml | 56 ++- .../schema/core.nwb.icephys.include.yaml | 167 +++++-- nwb_linkml/schema/core.nwb.icephys.yaml | 100 +++- nwb_linkml/schema/core.nwb.image.include.yaml | 103 +--- nwb_linkml/schema/core.nwb.image.yaml | 48 +- nwb_linkml/schema/core.nwb.misc.include.yaml | 197 ++++---- nwb_linkml/schema/core.nwb.misc.yaml | 43 +- nwb_linkml/schema/core.nwb.ogen.include.yaml | 24 - nwb_linkml/schema/core.nwb.ogen.yaml | 15 +- nwb_linkml/schema/core.nwb.ophys.include.yaml | 76 ++- nwb_linkml/schema/core.nwb.ophys.yaml | 85 +++- .../schema/core.nwb.retinotopy.include.yaml | 82 ++-- nwb_linkml/schema/core.nwb.retinotopy.yaml | 9 +- .../schema/hdmf-common.base.include.yaml | 7 - nwb_linkml/schema/hdmf-common.base.yaml | 22 +- .../schema/hdmf-common.sparse.include.yaml | 39 -- nwb_linkml/schema/hdmf-common.sparse.yaml | 18 +- .../schema/hdmf-common.table.include.yaml | 11 - nwb_linkml/schema/hdmf-common.table.yaml | 38 +- ...dmf-experimental.experimental.include.yaml | 8 - .../hdmf-experimental.experimental.yaml | 6 +- .../hdmf-experimental.resources.include.yaml | 79 --- .../schema/hdmf-experimental.resources.yaml | 30 +- nwb_linkml/schema/nwb.language.yaml | 2 +- pytest.ini | 4 + scripts/generate_core.py | 2 +- tests/test_adapter.py | 22 + tests/test_adapter_dataset.py | 4 + tests/test_adapter_group.py | 4 + ..._adapter.py => test_adapter_namespaces.py} | 18 +- tests/test_adapter_schema.py | 14 + tests/test_adapters/__init__.py | 0 tests/test_adapters/test_adapter_dataset.py | 1 - tests/test_generate.py | 2 + 92 files changed, 2735 insertions(+), 3131 deletions(-) delete mode 100644 nwb_linkml/models/core_nwb_device_include.py delete mode 100644 nwb_linkml/models/hdmf_common_base_include.py delete mode 100644 nwb_linkml/models/hdmf_common_sparse_include.py delete mode 100644 nwb_linkml/models/hdmf_experimental_experimental_include.py delete mode 100644 nwb_linkml/models/hdmf_experimental_resources_include.py delete mode 100644 nwb_linkml/schema/core.nwb.device.include.yaml delete mode 100644 nwb_linkml/schema/core.nwb.ogen.include.yaml delete mode 100644 nwb_linkml/schema/hdmf-common.base.include.yaml delete mode 100644 nwb_linkml/schema/hdmf-common.sparse.include.yaml delete mode 100644 nwb_linkml/schema/hdmf-experimental.experimental.include.yaml delete mode 100644 nwb_linkml/schema/hdmf-experimental.resources.include.yaml create mode 100644 pytest.ini create mode 100644 tests/test_adapter.py create mode 100644 tests/test_adapter_dataset.py create mode 100644 tests/test_adapter_group.py rename tests/{test_adapters/test_adapter.py => test_adapter_namespaces.py} (57%) create mode 100644 tests/test_adapter_schema.py delete mode 100644 tests/test_adapters/__init__.py delete mode 100644 tests/test_adapters/test_adapter_dataset.py diff --git a/nwb_linkml/adapters/adapter.py b/nwb_linkml/adapters/adapter.py index 6d466c1..a33e0fc 100644 --- a/nwb_linkml/adapters/adapter.py +++ b/nwb_linkml/adapters/adapter.py @@ -46,6 +46,26 @@ class BuildResult: self.types.extend(other.types) return self + def __repr__(self): + out_str = "\nBuild Result:\n" + out_str += '-'*len(out_str) + + for label, alist in ( + ('Schemas', self.schemas), + ('Classes', self.classes), + ('Slots', self.slots), + ('Types', self.types)): + if len(alist) == 0: + continue + + name_str = "\n\n" + label + ':' + name_str += "\n" + '-'*len(name_str) + '\n' + name_list = sorted([i.name for i in alist]) + item_str = '\n '.join(name_list) + out_str += name_str + item_str + + return out_str + T = TypeVar Ts = TypeVarTuple('Ts') @@ -59,7 +79,14 @@ class Adapter(BaseModel): def walk(self, input: BaseModel | list | dict): yield input if isinstance(input, BaseModel): - for key in input.__fields__.keys(): + + for key in input.model_fields.keys(): + # Special case where SchemaAdapter Imports are themselves + # SchemaAdapters that should be located under the same + # NamespacesAdapter when it's important to query across SchemaAdapters, + # so skip to avoid combinatoric walking + if key == 'imports' and type(input).__name__ == "SchemaAdapter": + continue val = getattr(input, key) yield (key, val) if isinstance(val, (BaseModel, dict, list)): diff --git a/nwb_linkml/adapters/classes.py b/nwb_linkml/adapters/classes.py index f145a55..5eb89cc 100644 --- a/nwb_linkml/adapters/classes.py +++ b/nwb_linkml/adapters/classes.py @@ -51,25 +51,28 @@ class ClassAdapter(Adapter): # Build this class #name = self._get_full_name() + kwargs = {} if self.parent is not None: - name = self._get_full_name() + kwargs['name'] = self._get_full_name() else: - name = self._get_attr_name() + kwargs['name'] = self._get_attr_name() + kwargs['tree_root'] = True - # Get vanilla top-level attributes - attrs = self.build_attrs(self.cls) + # Attributes name_slot = self.build_name_slot() - attrs.append(name_slot) + kwargs['attributes'] = [name_slot] + # Get vanilla top-level attributes + kwargs['attributes'].extend(self.build_attrs(self.cls)) + if extra_attrs is not None: if isinstance(extra_attrs, SlotDefinition): extra_attrs = [extra_attrs] - attrs.extend(extra_attrs) + kwargs['attributes'].extend(extra_attrs) + kwargs['description'] = self.cls.doc + kwargs['is_a'] = self.cls.neurodata_type_inc cls = ClassDefinition( - name = name, - is_a = self.cls.neurodata_type_inc, - description=self.cls.doc, - attributes=attrs, + **kwargs ) slots = [] diff --git a/nwb_linkml/adapters/dataset.py b/nwb_linkml/adapters/dataset.py index 793eba0..eb17fb7 100644 --- a/nwb_linkml/adapters/dataset.py +++ b/nwb_linkml/adapters/dataset.py @@ -23,8 +23,12 @@ class DatasetAdapter(ClassAdapter): res = self.handle_arraylike(res, self.cls, self._get_full_name()) res = self.handle_1d_vector(res) + res = self.handle_listlike(res) res = self.handle_scalar(res) + if len(self._handlers) > 1: + raise RuntimeError(f"Only one handler should have been triggered, instead triggered {self._handlers}") + return res def handle_scalar(self, res:BuildResult) -> BuildResult: @@ -70,6 +74,47 @@ class DatasetAdapter(ClassAdapter): return res + def handle_listlike(self, res:BuildResult) -> BuildResult: + """ + Handle cases where the dataset is just a list of a specific type. + + Examples: + + datasets: + - name: file_create_date + dtype: isodatetime + dims: + - num_modifications + shape: + - null + + """ + if self.cls.name and (( + # single-layer list + not any([isinstance(dim, list) for dim in self.cls.dims]) and + len(self.cls.dims) == 1 + ) or ( + # nested list + all([isinstance(dim, list) for dim in self.cls.dims]) and + len(self.cls.dims) == 1 and + len(self.cls.dims[0]) == 1 + )): + res = BuildResult( + slots = [ + SlotDefinition( + name = self.cls.name, + multivalued=True, + range=self.handle_dtype(self.cls.dtype), + description=self.cls.doc, + required=False if self.cls.quantity in ('*', '?') else True + ) + ] + ) + return res + else: + return res + + def handle_arraylike(self, res: BuildResult, dataset: Dataset, name: Optional[str] = None) -> BuildResult: """ Handling the @@ -150,6 +195,9 @@ class DatasetAdapter(ClassAdapter): # if a dim is present in all possible combinations of dims, make it required if all([dims in inner_dim for inner_dim in dataset.dims]): required = True + # or if there is just a single list of possible dimensions + elif not any([isinstance(inner_dim, list) for inner_dim in dataset.dims]): + required = True else: required = False diff --git a/nwb_linkml/adapters/group.py b/nwb_linkml/adapters/group.py index a7d5bff..11dde34 100644 --- a/nwb_linkml/adapters/group.py +++ b/nwb_linkml/adapters/group.py @@ -6,7 +6,7 @@ from typing import List from linkml_runtime.linkml_model import ClassDefinition, SlotDefinition from nwb_schema_language import Dataset, Group, ReferenceDtype, CompoundDtype, DTypeType -from nwb_linkml.adapters.classes import ClassAdapter +from nwb_linkml.adapters.classes import ClassAdapter, camel_to_snake from nwb_linkml.adapters.dataset import DatasetAdapter from nwb_linkml.adapters.adapter import BuildResult from nwb_linkml.maps import QUANTITY_MAP @@ -16,6 +16,17 @@ class GroupAdapter(ClassAdapter): def build(self) -> BuildResult: + # Handle container groups with only * quantity unnamed groups + if len(self.cls.groups) > 0 and \ + all([self._check_if_container(g) for g in self.cls.groups]) and \ + self.parent is not None: + return self.handle_container_group(self.cls) + + # handle if we are a terminal container group without making a new class + if len(self.cls.groups) == 0 and \ + self.cls.neurodata_type_inc is not None and \ + self.parent is not None: + return self.handle_container_slot(self.cls) nested_res = self.build_subclasses() # we don't propagate slots up to the next level since they are meant for this @@ -26,21 +37,78 @@ class GroupAdapter(ClassAdapter): return res - def handle_children(self, children: List[Group]) -> BuildResult: + def handle_container_group(self, cls: Group) -> BuildResult: """ Make a special LinkML `children` slot that can have any number of the objects that are of `neurodata_type_inc` class + Examples: + - name: templates + groups: + - neurodata_type_inc: TimeSeries + doc: TimeSeries objects containing template data of presented stimuli. + quantity: '*' + - neurodata_type_inc: Images + doc: Images objects containing images of presented stimuli. + quantity: '*' + Args: children (List[:class:`.Group`]): Child groups """ - child_slot = SlotDefinition( - name='children', - multivalued=True, - any_of=[{'range': cls.neurodata_type_inc} for cls in children] + + # don't build subgroups as their own classes, just make a slot + # that can contain them + if not self.cls.name: + name = 'children' + else: + name = cls.name + + res = BuildResult( + slots = [SlotDefinition( + name=name, + multivalued=True, + description=cls.doc, + any_of=[{'range': subcls.neurodata_type_inc} for subcls in cls.groups] + )] ) - return BuildResult(slots=[child_slot]) + return res + + def handle_container_slot(self, cls:Group) -> BuildResult: + """ + Handle subgroups that contain arbitrarily numbered classes, + + eg. *each* of the groups in + + Examples: + - name: trials + neurodata_type_inc: TimeIntervals + doc: Repeated experimental events that have a logical grouping. + quantity: '?' + - name: invalid_times + neurodata_type_inc: TimeIntervals + doc: Time intervals that should be removed from analysis. + quantity: '?' + - neurodata_type_inc: TimeIntervals + doc: Optional additional table(s) for describing other experimental time intervals. + quantity: '*' + """ + if not self.cls.name: + name = camel_to_snake(self.cls.neurodata_type_inc) + else: + name = cls.name + + return BuildResult( + slots = [ + SlotDefinition( + name=name, + range=self.cls.neurodata_type_inc, + description=self.cls.doc, + **QUANTITY_MAP[cls.quantity] + ) + ] + ) + def build_subclasses(self) -> BuildResult: """ @@ -66,24 +134,35 @@ class GroupAdapter(ClassAdapter): # eg. a group can have multiple groups with `neurodata_type_inc`, no name, and quantity of *, # the group can then contain any number of groups of those included types as direct children - # group_res = BuildResult() - # children = [] - # for group in self.cls.groups: - # if not group.name and \ - # group.quantity == '*' and \ - # group.neurodata_type_inc: - # children.append(group) - # else: - # group_adapter = GroupAdapter(cls=group, parent=self) - # group_res += group_adapter.build() - # - # group_res += self.handle_children(children) - group_res = BuildResult() + for group in self.cls.groups: group_adapter = GroupAdapter(cls=group, parent=self) group_res += group_adapter.build() res = dataset_res + group_res - return res \ No newline at end of file + return res + + def _check_if_container(self, group:Group) -> bool: + """ + Check if a given subgroup is a container subgroup, + + ie. whether it's used to indicate a possible type for a child, as in: + + - name: templates + groups: + - neurodata_type_inc: TimeSeries + doc: TimeSeries objects containing template data of presented stimuli. + quantity: '*' + - neurodata_type_inc: Images + doc: Images objects containing images of presented stimuli. + quantity: '*' + """ + if not group.name and \ + group.quantity == '*' and \ + group.neurodata_type_inc: + return True + else: + return False + diff --git a/nwb_linkml/adapters/namespaces.py b/nwb_linkml/adapters/namespaces.py index b0f687d..d939953 100644 --- a/nwb_linkml/adapters/namespaces.py +++ b/nwb_linkml/adapters/namespaces.py @@ -74,6 +74,8 @@ class NamespacesAdapter(Adapter): def find_type_source(self, name:str) -> SchemaAdapter: """ Given some neurodata_type_inc, find the schema that it's defined in. + + Rather than returning as soon as a match is found, check all """ # First check within the main schema internal_matches = [] @@ -82,6 +84,12 @@ class NamespacesAdapter(Adapter): if name in class_names: internal_matches.append(schema) + if len(internal_matches) > 1: + raise KeyError( + f"Found multiple schemas in namespace that define {name}:\ninternal: {pformat(internal_matches)}\nimported:{pformat(import_matches)}") + elif len(internal_matches) == 1: + return internal_matches[0] + import_matches = [] for imported_ns in self.imported: for schema in imported_ns.schemas: @@ -89,12 +97,10 @@ class NamespacesAdapter(Adapter): if name in class_names: import_matches.append(schema) - all_matches = [*internal_matches, *import_matches] - - if len(all_matches)>1: + if len(import_matches)>1: raise KeyError(f"Found multiple schemas in namespace that define {name}:\ninternal: {pformat(internal_matches)}\nimported:{pformat(import_matches)}") - elif len(all_matches) == 1: - return all_matches[0] + elif len(import_matches) == 1: + return import_matches[0] else: raise KeyError(f"No schema found that define {name}") diff --git a/nwb_linkml/adapters/schema.py b/nwb_linkml/adapters/schema.py index 1c4a878..d96097f 100644 --- a/nwb_linkml/adapters/schema.py +++ b/nwb_linkml/adapters/schema.py @@ -2,10 +2,10 @@ Since NWB doesn't necessarily have a term for a single nwb schema file, we're going to call them "schema" objects """ - -from typing import Optional, List, TYPE_CHECKING +import pdb +from typing import Optional, List, TYPE_CHECKING, Type from pathlib import Path -from pydantic import Field +from pydantic import Field, PrivateAttr from nwb_linkml.adapters.adapter import Adapter, BuildResult from nwb_linkml.adapters.dataset import DatasetAdapter @@ -21,7 +21,7 @@ from linkml_runtime.linkml_model import SchemaDefinition class SplitSchema(NamedTuple): main: BuildResult - split: BuildResult + split: Optional[BuildResult] class SchemaAdapter(Adapter): """ @@ -38,6 +38,7 @@ class SchemaAdapter(Adapter): True, description="Split anonymous subclasses into a separate schema file" ) + _created_classes: List[Type[Group | Dataset]] = PrivateAttr(default_factory=list) @property def name(self) -> str: @@ -118,7 +119,8 @@ class SchemaAdapter(Adapter): # need to mutually import the two schemas because the subclasses # could refer to the main classes main_imports = imports - main_imports.append(split_sch_name) + if len(split_classes)>0: + main_imports.append(split_sch_name) imports.append(self.name) main_sch = SchemaDefinition( name=self.name, @@ -128,6 +130,7 @@ class SchemaAdapter(Adapter): slots=classes.slots, types=classes.types ) + split_sch = SchemaDefinition( name=split_sch_name, id=split_sch_name, @@ -136,17 +139,23 @@ class SchemaAdapter(Adapter): slots=classes.slots, types=classes.types ) - res = BuildResult( - schemas=[main_sch, split_sch] - ) + if len(split_classes) > 0: + res = BuildResult( + schemas=[main_sch, split_sch] + ) + else: + res = BuildResult( + schemas=[main_sch] + ) return res @property - def created_classes(self) -> List[Group|Dataset]: - classes = [t for t in self.walk_types([self.groups, self.datasets], (Group, Dataset)) if t.neurodata_type_def is not None] - return classes + def created_classes(self) -> List[Type[Group | Dataset]]: + if len(self._created_classes) == 0: + self._created_classes = [t for t in self.walk_types([self.groups, self.datasets], (Group, Dataset)) if t.neurodata_type_def is not None] + return self._created_classes @property def needed_imports(self) -> List[str]: @@ -164,5 +173,3 @@ class SchemaAdapter(Adapter): return need - - diff --git a/nwb_linkml/generators/pydantic.py b/nwb_linkml/generators/pydantic.py index d9ef96d..8a85731 100644 --- a/nwb_linkml/generators/pydantic.py +++ b/nwb_linkml/generators/pydantic.py @@ -131,6 +131,9 @@ class {{ c.name }} {{attr.name}}: {{ attr.annotations['python_range'].value }} = Field( {%- if predefined_slot_values[c.name][attr.name] -%} {{ predefined_slot_values[c.name][attr.name] }} + {%- if attr.equals_string -%} + , const=True + {%- endif -%} {%- elif attr.required -%} ... {%- else -%} @@ -182,6 +185,10 @@ class NWBPydanticGenerator(PydanticGenerator): for slot_name, slot in cls.attributes.items(): if slot.range in all_classes: needed_classes.append(slot.range) + if slot.any_of: + for any_slot_range in slot.any_of: + if any_slot_range.range in all_classes: + needed_classes.append(any_slot_range.range) needed_classes = [cls for cls in set(needed_classes) if cls is not None] imports = {} @@ -245,16 +252,16 @@ class NWBPydanticGenerator(PydanticGenerator): if not base_range_subsumes_any_of: raise ValueError("Slot cannot have both range and any_of defined") - def _get_numpy_slot_range(self, cls:ClassDefinition) -> str: + def _make_npytyping_range(self, attrs: Dict[str, SlotDefinition]) -> str: # slot always starts with... - prefix='NDArray[' + prefix = 'NDArray[' # and then we specify the shape: shape_prefix = 'Shape["' # using the cardinality from the attributes dim_pieces = [] - for attr in cls.attributes.values(): + for attr in attrs.values(): if attr.maximum_cardinality: shape_part = str(attr.maximum_cardinality) @@ -271,16 +278,41 @@ class NWBPydanticGenerator(PydanticGenerator): # all dimensions should be the same dtype try: - dtype = flat_to_npytyping[list(cls.attributes.values())[0].range] + dtype = flat_to_npytyping[list(attrs.values())[0].range] except KeyError as e: warnings.warn(e) - range = list(cls.attributes.values())[0].range + range = list(attrs.values())[0].range return f'List[{range}] | {range}' suffix = "]" slot = ''.join([prefix, shape_prefix, dimension, shape_suffix, dtype, suffix]) return slot + def _get_numpy_slot_range(self, cls:ClassDefinition) -> str: + # if none of the dimensions are optional, we just have one possible array shape + if all([s.required for s in cls.attributes.values()]): + return self._make_npytyping_range(cls.attributes) + # otherwise we need to make permutations + # but not all permutations, because we typically just want to be able to exlude the last possible dimensions + # the array classes should always be well-defined where the optional dimensions are at the end, so + requireds = {k:v for k,v in cls.attributes.items() if v.required} + optionals = [(k,v) for k, v in cls.attributes.items() if not v.required] + + annotations = [] + if len(requireds) > 0: + # first the base case + annotations.append(self._make_npytyping_range(requireds)) + # then add back each optional dimension + for i in range(len(optionals)): + attrs = {**requireds, **{k:v for k, v in optionals[0:i+1]}} + annotations.append(self._make_npytyping_range(attrs)) + + # now combine with a union: + union = "Union[\n" + ' '*8 + union += (',\n' + ' '*8).join(annotations) + union += '\n' + ' '*4 + ']' + return union + def sort_classes(self, clist: List[ClassDefinition], imports:List[str]) -> List[ClassDefinition]: """ diff --git a/nwb_linkml/maps/dtype.py b/nwb_linkml/maps/dtype.py index 008a05f..dd6cec6 100644 --- a/nwb_linkml/maps/dtype.py +++ b/nwb_linkml/maps/dtype.py @@ -24,7 +24,7 @@ flat_to_linkml = { "utf_8" : "string", "ascii" : "string", "bool" : "boolean", - "isodatetime" : "date" + "isodatetime" : "datetime" } """ Map between the flat data types and the simpler linkml base types diff --git a/nwb_linkml/models/core.py b/nwb_linkml/models/core.py index ac69d88..d17657b 100644 --- a/nwb_linkml/models/core.py +++ b/nwb_linkml/models/core.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "2.6.0-alpha" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -29,5 +25,6 @@ class ConfiguredBaseModel(WeakRefShimBaseModel, -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_base.py b/nwb_linkml/models/core_nwb_base.py index 16451d9..8ba36a9 100644 --- a/nwb_linkml/models/core_nwb_base.py +++ b/nwb_linkml/models/core_nwb_base.py @@ -11,39 +11,32 @@ else: from typing_extensions import Literal -from .core_nwb_base_include import ( - TimeSeriesSync, - TimeSeriesControlDescription, - # ImageReferencesArray, - ImageArray, - TimeSeriesControl, - TimeSeriesData, - # ImagesOrderOfImages, - TimeSeriesTimestamps, - TimeSeriesStartingTime +from .hdmf_common_table import ( + DynamicTable, + VectorData ) from .hdmf_common_base import ( - Container, - Data + Data, + Container ) -# from .hdmf_common_table import ( -# DynamicTable, -# VectorData -# ) +from .core_nwb_base_include import ( + TimeSeriesStartingTime, + ImageArray, + ImageReferencesArray, + TimeSeriesSync, + ImagesOrderOfImages, + TimeSeriesData +) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -54,88 +47,104 @@ class NWBData(Data): """ An abstract data type for a dataset. """ - None + name: str = Field(...) -# class TimeSeriesReferenceVectorData(VectorData): -# """ -# 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. -# """ -# description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") -# array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any]] = Field(None) -# +class TimeSeriesReferenceVectorData(VectorData): + """ + 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. + """ + name: str = Field(...) + description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) + class Image(NWBData): """ An abstract data type for an image. Shape can be 2-D (x, y), or 3-D where the third dimension can have three or four elements, e.g. (x, y, (r, g, b)) or (x, y, (r, g, b, a)). """ + name: str = Field(...) resolution: Optional[float] = Field(None, description="""Pixel resolution of the image, in pixels per centimeter.""") description: Optional[str] = Field(None, description="""Description of the image.""") - array: Optional[NDArray[Shape["* x, * y, 3 r_g_b, 4 r_g_b_a"], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* x, * y"], Number], + NDArray[Shape["* x, * y, 3 r_g_b"], Number], + NDArray[Shape["* x, * y, 3 r_g_b, 4 r_g_b_a"], Number] + ]] = Field(None) -# class ImageReferences(NWBData): -# """ -# Ordered dataset of references to Image objects. -# """ -# array: Optional[List[Image] | Image] = Field(None) -# +class ImageReferences(NWBData): + """ + Ordered dataset of references to Image objects. + """ + name: str = Field(...) + array: Optional[List[Image] | Image] = Field(None) + class NWBContainer(Container): """ An abstract data type for a generic container storing collections of data and metadata. Base type for all data and metadata containers. """ - None + name: str = Field(...) class NWBDataInterface(NWBContainer): """ An abstract data type for a generic container storing collections of data, as opposed to metadata. """ - None + name: str = Field(...) class TimeSeries(NWBDataInterface): """ General purpose time series. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") data: TimeSeriesData = Field(..., description="""Data values. Data can be in 1-D, 2-D, 3-D, or 4-D. The first dimension should always represent time. This can also be used to store binary data (e.g., image frames). This can also be a link to data stored in an external file.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") -# class ProcessingModule(NWBContainer): -# """ -# A collection of processed data. -# """ -# description: Optional[str] = Field(None, description="""Description of this collection of processed data.""") -# NWBDataInterface: Optional[List[NWBDataInterface]] = Field(default_factory=list, description="""Data objects stored in this collection.""") -# DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""Tables stored in this collection.""") -# +class ProcessingModule(NWBContainer): + """ + A collection of processed data. + """ + name: str = Field(...) + description: Optional[str] = Field(None, description="""Description of this collection of processed data.""") + nwb_data_interface: Optional[List[NWBDataInterface]] = Field(default_factory=list, description="""Data objects stored in this collection.""") + dynamic_table: Optional[List[DynamicTable]] = Field(default_factory=list, description="""Tables stored in this collection.""") + -# class Images(NWBDataInterface): -# """ -# A collection of images with an optional way to specify the order of the images using the \"order_of_images\" dataset. An order must be specified if the images are referenced by index, e.g., from an IndexSeries. -# """ -# description: Optional[str] = Field(None, description="""Description of this collection of images.""") -# Image: List[Image] = Field(default_factory=list, description="""Images stored in this collection.""") -# order_of_images: Optional[ImagesOrderOfImages] = Field(None, description="""Ordered dataset of references to Image objects stored in the parent group. Each Image object in the Images group should be stored once and only once, so the dataset should have the same length as the number of images.""") -# +class Images(NWBDataInterface): + """ + A collection of images with an optional way to specify the order of the images using the \"order_of_images\" dataset. An order must be specified if the images are referenced by index, e.g., from an IndexSeries. + """ + name: str = Field(...) + description: Optional[str] = Field(None, description="""Description of this collection of images.""") + Image: List[Image] = Field(default_factory=list, description="""Images stored in this collection.""") + order_of_images: Optional[ImagesOrderOfImages] = Field(None, description="""Ordered dataset of references to Image objects stored in the parent group. Each Image object in the Images group should be stored once and only once, so the dataset should have the same length as the number of images.""") + -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -NWBData.update_forward_refs() -# TimeSeriesReferenceVectorData.update_forward_refs() -Image.update_forward_refs() -# ImageReferences.update_forward_refs() -NWBContainer.update_forward_refs() -NWBDataInterface.update_forward_refs() -TimeSeries.update_forward_refs() -# ProcessingModule.update_forward_refs() -# Images.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +NWBData.model_rebuild() +TimeSeriesReferenceVectorData.model_rebuild() +Image.model_rebuild() +ImageReferences.model_rebuild() +NWBContainer.model_rebuild() +NWBDataInterface.model_rebuild() +TimeSeries.model_rebuild() +ProcessingModule.model_rebuild() +Images.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_base_include.py b/nwb_linkml/models/core_nwb_base_include.py index 1468540..6eb4c60 100644 --- a/nwb_linkml/models/core_nwb_base_include.py +++ b/nwb_linkml/models/core_nwb_base_include.py @@ -15,22 +15,18 @@ from .nwb_language import ( Arraylike ) -# from .core_nwb_base import ( -# ImageReferences, -# Image -# ) +from .core_nwb_base import ( + ImageReferences, + Image +) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -45,21 +41,27 @@ class ImageArray(Arraylike): r_g_b_a: Optional[float] = Field(None) -# class ImageReferencesArray(Arraylike): -# -# num_images: Image = Field(...) +class ImageReferencesArray(Arraylike): + + num_images: Image = Field(...) class TimeSeriesData(ConfiguredBaseModel): """ Data values. Data can be in 1-D, 2-D, 3-D, or 4-D. The first dimension should always represent time. This can also be used to store binary data (e.g., image frames). This can also be a link to data stored in an external file. """ + name: str = Field("data", const=True) conversion: Optional[float] = Field(None, description="""Scalar to multiply each element in data to convert it to the specified 'unit'. If the data are stored in acquisition system units or other units that require a conversion to be interpretable, multiply the data by 'conversion' to convert the data to the specified 'unit'. e.g. if the data acquisition system stores values in this object as signed 16-bit integers (int16 range -32,768 to 32,767) that correspond to a 5V range (-2.5V to 2.5V), and the data acquisition system gain is 8000X, then the 'conversion' multiplier to get from raw data acquisition values to recorded volts is 2.5/32768/8000 = 9.5367e-9.""") offset: Optional[float] = Field(None, description="""Scalar to add to the data after scaling by 'conversion' to finalize its coercion to the specified 'unit'. Two common examples of this include (a) data stored in an unsigned type that requires a shift after scaling to re-center the data, and (b) specialized recording devices that naturally cause a scalar offset with respect to the true units.""") resolution: Optional[float] = Field(None, description="""Smallest meaningful difference between values in data, stored in the specified by unit, 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.""") unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") continuity: Optional[str] = Field(None, description="""Optionally describe the continuity of the data. Can be \"continuous\", \"instantaneous\", or \"step\". For example, a voltage trace would be \"continuous\", because samples are recorded from a continuous process. An array of lick times would be \"instantaneous\", because the data represents distinct moments in time. Times of image presentations would be \"step\" because the picture remains the same until the next timepoint. This field is optional, but is useful in providing information about the underlying data. It may inform the way this data is interpreted, the way it is visualized, and what analysis methods are applicable.""") - array: Optional[NDArray[Shape["* num_times, ..."], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* num_times"], Any], + NDArray[Shape["* num_times, * num_DIM2"], Any], + NDArray[Shape["* num_times, * num_DIM2, * num_DIM3"], Any], + NDArray[Shape["* num_times, * num_DIM2, * num_DIM3, * num_DIM4"], Any] + ]] = Field(None) class TimeSeriesDataArray(Arraylike): @@ -74,57 +76,34 @@ class TimeSeriesStartingTime(ConfiguredBaseModel): """ Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute. """ + name: str = Field("starting_time", const=True) rate: Optional[float] = Field(None, description="""Sampling rate, in Hz.""") unit: Optional[str] = Field(None, description="""Unit of measurement for time, which is fixed to 'seconds'.""") -class TimeSeriesTimestamps(ConfiguredBaseModel): - """ - Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. - """ - interval: Optional[int] = Field(None, description="""Value is '1'""") - unit: Optional[str] = Field(None, description="""Unit of measurement for timestamps, which is fixed to 'seconds'.""") - timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - - -class TimeSeriesControl(ConfiguredBaseModel): - """ - Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data. - """ - control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - - -class TimeSeriesControlDescription(ConfiguredBaseModel): - """ - Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0. - """ - control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") - - class TimeSeriesSync(ConfiguredBaseModel): """ Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes. """ - None + name: str = Field("sync", const=True) -# class ImagesOrderOfImages(ImageReferences): -# """ -# Ordered dataset of references to Image objects stored in the parent group. Each Image object in the Images group should be stored once and only once, so the dataset should have the same length as the number of images. -# """ -# array: Optional[List[Image] | Image] = Field(None) +class ImagesOrderOfImages(ImageReferences): + """ + Ordered dataset of references to Image objects stored in the parent group. Each Image object in the Images group should be stored once and only once, so the dataset should have the same length as the number of images. + """ + name: str = Field("order_of_images", const=True) + array: Optional[List[Image] | Image] = Field(None) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ImageArray.update_forward_refs() -# ImageReferencesArray.update_forward_refs() -TimeSeriesData.update_forward_refs() -TimeSeriesDataArray.update_forward_refs() -TimeSeriesStartingTime.update_forward_refs() -TimeSeriesTimestamps.update_forward_refs() -TimeSeriesControl.update_forward_refs() -TimeSeriesControlDescription.update_forward_refs() -TimeSeriesSync.update_forward_refs() -# ImagesOrderOfImages.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ImageArray.model_rebuild() +ImageReferencesArray.model_rebuild() +TimeSeriesData.model_rebuild() +TimeSeriesDataArray.model_rebuild() +TimeSeriesStartingTime.model_rebuild() +TimeSeriesSync.model_rebuild() +ImagesOrderOfImages.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_behavior.py b/nwb_linkml/models/core_nwb_behavior.py index f6bb62e..e7dc6c8 100644 --- a/nwb_linkml/models/core_nwb_behavior.py +++ b/nwb_linkml/models/core_nwb_behavior.py @@ -11,15 +11,15 @@ else: from typing_extensions import Literal -from .core_nwb_behavior_include import ( - SpatialSeriesData -) - from .core_nwb_base import ( TimeSeries, NWBDataInterface ) +from .core_nwb_behavior_include import ( + SpatialSeriesData +) + from .core_nwb_misc import ( IntervalSeries ) @@ -28,13 +28,9 @@ from .core_nwb_misc import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -45,14 +41,15 @@ class SpatialSeries(TimeSeries): """ Direction, e.g., of gaze or travel, or position. The TimeSeries::data field is a 2D array storing position or direction relative to some reference frame. Array structure: [num measurements] [num dimensions]. Each SpatialSeries has a text dataset reference_frame that indicates the zero-position, or the zero-axes for direction. For example, if representing gaze direction, 'straight-ahead' might be a specific pixel on the monitor, or some other point in space. For position data, the 0,0 point might be the top-left corner of an enclosure, as viewed from the tracking camera. The unit of data will indicate how to interpret SpatialSeries values. """ + name: str = Field(...) data: SpatialSeriesData = Field(..., description="""1-D or 2-D array storing position or direction relative to some reference frame.""") reference_frame: Optional[str] = Field(None, description="""Description defining what exactly 'straight-ahead' means.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -60,59 +57,67 @@ class BehavioralEpochs(NWBDataInterface): """ TimeSeries for storing behavioral epochs. The objective of this and the other two Behavioral interfaces (e.g. BehavioralEvents and BehavioralTimeSeries) is to provide generic hooks for software tools/scripts. This allows a tool/script to take the output one specific interface (e.g., UnitTimes) and plot that data relative to another data modality (e.g., behavioral events) without having to define all possible modalities in advance. Declaring one of these interfaces means that one or more TimeSeries of the specified type is published. These TimeSeries should reside in a group having the same name as the interface. For example, if a BehavioralTimeSeries interface is declared, the module will have one or more TimeSeries defined in the module sub-group 'BehavioralTimeSeries'. BehavioralEpochs should use IntervalSeries. BehavioralEvents is used for irregular events. BehavioralTimeSeries is for continuous data. """ - IntervalSeries: Optional[List[IntervalSeries]] = Field(default_factory=list, description="""IntervalSeries object containing start and stop times of epochs.""") + name: str = Field(...) + interval_series: Optional[List[IntervalSeries]] = Field(default_factory=list, description="""IntervalSeries object containing start and stop times of epochs.""") class BehavioralEvents(NWBDataInterface): """ TimeSeries for storing behavioral events. See description of BehavioralEpochs for more details. """ - TimeSeries: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries object containing behavioral events.""") + name: str = Field(...) + time_series: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries object containing behavioral events.""") class BehavioralTimeSeries(NWBDataInterface): """ TimeSeries for storing Behavoioral time series data. See description of BehavioralEpochs for more details. """ - TimeSeries: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries object containing continuous behavioral data.""") + name: str = Field(...) + time_series: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries object containing continuous behavioral data.""") class PupilTracking(NWBDataInterface): """ Eye-tracking data, representing pupil size. """ - TimeSeries: List[TimeSeries] = Field(default_factory=list, description="""TimeSeries object containing time series data on pupil size.""") + name: str = Field(...) + time_series: List[TimeSeries] = Field(default_factory=list, description="""TimeSeries object containing time series data on pupil size.""") class EyeTracking(NWBDataInterface): """ Eye-tracking data, representing direction of gaze. """ - SpatialSeries: Optional[List[SpatialSeries]] = Field(default_factory=list, description="""SpatialSeries object containing data measuring direction of gaze.""") + name: str = Field(...) + spatial_series: Optional[List[SpatialSeries]] = Field(default_factory=list, description="""SpatialSeries object containing data measuring direction of gaze.""") class CompassDirection(NWBDataInterface): """ With a CompassDirection interface, a module publishes a SpatialSeries object representing a floating point value for theta. The SpatialSeries::reference_frame field should indicate what direction corresponds to 0 and which is the direction of rotation (this should be clockwise). The si_unit for the SpatialSeries should be radians or degrees. """ - SpatialSeries: Optional[List[SpatialSeries]] = Field(default_factory=list, description="""SpatialSeries object containing direction of gaze travel.""") + name: str = Field(...) + spatial_series: Optional[List[SpatialSeries]] = Field(default_factory=list, description="""SpatialSeries object containing direction of gaze travel.""") class Position(NWBDataInterface): """ Position data, whether along the x, x/y or x/y/z axis. """ - SpatialSeries: List[SpatialSeries] = Field(default_factory=list, description="""SpatialSeries object containing position data.""") + name: str = Field(...) + spatial_series: List[SpatialSeries] = Field(default_factory=list, description="""SpatialSeries object containing position data.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -SpatialSeries.update_forward_refs() -BehavioralEpochs.update_forward_refs() -BehavioralEvents.update_forward_refs() -BehavioralTimeSeries.update_forward_refs() -PupilTracking.update_forward_refs() -EyeTracking.update_forward_refs() -CompassDirection.update_forward_refs() -Position.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +SpatialSeries.model_rebuild() +BehavioralEpochs.model_rebuild() +BehavioralEvents.model_rebuild() +BehavioralTimeSeries.model_rebuild() +PupilTracking.model_rebuild() +EyeTracking.model_rebuild() +CompassDirection.model_rebuild() +Position.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_behavior_include.py b/nwb_linkml/models/core_nwb_behavior_include.py index a16bee4..df2b19d 100644 --- a/nwb_linkml/models/core_nwb_behavior_include.py +++ b/nwb_linkml/models/core_nwb_behavior_include.py @@ -19,13 +19,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -36,8 +32,14 @@ class SpatialSeriesData(ConfiguredBaseModel): """ 1-D or 2-D array storing position or direction relative to some reference frame. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. The default value is 'meters'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") - array: Optional[NDArray[Shape["* num_times, 1 x, 2 x_y, 3 x_y_z"], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* num_times"], Number], + NDArray[Shape["* num_times, 1 x"], Number], + NDArray[Shape["* num_times, 1 x, 2 x_y"], Number], + NDArray[Shape["* num_times, 1 x, 2 x_y, 3 x_y_z"], Number] + ]] = Field(None) class SpatialSeriesDataArray(Arraylike): @@ -49,7 +51,8 @@ class SpatialSeriesDataArray(Arraylike): -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -SpatialSeriesData.update_forward_refs() -SpatialSeriesDataArray.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +SpatialSeriesData.model_rebuild() +SpatialSeriesDataArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_device.py b/nwb_linkml/models/core_nwb_device.py index 5e3e7f6..1467dd3 100644 --- a/nwb_linkml/models/core_nwb_device.py +++ b/nwb_linkml/models/core_nwb_device.py @@ -19,13 +19,9 @@ from .core_nwb_base import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -36,11 +32,13 @@ class Device(NWBContainer): """ Metadata about a data acquisition device, e.g., recording system, electrode, microscope. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of the device (e.g., model, firmware version, processing software version, etc.) as free-form text.""") manufacturer: Optional[str] = Field(None, description="""The name of the manufacturer of the device.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -Device.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +Device.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_device_include.py b/nwb_linkml/models/core_nwb_device_include.py deleted file mode 100644 index c923ad6..0000000 --- a/nwb_linkml/models/core_nwb_device_include.py +++ /dev/null @@ -1,33 +0,0 @@ -from __future__ import annotations -from datetime import datetime, date -from enum import Enum -from typing import List, Dict, Optional, Any, Union -from pydantic import BaseModel as BaseModel, Field -from nptyping import NDArray, Shape, Float, Float32, Double, Float64, LongLong, Int64, Int, Int32, Int16, Short, Int8, UInt, UInt32, UInt16, UInt8, UInt64, Number, String, Unicode, Unicode, Unicode, String, Bool, Datetime64 -import sys -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - - - -metamodel_version = "None" -version = "None" - -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, - validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, - extra = 'forbid', - arbitrary_types_allowed = True, - use_enum_values = True): - pass - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ diff --git a/nwb_linkml/models/core_nwb_ecephys.py b/nwb_linkml/models/core_nwb_ecephys.py index 28323c9..fa575f3 100644 --- a/nwb_linkml/models/core_nwb_ecephys.py +++ b/nwb_linkml/models/core_nwb_ecephys.py @@ -11,42 +11,29 @@ else: from typing_extensions import Literal -from .core_nwb_ecephys_include import ( - ClusteringPeakOverRms, - FeatureExtractionDescription, - FeatureExtractionFeatures, - EventDetectionSourceIdx, - ClusteringTimes, - SpikeEventSeriesTimestamps, - EventDetectionTimes, - ClusterWaveformsWaveformMean, - SpikeEventSeriesData, - FeatureExtractionTimes, - ClusteringNum, - ElectricalSeriesChannelConversion, - ClusterWaveformsWaveformSd, - ElectricalSeriesData, - ElectricalSeriesElectrodes, - FeatureExtractionElectrodes -) - from .core_nwb_base import ( TimeSeries, NWBContainer, NWBDataInterface ) +from .core_nwb_ecephys_include import ( + FeatureExtractionElectrodes, + ClusterWaveformsWaveformSd, + ClusterWaveformsWaveformMean, + SpikeEventSeriesData, + ElectricalSeriesElectrodes, + ElectricalSeriesData, + FeatureExtractionFeatures +) + metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -57,16 +44,17 @@ class ElectricalSeries(TimeSeries): """ A time series of acquired voltage data from extracellular recordings. The data field is an int or float array storing data in volts. The first dimension should always represent time. The second dimension, if present, should represent channels. """ + name: str = Field(...) filtering: Optional[str] = Field(None, description="""Filtering applied to all channels of the data. For example, if this ElectricalSeries represents high-pass-filtered data (also known as AP Band), then this value could be \"High-pass 4-pole Bessel filter at 500 Hz\". If this ElectricalSeries represents low-pass-filtered LFP data and the type of filter is unknown, then this value could be \"Low-pass filter at 300 Hz\". If a non-standard filter type is used, provide as much detail about the filter properties as possible.""") data: ElectricalSeriesData = Field(..., description="""Recorded voltage data.""") electrodes: ElectricalSeriesElectrodes = Field(..., description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""") - channel_conversion: Optional[ElectricalSeriesChannelConversion] = Field(None, description="""Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels.""") + channel_conversion: Optional[List[float]] = Field(default_factory=list, description="""Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -74,16 +62,17 @@ class SpikeEventSeries(ElectricalSeries): """ Stores snapshots/snippets of recorded spike events (i.e., threshold crossings). This may also be raw data, as reported by ephys hardware. If so, the TimeSeries::description field should describe how events were detected. All SpikeEventSeries should reside in a module (under EventWaveform interface) even if the spikes were reported and stored by hardware. All events span the same recording channels and store snapshots of equal duration. TimeSeries::data array structure: [num events] [num channels] [num samples] (or [num events] [num samples] for single electrode). """ + name: str = Field(...) data: SpikeEventSeriesData = Field(..., description="""Spike waveforms.""") - timestamps: SpikeEventSeriesTimestamps = Field(..., description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. Timestamps are required for the events. Unlike for TimeSeries, timestamps are required for SpikeEventSeries and are thus re-specified here.""") + timestamps: List[float] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. Timestamps are required for the events. Unlike for TimeSeries, timestamps are required for SpikeEventSeries and are thus re-specified here.""") filtering: Optional[str] = Field(None, description="""Filtering applied to all channels of the data. For example, if this ElectricalSeries represents high-pass-filtered data (also known as AP Band), then this value could be \"High-pass 4-pole Bessel filter at 500 Hz\". If this ElectricalSeries represents low-pass-filtered LFP data and the type of filter is unknown, then this value could be \"Low-pass filter at 300 Hz\". If a non-standard filter type is used, provide as much detail about the filter properties as possible.""") electrodes: ElectricalSeriesElectrodes = Field(..., description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""") - channel_conversion: Optional[ElectricalSeriesChannelConversion] = Field(None, description="""Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels.""") + channel_conversion: Optional[List[float]] = Field(default_factory=list, description="""Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -91,9 +80,10 @@ class FeatureExtraction(NWBDataInterface): """ Features, such as PC1 and PC2, that are extracted from signals stored in a SpikeEventSeries or other source. """ - description: FeatureExtractionDescription = Field(..., description="""Description of features (eg, ''PC1'') for each of the extracted features.""") + name: str = Field(...) + description: List[str] = Field(default_factory=list, description="""Description of features (eg, ''PC1'') for each of the extracted features.""") features: FeatureExtractionFeatures = Field(..., description="""Multi-dimensional array of features extracted from each event.""") - times: FeatureExtractionTimes = Field(..., description="""Times of events that features correspond to (can be a link).""") + times: List[float] = Field(default_factory=list, description="""Times of events that features correspond to (can be a link).""") electrodes: FeatureExtractionElectrodes = Field(..., description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""") @@ -101,36 +91,41 @@ class EventDetection(NWBDataInterface): """ Detected spike events from voltage trace(s). """ + name: str = Field(...) detection_method: str = Field(..., description="""Description of how events were detected, such as voltage threshold, or dV/dT threshold, as well as relevant values.""") - source_idx: EventDetectionSourceIdx = Field(..., description="""Indices (zero-based) into source ElectricalSeries::data array corresponding to time of event. ''description'' should define what is meant by time of event (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index points to each event from the raw data.""") - times: EventDetectionTimes = Field(..., description="""Timestamps of events, in seconds.""") + source_idx: List[int] = Field(default_factory=list, description="""Indices (zero-based) into source ElectricalSeries::data array corresponding to time of event. ''description'' should define what is meant by time of event (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index points to each event from the raw data.""") + times: List[float] = Field(default_factory=list, description="""Timestamps of events, in seconds.""") class EventWaveform(NWBDataInterface): """ Represents either the waveforms of detected events, as extracted from a raw data trace in /acquisition, or the event waveforms that were stored during experiment acquisition. """ - SpikeEventSeries: Optional[List[SpikeEventSeries]] = Field(default_factory=list, description="""SpikeEventSeries object(s) containing detected spike event waveforms.""") + name: str = Field(...) + spike_event_series: Optional[List[SpikeEventSeries]] = Field(default_factory=list, description="""SpikeEventSeries object(s) containing detected spike event waveforms.""") class FilteredEphys(NWBDataInterface): """ Electrophysiology data from one or more channels that has been subjected to filtering. Examples of filtered data include Theta and Gamma (LFP has its own interface). FilteredEphys modules publish an ElectricalSeries for each filtered channel or set of channels. The name of each ElectricalSeries is arbitrary but should be informative. The source of the filtered data, whether this is from analysis of another time series or as acquired by hardware, should be noted in each's TimeSeries::description field. There is no assumed 1::1 correspondence between filtered ephys signals and electrodes, as a single signal can apply to many nearby electrodes, and one electrode may have different filtered (e.g., theta and/or gamma) signals represented. Filter properties should be noted in the ElectricalSeries 'filtering' attribute. """ - ElectricalSeries: List[ElectricalSeries] = Field(default_factory=list, description="""ElectricalSeries object(s) containing filtered electrophysiology data.""") + name: str = Field(...) + electrical_series: List[ElectricalSeries] = Field(default_factory=list, description="""ElectricalSeries object(s) containing filtered electrophysiology data.""") class LFP(NWBDataInterface): """ LFP data from one or more channels. The electrode map in each published ElectricalSeries will identify which channels are providing LFP data. Filter properties should be noted in the ElectricalSeries 'filtering' attribute. """ - ElectricalSeries: List[ElectricalSeries] = Field(default_factory=list, description="""ElectricalSeries object(s) containing LFP data for one or more channels.""") + name: str = Field(...) + electrical_series: List[ElectricalSeries] = Field(default_factory=list, description="""ElectricalSeries object(s) containing LFP data for one or more channels.""") class ElectrodeGroup(NWBContainer): """ A physical grouping of electrodes, e.g. a shank of an array. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of this electrode group.""") location: Optional[str] = Field(None, description="""Location of electrode group. Specify the area, layer, comments on estimation of area/layer, etc. Use standard atlas names for anatomical regions when possible.""") position: Optional[Any] = Field(None, description="""stereotaxic or common framework coordinates""") @@ -140,6 +135,7 @@ class ClusterWaveforms(NWBDataInterface): """ DEPRECATED The mean waveform shape, including standard deviation, of the different clusters. Ideally, the waveform analysis should be performed on data that is only high-pass filtered. This is a separate module because it is expected to require updating. For example, IMEC probes may require different storage requirements to store/display mean waveforms, requiring a new interface or an extension of this one. """ + name: str = Field(...) waveform_filtering: str = Field(..., description="""Filtering applied to data before generating mean/sd""") waveform_mean: ClusterWaveformsWaveformMean = Field(..., description="""The mean waveform for each cluster, using the same indices for each wave as cluster numbers in the associated Clustering module (i.e, cluster 3 is in array slot [3]). Waveforms corresponding to gaps in cluster sequence should be empty (e.g., zero- filled)""") waveform_sd: ClusterWaveformsWaveformSd = Field(..., description="""Stdev of waveforms for each cluster, using the same indices as in mean""") @@ -149,22 +145,24 @@ class Clustering(NWBDataInterface): """ DEPRECATED Clustered spike data, whether from automatic clustering tools (e.g., klustakwik) or as a result of manual sorting. """ + name: str = Field(...) description: str = Field(..., description="""Description of clusters or clustering, (e.g. cluster 0 is noise, clusters curated using Klusters, etc)""") - num: ClusteringNum = Field(..., description="""Cluster number of each event""") - peak_over_rms: ClusteringPeakOverRms = Field(..., description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""") - times: ClusteringTimes = Field(..., description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""") + num: List[int] = Field(default_factory=list, description="""Cluster number of each event""") + peak_over_rms: List[float] = Field(default_factory=list, description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""") + times: List[float] = Field(default_factory=list, description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ElectricalSeries.update_forward_refs() -SpikeEventSeries.update_forward_refs() -FeatureExtraction.update_forward_refs() -EventDetection.update_forward_refs() -EventWaveform.update_forward_refs() -FilteredEphys.update_forward_refs() -LFP.update_forward_refs() -ElectrodeGroup.update_forward_refs() -ClusterWaveforms.update_forward_refs() -Clustering.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ElectricalSeries.model_rebuild() +SpikeEventSeries.model_rebuild() +FeatureExtraction.model_rebuild() +EventDetection.model_rebuild() +EventWaveform.model_rebuild() +FilteredEphys.model_rebuild() +LFP.model_rebuild() +ElectrodeGroup.model_rebuild() +ClusterWaveforms.model_rebuild() +Clustering.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_ecephys_include.py b/nwb_linkml/models/core_nwb_ecephys_include.py index b36e7ff..f0989c9 100644 --- a/nwb_linkml/models/core_nwb_ecephys_include.py +++ b/nwb_linkml/models/core_nwb_ecephys_include.py @@ -23,13 +23,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -40,8 +36,13 @@ class ElectricalSeriesData(ConfiguredBaseModel): """ Recorded voltage data. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. This value is fixed to 'volts'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion', followed by 'channel_conversion' (if present), and then add 'offset'.""") - array: Optional[NDArray[Shape["* num_times, * num_channels, * num_samples"], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* num_times"], Number], + NDArray[Shape["* num_times, * num_channels"], Number], + NDArray[Shape["* num_times, * num_channels, * num_samples"], Number] + ]] = Field(None) class ElectricalSeriesDataArray(Arraylike): @@ -55,25 +56,27 @@ class ElectricalSeriesElectrodes(DynamicTableRegion): """ DynamicTableRegion pointer to the electrodes that this time series was generated from. """ + name: str = Field("electrodes", const=True) table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class ElectricalSeriesChannelConversion(ConfiguredBaseModel): - """ - Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels. - """ - axis: Optional[int] = Field(None, description="""The zero-indexed axis of the 'data' dataset that the channel-specific conversion factor corresponds to. This value is fixed to 1.""") - channel_conversion: Optional[List[float]] = Field(default_factory=list, description="""Channel-specific conversion factor. Multiply the data in the 'data' dataset by these values along the channel axis (as indicated by axis attribute) AND by the global conversion factor in the 'conversion' attribute of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion * channel_conversion. This approach allows for both global and per-channel data conversion factors needed to support the storage of electrical recordings as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels.""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class SpikeEventSeriesData(ConfiguredBaseModel): """ Spike waveforms. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for waveforms, which is fixed to 'volts'.""") - array: Optional[NDArray[Shape["* num_events, * num_samples, * num_channels"], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* num_events, * num_samples"], Number], + NDArray[Shape["* num_events, * num_samples, * num_channels"], Number] + ]] = Field(None) class SpikeEventSeriesDataArray(Arraylike): @@ -83,135 +86,77 @@ class SpikeEventSeriesDataArray(Arraylike): num_channels: Optional[float] = Field(None) -class SpikeEventSeriesTimestamps(ConfiguredBaseModel): - """ - Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. Timestamps are required for the events. Unlike for TimeSeries, timestamps are required for SpikeEventSeries and are thus re-specified here. - """ - interval: Optional[int] = Field(None, description="""Value is '1'""") - unit: Optional[str] = Field(None, description="""Unit of measurement for timestamps, which is fixed to 'seconds'.""") - timestamps: List[float] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. Timestamps are required for the events. Unlike for TimeSeries, timestamps are required for SpikeEventSeries and are thus re-specified here.""") - - -class FeatureExtractionDescription(ConfiguredBaseModel): - """ - Description of features (eg, ''PC1'') for each of the extracted features. - """ - description: List[str] = Field(default_factory=list, description="""Description of features (eg, ''PC1'') for each of the extracted features.""") - - class FeatureExtractionFeatures(ConfiguredBaseModel): """ Multi-dimensional array of features extracted from each event. """ + name: str = Field("features", const=True) array: Optional[NDArray[Shape["* num_events, * num_channels, * num_features"], Float32]] = Field(None) class FeatureExtractionFeaturesArray(Arraylike): - num_events: Optional[float] = Field(None) - num_channels: Optional[float] = Field(None) - num_features: Optional[float] = Field(None) - - -class FeatureExtractionTimes(ConfiguredBaseModel): - """ - Times of events that features correspond to (can be a link). - """ - times: List[float] = Field(default_factory=list, description="""Times of events that features correspond to (can be a link).""") + num_events: float = Field(...) + num_channels: float = Field(...) + num_features: float = Field(...) class FeatureExtractionElectrodes(DynamicTableRegion): """ DynamicTableRegion pointer to the electrodes that this time series was generated from. """ + name: str = Field("electrodes", const=True) table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class EventDetectionSourceIdx(ConfiguredBaseModel): - """ - Indices (zero-based) into source ElectricalSeries::data array corresponding to time of event. ''description'' should define what is meant by time of event (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index points to each event from the raw data. - """ - source_idx: List[int] = Field(default_factory=list, description="""Indices (zero-based) into source ElectricalSeries::data array corresponding to time of event. ''description'' should define what is meant by time of event (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index points to each event from the raw data.""") - - -class EventDetectionTimes(ConfiguredBaseModel): - """ - Timestamps of events, in seconds. - """ - unit: Optional[str] = Field(None, description="""Unit of measurement for event times, which is fixed to 'seconds'.""") - times: List[float] = Field(default_factory=list, description="""Timestamps of events, in seconds.""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class ClusterWaveformsWaveformMean(ConfiguredBaseModel): """ The mean waveform for each cluster, using the same indices for each wave as cluster numbers in the associated Clustering module (i.e, cluster 3 is in array slot [3]). Waveforms corresponding to gaps in cluster sequence should be empty (e.g., zero- filled) """ + name: str = Field("waveform_mean", const=True) array: Optional[NDArray[Shape["* num_clusters, * num_samples"], Float32]] = Field(None) class ClusterWaveformsWaveformMeanArray(Arraylike): - num_clusters: Optional[float] = Field(None) - num_samples: Optional[float] = Field(None) + num_clusters: float = Field(...) + num_samples: float = Field(...) class ClusterWaveformsWaveformSd(ConfiguredBaseModel): """ Stdev of waveforms for each cluster, using the same indices as in mean """ + name: str = Field("waveform_sd", const=True) array: Optional[NDArray[Shape["* num_clusters, * num_samples"], Float32]] = Field(None) class ClusterWaveformsWaveformSdArray(Arraylike): - num_clusters: Optional[float] = Field(None) - num_samples: Optional[float] = Field(None) - - -class ClusteringNum(ConfiguredBaseModel): - """ - Cluster number of each event - """ - num: List[int] = Field(default_factory=list, description="""Cluster number of each event""") - - -class ClusteringPeakOverRms(ConfiguredBaseModel): - """ - Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric). - """ - peak_over_rms: List[float] = Field(default_factory=list, description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""") - - -class ClusteringTimes(ConfiguredBaseModel): - """ - Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module. - """ - times: List[float] = Field(default_factory=list, description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""") + num_clusters: float = Field(...) + num_samples: float = Field(...) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ElectricalSeriesData.update_forward_refs() -ElectricalSeriesDataArray.update_forward_refs() -ElectricalSeriesElectrodes.update_forward_refs() -ElectricalSeriesChannelConversion.update_forward_refs() -SpikeEventSeriesData.update_forward_refs() -SpikeEventSeriesDataArray.update_forward_refs() -SpikeEventSeriesTimestamps.update_forward_refs() -FeatureExtractionDescription.update_forward_refs() -FeatureExtractionFeatures.update_forward_refs() -FeatureExtractionFeaturesArray.update_forward_refs() -FeatureExtractionTimes.update_forward_refs() -FeatureExtractionElectrodes.update_forward_refs() -EventDetectionSourceIdx.update_forward_refs() -EventDetectionTimes.update_forward_refs() -ClusterWaveformsWaveformMean.update_forward_refs() -ClusterWaveformsWaveformMeanArray.update_forward_refs() -ClusterWaveformsWaveformSd.update_forward_refs() -ClusterWaveformsWaveformSdArray.update_forward_refs() -ClusteringNum.update_forward_refs() -ClusteringPeakOverRms.update_forward_refs() -ClusteringTimes.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ElectricalSeriesData.model_rebuild() +ElectricalSeriesDataArray.model_rebuild() +ElectricalSeriesElectrodes.model_rebuild() +SpikeEventSeriesData.model_rebuild() +SpikeEventSeriesDataArray.model_rebuild() +FeatureExtractionFeatures.model_rebuild() +FeatureExtractionFeaturesArray.model_rebuild() +FeatureExtractionElectrodes.model_rebuild() +ClusterWaveformsWaveformMean.model_rebuild() +ClusterWaveformsWaveformMeanArray.model_rebuild() +ClusterWaveformsWaveformSd.model_rebuild() +ClusterWaveformsWaveformSdArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_epoch.py b/nwb_linkml/models/core_nwb_epoch.py index 9834eaf..d9890ce 100644 --- a/nwb_linkml/models/core_nwb_epoch.py +++ b/nwb_linkml/models/core_nwb_epoch.py @@ -11,27 +11,23 @@ else: from typing_extensions import Literal -from .core_nwb_epoch_include import ( - TimeIntervalsTimeseriesIndex, - TimeIntervalsTagsIndex, - TimeIntervalsTimeseries -) - from .hdmf_common_table import ( DynamicTable ) +from .core_nwb_epoch_include import ( + TimeIntervalsTimeseriesIndex, + TimeIntervalsTimeseries, + TimeIntervalsTagsIndex +) + metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -42,6 +38,7 @@ class TimeIntervals(DynamicTable): """ A container for aggregating epoch data and the TimeSeries that each epoch applies to. """ + name: str = Field(...) start_time: Optional[List[float]] = Field(default_factory=list, description="""Start time of epoch, in seconds.""") stop_time: Optional[List[float]] = Field(default_factory=list, description="""Stop time of epoch, in seconds.""") tags: Optional[List[str]] = Field(default_factory=list, description="""User-defined tags that identify or categorize events.""") @@ -50,11 +47,12 @@ class TimeIntervals(DynamicTable): timeseries_index: Optional[TimeIntervalsTimeseriesIndex] = Field(None, description="""Index for timeseries.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -TimeIntervals.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +TimeIntervals.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_epoch_include.py b/nwb_linkml/models/core_nwb_epoch_include.py index 170f9de..5f68166 100644 --- a/nwb_linkml/models/core_nwb_epoch_include.py +++ b/nwb_linkml/models/core_nwb_epoch_include.py @@ -11,25 +11,21 @@ else: from typing_extensions import Literal -from .core_nwb_base import ( - TimeSeriesReferenceVectorData -) - from .hdmf_common_table import ( VectorIndex ) +from .core_nwb_base import ( + TimeSeriesReferenceVectorData +) + metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -40,31 +36,50 @@ class TimeIntervalsTagsIndex(VectorIndex): """ Index for tags. """ + name: str = Field("tags_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class TimeIntervalsTimeseries(TimeSeriesReferenceVectorData): """ An index into a TimeSeries object. """ + name: str = Field("timeseries", const=True) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class TimeIntervalsTimeseriesIndex(VectorIndex): """ Index for timeseries. """ + name: str = Field("timeseries_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -TimeIntervalsTagsIndex.update_forward_refs() -TimeIntervalsTimeseries.update_forward_refs() -TimeIntervalsTimeseriesIndex.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +TimeIntervalsTagsIndex.model_rebuild() +TimeIntervalsTimeseries.model_rebuild() +TimeIntervalsTimeseriesIndex.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_file.py b/nwb_linkml/models/core_nwb_file.py index 6001fb9..efa62f8 100644 --- a/nwb_linkml/models/core_nwb_file.py +++ b/nwb_linkml/models/core_nwb_file.py @@ -11,35 +11,35 @@ else: from typing_extensions import Literal -from .core_nwb_file_include import ( - NWBFileScratch, - NWBFileGeneral, - NWBFileIntervals, - NWBFileFileCreateDate, - NWBFileUnits, - SubjectAge, - NWBFileStimulus, - NWBFileAcquisition, - NWBFileProcessing, - NWBFileAnalysis +from .hdmf_common_table import ( + DynamicTable ) from .core_nwb_base import ( - NWBContainer, - NWBData + NWBData, + ProcessingModule, + NWBDataInterface, + NWBContainer +) + +from .core_nwb_file_include import ( + NWBFileGeneral, + SubjectAge, + NWBFileIntervals, + NWBFileStimulus +) + +from .core_nwb_misc import ( + Units ) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -50,6 +50,7 @@ class ScratchData(NWBData): """ Any one-off datasets """ + name: str = Field(...) notes: Optional[str] = Field(None, description="""Any notes the user has about the dataset being stored""") @@ -57,35 +58,37 @@ class NWBFile(NWBContainer): """ An NWB file storing cellular-based neurophysiology data from a single experimental session. """ + name: str = Field("root", const=True) nwb_version: Optional[str] = Field(None, description="""File version string. Use semantic versioning, e.g. 1.2.1. This will be the name of the format with trailing major, minor and patch numbers.""") - file_create_date: NWBFileFileCreateDate = Field(..., description="""A record of the date the file was created and of subsequent modifications. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted strings: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. The file can be created after the experiment was run, so this may differ from the experiment start time. Each modification to the nwb file adds a new entry to the array.""") + file_create_date: List[datetime ] = Field(default_factory=list, description="""A record of the date the file was created and of subsequent modifications. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted strings: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. The file can be created after the experiment was run, so this may differ from the experiment start time. Each modification to the nwb file adds a new entry to the array.""") identifier: str = Field(..., description="""A unique text identifier for the file. For example, concatenated lab name, file creation date/time and experimentalist, or a hash of these and/or other values. The goal is that the string should be unique to all other files.""") session_description: str = Field(..., description="""A description of the experimental session and data in the file.""") - session_start_time: date = Field(..., description="""Date and time of the experiment/session start. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds.""") - timestamps_reference_time: date = Field(..., description="""Date and time corresponding to time zero of all timestamps. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. All times stored in the file use this time as reference (i.e., time zero).""") - acquisition: NWBFileAcquisition = Field(..., description="""Data streams recorded from the system, including ephys, ophys, tracking, etc. This group should be read-only after the experiment is completed and timestamps are corrected to a common timebase. The data stored here may be links to raw data stored in external NWB files. This will allow keeping bulky raw data out of the file while preserving the option of keeping some/all in the file. Acquired data includes tracking and experimental data streams (i.e., everything measured from the system). If bulky data is stored in the /acquisition group, the data can exist in a separate NWB file that is linked to by the file being used for processing and analysis.""") - analysis: NWBFileAnalysis = Field(..., description="""Lab-specific and custom scientific analysis of data. There is no defined format for the content of this group - the format is up to the individual user/lab. To facilitate sharing analysis data between labs, the contents here should be stored in standard types (e.g., neurodata_types) and appropriately documented. The file can store lab-specific and custom data analysis without restriction on its form or schema, reducing data formatting restrictions on end users. Such data should be placed in the analysis group. The analysis data should be documented so that it could be shared with other labs.""") - scratch: Optional[NWBFileScratch] = Field(None, description="""A place to store one-off analysis results. Data placed here is not intended for sharing. By placing data here, users acknowledge that there is no guarantee that their data meets any standard.""") - processing: NWBFileProcessing = Field(..., description="""The home for ProcessingModules. These modules perform intermediate analysis of data that is necessary to perform before scientific analysis. Examples include spike clustering, extracting position from tracking data, stitching together image slices. ProcessingModules can be large and express many data sets from relatively complex analysis (e.g., spike detection and clustering) or small, representing extraction of position information from tracking video, or even binary lick/no-lick decisions. Common software tools (e.g., klustakwik, MClust) are expected to read/write data here. 'Processing' refers to intermediate analysis of the acquired data to make it more amenable to scientific analysis.""") + session_start_time: datetime = Field(..., description="""Date and time of the experiment/session start. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds.""") + timestamps_reference_time: datetime = Field(..., description="""Date and time corresponding to time zero of all timestamps. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. All times stored in the file use this time as reference (i.e., time zero).""") + acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(default_factory=list, description="""Data streams recorded from the system, including ephys, ophys, tracking, etc. This group should be read-only after the experiment is completed and timestamps are corrected to a common timebase. The data stored here may be links to raw data stored in external NWB files. This will allow keeping bulky raw data out of the file while preserving the option of keeping some/all in the file. Acquired data includes tracking and experimental data streams (i.e., everything measured from the system). If bulky data is stored in the /acquisition group, the data can exist in a separate NWB file that is linked to by the file being used for processing and analysis.""") + analysis: Optional[List[Union[DynamicTable, NWBContainer]]] = Field(default_factory=list, description="""Lab-specific and custom scientific analysis of data. There is no defined format for the content of this group - the format is up to the individual user/lab. To facilitate sharing analysis data between labs, the contents here should be stored in standard types (e.g., neurodata_types) and appropriately documented. The file can store lab-specific and custom data analysis without restriction on its form or schema, reducing data formatting restrictions on end users. Such data should be placed in the analysis group. The analysis data should be documented so that it could be shared with other labs.""") + scratch: Optional[List[Union[DynamicTable, NWBContainer]]] = Field(default_factory=list, description="""A place to store one-off analysis results. Data placed here is not intended for sharing. By placing data here, users acknowledge that there is no guarantee that their data meets any standard.""") + processing: Optional[List[ProcessingModule]] = Field(default_factory=list, description="""The home for ProcessingModules. These modules perform intermediate analysis of data that is necessary to perform before scientific analysis. Examples include spike clustering, extracting position from tracking data, stitching together image slices. ProcessingModules can be large and express many data sets from relatively complex analysis (e.g., spike detection and clustering) or small, representing extraction of position information from tracking video, or even binary lick/no-lick decisions. Common software tools (e.g., klustakwik, MClust) are expected to read/write data here. 'Processing' refers to intermediate analysis of the acquired data to make it more amenable to scientific analysis.""") stimulus: NWBFileStimulus = Field(..., description="""Data pushed into the system (eg, video stimulus, sound, voltage, etc) and secondary representations of that data (eg, measurements of something used as a stimulus). This group should be made read-only after experiment complete and timestamps are corrected to common timebase. Stores both presented stimuli and stimulus templates, the latter in case the same stimulus is presented multiple times, or is pulled from an external stimulus library. Stimuli are here defined as any signal that is pushed into the system as part of the experiment (eg, sound, video, voltage, etc). Many different experiments can use the same stimuli, and stimuli can be re-used during an experiment. The stimulus group is organized so that one version of template stimuli can be stored and these be used multiple times. These templates can exist in the present file or can be linked to a remote library file.""") general: NWBFileGeneral = Field(..., description="""Experimental metadata, including protocol, notes and description of hardware device(s). The metadata stored in this section should be used to describe the experiment. Metadata necessary for interpreting the data is stored with the data. General experimental metadata, including animal strain, experimental protocols, experimenter, devices, etc, are stored under 'general'. Core metadata (e.g., that required to interpret data fields) is stored with the data itself, and implicitly defined by the file specification (e.g., time is in seconds). The strategy used here for storing non-core metadata is to use free-form text fields, such as would appear in sentences or paragraphs from a Methods section. Metadata fields are text to enable them to be more general, for example to represent ranges instead of numerical values. Machine-readable metadata is stored as attributes to these free-form datasets. All entries in the below table are to be included when data is present. Unused groups (e.g., intracellular_ephys in an optophysiology experiment) should not be created unless there is data to store within them.""") intervals: Optional[NWBFileIntervals] = Field(None, description="""Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data.""") - units: Optional[NWBFileUnits] = Field(None, description="""Data about sorted spike units.""") + units: Optional[Units] = Field(None, description="""Data about sorted spike units.""") class LabMetaData(NWBContainer): """ Lab-specific meta-data. """ - None + name: str = Field(...) class Subject(NWBContainer): """ Information about the animal or person from which the data was measured. """ + name: str = Field(...) age: Optional[SubjectAge] = Field(None, description="""Age of subject. Can be supplied instead of 'date_of_birth'.""") - date_of_birth: Optional[date] = Field(None, description="""Date of birth of subject. Can be supplied instead of 'age'.""") + date_of_birth: Optional[datetime ] = Field(None, description="""Date of birth of subject. Can be supplied instead of 'age'.""") description: Optional[str] = Field(None, description="""Description of subject and where subject came from (e.g., breeder, if animal).""") genotype: Optional[str] = Field(None, description="""Genetic strain. If absent, assume Wild Type (WT).""") sex: Optional[str] = Field(None, description="""Gender of subject.""") @@ -96,9 +99,10 @@ class Subject(NWBContainer): -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ScratchData.update_forward_refs() -NWBFile.update_forward_refs() -LabMetaData.update_forward_refs() -Subject.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ScratchData.model_rebuild() +NWBFile.model_rebuild() +LabMetaData.model_rebuild() +Subject.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_file_include.py b/nwb_linkml/models/core_nwb_file_include.py index 7590095..09c121a 100644 --- a/nwb_linkml/models/core_nwb_file_include.py +++ b/nwb_linkml/models/core_nwb_file_include.py @@ -11,40 +11,36 @@ else: from typing_extensions import Literal -from .core_nwb_file import ( - LabMetaData, - ScratchData, - Subject -) - -from .core_nwb_misc import ( - Units -) - from .core_nwb_base import ( TimeSeries, - Images, - NWBContainer, - NWBDataInterface, - ProcessingModule + Images ) from .core_nwb_icephys import ( - RepetitionsTable, ExperimentalConditionsTable, - IntracellularElectrode, - SimultaneousRecordingsTable, SweepTable, + IntracellularElectrode, SequentialRecordingsTable, + RepetitionsTable, + SimultaneousRecordingsTable, IntracellularRecordingsTable ) +from .core_nwb_ogen import ( + OptogeneticStimulusSite +) + from .core_nwb_epoch import ( TimeIntervals ) -from .core_nwb_ogen import ( - OptogeneticStimulusSite +from .core_nwb_file import ( + LabMetaData, + Subject +) + +from .hdmf_common_table import ( + DynamicTable ) from .core_nwb_device import ( @@ -55,10 +51,6 @@ from .core_nwb_ecephys import ( ElectrodeGroup ) -from .hdmf_common_table import ( - DynamicTable -) - from .core_nwb_ophys import ( ImagingPlane ) @@ -67,414 +59,113 @@ from .core_nwb_ophys import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): pass -class NWBFileFileCreateDate(ConfiguredBaseModel): - """ - A record of the date the file was created and of subsequent modifications. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted strings: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. The file can be created after the experiment was run, so this may differ from the experiment start time. Each modification to the nwb file adds a new entry to the array. - """ - file_create_date: List[date] = Field(default_factory=list, description="""A record of the date the file was created and of subsequent modifications. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted strings: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. The file can be created after the experiment was run, so this may differ from the experiment start time. Each modification to the nwb file adds a new entry to the array.""") - - -class NWBFileAcquisition(ConfiguredBaseModel): - """ - Data streams recorded from the system, including ephys, ophys, tracking, etc. This group should be read-only after the experiment is completed and timestamps are corrected to a common timebase. The data stored here may be links to raw data stored in external NWB files. This will allow keeping bulky raw data out of the file while preserving the option of keeping some/all in the file. Acquired data includes tracking and experimental data streams (i.e., everything measured from the system). If bulky data is stored in the /acquisition group, the data can exist in a separate NWB file that is linked to by the file being used for processing and analysis. - """ - NWBDataInterface: Optional[List[NWBDataInterface]] = Field(default_factory=list, description="""Acquired, raw data.""") - DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""Tabular data that is relevant to acquisition""") - - -class NWBFileAnalysis(ConfiguredBaseModel): - """ - Lab-specific and custom scientific analysis of data. There is no defined format for the content of this group - the format is up to the individual user/lab. To facilitate sharing analysis data between labs, the contents here should be stored in standard types (e.g., neurodata_types) and appropriately documented. The file can store lab-specific and custom data analysis without restriction on its form or schema, reducing data formatting restrictions on end users. Such data should be placed in the analysis group. The analysis data should be documented so that it could be shared with other labs. - """ - NWBContainer: Optional[List[NWBContainer]] = Field(default_factory=list, description="""Custom analysis results.""") - DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""Tabular data that is relevant to data stored in analysis""") - - -class NWBFileScratch(ConfiguredBaseModel): - """ - A place to store one-off analysis results. Data placed here is not intended for sharing. By placing data here, users acknowledge that there is no guarantee that their data meets any standard. - """ - ScratchData: Optional[List[ScratchData]] = Field(default_factory=list, description="""Any one-off datasets""") - NWBContainer: Optional[List[NWBContainer]] = Field(default_factory=list, description="""Any one-off containers""") - DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""Any one-off tables""") - - -class NWBFileProcessing(ConfiguredBaseModel): - """ - The home for ProcessingModules. These modules perform intermediate analysis of data that is necessary to perform before scientific analysis. Examples include spike clustering, extracting position from tracking data, stitching together image slices. ProcessingModules can be large and express many data sets from relatively complex analysis (e.g., spike detection and clustering) or small, representing extraction of position information from tracking video, or even binary lick/no-lick decisions. Common software tools (e.g., klustakwik, MClust) are expected to read/write data here. 'Processing' refers to intermediate analysis of the acquired data to make it more amenable to scientific analysis. - """ - ProcessingModule: Optional[List[ProcessingModule]] = Field(default_factory=list, description="""Intermediate analysis of acquired data.""") - - class NWBFileStimulus(ConfiguredBaseModel): """ Data pushed into the system (eg, video stimulus, sound, voltage, etc) and secondary representations of that data (eg, measurements of something used as a stimulus). This group should be made read-only after experiment complete and timestamps are corrected to common timebase. Stores both presented stimuli and stimulus templates, the latter in case the same stimulus is presented multiple times, or is pulled from an external stimulus library. Stimuli are here defined as any signal that is pushed into the system as part of the experiment (eg, sound, video, voltage, etc). Many different experiments can use the same stimuli, and stimuli can be re-used during an experiment. The stimulus group is organized so that one version of template stimuli can be stored and these be used multiple times. These templates can exist in the present file or can be linked to a remote library file. """ - presentation: NWBFileStimulusPresentation = Field(..., description="""Stimuli presented during the experiment.""") - templates: NWBFileStimulusTemplates = Field(..., description="""Template stimuli. Timestamps in templates are based on stimulus design and are relative to the beginning of the stimulus. When templates are used, the stimulus instances must convert presentation times to the experiment`s time reference frame.""") - - -class NWBFileStimulusPresentation(ConfiguredBaseModel): - """ - Stimuli presented during the experiment. - """ - TimeSeries: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries objects containing data of presented stimuli.""") - - -class NWBFileStimulusTemplates(ConfiguredBaseModel): - """ - Template stimuli. Timestamps in templates are based on stimulus design and are relative to the beginning of the stimulus. When templates are used, the stimulus instances must convert presentation times to the experiment`s time reference frame. - """ - TimeSeries: Optional[List[TimeSeries]] = Field(default_factory=list, description="""TimeSeries objects containing template data of presented stimuli.""") - Images: Optional[List[Images]] = Field(default_factory=list, description="""Images objects containing images of presented stimuli.""") + name: str = Field("stimulus", const=True) + presentation: Optional[List[TimeSeries]] = Field(default_factory=list, description="""Stimuli presented during the experiment.""") + templates: Optional[List[Union[Images, TimeSeries]]] = Field(default_factory=list, description="""Template stimuli. Timestamps in templates are based on stimulus design and are relative to the beginning of the stimulus. When templates are used, the stimulus instances must convert presentation times to the experiment`s time reference frame.""") class NWBFileGeneral(ConfiguredBaseModel): """ Experimental metadata, including protocol, notes and description of hardware device(s). The metadata stored in this section should be used to describe the experiment. Metadata necessary for interpreting the data is stored with the data. General experimental metadata, including animal strain, experimental protocols, experimenter, devices, etc, are stored under 'general'. Core metadata (e.g., that required to interpret data fields) is stored with the data itself, and implicitly defined by the file specification (e.g., time is in seconds). The strategy used here for storing non-core metadata is to use free-form text fields, such as would appear in sentences or paragraphs from a Methods section. Metadata fields are text to enable them to be more general, for example to represent ranges instead of numerical values. Machine-readable metadata is stored as attributes to these free-form datasets. All entries in the below table are to be included when data is present. Unused groups (e.g., intracellular_ephys in an optophysiology experiment) should not be created unless there is data to store within them. """ + name: str = Field("general", const=True) data_collection: Optional[str] = Field(None, description="""Notes about data collection and analysis.""") experiment_description: Optional[str] = Field(None, description="""General description of the experiment.""") - experimenter: Optional[NWBFileGeneralExperimenter] = Field(None, description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""") + experimenter: Optional[List[str]] = Field(default_factory=list, description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""") institution: Optional[str] = Field(None, description="""Institution(s) where experiment was performed.""") - keywords: Optional[NWBFileGeneralKeywords] = Field(None, description="""Terms to search over.""") + keywords: Optional[List[str]] = Field(default_factory=list, description="""Terms to search over.""") lab: Optional[str] = Field(None, description="""Laboratory where experiment was performed.""") notes: Optional[str] = Field(None, description="""Notes about the experiment.""") pharmacology: Optional[str] = Field(None, description="""Description of drugs used, including how and when they were administered. Anesthesia(s), painkiller(s), etc., plus dosage, concentration, etc.""") protocol: Optional[str] = Field(None, description="""Experimental protocol, if applicable. e.g., include IACUC protocol number.""") - related_publications: Optional[NWBFileGeneralRelatedPublications] = Field(None, description="""Publication information. PMID, DOI, URL, etc.""") + related_publications: Optional[List[str]] = Field(default_factory=list, description="""Publication information. PMID, DOI, URL, etc.""") session_id: Optional[str] = Field(None, description="""Lab-specific ID for the session.""") slices: Optional[str] = Field(None, description="""Description of slices, including information about preparation thickness, orientation, temperature, and bath solution.""") source_script: Optional[NWBFileGeneralSourceScript] = Field(None, description="""Script file or link to public source code used to create this NWB file.""") stimulus: Optional[str] = Field(None, description="""Notes about stimuli, such as how and where they were presented.""") surgery: Optional[str] = Field(None, description="""Narrative description about surgery/surgeries, including date(s) and who performed surgery.""") virus: Optional[str] = Field(None, description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""") - LabMetaData: Optional[List[LabMetaData]] = Field(default_factory=list, description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""") - devices: Optional[NWBFileGeneralDevices] = Field(None, description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""") - subject: Optional[NWBFileGeneralSubject] = Field(None, description="""Information about the animal or person from which the data was measured.""") + lab_meta_data: Optional[List[LabMetaData]] = Field(default_factory=list, description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""") + devices: Optional[List[Device]] = Field(default_factory=list, description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""") + subject: Optional[Subject] = Field(None, description="""Information about the animal or person from which the data was measured.""") extracellular_ephys: Optional[NWBFileGeneralExtracellularEphys] = Field(None, description="""Metadata related to extracellular electrophysiology.""") intracellular_ephys: Optional[NWBFileGeneralIntracellularEphys] = Field(None, description="""Metadata related to intracellular electrophysiology.""") - optogenetics: Optional[NWBFileGeneralOptogenetics] = Field(None, description="""Metadata describing optogenetic stimuluation.""") - optophysiology: Optional[NWBFileGeneralOptophysiology] = Field(None, description="""Metadata related to optophysiology.""") - - -class NWBFileGeneralExperimenter(ConfiguredBaseModel): - """ - Name of person(s) who performed the experiment. Can also specify roles of different people involved. - """ - experimenter: Optional[List[str]] = Field(default_factory=list, description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""") - - -class NWBFileGeneralKeywords(ConfiguredBaseModel): - """ - Terms to search over. - """ - keywords: Optional[List[str]] = Field(default_factory=list, description="""Terms to search over.""") - - -class NWBFileGeneralRelatedPublications(ConfiguredBaseModel): - """ - Publication information. PMID, DOI, URL, etc. - """ - related_publications: Optional[List[str]] = Field(default_factory=list, description="""Publication information. PMID, DOI, URL, etc.""") + optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(default_factory=list, description="""Metadata describing optogenetic stimuluation.""") + optophysiology: Optional[List[ImagingPlane]] = Field(default_factory=list, description="""Metadata related to optophysiology.""") class NWBFileGeneralSourceScript(ConfiguredBaseModel): """ Script file or link to public source code used to create this NWB file. """ + name: str = Field("source_script", const=True) file_name: Optional[str] = Field(None, description="""Name of script file.""") -class NWBFileGeneralDevices(ConfiguredBaseModel): - """ - Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc. - """ - Device: Optional[List[Device]] = Field(default_factory=list, description="""Data acquisition devices.""") - - -class NWBFileGeneralSubject(Subject): - """ - Information about the animal or person from which the data was measured. - """ - age: Optional[SubjectAge] = Field(None, description="""Age of subject. Can be supplied instead of 'date_of_birth'.""") - date_of_birth: Optional[date] = Field(None, description="""Date of birth of subject. Can be supplied instead of 'age'.""") - description: Optional[str] = Field(None, description="""Description of subject and where subject came from (e.g., breeder, if animal).""") - genotype: Optional[str] = Field(None, description="""Genetic strain. If absent, assume Wild Type (WT).""") - sex: Optional[str] = Field(None, description="""Gender of subject.""") - species: Optional[str] = Field(None, description="""Species of subject.""") - strain: Optional[str] = Field(None, description="""Strain of subject.""") - subject_id: Optional[str] = Field(None, description="""ID of animal/person used/participating in experiment (lab convention).""") - weight: Optional[str] = Field(None, description="""Weight at time of experiment, at time of surgery and at other important times.""") - - class NWBFileGeneralExtracellularEphys(ConfiguredBaseModel): """ Metadata related to extracellular electrophysiology. """ - ElectrodeGroup: Optional[List[ElectrodeGroup]] = Field(default_factory=list, description="""Physical group of electrodes.""") - electrodes: Optional[NWBFileGeneralExtracellularEphysElectrodes] = Field(None, description="""A table of all electrodes (i.e. channels) used for recording.""") - - -class NWBFileGeneralExtracellularEphysElectrodes(DynamicTable): - """ - A table of all electrodes (i.e. channels) used for recording. - """ - x: Optional[List[float]] = Field(default_factory=list, description="""x coordinate of the channel location in the brain (+x is posterior).""") - y: Optional[List[float]] = Field(default_factory=list, description="""y coordinate of the channel location in the brain (+y is inferior).""") - z: Optional[List[float]] = Field(default_factory=list, description="""z coordinate of the channel location in the brain (+z is right).""") - imp: Optional[List[float]] = Field(default_factory=list, description="""Impedance of the channel, in ohms.""") - location: Optional[List[str]] = Field(default_factory=list, description="""Location of the electrode (channel). Specify the area, layer, comments on estimation of area/layer, stereotaxic coordinates if in vivo, etc. Use standard atlas names for anatomical regions when possible.""") - filtering: Optional[List[str]] = Field(default_factory=list, description="""Description of hardware filtering, including the filter name and frequency cutoffs.""") - group: Optional[List[ElectrodeGroup]] = Field(default_factory=list, description="""Reference to the ElectrodeGroup this electrode is a part of.""") - group_name: Optional[List[str]] = Field(default_factory=list, description="""Name of the ElectrodeGroup this electrode is a part of.""") - rel_x: Optional[List[float]] = Field(default_factory=list, description="""x coordinate in electrode group""") - rel_y: Optional[List[float]] = Field(default_factory=list, description="""y coordinate in electrode group""") - rel_z: Optional[List[float]] = Field(default_factory=list, description="""z coordinate in electrode group""") - reference: Optional[List[str]] = Field(default_factory=list, description="""Description of the reference electrode and/or reference scheme used for this electrode, e.g., \"stainless steel skull screw\" or \"online common average referencing\".""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") + name: str = Field("extracellular_ephys", const=True) + electrode_group: Optional[List[ElectrodeGroup]] = Field(default_factory=list, description="""Physical group of electrodes.""") + electrodes: Optional[DynamicTable] = Field(None, description="""A table of all electrodes (i.e. channels) used for recording.""") class NWBFileGeneralIntracellularEphys(ConfiguredBaseModel): """ Metadata related to intracellular electrophysiology. """ + name: str = Field("intracellular_ephys", const=True) filtering: Optional[str] = Field(None, description="""[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.""") - IntracellularElectrode: Optional[List[IntracellularElectrode]] = Field(default_factory=list, description="""An intracellular electrode.""") - sweep_table: Optional[NWBFileGeneralIntracellularEphysSweepTable] = Field(None, description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tables. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""") - intracellular_recordings: Optional[NWBFileGeneralIntracellularEphysIntracellularRecordings] = Field(None, description="""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.""") - simultaneous_recordings: Optional[NWBFileGeneralIntracellularEphysSimultaneousRecordings] = Field(None, description="""A table for grouping different intracellular recordings from the IntracellularRecordingsTable table together that were recorded simultaneously from different electrodes""") - sequential_recordings: Optional[NWBFileGeneralIntracellularEphysSequentialRecordings] = Field(None, description="""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.""") - repetitions: Optional[NWBFileGeneralIntracellularEphysRepetitions] = Field(None, description="""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.""") - experimental_conditions: Optional[NWBFileGeneralIntracellularEphysExperimentalConditions] = Field(None, description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""") - - -class NWBFileGeneralIntracellularEphysSweepTable(SweepTable): - """ - [DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tables. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata. - """ - sweep_number: Optional[List[int]] = Field(default_factory=list, description="""Sweep number of the PatchClampSeries in that row.""") - series: Optional[List[PatchClampSeries]] = Field(default_factory=list, description="""The PatchClampSeries with the sweep number in that row.""") - series_index: SweepTableSeriesIndex = Field(..., description="""Index for series.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralIntracellularEphysIntracellularRecordings(IntracellularRecordingsTable): - """ - 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. - """ - description: Optional[str] = Field(None, description="""Description of the contents of this table. Inherited from AlignedDynamicTable and overwritten here to fix the value of the attribute.""") - electrodes: IntracellularRecordingsTableElectrodes = Field(..., description="""Table for storing intracellular electrode related metadata.""") - stimuli: IntracellularRecordingsTableStimuli = Field(..., description="""Table for storing intracellular stimulus related metadata.""") - responses: IntracellularRecordingsTableResponses = Field(..., description="""Table for storing intracellular response related metadata.""") - categories: Optional[str] = Field(None, description="""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 and the category names must match the names of the corresponding DynamicTable in the group.""") - DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""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.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralIntracellularEphysSimultaneousRecordings(SimultaneousRecordingsTable): - """ - A table for grouping different intracellular recordings from the IntracellularRecordingsTable table together that were recorded simultaneously from different electrodes - """ - recordings: SimultaneousRecordingsTableRecordings = Field(..., description="""A reference to one or more rows in the IntracellularRecordingsTable table.""") - recordings_index: SimultaneousRecordingsTableRecordingsIndex = Field(..., description="""Index dataset for the recordings column.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralIntracellularEphysSequentialRecordings(SequentialRecordingsTable): - """ - 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. - """ - simultaneous_recordings: SequentialRecordingsTableSimultaneousRecordings = Field(..., description="""A reference to one or more rows in the SimultaneousRecordingsTable table.""") - simultaneous_recordings_index: SequentialRecordingsTableSimultaneousRecordingsIndex = Field(..., description="""Index dataset for the simultaneous_recordings column.""") - stimulus_type: Optional[List[str]] = Field(default_factory=list, description="""The type of stimulus used for the sequential recording.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralIntracellularEphysRepetitions(RepetitionsTable): - """ - 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. - """ - sequential_recordings: RepetitionsTableSequentialRecordings = Field(..., description="""A reference to one or more rows in the SequentialRecordingsTable table.""") - sequential_recordings_index: RepetitionsTableSequentialRecordingsIndex = Field(..., description="""Index dataset for the sequential_recordings column.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralIntracellularEphysExperimentalConditions(ExperimentalConditionsTable): - """ - A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions. - """ - repetitions: ExperimentalConditionsTableRepetitions = Field(..., description="""A reference to one or more rows in the RepetitionsTable table.""") - repetitions_index: ExperimentalConditionsTableRepetitionsIndex = Field(..., description="""Index dataset for the repetitions column.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileGeneralOptogenetics(ConfiguredBaseModel): - """ - Metadata describing optogenetic stimuluation. - """ - OptogeneticStimulusSite: Optional[List[OptogeneticStimulusSite]] = Field(default_factory=list, description="""An optogenetic stimulation site.""") - - -class NWBFileGeneralOptophysiology(ConfiguredBaseModel): - """ - Metadata related to optophysiology. - """ - ImagingPlane: Optional[List[ImagingPlane]] = Field(default_factory=list, description="""An imaging plane.""") + intracellular_electrode: Optional[List[IntracellularElectrode]] = Field(default_factory=list, description="""An intracellular electrode.""") + sweep_table: Optional[SweepTable] = Field(None, description="""[DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tables. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.""") + intracellular_recordings: Optional[IntracellularRecordingsTable] = Field(None, description="""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.""") + simultaneous_recordings: Optional[SimultaneousRecordingsTable] = Field(None, description="""A table for grouping different intracellular recordings from the IntracellularRecordingsTable table together that were recorded simultaneously from different electrodes""") + sequential_recordings: Optional[SequentialRecordingsTable] = Field(None, description="""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.""") + repetitions: Optional[RepetitionsTable] = Field(None, description="""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.""") + experimental_conditions: Optional[ExperimentalConditionsTable] = Field(None, description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""") class NWBFileIntervals(ConfiguredBaseModel): """ Experimental intervals, whether that be logically distinct sub-experiments having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data. """ - epochs: Optional[NWBFileIntervalsEpochs] = Field(None, description="""Divisions in time marking experimental stages or sub-divisions of a single recording session.""") - trials: Optional[NWBFileIntervalsTrials] = Field(None, description="""Repeated experimental events that have a logical grouping.""") - invalid_times: Optional[NWBFileIntervalsInvalidTimes] = Field(None, description="""Time intervals that should be removed from analysis.""") - TimeIntervals: Optional[List[TimeIntervals]] = Field(default_factory=list, description="""Optional additional table(s) for describing other experimental time intervals.""") - - -class NWBFileIntervalsEpochs(TimeIntervals): - """ - Divisions in time marking experimental stages or sub-divisions of a single recording session. - """ - start_time: Optional[List[float]] = Field(default_factory=list, description="""Start time of epoch, in seconds.""") - stop_time: Optional[List[float]] = Field(default_factory=list, description="""Stop time of epoch, in seconds.""") - tags: Optional[List[str]] = Field(default_factory=list, description="""User-defined tags that identify or categorize events.""") - tags_index: Optional[TimeIntervalsTagsIndex] = Field(None, description="""Index for tags.""") - timeseries: Optional[TimeIntervalsTimeseries] = Field(None, description="""An index into a TimeSeries object.""") - timeseries_index: Optional[TimeIntervalsTimeseriesIndex] = Field(None, description="""Index for timeseries.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileIntervalsTrials(TimeIntervals): - """ - Repeated experimental events that have a logical grouping. - """ - start_time: Optional[List[float]] = Field(default_factory=list, description="""Start time of epoch, in seconds.""") - stop_time: Optional[List[float]] = Field(default_factory=list, description="""Stop time of epoch, in seconds.""") - tags: Optional[List[str]] = Field(default_factory=list, description="""User-defined tags that identify or categorize events.""") - tags_index: Optional[TimeIntervalsTagsIndex] = Field(None, description="""Index for tags.""") - timeseries: Optional[TimeIntervalsTimeseries] = Field(None, description="""An index into a TimeSeries object.""") - timeseries_index: Optional[TimeIntervalsTimeseriesIndex] = Field(None, description="""Index for timeseries.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileIntervalsInvalidTimes(TimeIntervals): - """ - Time intervals that should be removed from analysis. - """ - start_time: Optional[List[float]] = Field(default_factory=list, description="""Start time of epoch, in seconds.""") - stop_time: Optional[List[float]] = Field(default_factory=list, description="""Stop time of epoch, in seconds.""") - tags: Optional[List[str]] = Field(default_factory=list, description="""User-defined tags that identify or categorize events.""") - tags_index: Optional[TimeIntervalsTagsIndex] = Field(None, description="""Index for tags.""") - timeseries: Optional[TimeIntervalsTimeseries] = Field(None, description="""An index into a TimeSeries object.""") - timeseries_index: Optional[TimeIntervalsTimeseriesIndex] = Field(None, description="""Index for timeseries.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class NWBFileUnits(Units): - """ - Data about sorted spike units. - """ - spike_times_index: Optional[UnitsSpikeTimesIndex] = Field(None, description="""Index into the spike_times dataset.""") - spike_times: Optional[UnitsSpikeTimes] = Field(None, description="""Spike times for each unit in seconds.""") - obs_intervals_index: Optional[UnitsObsIntervalsIndex] = Field(None, description="""Index into the obs_intervals dataset.""") - obs_intervals: Optional[UnitsObsIntervals] = Field(None, description="""Observation intervals for each unit.""") - electrodes_index: Optional[UnitsElectrodesIndex] = Field(None, description="""Index into electrodes.""") - electrodes: Optional[UnitsElectrodes] = Field(None, description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""") - electrode_group: Optional[List[ElectrodeGroup]] = Field(default_factory=list, description="""Electrode group that each spike unit came from.""") - waveform_mean: Optional[UnitsWaveformMean] = Field(None, description="""Spike waveform mean for each spike unit.""") - waveform_sd: Optional[UnitsWaveformSd] = Field(None, description="""Spike waveform standard deviation for each spike unit.""") - waveforms: Optional[UnitsWaveforms] = Field(None, description="""Individual waveforms for each spike on each electrode. This is a doubly indexed column. The 'waveforms_index' column indexes which waveforms in this column belong to the same spike event for a given unit, where each waveform was recorded from a different electrode. The 'waveforms_index_index' column indexes the 'waveforms_index' column to indicate which spike events belong to a given unit. For example, if the 'waveforms_index_index' column has values [2, 5, 6], then the first 2 elements of the 'waveforms_index' column correspond to the 2 spike events of the first unit, the next 3 elements of the 'waveforms_index' column correspond to the 3 spike events of the second unit, and the next 1 element of the 'waveforms_index' column corresponds to the 1 spike event of the third unit. If the 'waveforms_index' column has values [3, 6, 8, 10, 12, 13], then the first 3 elements of the 'waveforms' column contain the 3 spike waveforms that were recorded from 3 different electrodes for the first spike time of the first unit. See https://nwb-schema.readthedocs.io/en/stable/format_description.html#doubly-ragged-arrays for a graphical representation of this example. When there is only one electrode for each unit (i.e., each spike time is associated with a single waveform), then the 'waveforms_index' column will have values 1, 2, ..., N, where N is the number of spike events. The number of electrodes for each spike event should be the same within a given unit. The 'electrodes' column should be used to indicate which electrodes are associated with each unit, and the order of the waveforms within a given unit x spike event should be in the same order as the electrodes referenced in the 'electrodes' column of this table. The number of samples for each waveform must be the same.""") - waveforms_index: Optional[UnitsWaveformsIndex] = Field(None, description="""Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.""") - waveforms_index_index: Optional[UnitsWaveformsIndexIndex] = Field(None, description="""Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") + name: str = Field("intervals", const=True) + epochs: Optional[TimeIntervals] = Field(None, description="""Divisions in time marking experimental stages or sub-divisions of a single recording session.""") + trials: Optional[TimeIntervals] = Field(None, description="""Repeated experimental events that have a logical grouping.""") + invalid_times: Optional[TimeIntervals] = Field(None, description="""Time intervals that should be removed from analysis.""") + time_intervals: Optional[List[TimeIntervals]] = Field(default_factory=list, description="""Optional additional table(s) for describing other experimental time intervals.""") class SubjectAge(ConfiguredBaseModel): """ Age of subject. Can be supplied instead of 'date_of_birth'. """ + name: str = Field("age", const=True) reference: Optional[str] = Field(None, description="""Age is with reference to this event. Can be 'birth' or 'gestational'. If reference is omitted, 'birth' is implied.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -NWBFileFileCreateDate.update_forward_refs() -NWBFileAcquisition.update_forward_refs() -NWBFileAnalysis.update_forward_refs() -NWBFileScratch.update_forward_refs() -NWBFileProcessing.update_forward_refs() -NWBFileStimulus.update_forward_refs() -NWBFileStimulusPresentation.update_forward_refs() -NWBFileStimulusTemplates.update_forward_refs() -NWBFileGeneral.update_forward_refs() -NWBFileGeneralExperimenter.update_forward_refs() -NWBFileGeneralKeywords.update_forward_refs() -NWBFileGeneralRelatedPublications.update_forward_refs() -NWBFileGeneralSourceScript.update_forward_refs() -NWBFileGeneralDevices.update_forward_refs() -NWBFileGeneralSubject.update_forward_refs() -NWBFileGeneralExtracellularEphys.update_forward_refs() -NWBFileGeneralExtracellularEphysElectrodes.update_forward_refs() -NWBFileGeneralIntracellularEphys.update_forward_refs() -NWBFileGeneralIntracellularEphysSweepTable.update_forward_refs() -NWBFileGeneralIntracellularEphysIntracellularRecordings.update_forward_refs() -NWBFileGeneralIntracellularEphysSimultaneousRecordings.update_forward_refs() -NWBFileGeneralIntracellularEphysSequentialRecordings.update_forward_refs() -NWBFileGeneralIntracellularEphysRepetitions.update_forward_refs() -NWBFileGeneralIntracellularEphysExperimentalConditions.update_forward_refs() -NWBFileGeneralOptogenetics.update_forward_refs() -NWBFileGeneralOptophysiology.update_forward_refs() -NWBFileIntervals.update_forward_refs() -NWBFileIntervalsEpochs.update_forward_refs() -NWBFileIntervalsTrials.update_forward_refs() -NWBFileIntervalsInvalidTimes.update_forward_refs() -NWBFileUnits.update_forward_refs() -SubjectAge.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +NWBFileStimulus.model_rebuild() +NWBFileGeneral.model_rebuild() +NWBFileGeneralSourceScript.model_rebuild() +NWBFileGeneralExtracellularEphys.model_rebuild() +NWBFileGeneralIntracellularEphys.model_rebuild() +NWBFileIntervals.model_rebuild() +SubjectAge.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_icephys.py b/nwb_linkml/models/core_nwb_icephys.py index d48d914..7f5bff8 100644 --- a/nwb_linkml/models/core_nwb_icephys.py +++ b/nwb_linkml/models/core_nwb_icephys.py @@ -11,42 +11,38 @@ else: from typing_extensions import Literal -from .core_nwb_icephys_include import ( - IntracellularRecordingsTableResponses, - VoltageClampSeriesResistanceCompBandwidth, - RepetitionsTableSequentialRecordingsIndex, - ExperimentalConditionsTableRepetitionsIndex, - SequentialRecordingsTableSimultaneousRecordingsIndex, - IntracellularResponsesTableResponse, - VoltageClampSeriesWholeCellCapacitanceComp, - CurrentClampStimulusSeriesData, - IntracellularRecordingsTableElectrodes, - RepetitionsTableSequentialRecordings, - VoltageClampSeriesCapacitanceSlow, - IntracellularStimuliTableStimulus, - VoltageClampSeriesWholeCellSeriesResistanceComp, - VoltageClampSeriesData, - ExperimentalConditionsTableRepetitions, - PatchClampSeriesData, - VoltageClampSeriesResistanceCompPrediction, - IntracellularRecordingsTableStimuli, - CurrentClampSeriesData, - SimultaneousRecordingsTableRecordingsIndex, - SequentialRecordingsTableSimultaneousRecordings, - VoltageClampStimulusSeriesData, - VoltageClampSeriesResistanceCompCorrection, - SweepTableSeriesIndex, - VoltageClampSeriesCapacitanceFast, - SimultaneousRecordingsTableRecordings -) - from .core_nwb_base import ( TimeSeries, - NWBContainer, - DynamicTable + NWBContainer +) + +from .core_nwb_icephys_include import ( + VoltageClampSeriesCapacitanceSlow, + ExperimentalConditionsTableRepetitions, + VoltageClampStimulusSeriesData, + ExperimentalConditionsTableRepetitionsIndex, + VoltageClampSeriesResistanceCompPrediction, + VoltageClampSeriesWholeCellSeriesResistanceComp, + SequentialRecordingsTableSimultaneousRecordings, + VoltageClampSeriesCapacitanceFast, + RepetitionsTableSequentialRecordingsIndex, + IntracellularStimuliTableStimulus, + VoltageClampSeriesResistanceCompCorrection, + SequentialRecordingsTableSimultaneousRecordingsIndex, + SimultaneousRecordingsTableRecordings, + IntracellularResponsesTableResponse, + VoltageClampSeriesResistanceCompBandwidth, + CurrentClampSeriesData, + SimultaneousRecordingsTableRecordingsIndex, + VoltageClampSeriesData, + RepetitionsTableSequentialRecordings, + VoltageClampSeriesWholeCellCapacitanceComp, + CurrentClampStimulusSeriesData, + SweepTableSeriesIndex ) from .hdmf_common_table import ( + DynamicTable, AlignedDynamicTable ) @@ -54,13 +50,9 @@ from .hdmf_common_table import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -71,16 +63,17 @@ class PatchClampSeries(TimeSeries): """ An abstract base class for patch-clamp data - stimulus or response, current or voltage. """ + name: str = Field(...) stimulus_description: Optional[str] = Field(None, description="""Protocol/stimulus name for this patch-clamp dataset.""") sweep_number: Optional[int] = Field(None, description="""Sweep number, allows to group different PatchClampSeries together.""") - data: PatchClampSeriesData = Field(..., description="""Recorded voltage or current.""") + data: List[float] = Field(default_factory=list, description="""Recorded voltage or current.""") gain: Optional[float] = Field(None, description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -88,6 +81,7 @@ class CurrentClampSeries(PatchClampSeries): """ Voltage data from an intracellular current-clamp recording. A corresponding CurrentClampStimulusSeries (stored separately as a stimulus) is used to store the current injected. """ + name: str = Field(...) data: CurrentClampSeriesData = Field(..., description="""Recorded voltage.""") bias_current: Optional[float] = Field(None, description="""Bias current, in amps.""") bridge_balance: Optional[float] = Field(None, description="""Bridge balance, in ohms.""") @@ -98,9 +92,9 @@ class CurrentClampSeries(PatchClampSeries): description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -108,6 +102,7 @@ class IZeroClampSeries(CurrentClampSeries): """ Voltage data from an intracellular recording when all current and amplifier settings are off (i.e., CurrentClampSeries fields will be zero). There is no CurrentClampStimulusSeries associated with an IZero series because the amplifier is disconnected and no stimulus can reach the cell. """ + name: str = Field(...) stimulus_description: Optional[str] = Field(None, description="""An IZeroClampSeries has no stimulus, so this attribute is automatically set to \"N/A\"""") bias_current: float = Field(..., description="""Bias current, in amps, fixed to 0.0.""") bridge_balance: float = Field(..., description="""Bridge balance, in ohms, fixed to 0.0.""") @@ -118,9 +113,9 @@ class IZeroClampSeries(CurrentClampSeries): description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -128,6 +123,7 @@ class CurrentClampStimulusSeries(PatchClampSeries): """ Stimulus current applied during current clamp recording. """ + name: str = Field(...) data: CurrentClampStimulusSeriesData = Field(..., description="""Stimulus current applied.""") stimulus_description: Optional[str] = Field(None, description="""Protocol/stimulus name for this patch-clamp dataset.""") sweep_number: Optional[int] = Field(None, description="""Sweep number, allows to group different PatchClampSeries together.""") @@ -135,9 +131,9 @@ class CurrentClampStimulusSeries(PatchClampSeries): description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -145,6 +141,7 @@ class VoltageClampSeries(PatchClampSeries): """ Current data from an intracellular voltage-clamp recording. A corresponding VoltageClampStimulusSeries (stored separately as a stimulus) is used to store the voltage injected. """ + name: str = Field(...) data: VoltageClampSeriesData = Field(..., description="""Recorded current.""") capacitance_fast: Optional[VoltageClampSeriesCapacitanceFast] = Field(None, description="""Fast capacitance, in farads.""") capacitance_slow: Optional[VoltageClampSeriesCapacitanceSlow] = Field(None, description="""Slow capacitance, in farads.""") @@ -159,9 +156,9 @@ class VoltageClampSeries(PatchClampSeries): description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -169,6 +166,7 @@ class VoltageClampStimulusSeries(PatchClampSeries): """ Stimulus voltage applied during a voltage clamp recording. """ + name: str = Field(...) data: VoltageClampStimulusSeriesData = Field(..., description="""Stimulus voltage applied.""") stimulus_description: Optional[str] = Field(None, description="""Protocol/stimulus name for this patch-clamp dataset.""") sweep_number: Optional[int] = Field(None, description="""Sweep number, allows to group different PatchClampSeries together.""") @@ -176,9 +174,9 @@ class VoltageClampStimulusSeries(PatchClampSeries): description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -186,6 +184,7 @@ class IntracellularElectrode(NWBContainer): """ An intracellular electrode and its metadata. """ + name: str = Field(...) cell_id: Optional[str] = Field(None, description="""unique ID of the cell""") description: str = Field(..., description="""Description of electrode (e.g., whole-cell, sharp, etc.).""") filtering: Optional[str] = Field(None, description="""Electrode specific filtering.""") @@ -200,12 +199,13 @@ class SweepTable(DynamicTable): """ [DEPRECATED] Table used to group different PatchClampSeries. SweepTable is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable tables. Additional SequentialRecordingsTable, RepetitionsTable, and ExperimentalConditions tables provide enhanced support for experiment metadata. """ + name: str = Field(...) sweep_number: Optional[List[int]] = Field(default_factory=list, description="""Sweep number of the PatchClampSeries in that row.""") series: Optional[List[PatchClampSeries]] = Field(default_factory=list, description="""The PatchClampSeries with the sweep number in that row.""") series_index: SweepTableSeriesIndex = Field(..., description="""Index for series.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -213,10 +213,11 @@ class IntracellularElectrodesTable(DynamicTable): """ Table for storing intracellular electrode related metadata. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") electrode: Optional[List[IntracellularElectrode]] = Field(default_factory=list, description="""Column for storing the reference to the intracellular electrode.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -224,10 +225,11 @@ class IntracellularStimuliTable(DynamicTable): """ Table for storing intracellular stimulus related metadata. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") stimulus: IntracellularStimuliTableStimulus = Field(..., description="""Column storing the reference to the recorded stimulus for the recording (rows).""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -235,10 +237,11 @@ class IntracellularResponsesTable(DynamicTable): """ Table for storing intracellular response related metadata. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") response: IntracellularResponsesTableResponse = Field(..., description="""Column storing the reference to the recorded response for the recording (rows)""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -246,14 +249,15 @@ class IntracellularRecordingsTable(AlignedDynamicTable): """ 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 is recorded 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. """ + name: str = Field("intracellular_recordings", const=True) description: Optional[str] = Field(None, description="""Description of the contents of this table. Inherited from AlignedDynamicTable and overwritten here to fix the value of the attribute.""") - electrodes: IntracellularRecordingsTableElectrodes = Field(..., description="""Table for storing intracellular electrode related metadata.""") - stimuli: IntracellularRecordingsTableStimuli = Field(..., description="""Table for storing intracellular stimulus related metadata.""") - responses: IntracellularRecordingsTableResponses = Field(..., description="""Table for storing intracellular response related metadata.""") + electrodes: IntracellularElectrodesTable = Field(..., description="""Table for storing intracellular electrode related metadata.""") + stimuli: IntracellularStimuliTable = Field(..., description="""Table for storing intracellular stimulus related metadata.""") + responses: IntracellularResponsesTable = Field(..., description="""Table for storing intracellular response related metadata.""") categories: Optional[str] = Field(None, description="""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 and the category names must match the names of the corresponding DynamicTable in the group.""") - DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""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.""") + dynamic_table: Optional[List[DynamicTable]] = Field(default_factory=list, description="""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.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -261,11 +265,12 @@ class SimultaneousRecordingsTable(DynamicTable): """ A table for grouping different intracellular recordings from the IntracellularRecordingsTable table together that were recorded simultaneously from different electrodes. """ + name: str = Field("simultaneous_recordings", const=True) recordings: SimultaneousRecordingsTableRecordings = Field(..., description="""A reference to one or more rows in the IntracellularRecordingsTable table.""") recordings_index: SimultaneousRecordingsTableRecordingsIndex = Field(..., description="""Index dataset for the recordings column.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -273,12 +278,13 @@ class SequentialRecordingsTable(DynamicTable): """ A table for grouping different sequential recordings from the SimultaneousRecordingsTable table together. This is typically used to group together sequential recordings where a sequence of stimuli of the same type with varying parameters have been presented in a sequence. """ + name: str = Field("sequential_recordings", const=True) simultaneous_recordings: SequentialRecordingsTableSimultaneousRecordings = Field(..., description="""A reference to one or more rows in the SimultaneousRecordingsTable table.""") simultaneous_recordings_index: SequentialRecordingsTableSimultaneousRecordingsIndex = Field(..., description="""Index dataset for the simultaneous_recordings column.""") stimulus_type: Optional[List[str]] = Field(default_factory=list, description="""The type of stimulus used for the sequential recording.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -286,11 +292,12 @@ class RepetitionsTable(DynamicTable): """ 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. """ + name: str = Field("repetitions", const=True) sequential_recordings: RepetitionsTableSequentialRecordings = Field(..., description="""A reference to one or more rows in the SequentialRecordingsTable table.""") sequential_recordings_index: RepetitionsTableSequentialRecordingsIndex = Field(..., description="""Index dataset for the sequential_recordings column.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -298,30 +305,32 @@ class ExperimentalConditionsTable(DynamicTable): """ A table for grouping different intracellular recording repetitions together that belong to the same experimental condition. """ + name: str = Field("experimental_conditions", const=True) repetitions: ExperimentalConditionsTableRepetitions = Field(..., description="""A reference to one or more rows in the RepetitionsTable table.""") repetitions_index: ExperimentalConditionsTableRepetitionsIndex = Field(..., description="""Index dataset for the repetitions column.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -PatchClampSeries.update_forward_refs() -CurrentClampSeries.update_forward_refs() -IZeroClampSeries.update_forward_refs() -CurrentClampStimulusSeries.update_forward_refs() -VoltageClampSeries.update_forward_refs() -VoltageClampStimulusSeries.update_forward_refs() -IntracellularElectrode.update_forward_refs() -SweepTable.update_forward_refs() -IntracellularElectrodesTable.update_forward_refs() -IntracellularStimuliTable.update_forward_refs() -IntracellularResponsesTable.update_forward_refs() -IntracellularRecordingsTable.update_forward_refs() -SimultaneousRecordingsTable.update_forward_refs() -SequentialRecordingsTable.update_forward_refs() -RepetitionsTable.update_forward_refs() -ExperimentalConditionsTable.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +PatchClampSeries.model_rebuild() +CurrentClampSeries.model_rebuild() +IZeroClampSeries.model_rebuild() +CurrentClampStimulusSeries.model_rebuild() +VoltageClampSeries.model_rebuild() +VoltageClampStimulusSeries.model_rebuild() +IntracellularElectrode.model_rebuild() +SweepTable.model_rebuild() +IntracellularElectrodesTable.model_rebuild() +IntracellularStimuliTable.model_rebuild() +IntracellularResponsesTable.model_rebuild() +IntracellularRecordingsTable.model_rebuild() +SimultaneousRecordingsTable.model_rebuild() +SequentialRecordingsTable.model_rebuild() +RepetitionsTable.model_rebuild() +ExperimentalConditionsTable.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_icephys_include.py b/nwb_linkml/models/core_nwb_icephys_include.py index a014c3c..d6eedd3 100644 --- a/nwb_linkml/models/core_nwb_icephys_include.py +++ b/nwb_linkml/models/core_nwb_icephys_include.py @@ -16,49 +16,35 @@ from .hdmf_common_table import ( VectorIndex ) -from .core_nwb_base import ( - TimeSeriesReferenceVectorData +from .core_nwb_icephys import ( + SequentialRecordingsTable, + RepetitionsTable, + SimultaneousRecordingsTable, + IntracellularRecordingsTable ) -from .core_nwb_icephys import ( - SimultaneousRecordingsTable, - IntracellularElectrodesTable, - IntracellularResponsesTable, - SequentialRecordingsTable, - IntracellularRecordingsTable, - IntracellularStimuliTable, - RepetitionsTable +from .core_nwb_base import ( + TimeSeriesReferenceVectorData ) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): pass -class PatchClampSeriesData(ConfiguredBaseModel): - """ - Recorded voltage or current. - """ - unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") - data: List[float] = Field(default_factory=list, description="""Recorded voltage or current.""") - - class CurrentClampSeriesData(ConfiguredBaseModel): """ Recorded voltage. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. which is fixed to 'volts'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") @@ -66,6 +52,7 @@ class CurrentClampStimulusSeriesData(ConfiguredBaseModel): """ Stimulus current applied. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. which is fixed to 'amperes'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") @@ -73,6 +60,7 @@ class VoltageClampSeriesData(ConfiguredBaseModel): """ Recorded current. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. which is fixed to 'amperes'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") @@ -80,6 +68,7 @@ class VoltageClampSeriesCapacitanceFast(ConfiguredBaseModel): """ Fast capacitance, in farads. """ + name: str = Field("capacitance_fast", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""") @@ -87,6 +76,7 @@ class VoltageClampSeriesCapacitanceSlow(ConfiguredBaseModel): """ Slow capacitance, in farads. """ + name: str = Field("capacitance_slow", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""") @@ -94,6 +84,7 @@ class VoltageClampSeriesResistanceCompBandwidth(ConfiguredBaseModel): """ Resistance compensation bandwidth, in hertz. """ + name: str = Field("resistance_comp_bandwidth", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for resistance_comp_bandwidth, which is fixed to 'hertz'.""") @@ -101,6 +92,7 @@ class VoltageClampSeriesResistanceCompCorrection(ConfiguredBaseModel): """ Resistance compensation correction, in percent. """ + name: str = Field("resistance_comp_correction", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for resistance_comp_correction, which is fixed to 'percent'.""") @@ -108,6 +100,7 @@ class VoltageClampSeriesResistanceCompPrediction(ConfiguredBaseModel): """ Resistance compensation prediction, in percent. """ + name: str = Field("resistance_comp_prediction", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for resistance_comp_prediction, which is fixed to 'percent'.""") @@ -115,6 +108,7 @@ class VoltageClampSeriesWholeCellCapacitanceComp(ConfiguredBaseModel): """ Whole cell capacitance compensation, in farads. """ + name: str = Field("whole_cell_capacitance_comp", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for whole_cell_capacitance_comp, which is fixed to 'farads'.""") @@ -122,6 +116,7 @@ class VoltageClampSeriesWholeCellSeriesResistanceComp(ConfiguredBaseModel): """ Whole cell series resistance compensation, in ohms. """ + name: str = Field("whole_cell_series_resistance_comp", const=True) unit: Optional[str] = Field(None, description="""Unit of measurement for whole_cell_series_resistance_comp, which is fixed to 'ohms'.""") @@ -129,6 +124,7 @@ class VoltageClampStimulusSeriesData(ConfiguredBaseModel): """ Stimulus voltage applied. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. which is fixed to 'volts'. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion' and add 'offset'.""") @@ -136,158 +132,188 @@ class SweepTableSeriesIndex(VectorIndex): """ Index for series. """ + name: str = Field("series_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class IntracellularStimuliTableStimulus(TimeSeriesReferenceVectorData): """ Column storing the reference to the recorded stimulus for the recording (rows). """ + name: str = Field("stimulus", const=True) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class IntracellularResponsesTableResponse(TimeSeriesReferenceVectorData): """ Column storing the reference to the recorded response for the recording (rows) """ + name: str = Field("response", const=True) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class IntracellularRecordingsTableElectrodes(IntracellularElectrodesTable): - """ - Table for storing intracellular electrode related metadata. - """ - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - electrode: Optional[List[IntracellularElectrode]] = Field(default_factory=list, description="""Column for storing the reference to the intracellular electrode.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class IntracellularRecordingsTableStimuli(IntracellularStimuliTable): - """ - Table for storing intracellular stimulus related metadata. - """ - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - stimulus: IntracellularStimuliTableStimulus = Field(..., description="""Column storing the reference to the recorded stimulus for the recording (rows).""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class IntracellularRecordingsTableResponses(IntracellularResponsesTable): - """ - Table for storing intracellular response related metadata. - """ - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - response: IntracellularResponsesTableResponse = Field(..., description="""Column storing the reference to the recorded response for the recording (rows)""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class SimultaneousRecordingsTableRecordings(DynamicTableRegion): """ A reference to one or more rows in the IntracellularRecordingsTable table. """ + name: str = Field("recordings", const=True) table: Optional[IntracellularRecordingsTable] = Field(None, description="""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.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class SimultaneousRecordingsTableRecordingsIndex(VectorIndex): """ Index dataset for the recordings column. """ + name: str = Field("recordings_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class SequentialRecordingsTableSimultaneousRecordings(DynamicTableRegion): """ A reference to one or more rows in the SimultaneousRecordingsTable table. """ + name: str = Field("simultaneous_recordings", const=True) table: Optional[SimultaneousRecordingsTable] = Field(None, description="""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.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class SequentialRecordingsTableSimultaneousRecordingsIndex(VectorIndex): """ Index dataset for the simultaneous_recordings column. """ + name: str = Field("simultaneous_recordings_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class RepetitionsTableSequentialRecordings(DynamicTableRegion): """ A reference to one or more rows in the SequentialRecordingsTable table. """ + name: str = Field("sequential_recordings", const=True) table: Optional[SequentialRecordingsTable] = Field(None, description="""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.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class RepetitionsTableSequentialRecordingsIndex(VectorIndex): """ Index dataset for the sequential_recordings column. """ + name: str = Field("sequential_recordings_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class ExperimentalConditionsTableRepetitions(DynamicTableRegion): """ A reference to one or more rows in the RepetitionsTable table. """ + name: str = Field("repetitions", const=True) table: Optional[RepetitionsTable] = Field(None, description="""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.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class ExperimentalConditionsTableRepetitionsIndex(VectorIndex): """ Index dataset for the repetitions column. """ + name: str = Field("repetitions_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -PatchClampSeriesData.update_forward_refs() -CurrentClampSeriesData.update_forward_refs() -CurrentClampStimulusSeriesData.update_forward_refs() -VoltageClampSeriesData.update_forward_refs() -VoltageClampSeriesCapacitanceFast.update_forward_refs() -VoltageClampSeriesCapacitanceSlow.update_forward_refs() -VoltageClampSeriesResistanceCompBandwidth.update_forward_refs() -VoltageClampSeriesResistanceCompCorrection.update_forward_refs() -VoltageClampSeriesResistanceCompPrediction.update_forward_refs() -VoltageClampSeriesWholeCellCapacitanceComp.update_forward_refs() -VoltageClampSeriesWholeCellSeriesResistanceComp.update_forward_refs() -VoltageClampStimulusSeriesData.update_forward_refs() -SweepTableSeriesIndex.update_forward_refs() -IntracellularStimuliTableStimulus.update_forward_refs() -IntracellularResponsesTableResponse.update_forward_refs() -IntracellularRecordingsTableElectrodes.update_forward_refs() -IntracellularRecordingsTableStimuli.update_forward_refs() -IntracellularRecordingsTableResponses.update_forward_refs() -SimultaneousRecordingsTableRecordings.update_forward_refs() -SimultaneousRecordingsTableRecordingsIndex.update_forward_refs() -SequentialRecordingsTableSimultaneousRecordings.update_forward_refs() -SequentialRecordingsTableSimultaneousRecordingsIndex.update_forward_refs() -RepetitionsTableSequentialRecordings.update_forward_refs() -RepetitionsTableSequentialRecordingsIndex.update_forward_refs() -ExperimentalConditionsTableRepetitions.update_forward_refs() -ExperimentalConditionsTableRepetitionsIndex.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +CurrentClampSeriesData.model_rebuild() +CurrentClampStimulusSeriesData.model_rebuild() +VoltageClampSeriesData.model_rebuild() +VoltageClampSeriesCapacitanceFast.model_rebuild() +VoltageClampSeriesCapacitanceSlow.model_rebuild() +VoltageClampSeriesResistanceCompBandwidth.model_rebuild() +VoltageClampSeriesResistanceCompCorrection.model_rebuild() +VoltageClampSeriesResistanceCompPrediction.model_rebuild() +VoltageClampSeriesWholeCellCapacitanceComp.model_rebuild() +VoltageClampSeriesWholeCellSeriesResistanceComp.model_rebuild() +VoltageClampStimulusSeriesData.model_rebuild() +SweepTableSeriesIndex.model_rebuild() +IntracellularStimuliTableStimulus.model_rebuild() +IntracellularResponsesTableResponse.model_rebuild() +SimultaneousRecordingsTableRecordings.model_rebuild() +SimultaneousRecordingsTableRecordingsIndex.model_rebuild() +SequentialRecordingsTableSimultaneousRecordings.model_rebuild() +SequentialRecordingsTableSimultaneousRecordingsIndex.model_rebuild() +RepetitionsTableSequentialRecordings.model_rebuild() +RepetitionsTableSequentialRecordingsIndex.model_rebuild() +ExperimentalConditionsTableRepetitions.model_rebuild() +ExperimentalConditionsTableRepetitionsIndex.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_image.py b/nwb_linkml/models/core_nwb_image.py index 7c9c9f4..c05d446 100644 --- a/nwb_linkml/models/core_nwb_image.py +++ b/nwb_linkml/models/core_nwb_image.py @@ -11,44 +11,38 @@ else: from typing_extensions import Literal -# from .core_nwb_image_include import ( -# ImageSeriesData, -# OpticalSeriesFieldOfView, -# RGBAImageArray, -# IndexSeriesData, -# ImageSeriesDimension, -# OpticalSeriesData, -# ImageSeriesExternalFile, -# GrayscaleImageArray, -# RGBImageArray -# ) - from .core_nwb_base import ( - Image, - TimeSeries + TimeSeries, + Image +) + +from .core_nwb_image_include import ( + ImageSeriesData, + RGBAImageArray, + GrayscaleImageArray, + RGBImageArray, + OpticalSeriesFieldOfView, + OpticalSeriesData ) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): pass -class GrayscaleImage(ConfiguredBaseModel): +class GrayscaleImage(Image): """ A grayscale image. """ + name: str = Field(...) array: Optional[NDArray[Shape["* x, * y"], Number]] = Field(None) resolution: Optional[float] = Field(None, description="""Pixel resolution of the image, in pixels per centimeter.""") description: Optional[str] = Field(None, description="""Description of the image.""") @@ -58,6 +52,7 @@ class RGBImage(Image): """ A color image. """ + name: str = Field(...) array: Optional[NDArray[Shape["* x, * y, 3 r_g_b"], Number]] = Field(None) resolution: Optional[float] = Field(None, description="""Pixel resolution of the image, in pixels per centimeter.""") description: Optional[str] = Field(None, description="""Description of the image.""") @@ -67,86 +62,92 @@ class RGBAImage(Image): """ A color image with transparency. """ + name: str = Field(...) array: Optional[NDArray[Shape["* x, * y, 4 r_g_b_a"], Number]] = Field(None) resolution: Optional[float] = Field(None, description="""Pixel resolution of the image, in pixels per centimeter.""") description: Optional[str] = Field(None, description="""Description of the image.""") -# -# class ImageSeries(TimeSeries): -# """ -# General image data that is common between acquisition and stimulus time series. Sometimes the image data is stored in the file in a raw format while other times it will be stored as a series of external image files in the host file system. The data field will either be binary data, if the data is stored in the NWB file, or empty, if the data is stored in an external image stack. [frame][x][y] or [frame][x][y][z]. -# """ -# data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") -# dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") -# external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") -# format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") -# description: Optional[str] = Field(None, description="""Description of the time series.""") -# comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") -# starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") -# timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") -# control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") -# control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") -# sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") -# -# -# class ImageMaskSeries(ImageSeries): -# """ -# An alpha mask that is applied to a presented visual stimulus. The 'data' array contains an array of mask values that are applied to the displayed image. Mask values are stored as RGBA. Mask can vary with time. The timestamps array indicates the starting time of a mask, and that mask pattern continues until it's explicitly changed. -# """ -# data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") -# dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") -# external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") -# format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") -# description: Optional[str] = Field(None, description="""Description of the time series.""") -# comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") -# starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") -# timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") -# control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") -# control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") -# sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") -# -# -# class OpticalSeries(ImageSeries): -# """ -# Image data that is presented or recorded. A stimulus template movie will be stored only as an image. When the image is presented as stimulus, additional data is required, such as field of view (e.g., how much of the visual field the image covers, or how what is the area of the target being imaged). If the OpticalSeries represents acquired imaging data, orientation is also important. -# """ -# distance: Optional[float] = Field(None, description="""Distance from camera/monitor to target/eye.""") -# field_of_view: Optional[OpticalSeriesFieldOfView] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""") -# data: OpticalSeriesData = Field(..., description="""Images presented to subject, either grayscale or RGB""") -# orientation: Optional[str] = Field(None, description="""Description of image relative to some reference frame (e.g., which way is up). Must also specify frame of reference.""") -# dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") -# external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") -# format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") -# description: Optional[str] = Field(None, description="""Description of the time series.""") -# comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") -# starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") -# timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") -# control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") -# control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") -# sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") -# -# -# class IndexSeries(TimeSeries): -# """ -# Stores indices to image frames stored in an ImageSeries. The purpose of the IndexSeries is to allow a static image stack to be stored in an Images object, and the images in the stack to be referenced out-of-order. This can be for the display of individual images, or of movie segments (as a movie is simply a series of images). The data field stores the index of the frame in the referenced Images object, and the timestamps array indicates when that image was displayed. -# """ -# data: IndexSeriesData = Field(..., description="""Index of the image (using zero-indexing) in the linked Images object.""") -# description: Optional[str] = Field(None, description="""Description of the time series.""") -# comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") -# starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") -# timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") -# control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") -# control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") -# sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") -# -# -# -# # Update forward refs -# # see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -# GrayscaleImage.update_forward_refs() -# RGBImage.update_forward_refs() -# RGBAImage.update_forward_refs() -# ImageSeries.update_forward_refs() -# ImageMaskSeries.update_forward_refs() -# OpticalSeries.update_forward_refs() -# IndexSeries.update_forward_refs() + +class ImageSeries(TimeSeries): + """ + General image data that is common between acquisition and stimulus time series. Sometimes the image data is stored in the file in a raw format while other times it will be stored as a series of external image files in the host file system. The data field will either be binary data, if the data is stored in the NWB file, or empty, if the data is stored in an external image stack. [frame][x][y] or [frame][x][y][z]. + """ + name: str = Field(...) + data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") + dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") + external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") + format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") + description: Optional[str] = Field(None, description="""Description of the time series.""") + comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") + starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") + + +class ImageMaskSeries(ImageSeries): + """ + An alpha mask that is applied to a presented visual stimulus. The 'data' array contains an array of mask values that are applied to the displayed image. Mask values are stored as RGBA. Mask can vary with time. The timestamps array indicates the starting time of a mask, and that mask pattern continues until it's explicitly changed. + """ + name: str = Field(...) + data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") + dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") + external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") + format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") + description: Optional[str] = Field(None, description="""Description of the time series.""") + comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") + starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") + + +class OpticalSeries(ImageSeries): + """ + Image data that is presented or recorded. A stimulus template movie will be stored only as an image. When the image is presented as stimulus, additional data is required, such as field of view (e.g., how much of the visual field the image covers, or how what is the area of the target being imaged). If the OpticalSeries represents acquired imaging data, orientation is also important. + """ + name: str = Field(...) + distance: Optional[float] = Field(None, description="""Distance from camera/monitor to target/eye.""") + field_of_view: Optional[OpticalSeriesFieldOfView] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""") + data: OpticalSeriesData = Field(..., description="""Images presented to subject, either grayscale or RGB""") + orientation: Optional[str] = Field(None, description="""Description of image relative to some reference frame (e.g., which way is up). Must also specify frame of reference.""") + dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") + external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") + format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") + description: Optional[str] = Field(None, description="""Description of the time series.""") + comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") + starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") + + +class IndexSeries(TimeSeries): + """ + Stores indices to image frames stored in an ImageSeries. The purpose of the IndexSeries is to allow a static image stack to be stored in an Images object, and the images in the stack to be referenced out-of-order. This can be for the display of individual images, or of movie segments (as a movie is simply a series of images). The data field stores the index of the frame in the referenced Images object, and the timestamps array indicates when that image was displayed. + """ + name: str = Field(...) + data: List[int] = Field(default_factory=list, description="""Index of the image (using zero-indexing) in the linked Images object.""") + description: Optional[str] = Field(None, description="""Description of the time series.""") + comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") + starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") + + + +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +GrayscaleImage.model_rebuild() +RGBImage.model_rebuild() +RGBAImage.model_rebuild() +ImageSeries.model_rebuild() +ImageMaskSeries.model_rebuild() +OpticalSeries.model_rebuild() +IndexSeries.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_image_include.py b/nwb_linkml/models/core_nwb_image_include.py index bc3a474..2768709 100644 --- a/nwb_linkml/models/core_nwb_image_include.py +++ b/nwb_linkml/models/core_nwb_image_include.py @@ -19,13 +19,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -34,29 +30,33 @@ class ConfiguredBaseModel(WeakRefShimBaseModel, class GrayscaleImageArray(Arraylike): - x: Optional[float] = Field(None) - y: Optional[float] = Field(None) + x: float = Field(...) + y: float = Field(...) class RGBImageArray(Arraylike): - x: Optional[float] = Field(None) - y: Optional[float] = Field(None) - r_g_b: Optional[float] = Field(None) + x: float = Field(...) + y: float = Field(...) + r_g_b: float = Field(...) class RGBAImageArray(Arraylike): - x: Optional[float] = Field(None) - y: Optional[float] = Field(None) - r_g_b_a: Optional[float] = Field(None) + x: float = Field(...) + y: float = Field(...) + r_g_b_a: float = Field(...) class ImageSeriesData(ConfiguredBaseModel): """ Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array. """ - array: Optional[NDArray[Shape["* frame, * x, * y, * z"], Number]] = Field(None) + name: str = Field("data", const=True) + array: Optional[Union[ + NDArray[Shape["* frame, * x, * y"], Number], + NDArray[Shape["* frame, * x, * y, * z"], Number] + ]] = Field(None) class ImageSeriesDataArray(Arraylike): @@ -67,26 +67,15 @@ class ImageSeriesDataArray(Arraylike): z: Optional[float] = Field(None) -class ImageSeriesDimension(ConfiguredBaseModel): - """ - Number of pixels on x, y, (and z) axes. - """ - dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") - - -class ImageSeriesExternalFile(ConfiguredBaseModel): - """ - Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file. - """ - starting_frame: Optional[int] = Field(None, description="""Each external image may contain one or more consecutive frames of the full ImageSeries. This attribute serves as an index to indicate which frames each file contains, to facilitate random access. The 'starting_frame' attribute, hence, contains a list of frame numbers within the full ImageSeries of the first frame of each file listed in the parent 'external_file' dataset. Zero-based indexing is used (hence, the first element will always be zero). For example, if the 'external_file' dataset has three paths to files and the first file has 5 frames, the second file has 10 frames, and the third file has 20 frames, then this attribute will have values [0, 5, 15]. If there is a single external file that holds all of the frames of the ImageSeries (and so there is a single element in the 'external_file' dataset), then this attribute should have value [0].""") - external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") - - class OpticalSeriesFieldOfView(ConfiguredBaseModel): """ Width, height and depth of image, or imaged area, in meters. """ - array: Optional[NDArray[Shape["2 width_height, 3 width_height_depth"], Float32]] = Field(None) + name: str = Field("field_of_view", const=True) + array: Optional[Union[ + NDArray[Shape["2 width_height"], Float32], + NDArray[Shape["2 width_height, 3 width_height_depth"], Float32] + ]] = Field(None) class OpticalSeriesFieldOfViewArray(Arraylike): @@ -99,7 +88,11 @@ class OpticalSeriesData(ConfiguredBaseModel): """ Images presented to subject, either grayscale or RGB """ - array: Optional[NDArray[Shape["* frame, * x, * y, 3 r_g_b"], Number]] = Field(None) + name: str = Field("data", const=True) + array: Optional[Union[ + NDArray[Shape["* frame, * x, * y"], Number], + NDArray[Shape["* frame, * x, * y, 3 r_g_b"], Number] + ]] = Field(None) class OpticalSeriesDataArray(Arraylike): @@ -110,29 +103,16 @@ class OpticalSeriesDataArray(Arraylike): r_g_b: Optional[float] = Field(None) -class IndexSeriesData(ConfiguredBaseModel): - """ - Index of the image (using zero-indexing) in the linked Images object. - """ - conversion: Optional[float] = Field(None, description="""This field is unused by IndexSeries.""") - resolution: Optional[float] = Field(None, description="""This field is unused by IndexSeries.""") - offset: Optional[float] = Field(None, description="""This field is unused by IndexSeries.""") - unit: Optional[str] = Field(None, description="""This field is unused by IndexSeries and has the value N/A.""") - data: List[int] = Field(default_factory=list, description="""Index of the image (using zero-indexing) in the linked Images object.""") - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -GrayscaleImageArray.update_forward_refs() -RGBImageArray.update_forward_refs() -RGBAImageArray.update_forward_refs() -ImageSeriesData.update_forward_refs() -ImageSeriesDataArray.update_forward_refs() -ImageSeriesDimension.update_forward_refs() -ImageSeriesExternalFile.update_forward_refs() -OpticalSeriesFieldOfView.update_forward_refs() -OpticalSeriesFieldOfViewArray.update_forward_refs() -OpticalSeriesData.update_forward_refs() -OpticalSeriesDataArray.update_forward_refs() -IndexSeriesData.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +GrayscaleImageArray.model_rebuild() +RGBImageArray.model_rebuild() +RGBAImageArray.model_rebuild() +ImageSeriesData.model_rebuild() +ImageSeriesDataArray.model_rebuild() +OpticalSeriesFieldOfView.model_rebuild() +OpticalSeriesFieldOfViewArray.model_rebuild() +OpticalSeriesData.model_rebuild() +OpticalSeriesDataArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_misc.py b/nwb_linkml/models/core_nwb_misc.py index 741df45..be7b2f3 100644 --- a/nwb_linkml/models/core_nwb_misc.py +++ b/nwb_linkml/models/core_nwb_misc.py @@ -11,26 +11,25 @@ else: from typing_extensions import Literal +from .hdmf_common_table import ( + DynamicTable +) + from .core_nwb_misc_include import ( - AbstractFeatureSeriesFeatures, + UnitsElectrodes, UnitsElectrodesIndex, UnitsObsIntervalsIndex, - DecompositionSeriesData, UnitsSpikeTimes, - UnitsWaveformMean, - UnitsWaveformsIndexIndex, - UnitsWaveforms, - UnitsWaveformsIndex, - AnnotationSeriesData, - UnitsObsIntervals, - AbstractFeatureSeriesFeatureUnits, - DecompositionSeriesBands, + UnitsSpikeTimesIndex, UnitsWaveformSd, - UnitsElectrodes, - IntervalSeriesData, - DecompositionSeriesSourceChannels, + UnitsWaveformMean, + UnitsWaveforms, AbstractFeatureSeriesData, - UnitsSpikeTimesIndex + UnitsWaveformsIndexIndex, + UnitsObsIntervals, + UnitsWaveformsIndex, + DecompositionSeriesData, + DecompositionSeriesSourceChannels ) from .core_nwb_base import ( @@ -41,21 +40,13 @@ from .core_nwb_ecephys import ( ElectrodeGroup ) -from .hdmf_common_table import ( - DynamicTable -) - metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -66,15 +57,16 @@ class AbstractFeatureSeries(TimeSeries): """ Abstract features, such as quantitative descriptions of sensory stimuli. The TimeSeries::data field is a 2D array, storing those features (e.g., for visual grating stimulus this might be orientation, spatial frequency and contrast). Null stimuli (eg, uniform gray) can be marked as being an independent feature (eg, 1.0 for gray, 0.0 for actual stimulus) or by storing NaNs for feature values, or through use of the TimeSeries::control fields. A set of features is considered to persist until the next set of features is defined. The final set of features stored should be the null set. This is useful when storing the raw stimulus is impractical. """ + name: str = Field(...) data: AbstractFeatureSeriesData = Field(..., description="""Values of each feature at each time.""") - feature_units: Optional[AbstractFeatureSeriesFeatureUnits] = Field(None, description="""Units of each feature.""") - features: AbstractFeatureSeriesFeatures = Field(..., description="""Description of the features represented in TimeSeries::data.""") + feature_units: Optional[List[str]] = Field(default_factory=list, description="""Units of each feature.""") + features: List[str] = Field(default_factory=list, description="""Description of the features represented in TimeSeries::data.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -82,13 +74,14 @@ class AnnotationSeries(TimeSeries): """ Stores user annotations made during an experiment. The data[] field stores a text array, and timestamps are stored for each annotation (ie, interval=1). This is largely an alias to a standard TimeSeries storing a text array but that is identifiable as storing annotations in a machine-readable way. """ - data: AnnotationSeriesData = Field(..., description="""Annotations made during an experiment.""") + name: str = Field(...) + data: List[str] = Field(default_factory=list, description="""Annotations made during an experiment.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -96,13 +89,14 @@ class IntervalSeries(TimeSeries): """ Stores intervals of data. The timestamps field stores the beginning and end of intervals. The data field stores whether the interval just started (>0 value) or ended (<0 value). Different interval types can be represented in the same series by using multiple key values (eg, 1 for feature A, 2 for feature B, 3 for feature C, etc). The field data stores an 8-bit integer. This is largely an alias of a standard TimeSeries but that is identifiable as representing time intervals in a machine-readable way. """ - data: IntervalSeriesData = Field(..., description="""Use values >0 if interval started, <0 if interval ended.""") + name: str = Field(...) + data: List[int] = Field(default_factory=list, description="""Use values >0 if interval started, <0 if interval ended.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -110,16 +104,17 @@ class DecompositionSeries(TimeSeries): """ Spectral analysis of a time series, e.g. of an LFP or a speech signal. """ + name: str = Field(...) data: DecompositionSeriesData = Field(..., description="""Data decomposed into frequency bands.""") metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""") source_channels: Optional[DecompositionSeriesSourceChannels] = Field(None, description="""DynamicTableRegion pointer to the channels that this decomposition series was generated from.""") - bands: DecompositionSeriesBands = Field(..., description="""Table for describing the bands that this series was generated from. There should be one row in this table for each band.""") + bands: DynamicTable = Field(..., description="""Table for describing the bands that this series was generated from. There should be one row in this table for each band.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -127,6 +122,7 @@ class Units(DynamicTable): """ Data about spiking units. Event times of observed units (e.g. cell, synapse, etc.) should be concatenated and stored in spike_times. """ + name: str = Field(...) spike_times_index: Optional[UnitsSpikeTimesIndex] = Field(None, description="""Index into the spike_times dataset.""") spike_times: Optional[UnitsSpikeTimes] = Field(None, description="""Spike times for each unit in seconds.""") obs_intervals_index: Optional[UnitsObsIntervalsIndex] = Field(None, description="""Index into the obs_intervals dataset.""") @@ -141,15 +137,16 @@ class Units(DynamicTable): waveforms_index_index: Optional[UnitsWaveformsIndexIndex] = Field(None, description="""Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -AbstractFeatureSeries.update_forward_refs() -AnnotationSeries.update_forward_refs() -IntervalSeries.update_forward_refs() -DecompositionSeries.update_forward_refs() -Units.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +AbstractFeatureSeries.model_rebuild() +AnnotationSeries.model_rebuild() +IntervalSeries.model_rebuild() +DecompositionSeries.model_rebuild() +Units.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_misc_include.py b/nwb_linkml/models/core_nwb_misc_include.py index 33e78f7..1dca01f 100644 --- a/nwb_linkml/models/core_nwb_misc_include.py +++ b/nwb_linkml/models/core_nwb_misc_include.py @@ -13,9 +13,8 @@ else: from .hdmf_common_table import ( DynamicTableRegion, - DynamicTable, - VectorIndex, - VectorData + VectorData, + VectorIndex ) from .nwb_language import ( @@ -26,13 +25,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -43,8 +38,12 @@ class AbstractFeatureSeriesData(ConfiguredBaseModel): """ Values of each feature at each time. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Since there can be different units for different features, store the units in 'feature_units'. The default value for this attribute is \"see 'feature_units'\".""") - array: Optional[NDArray[Shape["* num_times, * num_features"], Number]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* num_times"], Number], + NDArray[Shape["* num_times, * num_features"], Number] + ]] = Field(None) class AbstractFeatureSeriesDataArray(Arraylike): @@ -53,225 +52,221 @@ class AbstractFeatureSeriesDataArray(Arraylike): num_features: Optional[float] = Field(None) -class AbstractFeatureSeriesFeatureUnits(ConfiguredBaseModel): - """ - Units of each feature. - """ - feature_units: Optional[List[str]] = Field(default_factory=list, description="""Units of each feature.""") - - -class AbstractFeatureSeriesFeatures(ConfiguredBaseModel): - """ - Description of the features represented in TimeSeries::data. - """ - features: List[str] = Field(default_factory=list, description="""Description of the features represented in TimeSeries::data.""") - - -class AnnotationSeriesData(ConfiguredBaseModel): - """ - Annotations made during an experiment. - """ - resolution: Optional[float] = Field(None, description="""Smallest meaningful difference between values in data. Annotations have no units, so the value is fixed to -1.0.""") - unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. Annotations have no units, so the value is fixed to 'n/a'.""") - data: List[str] = Field(default_factory=list, description="""Annotations made during an experiment.""") - - -class IntervalSeriesData(ConfiguredBaseModel): - """ - Use values >0 if interval started, <0 if interval ended. - """ - resolution: Optional[float] = Field(None, description="""Smallest meaningful difference between values in data. Annotations have no units, so the value is fixed to -1.0.""") - unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. Annotations have no units, so the value is fixed to 'n/a'.""") - data: List[int] = Field(default_factory=list, description="""Use values >0 if interval started, <0 if interval ended.""") - - class DecompositionSeriesData(ConfiguredBaseModel): """ Data decomposed into frequency bands. """ + name: str = Field("data", const=True) unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. Actual stored values are not necessarily stored in these units. To access the data in these units, multiply 'data' by 'conversion'.""") array: Optional[NDArray[Shape["* num_times, * num_channels, * num_bands"], Number]] = Field(None) class DecompositionSeriesDataArray(Arraylike): - num_times: Optional[float] = Field(None) - num_channels: Optional[float] = Field(None) - num_bands: Optional[float] = Field(None) + num_times: float = Field(...) + num_channels: float = Field(...) + num_bands: float = Field(...) class DecompositionSeriesSourceChannels(DynamicTableRegion): """ DynamicTableRegion pointer to the channels that this decomposition series was generated from. """ + name: str = Field("source_channels", const=True) table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class DecompositionSeriesBands(DynamicTable): - """ - Table for describing the bands that this series was generated from. There should be one row in this table for each band. - """ - band_name: Optional[List[str]] = Field(default_factory=list, description="""Name of the band, e.g. theta.""") - band_limits: DecompositionSeriesBandsBandLimits = Field(..., description="""Low and high limit of each band in Hz. If it is a Gaussian filter, use 2 SD on either side of the center.""") - band_mean: DecompositionSeriesBandsBandMean = Field(..., description="""The mean Gaussian filters, in Hz.""") - band_stdev: DecompositionSeriesBandsBandStdev = Field(..., description="""The standard deviation of Gaussian filters, in Hz.""") - colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") - description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") - VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") - - -class DecompositionSeriesBandsBandLimits(VectorData): - """ - Low and high limit of each band in Hz. If it is a Gaussian filter, use 2 SD on either side of the center. - """ - description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class DecompositionSeriesBandsBandMean(VectorData): - """ - The mean Gaussian filters, in Hz. - """ - description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class DecompositionSeriesBandsBandStdev(VectorData): - """ - The standard deviation of Gaussian filters, in Hz. - """ - description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsSpikeTimesIndex(VectorIndex): """ Index into the spike_times dataset. """ + name: str = Field("spike_times_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsSpikeTimes(VectorData): """ Spike times for each unit in seconds. """ + name: str = Field("spike_times", const=True) resolution: Optional[float] = Field(None, description="""The smallest possible difference between two spike times. Usually 1 divided by the acquisition sampling rate from which spike times were extracted, but could be larger if the acquisition time series was downsampled or smaller if the acquisition time series was smoothed/interpolated and it is possible for the spike time to be between samples.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsObsIntervalsIndex(VectorIndex): """ Index into the obs_intervals dataset. """ + name: str = Field("obs_intervals_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsObsIntervals(VectorData): """ Observation intervals for each unit. """ + name: str = Field("obs_intervals", const=True) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsElectrodesIndex(VectorIndex): """ Index into electrodes. """ + name: str = Field("electrodes_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsElectrodes(DynamicTableRegion): """ Electrode that each spike unit came from, specified using a DynamicTableRegion. """ + name: str = Field("electrodes", const=True) table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsWaveformMean(VectorData): """ Spike waveform mean for each spike unit. """ + name: str = Field("waveform_mean", const=True) sampling_rate: Optional[float] = Field(None, description="""Sampling rate, in hertz.""") unit: Optional[str] = Field(None, description="""Unit of measurement. This value is fixed to 'volts'.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsWaveformSd(VectorData): """ Spike waveform standard deviation for each spike unit. """ + name: str = Field("waveform_sd", const=True) sampling_rate: Optional[float] = Field(None, description="""Sampling rate, in hertz.""") unit: Optional[str] = Field(None, description="""Unit of measurement. This value is fixed to 'volts'.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsWaveforms(VectorData): """ Individual waveforms for each spike on each electrode. This is a doubly indexed column. The 'waveforms_index' column indexes which waveforms in this column belong to the same spike event for a given unit, where each waveform was recorded from a different electrode. The 'waveforms_index_index' column indexes the 'waveforms_index' column to indicate which spike events belong to a given unit. For example, if the 'waveforms_index_index' column has values [2, 5, 6], then the first 2 elements of the 'waveforms_index' column correspond to the 2 spike events of the first unit, the next 3 elements of the 'waveforms_index' column correspond to the 3 spike events of the second unit, and the next 1 element of the 'waveforms_index' column corresponds to the 1 spike event of the third unit. If the 'waveforms_index' column has values [3, 6, 8, 10, 12, 13], then the first 3 elements of the 'waveforms' column contain the 3 spike waveforms that were recorded from 3 different electrodes for the first spike time of the first unit. See https://nwb-schema.readthedocs.io/en/stable/format_description.html#doubly-ragged-arrays for a graphical representation of this example. When there is only one electrode for each unit (i.e., each spike time is associated with a single waveform), then the 'waveforms_index' column will have values 1, 2, ..., N, where N is the number of spike events. The number of electrodes for each spike event should be the same within a given unit. The 'electrodes' column should be used to indicate which electrodes are associated with each unit, and the order of the waveforms within a given unit x spike event should be in the same order as the electrodes referenced in the 'electrodes' column of this table. The number of samples for each waveform must be the same. """ + name: str = Field("waveforms", const=True) sampling_rate: Optional[float] = Field(None, description="""Sampling rate, in hertz.""") unit: Optional[str] = Field(None, description="""Unit of measurement. This value is fixed to 'volts'.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsWaveformsIndex(VectorIndex): """ Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail. """ + name: str = Field("waveforms_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class UnitsWaveformsIndexIndex(VectorIndex): """ Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail. """ + name: str = Field("waveforms_index_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -AbstractFeatureSeriesData.update_forward_refs() -AbstractFeatureSeriesDataArray.update_forward_refs() -AbstractFeatureSeriesFeatureUnits.update_forward_refs() -AbstractFeatureSeriesFeatures.update_forward_refs() -AnnotationSeriesData.update_forward_refs() -IntervalSeriesData.update_forward_refs() -DecompositionSeriesData.update_forward_refs() -DecompositionSeriesDataArray.update_forward_refs() -DecompositionSeriesSourceChannels.update_forward_refs() -DecompositionSeriesBands.update_forward_refs() -DecompositionSeriesBandsBandLimits.update_forward_refs() -DecompositionSeriesBandsBandMean.update_forward_refs() -DecompositionSeriesBandsBandStdev.update_forward_refs() -UnitsSpikeTimesIndex.update_forward_refs() -UnitsSpikeTimes.update_forward_refs() -UnitsObsIntervalsIndex.update_forward_refs() -UnitsObsIntervals.update_forward_refs() -UnitsElectrodesIndex.update_forward_refs() -UnitsElectrodes.update_forward_refs() -UnitsWaveformMean.update_forward_refs() -UnitsWaveformSd.update_forward_refs() -UnitsWaveforms.update_forward_refs() -UnitsWaveformsIndex.update_forward_refs() -UnitsWaveformsIndexIndex.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +AbstractFeatureSeriesData.model_rebuild() +AbstractFeatureSeriesDataArray.model_rebuild() +DecompositionSeriesData.model_rebuild() +DecompositionSeriesDataArray.model_rebuild() +DecompositionSeriesSourceChannels.model_rebuild() +UnitsSpikeTimesIndex.model_rebuild() +UnitsSpikeTimes.model_rebuild() +UnitsObsIntervalsIndex.model_rebuild() +UnitsObsIntervals.model_rebuild() +UnitsElectrodesIndex.model_rebuild() +UnitsElectrodes.model_rebuild() +UnitsWaveformMean.model_rebuild() +UnitsWaveformSd.model_rebuild() +UnitsWaveforms.model_rebuild() +UnitsWaveformsIndex.model_rebuild() +UnitsWaveformsIndexIndex.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_ogen.py b/nwb_linkml/models/core_nwb_ogen.py index 704882d..19bea43 100644 --- a/nwb_linkml/models/core_nwb_ogen.py +++ b/nwb_linkml/models/core_nwb_ogen.py @@ -16,21 +16,13 @@ from .core_nwb_base import ( TimeSeries ) -from .core_nwb_ogen_include import ( - OptogeneticSeriesData -) - metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -41,13 +33,14 @@ class OptogeneticSeries(TimeSeries): """ An optogenetic stimulus. """ - data: OptogeneticSeriesData = Field(..., description="""Applied power for optogenetic stimulus, in watts.""") + name: str = Field(...) + data: List[float] = Field(default_factory=list, description="""Applied power for optogenetic stimulus, in watts.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -55,13 +48,15 @@ class OptogeneticStimulusSite(NWBContainer): """ A site of optogenetic stimulation. """ + name: str = Field(...) description: str = Field(..., description="""Description of stimulation site.""") excitation_lambda: float = Field(..., description="""Excitation wavelength, in nm.""") location: str = Field(..., description="""Location of the stimulation site. Specify the area, layer, comments on estimation of area/layer, stereotaxic coordinates if in vivo, etc. Use standard atlas names for anatomical regions when possible.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -OptogeneticSeries.update_forward_refs() -OptogeneticStimulusSite.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +OptogeneticSeries.model_rebuild() +OptogeneticStimulusSite.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_ogen_include.py b/nwb_linkml/models/core_nwb_ogen_include.py index 357dc55..2918798 100644 --- a/nwb_linkml/models/core_nwb_ogen_include.py +++ b/nwb_linkml/models/core_nwb_ogen_include.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -37,6 +33,7 @@ class OptogeneticSeriesData(ConfiguredBaseModel): -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -OptogeneticSeriesData.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +OptogeneticSeriesData.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_ophys.py b/nwb_linkml/models/core_nwb_ophys.py index 909acc2..c833b85 100644 --- a/nwb_linkml/models/core_nwb_ophys.py +++ b/nwb_linkml/models/core_nwb_ophys.py @@ -11,25 +11,22 @@ else: from typing_extensions import Literal -from .core_nwb_ophys_include import ( - CorrectedImageStackXyTranslation, - PlaneSegmentationVoxelMaskIndex, - ImagingPlaneOriginCoords, - TwoPhotonSeriesFieldOfView, - RoiResponseSeriesRois, - CorrectedImageStackCorrected, - ImagingPlaneManifold, - PlaneSegmentationImageMask, - PlaneSegmentationReferenceImages, - ImagingPlaneGridSpacing, - RoiResponseSeriesData, - PlaneSegmentationPixelMaskIndex -) - from .core_nwb_base import ( TimeSeries, - NWBContainer, - NWBDataInterface + NWBDataInterface, + NWBContainer +) + +from .core_nwb_ophys_include import ( + RoiResponseSeriesRois, + TwoPhotonSeriesFieldOfView, + ImagingPlaneOriginCoords, + RoiResponseSeriesData, + PlaneSegmentationPixelMaskIndex, + PlaneSegmentationImageMask, + ImagingPlaneGridSpacing, + PlaneSegmentationVoxelMaskIndex, + ImagingPlaneManifold ) from .hdmf_common_table import ( @@ -44,13 +41,9 @@ from .core_nwb_image import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -61,6 +54,7 @@ class OnePhotonSeries(ImageSeries): """ Image stack recorded over time from 1-photon microscope. """ + name: str = Field(...) pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""") scan_line_rate: Optional[float] = Field(None, description="""Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.""") exposure_time: Optional[float] = Field(None, description="""Exposure time of the sample; often the inverse of the frequency.""") @@ -68,15 +62,15 @@ class OnePhotonSeries(ImageSeries): power: Optional[float] = Field(None, description="""Power of the excitation in mW, if known.""") intensity: Optional[float] = Field(None, description="""Intensity of the excitation in mW/mm^2, if known.""") data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") - dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") - external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") + dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") + external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -84,19 +78,20 @@ class TwoPhotonSeries(ImageSeries): """ Image stack recorded over time from 2-photon microscope. """ + name: str = Field(...) pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""") scan_line_rate: Optional[float] = Field(None, description="""Lines imaged per second. This is also stored in /general/optophysiology but is kept here as it is useful information for analysis, and so good to be stored w/ the actual data.""") field_of_view: Optional[TwoPhotonSeriesFieldOfView] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""") data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") - dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") - external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") + dimension: Optional[List[int]] = Field(default_factory=list, description="""Number of pixels on x, y, (and z) axes.""") + external_file: Optional[List[str]] = Field(default_factory=list, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -104,14 +99,15 @@ class RoiResponseSeries(TimeSeries): """ ROI responses over an imaging plane. The first dimension represents time. The second dimension, if present, represents ROIs. """ + name: str = Field(...) data: RoiResponseSeriesData = Field(..., description="""Signals from ROIs.""") rois: RoiResponseSeriesRois = Field(..., description="""DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.""") description: Optional[str] = Field(None, description="""Description of the time series.""") comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") + timestamps: Optional[List[float]] = Field(default_factory=list, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") + control: Optional[List[int]] = Field(default_factory=list, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") + control_description: Optional[List[str]] = Field(default_factory=list, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") @@ -119,36 +115,40 @@ class DfOverF(NWBDataInterface): """ dF/F information about a region of interest (ROI). Storage hierarchy of dF/F should be the same as for segmentation (i.e., same names for ROIs and for image planes). """ - RoiResponseSeries: List[RoiResponseSeries] = Field(default_factory=list, description="""RoiResponseSeries object(s) containing dF/F for a ROI.""") + name: str = Field(...) + roi_response_series: List[RoiResponseSeries] = Field(default_factory=list, description="""RoiResponseSeries object(s) containing dF/F for a ROI.""") class Fluorescence(NWBDataInterface): """ Fluorescence information about a region of interest (ROI). Storage hierarchy of fluorescence should be the same as for segmentation (ie, same names for ROIs and for image planes). """ - RoiResponseSeries: List[RoiResponseSeries] = Field(default_factory=list, description="""RoiResponseSeries object(s) containing fluorescence data for a ROI.""") + name: str = Field(...) + roi_response_series: List[RoiResponseSeries] = Field(default_factory=list, description="""RoiResponseSeries object(s) containing fluorescence data for a ROI.""") class ImageSegmentation(NWBDataInterface): """ Stores pixels in an image that represent different regions of interest (ROIs) or masks. All segmentation for a given imaging plane is stored together, with storage for multiple imaging planes (masks) supported. Each ROI is stored in its own subgroup, with the ROI group containing both a 2D mask and a list of pixels that make up this mask. Segments can also be used for masking neuropil. If segmentation is allowed to change with time, a new imaging plane (or module) is required and ROI names should remain consistent between them. """ - PlaneSegmentation: List[PlaneSegmentation] = Field(default_factory=list, description="""Results from image segmentation of a specific imaging plane.""") + name: str = Field(...) + plane_segmentation: List[PlaneSegmentation] = Field(default_factory=list, description="""Results from image segmentation of a specific imaging plane.""") class PlaneSegmentation(DynamicTable): """ Results from image segmentation of a specific imaging plane. """ + name: str = Field(...) image_mask: Optional[PlaneSegmentationImageMask] = Field(None, description="""ROI masks for each ROI. Each image mask is the size of the original imaging plane (or volume) and members of the ROI are finite non-zero.""") pixel_mask_index: Optional[PlaneSegmentationPixelMaskIndex] = Field(None, description="""Index into pixel_mask.""") pixel_mask: Optional[List[Any]] = Field(default_factory=list, description="""Pixel masks for each ROI: a list of indices and weights for the ROI. Pixel masks are concatenated and parsing of this dataset is maintained by the PlaneSegmentation""") voxel_mask_index: Optional[PlaneSegmentationVoxelMaskIndex] = Field(None, description="""Index into voxel_mask.""") voxel_mask: Optional[List[Any]] = Field(default_factory=list, description="""Voxel masks for each ROI: a list of indices and weights for the ROI. Voxel masks are concatenated and parsing of this dataset is maintained by the PlaneSegmentation""") - reference_images: PlaneSegmentationReferenceImages = Field(..., description="""Image stacks that the segmentation masks apply to.""") + reference_images: Optional[List[ImageSeries]] = Field(default_factory=list, description="""Image stacks that the segmentation masks apply to.""") colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") - id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") @@ -156,6 +156,7 @@ class ImagingPlane(NWBContainer): """ An imaging plane and its metadata. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of the imaging plane.""") excitation_lambda: float = Field(..., description="""Excitation wavelength, in nm.""") imaging_rate: Optional[float] = Field(None, description="""Rate that images are acquired, in Hz. If the corresponding TimeSeries is present, the rate should be stored there instead.""") @@ -165,13 +166,14 @@ class ImagingPlane(NWBContainer): origin_coords: Optional[ImagingPlaneOriginCoords] = Field(None, description="""Physical location of the first element of the imaging plane (0, 0) for 2-D data or (0, 0, 0) for 3-D data. See also reference_frame for what the physical location is relative to (e.g., bregma).""") grid_spacing: Optional[ImagingPlaneGridSpacing] = Field(None, description="""Space between pixels in (x, y) or voxels in (x, y, z) directions, in the specified unit. Assumes imaging plane is a regular grid. See also reference_frame to interpret the grid.""") reference_frame: Optional[str] = Field(None, description="""Describes reference frame of origin_coords and grid_spacing. For example, this can be a text description of the anatomical location and orientation of the grid defined by origin_coords and grid_spacing or the vectors needed to transform or rotate the grid to a common anatomical axis (e.g., AP/DV/ML). This field is necessary to interpret origin_coords and grid_spacing. If origin_coords and grid_spacing are not present, then this field is not required. For example, if the microscope takes 10 x 10 x 2 images, where the first value of the data matrix (index (0, 0, 0)) corresponds to (-1.2, -0.6, -2) mm relative to bregma, the spacing between pixels is 0.2 mm in x, 0.2 mm in y and 0.5 mm in z, and larger numbers in x means more anterior, larger numbers in y means more rightward, and larger numbers in z means more ventral, then enter the following -- origin_coords = (-1.2, -0.6, -2) grid_spacing = (0.2, 0.2, 0.5) reference_frame = \"Origin coordinates are relative to bregma. First dimension corresponds to anterior-posterior axis (larger index = more anterior). Second dimension corresponds to medial-lateral axis (larger index = more rightward). Third dimension corresponds to dorsal-ventral axis (larger index = more ventral).\"""") - OpticalChannel: List[OpticalChannel] = Field(default_factory=list, description="""An optical channel used to record from an imaging plane.""") + optical_channel: List[OpticalChannel] = Field(default_factory=list, description="""An optical channel used to record from an imaging plane.""") class OpticalChannel(NWBContainer): """ An optical channel used to record from an imaging plane. """ + name: str = Field(...) description: str = Field(..., description="""Description or other notes about the channel.""") emission_lambda: float = Field(..., description="""Emission wavelength for channel, in nm.""") @@ -180,28 +182,31 @@ class MotionCorrection(NWBDataInterface): """ An image stack where all frames are shifted (registered) to a common coordinate system, to account for movement and drift between frames. Note: each frame at each point in time is assumed to be 2-D (has only x & y dimensions). """ - CorrectedImageStack: List[CorrectedImageStack] = Field(default_factory=list, description="""Reuslts from motion correction of an image stack.""") + name: str = Field(...) + corrected_image_stack: List[CorrectedImageStack] = Field(default_factory=list, description="""Reuslts from motion correction of an image stack.""") class CorrectedImageStack(NWBDataInterface): """ Reuslts from motion correction of an image stack. """ - corrected: CorrectedImageStackCorrected = Field(..., description="""Image stack with frames shifted to the common coordinates.""") - xy_translation: CorrectedImageStackXyTranslation = Field(..., description="""Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image.""") + name: str = Field(...) + corrected: ImageSeries = Field(..., description="""Image stack with frames shifted to the common coordinates.""") + xy_translation: TimeSeries = Field(..., description="""Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -OnePhotonSeries.update_forward_refs() -TwoPhotonSeries.update_forward_refs() -RoiResponseSeries.update_forward_refs() -DfOverF.update_forward_refs() -Fluorescence.update_forward_refs() -ImageSegmentation.update_forward_refs() -PlaneSegmentation.update_forward_refs() -ImagingPlane.update_forward_refs() -OpticalChannel.update_forward_refs() -MotionCorrection.update_forward_refs() -CorrectedImageStack.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +OnePhotonSeries.model_rebuild() +TwoPhotonSeries.model_rebuild() +RoiResponseSeries.model_rebuild() +DfOverF.model_rebuild() +Fluorescence.model_rebuild() +ImageSegmentation.model_rebuild() +PlaneSegmentation.model_rebuild() +ImagingPlane.model_rebuild() +OpticalChannel.model_rebuild() +MotionCorrection.model_rebuild() +CorrectedImageStack.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_ophys_include.py b/nwb_linkml/models/core_nwb_ophys_include.py index 5947ced..3747ce7 100644 --- a/nwb_linkml/models/core_nwb_ophys_include.py +++ b/nwb_linkml/models/core_nwb_ophys_include.py @@ -13,33 +13,21 @@ else: from .hdmf_common_table import ( DynamicTableRegion, - VectorIndex, - VectorData -) - -from .core_nwb_image import ( - ImageSeries + VectorData, + VectorIndex ) from .nwb_language import ( Arraylike ) -from .core_nwb_base import ( - TimeSeries -) - metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -50,7 +38,11 @@ class TwoPhotonSeriesFieldOfView(ConfiguredBaseModel): """ Width, height and depth of image, or imaged area, in meters. """ - array: Optional[NDArray[Shape["2 width|height, 3 width|height|depth"], Float32]] = Field(None) + name: str = Field("field_of_view", const=True) + array: Optional[Union[ + NDArray[Shape["2 width|height"], Float32], + NDArray[Shape["2 width|height, 3 width|height|depth"], Float32] + ]] = Field(None) class TwoPhotonSeriesFieldOfViewArray(Arraylike): @@ -63,7 +55,11 @@ class RoiResponseSeriesData(ConfiguredBaseModel): """ Signals from ROIs. """ - array: Optional[NDArray[Shape["* num_times, * num_ROIs"], Number]] = Field(None) + name: str = Field("data", const=True) + array: Optional[Union[ + NDArray[Shape["* num_times"], Number], + NDArray[Shape["* num_times, * num_ROIs"], Number] + ]] = Field(None) class RoiResponseSeriesDataArray(Arraylike): @@ -76,51 +72,72 @@ class RoiResponseSeriesRois(DynamicTableRegion): """ DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries. """ + name: str = Field("rois", const=True) table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") description: Optional[str] = Field(None, description="""Description of what this table region points to.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class PlaneSegmentationImageMask(VectorData): """ ROI masks for each ROI. Each image mask is the size of the original imaging plane (or volume) and members of the ROI are finite non-zero. """ + name: str = Field("image_mask", const=True) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class PlaneSegmentationPixelMaskIndex(VectorIndex): """ Index into pixel_mask. """ + name: str = Field("pixel_mask_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class PlaneSegmentationVoxelMaskIndex(VectorIndex): """ Index into voxel_mask. """ + name: str = Field("voxel_mask_index", const=True) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) - - -class PlaneSegmentationReferenceImages(ConfiguredBaseModel): - """ - Image stacks that the segmentation masks apply to. - """ - ImageSeries: Optional[List[ImageSeries]] = Field(default_factory=list, description="""One or more image stacks that the masks apply to (can be one-element stack).""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class ImagingPlaneManifold(ConfiguredBaseModel): """ DEPRECATED Physical position of each pixel. 'xyz' represents the position of the pixel relative to the defined coordinate space. Deprecated in favor of origin_coords and grid_spacing. """ + name: str = Field("manifold", const=True) conversion: Optional[float] = Field(None, description="""Scalar to multiply each element in data to convert it to the specified 'unit'. If the data are stored in acquisition system units or other units that require a conversion to be interpretable, multiply the data by 'conversion' to convert the data to the specified 'unit'. e.g. if the data acquisition system stores values in this object as pixels from x = -500 to 499, y = -500 to 499 that correspond to a 2 m x 2 m range, then the 'conversion' multiplier to get from raw data acquisition pixel units to meters is 2/1000.""") unit: Optional[str] = Field(None, description="""Base unit of measurement for working with the data. The default value is 'meters'.""") - array: Optional[NDArray[Shape["* height, * width, 3 x_y_z, * depth"], Float32]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* height, * width, 3 x_y_z"], Float32], + NDArray[Shape["* height, * width, 3 x_y_z, * depth"], Float32] + ]] = Field(None) class ImagingPlaneManifoldArray(Arraylike): @@ -135,8 +152,12 @@ class ImagingPlaneOriginCoords(ConfiguredBaseModel): """ Physical location of the first element of the imaging plane (0, 0) for 2-D data or (0, 0, 0) for 3-D data. See also reference_frame for what the physical location is relative to (e.g., bregma). """ + name: str = Field("origin_coords", const=True) unit: Optional[str] = Field(None, description="""Measurement units for origin_coords. The default value is 'meters'.""") - array: Optional[NDArray[Shape["2 x_y, 3 x_y_z"], Float32]] = Field(None) + array: Optional[Union[ + NDArray[Shape["2 x_y"], Float32], + NDArray[Shape["2 x_y, 3 x_y_z"], Float32] + ]] = Field(None) class ImagingPlaneOriginCoordsArray(Arraylike): @@ -149,8 +170,12 @@ class ImagingPlaneGridSpacing(ConfiguredBaseModel): """ Space between pixels in (x, y) or voxels in (x, y, z) directions, in the specified unit. Assumes imaging plane is a regular grid. See also reference_frame to interpret the grid. """ + name: str = Field("grid_spacing", const=True) unit: Optional[str] = Field(None, description="""Measurement units for grid_spacing. The default value is 'meters'.""") - array: Optional[NDArray[Shape["2 x_y, 3 x_y_z"], Float32]] = Field(None) + array: Optional[Union[ + NDArray[Shape["2 x_y"], Float32], + NDArray[Shape["2 x_y, 3 x_y_z"], Float32] + ]] = Field(None) class ImagingPlaneGridSpacingArray(Arraylike): @@ -159,54 +184,21 @@ class ImagingPlaneGridSpacingArray(Arraylike): x_y_z: Optional[float] = Field(None) -class CorrectedImageStackCorrected(ImageSeries): - """ - Image stack with frames shifted to the common coordinates. - """ - data: ImageSeriesData = Field(..., description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""") - dimension: Optional[ImageSeriesDimension] = Field(None, description="""Number of pixels on x, y, (and z) axes.""") - external_file: Optional[ImageSeriesExternalFile] = Field(None, description="""Paths to one or more external file(s). The field is only present if format='external'. This is only relevant if the image series is stored in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file.""") - format: Optional[str] = Field(None, description="""Format of image. If this is 'external', then the attribute 'external_file' contains the path information to the image files. If this is 'raw', then the raw (single-channel) binary data is stored in the 'data' dataset. If this attribute is not present, then the default format='raw' case is assumed.""") - description: Optional[str] = Field(None, description="""Description of the time series.""") - comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") - starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") - sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") - -class CorrectedImageStackXyTranslation(TimeSeries): - """ - Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image. - """ - description: Optional[str] = Field(None, description="""Description of the time series.""") - comments: Optional[str] = Field(None, description="""Human-readable comments about the TimeSeries. This second descriptive field can be used to store additional information, or descriptive information if the primary description field is populated with a computer-readable string.""") - data: TimeSeriesData = Field(..., description="""Data values. Data can be in 1-D, 2-D, 3-D, or 4-D. The first dimension should always represent time. This can also be used to store binary data (e.g., image frames). This can also be a link to data stored in an external file.""") - starting_time: Optional[TimeSeriesStartingTime] = Field(None, description="""Timestamp of the first sample in seconds. When timestamps are uniformly spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute.""") - timestamps: Optional[TimeSeriesTimestamps] = Field(None, description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""") - control: Optional[TimeSeriesControl] = Field(None, description="""Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data.""") - control_description: Optional[TimeSeriesControlDescription] = Field(None, description="""Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0.""") - sync: Optional[TimeSeriesSync] = Field(None, description="""Lab-specific time and sync information as provided directly from hardware devices and that is necessary for aligning all acquired time information to a common timebase. The timestamp array stores time in the common timebase. This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes.""") - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -TwoPhotonSeriesFieldOfView.update_forward_refs() -TwoPhotonSeriesFieldOfViewArray.update_forward_refs() -RoiResponseSeriesData.update_forward_refs() -RoiResponseSeriesDataArray.update_forward_refs() -RoiResponseSeriesRois.update_forward_refs() -PlaneSegmentationImageMask.update_forward_refs() -PlaneSegmentationPixelMaskIndex.update_forward_refs() -PlaneSegmentationVoxelMaskIndex.update_forward_refs() -PlaneSegmentationReferenceImages.update_forward_refs() -ImagingPlaneManifold.update_forward_refs() -ImagingPlaneManifoldArray.update_forward_refs() -ImagingPlaneOriginCoords.update_forward_refs() -ImagingPlaneOriginCoordsArray.update_forward_refs() -ImagingPlaneGridSpacing.update_forward_refs() -ImagingPlaneGridSpacingArray.update_forward_refs() -CorrectedImageStackCorrected.update_forward_refs() -CorrectedImageStackXyTranslation.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +TwoPhotonSeriesFieldOfView.model_rebuild() +TwoPhotonSeriesFieldOfViewArray.model_rebuild() +RoiResponseSeriesData.model_rebuild() +RoiResponseSeriesDataArray.model_rebuild() +RoiResponseSeriesRois.model_rebuild() +PlaneSegmentationImageMask.model_rebuild() +PlaneSegmentationPixelMaskIndex.model_rebuild() +PlaneSegmentationVoxelMaskIndex.model_rebuild() +ImagingPlaneManifold.model_rebuild() +ImagingPlaneManifoldArray.model_rebuild() +ImagingPlaneOriginCoords.model_rebuild() +ImagingPlaneOriginCoordsArray.model_rebuild() +ImagingPlaneGridSpacing.model_rebuild() +ImagingPlaneGridSpacingArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_retinotopy.py b/nwb_linkml/models/core_nwb_retinotopy.py index feffd83..7d6fc4b 100644 --- a/nwb_linkml/models/core_nwb_retinotopy.py +++ b/nwb_linkml/models/core_nwb_retinotopy.py @@ -12,14 +12,13 @@ else: from .core_nwb_retinotopy_include import ( - ImagingRetinotopyAxisDescriptions, - ImagingRetinotopyFocalDepthImage, - ImagingRetinotopyAxis2PowerMap, - ImagingRetinotopyVasculatureImage, - ImagingRetinotopyAxis2PhaseMap, - ImagingRetinotopyAxis1PhaseMap, ImagingRetinotopyAxis1PowerMap, - ImagingRetinotopySignMap + ImagingRetinotopyAxis1PhaseMap, + ImagingRetinotopyVasculatureImage, + ImagingRetinotopySignMap, + ImagingRetinotopyAxis2PowerMap, + ImagingRetinotopyAxis2PhaseMap, + ImagingRetinotopyFocalDepthImage ) from .core_nwb_base import ( @@ -30,13 +29,9 @@ from .core_nwb_base import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -47,17 +42,19 @@ class ImagingRetinotopy(NWBDataInterface): """ Intrinsic signal optical imaging or widefield imaging for measuring retinotopy. Stores orthogonal maps (e.g., altitude/azimuth; radius/theta) of responses to specific stimuli and a combined polarity map from which to identify visual areas. This group does not store the raw responses imaged during retinotopic mapping or the stimuli presented, but rather the resulting phase and power maps after applying a Fourier transform on the averaged responses. Note: for data consistency, all images and arrays are stored in the format [row][column] and [row, col], which equates to [y][x]. Field of view and dimension arrays may appear backward (i.e., y before x). """ + name: str = Field(...) axis_1_phase_map: ImagingRetinotopyAxis1PhaseMap = Field(..., description="""Phase response to stimulus on the first measured axis.""") axis_1_power_map: Optional[ImagingRetinotopyAxis1PowerMap] = Field(None, description="""Power response on the first measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power.""") axis_2_phase_map: ImagingRetinotopyAxis2PhaseMap = Field(..., description="""Phase response to stimulus on the second measured axis.""") axis_2_power_map: Optional[ImagingRetinotopyAxis2PowerMap] = Field(None, description="""Power response on the second measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power.""") - axis_descriptions: ImagingRetinotopyAxisDescriptions = Field(..., description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""") + axis_descriptions: List[str] = Field(default_factory=list, description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""") focal_depth_image: Optional[ImagingRetinotopyFocalDepthImage] = Field(None, description="""Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns].""") sign_map: Optional[ImagingRetinotopySignMap] = Field(None, description="""Sine of the angle between the direction of the gradient in axis_1 and axis_2.""") vasculature_image: ImagingRetinotopyVasculatureImage = Field(..., description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ImagingRetinotopy.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ImagingRetinotopy.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/core_nwb_retinotopy_include.py b/nwb_linkml/models/core_nwb_retinotopy_include.py index 136213e..1f79d76 100644 --- a/nwb_linkml/models/core_nwb_retinotopy_include.py +++ b/nwb_linkml/models/core_nwb_retinotopy_include.py @@ -19,13 +19,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -36,6 +32,7 @@ class ImagingRetinotopyAxis1PhaseMap(ConfiguredBaseModel): """ Phase response to stimulus on the first measured axis. """ + name: str = Field("axis_1_phase_map", const=True) dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") unit: Optional[str] = Field(None, description="""Unit that axis data is stored in (e.g., degrees).""") @@ -44,14 +41,15 @@ class ImagingRetinotopyAxis1PhaseMap(ConfiguredBaseModel): class ImagingRetinotopyAxis1PhaseMapArray(Arraylike): - num_rows: Optional[float] = Field(None) - num_cols: Optional[float] = Field(None) + num_rows: float = Field(...) + num_cols: float = Field(...) class ImagingRetinotopyAxis1PowerMap(ConfiguredBaseModel): """ Power response on the first measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power. """ + name: str = Field("axis_1_power_map", const=True) dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") unit: Optional[str] = Field(None, description="""Unit that axis data is stored in (e.g., degrees).""") @@ -60,14 +58,15 @@ class ImagingRetinotopyAxis1PowerMap(ConfiguredBaseModel): class ImagingRetinotopyAxis1PowerMapArray(Arraylike): - num_rows: Optional[float] = Field(None) - num_cols: Optional[float] = Field(None) + num_rows: float = Field(...) + num_cols: float = Field(...) class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel): """ Phase response to stimulus on the second measured axis. """ + name: str = Field("axis_2_phase_map", const=True) dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") unit: Optional[str] = Field(None, description="""Unit that axis data is stored in (e.g., degrees).""") @@ -76,14 +75,15 @@ class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel): class ImagingRetinotopyAxis2PhaseMapArray(Arraylike): - num_rows: Optional[float] = Field(None) - num_cols: Optional[float] = Field(None) + num_rows: float = Field(...) + num_cols: float = Field(...) class ImagingRetinotopyAxis2PowerMap(ConfiguredBaseModel): """ Power response on the second measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power. """ + name: str = Field("axis_2_power_map", const=True) dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") unit: Optional[str] = Field(None, description="""Unit that axis data is stored in (e.g., degrees).""") @@ -92,21 +92,15 @@ class ImagingRetinotopyAxis2PowerMap(ConfiguredBaseModel): class ImagingRetinotopyAxis2PowerMapArray(Arraylike): - num_rows: Optional[float] = Field(None) - num_cols: Optional[float] = Field(None) - - -class ImagingRetinotopyAxisDescriptions(ConfiguredBaseModel): - """ - Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta']. - """ - axis_descriptions: List[str] = Field(default_factory=list, description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""") + num_rows: float = Field(...) + num_cols: float = Field(...) class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel): """ Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns]. """ + name: str = Field("focal_depth_image", const=True) bits_per_pixel: Optional[int] = Field(None, description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value.""") dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") @@ -117,14 +111,15 @@ class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel): class ImagingRetinotopyFocalDepthImageArray(Arraylike): - num_rows: Optional[int] = Field(None) - num_cols: Optional[int] = Field(None) + num_rows: int = Field(...) + num_cols: int = Field(...) class ImagingRetinotopySignMap(ConfiguredBaseModel): """ Sine of the angle between the direction of the gradient in axis_1 and axis_2. """ + name: str = Field("sign_map", const=True) dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") array: Optional[NDArray[Shape["* num_rows, * num_cols"], Float32]] = Field(None) @@ -132,14 +127,15 @@ class ImagingRetinotopySignMap(ConfiguredBaseModel): class ImagingRetinotopySignMapArray(Arraylike): - num_rows: Optional[float] = Field(None) - num_cols: Optional[float] = Field(None) + num_rows: float = Field(...) + num_cols: float = Field(...) class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel): """ Gray-scale anatomical image of cortical surface. Array structure: [rows][columns] """ + name: str = Field("vasculature_image", const=True) bits_per_pixel: Optional[int] = Field(None, description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value""") dimension: Optional[int] = Field(None, description="""Number of rows and columns in the image. NOTE: row, column representation is equivalent to height, width.""") field_of_view: Optional[float] = Field(None, description="""Size of viewing area, in meters.""") @@ -149,25 +145,25 @@ class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel): class ImagingRetinotopyVasculatureImageArray(Arraylike): - num_rows: Optional[int] = Field(None) - num_cols: Optional[int] = Field(None) + num_rows: int = Field(...) + num_cols: int = Field(...) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -ImagingRetinotopyAxis1PhaseMap.update_forward_refs() -ImagingRetinotopyAxis1PhaseMapArray.update_forward_refs() -ImagingRetinotopyAxis1PowerMap.update_forward_refs() -ImagingRetinotopyAxis1PowerMapArray.update_forward_refs() -ImagingRetinotopyAxis2PhaseMap.update_forward_refs() -ImagingRetinotopyAxis2PhaseMapArray.update_forward_refs() -ImagingRetinotopyAxis2PowerMap.update_forward_refs() -ImagingRetinotopyAxis2PowerMapArray.update_forward_refs() -ImagingRetinotopyAxisDescriptions.update_forward_refs() -ImagingRetinotopyFocalDepthImage.update_forward_refs() -ImagingRetinotopyFocalDepthImageArray.update_forward_refs() -ImagingRetinotopySignMap.update_forward_refs() -ImagingRetinotopySignMapArray.update_forward_refs() -ImagingRetinotopyVasculatureImage.update_forward_refs() -ImagingRetinotopyVasculatureImageArray.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +ImagingRetinotopyAxis1PhaseMap.model_rebuild() +ImagingRetinotopyAxis1PhaseMapArray.model_rebuild() +ImagingRetinotopyAxis1PowerMap.model_rebuild() +ImagingRetinotopyAxis1PowerMapArray.model_rebuild() +ImagingRetinotopyAxis2PhaseMap.model_rebuild() +ImagingRetinotopyAxis2PhaseMapArray.model_rebuild() +ImagingRetinotopyAxis2PowerMap.model_rebuild() +ImagingRetinotopyAxis2PowerMapArray.model_rebuild() +ImagingRetinotopyFocalDepthImage.model_rebuild() +ImagingRetinotopyFocalDepthImageArray.model_rebuild() +ImagingRetinotopySignMap.model_rebuild() +ImagingRetinotopySignMapArray.model_rebuild() +ImagingRetinotopyVasculatureImage.model_rebuild() +ImagingRetinotopyVasculatureImageArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_common.py b/nwb_linkml/models/hdmf_common.py index 0802341..807ea7c 100644 --- a/nwb_linkml/models/hdmf_common.py +++ b/nwb_linkml/models/hdmf_common.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "1.8.0" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -29,5 +25,6 @@ class ConfiguredBaseModel(WeakRefShimBaseModel, -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_common_base.py b/nwb_linkml/models/hdmf_common_base.py index be2c9e5..459b407 100644 --- a/nwb_linkml/models/hdmf_common_base.py +++ b/nwb_linkml/models/hdmf_common_base.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -32,27 +28,29 @@ class Data(ConfiguredBaseModel): """ An abstract data type for a dataset. """ - None + name: str = Field(...) class Container(ConfiguredBaseModel): """ An abstract data type for a group storing collections of data and metadata. Base type for all data and metadata containers. """ - None + name: str = Field(...) class SimpleMultiContainer(Container): """ A simple Container for holding onto multiple containers. """ + name: str = Field(...) Data: Optional[List[Data]] = Field(default_factory=list, description="""Data objects held within this SimpleMultiContainer.""") - Container: Optional[List[Container]] = Field(default_factory=list, description="""Container objects held within this SimpleMultiContainer.""") + container: Optional[List[Container]] = Field(default_factory=list, description="""Container objects held within this SimpleMultiContainer.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -Data.update_forward_refs() -Container.update_forward_refs() -SimpleMultiContainer.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +Data.model_rebuild() +Container.model_rebuild() +SimpleMultiContainer.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_common_base_include.py b/nwb_linkml/models/hdmf_common_base_include.py deleted file mode 100644 index c923ad6..0000000 --- a/nwb_linkml/models/hdmf_common_base_include.py +++ /dev/null @@ -1,33 +0,0 @@ -from __future__ import annotations -from datetime import datetime, date -from enum import Enum -from typing import List, Dict, Optional, Any, Union -from pydantic import BaseModel as BaseModel, Field -from nptyping import NDArray, Shape, Float, Float32, Double, Float64, LongLong, Int64, Int, Int32, Int16, Short, Int8, UInt, UInt32, UInt16, UInt8, UInt64, Number, String, Unicode, Unicode, Unicode, String, Bool, Datetime64 -import sys -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - - - -metamodel_version = "None" -version = "None" - -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, - validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, - extra = 'forbid', - arbitrary_types_allowed = True, - use_enum_values = True): - pass - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ diff --git a/nwb_linkml/models/hdmf_common_sparse.py b/nwb_linkml/models/hdmf_common_sparse.py index 79fc060..e75e3b4 100644 --- a/nwb_linkml/models/hdmf_common_sparse.py +++ b/nwb_linkml/models/hdmf_common_sparse.py @@ -11,12 +11,6 @@ else: from typing_extensions import Literal -from .hdmf_common_sparse_include import ( - CSRMatrixData, - CSRMatrixIndices, - CSRMatrixIndptr -) - from .hdmf_common_base import ( Container ) @@ -25,13 +19,9 @@ from .hdmf_common_base import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -42,13 +32,15 @@ class CSRMatrix(Container): """ A compressed sparse row matrix. Data are stored in the standard CSR format, where column indices for row i are stored in indices[indptr[i]:indptr[i+1]] and their corresponding values are stored in data[indptr[i]:indptr[i+1]]. """ + name: str = Field(...) shape: Optional[int] = Field(None, description="""The shape (number of rows, number of columns) of this sparse matrix.""") - indices: CSRMatrixIndices = Field(..., description="""The column indices.""") - indptr: CSRMatrixIndptr = Field(..., description="""The row index pointer.""") - data: CSRMatrixData = Field(..., description="""The non-zero values in the matrix.""") + indices: List[int] = Field(default_factory=list, description="""The column indices.""") + indptr: List[int] = Field(default_factory=list, description="""The row index pointer.""") + data: List[Any] = Field(default_factory=list, description="""The non-zero values in the matrix.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -CSRMatrix.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +CSRMatrix.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_common_sparse_include.py b/nwb_linkml/models/hdmf_common_sparse_include.py deleted file mode 100644 index e1e2206..0000000 --- a/nwb_linkml/models/hdmf_common_sparse_include.py +++ /dev/null @@ -1,57 +0,0 @@ -from __future__ import annotations -from datetime import datetime, date -from enum import Enum -from typing import List, Dict, Optional, Any, Union -from pydantic import BaseModel as BaseModel, Field -from nptyping import NDArray, Shape, Float, Float32, Double, Float64, LongLong, Int64, Int, Int32, Int16, Short, Int8, UInt, UInt32, UInt16, UInt8, UInt64, Number, String, Unicode, Unicode, Unicode, String, Bool, Datetime64 -import sys -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - - - -metamodel_version = "None" -version = "None" - -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, - validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, - extra = 'forbid', - arbitrary_types_allowed = True, - use_enum_values = True): - pass - - -class CSRMatrixIndices(ConfiguredBaseModel): - """ - The column indices. - """ - indices: List[int] = Field(default_factory=list, description="""The column indices.""") - - -class CSRMatrixIndptr(ConfiguredBaseModel): - """ - The row index pointer. - """ - indptr: List[int] = Field(default_factory=list, description="""The row index pointer.""") - - -class CSRMatrixData(ConfiguredBaseModel): - """ - The non-zero values in the matrix. - """ - data: List[Any] = Field(default_factory=list, description="""The non-zero values in the matrix.""") - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -CSRMatrixIndices.update_forward_refs() -CSRMatrixIndptr.update_forward_refs() -CSRMatrixData.update_forward_refs() diff --git a/nwb_linkml/models/hdmf_common_table.py b/nwb_linkml/models/hdmf_common_table.py index 5a2971c..f144e4f 100644 --- a/nwb_linkml/models/hdmf_common_table.py +++ b/nwb_linkml/models/hdmf_common_table.py @@ -11,28 +11,23 @@ else: from typing_extensions import Literal -# from .hdmf_common_table_include import ( -# VectorDataArray, -# ElementIdentifiersArray, -# DynamicTableId -# ) - from .hdmf_common_base import ( - Container, - Data + Data, + Container +) + +from .hdmf_common_table_include import ( + VectorDataArray, + ElementIdentifiersArray ) metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -43,63 +38,85 @@ class VectorData(Data): """ An n-dimensional dataset representing a column of a DynamicTable. If used without an accompanying VectorIndex, first dimension is along the rows of the DynamicTable and each step along the first dimension is a cell of the larger table. VectorData can also be used to represent a ragged array if paired with a VectorIndex. This allows for storing arrays of varying length in a single cell of the DynamicTable by indexing into this VectorData. The first vector is at VectorData[0:VectorIndex[0]]. The second vector is at VectorData[VectorIndex[0]:VectorIndex[1]], and so on. """ + name: str = Field(...) description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class VectorIndex(VectorData): """ Used with VectorData to encode a ragged array. An array of indices into the first dimension of the target VectorData, and forming a map between the rows of a DynamicTable and the indices of the VectorData. The name of the VectorIndex is expected to be the name of the target VectorData object followed by \"_index\". """ + name: str = Field(...) target: Optional[VectorData] = Field(None, description="""Reference to the target dataset that this index applies to.""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) class ElementIdentifiers(Data): """ A list of unique identifiers for values within a dataset, e.g. rows of a DynamicTable. """ + name: str = Field(...) array: Optional[NDArray[Shape["* num_elements"], Int]] = Field(None) -# class DynamicTableRegion(VectorData): -# """ -# DynamicTableRegion provides a link from one table to an index or region of another. The `table` attribute is a link to another `DynamicTable`, indicating which table is referenced, and the data is int(s) indicating the row(s) (0-indexed) of the target array. `DynamicTableRegion`s can be used to associate rows with repeated meta-data without data duplication. They can also be used to create hierarchical relationships between multiple `DynamicTable`s. `DynamicTableRegion` objects may be paired with a `VectorIndex` object to create ragged references, so a single cell of a `DynamicTable` can reference many rows of another `DynamicTable`. -# """ -# table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") -# description: Optional[str] = Field(None, description="""Description of what this table region points to.""") -# array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any]] = Field(None) -# +class DynamicTableRegion(VectorData): + """ + DynamicTableRegion provides a link from one table to an index or region of another. The `table` attribute is a link to another `DynamicTable`, indicating which table is referenced, and the data is int(s) indicating the row(s) (0-indexed) of the target array. `DynamicTableRegion`s can be used to associate rows with repeated meta-data without data duplication. They can also be used to create hierarchical relationships between multiple `DynamicTable`s. `DynamicTableRegion` objects may be paired with a `VectorIndex` object to create ragged references, so a single cell of a `DynamicTable` can reference many rows of another `DynamicTable`. + """ + name: str = Field(...) + table: Optional[DynamicTable] = Field(None, description="""Reference to the DynamicTable object that this region applies to.""") + description: Optional[str] = Field(None, description="""Description of what this table region points to.""") + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) + -# class DynamicTable(Container): -# """ -# A group containing multiple datasets that are aligned on the first dimension (Currently, this requirement if left up to APIs to check and enforce). These datasets represent different columns in the table. Apart from a column that contains unique identifiers for each row, there are no other required datasets. Users are free to add any number of custom VectorData objects (columns) here. DynamicTable also supports ragged array columns, where each element can be of a different size. To add a ragged array column, use a VectorIndex type to index the corresponding VectorData type. See documentation for VectorData and VectorIndex for more details. Unlike a compound data type, which is analogous to storing an array-of-structs, a DynamicTable can be thought of as a struct-of-arrays. This provides an alternative structure to choose from when optimizing storage for anticipated access patterns. Additionally, this type provides a way of creating a table without having to define a compound type up front. Although this convenience may be attractive, users should think carefully about how data will be accessed. DynamicTable is more appropriate for column-centric access, whereas a dataset with a compound type would be more appropriate for row-centric access. Finally, data size should also be taken into account. For small tables, performance loss may be an acceptable trade-off for the flexibility of a DynamicTable. -# """ -# colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") -# description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") -# id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") -# VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") -# +class DynamicTable(Container): + """ + A group containing multiple datasets that are aligned on the first dimension (Currently, this requirement if left up to APIs to check and enforce). These datasets represent different columns in the table. Apart from a column that contains unique identifiers for each row, there are no other required datasets. Users are free to add any number of custom VectorData objects (columns) here. DynamicTable also supports ragged array columns, where each element can be of a different size. To add a ragged array column, use a VectorIndex type to index the corresponding VectorData type. See documentation for VectorData and VectorIndex for more details. Unlike a compound data type, which is analogous to storing an array-of-structs, a DynamicTable can be thought of as a struct-of-arrays. This provides an alternative structure to choose from when optimizing storage for anticipated access patterns. Additionally, this type provides a way of creating a table without having to define a compound type up front. Although this convenience may be attractive, users should think carefully about how data will be accessed. DynamicTable is more appropriate for column-centric access, whereas a dataset with a compound type would be more appropriate for row-centric access. Finally, data size should also be taken into account. For small tables, performance loss may be an acceptable trade-off for the flexibility of a DynamicTable. + """ + name: str = Field(...) + colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") + description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") + VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") + -# class AlignedDynamicTable(DynamicTable): -# """ -# DynamicTable container that supports storing a collection of sub-tables. 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. -# """ -# categories: Optional[str] = Field(None, description="""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 and the category names must match the names of the corresponding DynamicTable in the group.""") -# DynamicTable: Optional[List[DynamicTable]] = Field(default_factory=list, description="""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.""") -# colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") -# description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") -# id: DynamicTableId = Field(..., description="""Array of unique identifiers for the rows of this dynamic table.""") -# VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") -# +class AlignedDynamicTable(DynamicTable): + """ + DynamicTable container that supports storing a collection of sub-tables. 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. + """ + name: str = Field(...) + categories: Optional[str] = Field(None, description="""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 and the category names must match the names of the corresponding DynamicTable in the group.""") + dynamic_table: Optional[List[DynamicTable]] = Field(default_factory=list, description="""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.""") + colnames: Optional[str] = Field(None, description="""The names of the columns in this table. This should be used to specify an order to the columns.""") + description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""") + id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") + VectorData: Optional[List[VectorData]] = Field(default_factory=list, description="""Vector columns, including index columns, of this dynamic table.""") + -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -VectorData.update_forward_refs() -VectorIndex.update_forward_refs() -ElementIdentifiers.update_forward_refs() -DynamicTableRegion.update_forward_refs() -# DynamicTable.update_forward_refs() -# AlignedDynamicTable.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +VectorData.model_rebuild() +VectorIndex.model_rebuild() +ElementIdentifiers.model_rebuild() +DynamicTableRegion.model_rebuild() +DynamicTable.model_rebuild() +AlignedDynamicTable.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_common_table_include.py b/nwb_linkml/models/hdmf_common_table_include.py index 043b0fa..38950d4 100644 --- a/nwb_linkml/models/hdmf_common_table_include.py +++ b/nwb_linkml/models/hdmf_common_table_include.py @@ -11,10 +11,6 @@ else: from typing_extensions import Literal -# from .hdmf_common_table import ( -# ElementIdentifiers -# ) - from .nwb_language import ( Arraylike ) @@ -23,13 +19,9 @@ from .nwb_language import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -49,17 +41,9 @@ class ElementIdentifiersArray(Arraylike): num_elements: int = Field(...) -# class DynamicTableId(ElementIdentifiers): -# """ -# Array of unique identifiers for the rows of this dynamic table. -# """ -# id: List[int] = Field(default_factory=list, description="""Array of unique identifiers for the rows of this dynamic table.""") -# array: Optional[NDArray[Shape["* num_elements"], Int]] = Field(None) -# - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -VectorDataArray.update_forward_refs() -ElementIdentifiersArray.update_forward_refs() -DynamicTableId.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +VectorDataArray.model_rebuild() +ElementIdentifiersArray.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_experimental.py b/nwb_linkml/models/hdmf_experimental.py index 42ed1e5..353ade5 100644 --- a/nwb_linkml/models/hdmf_experimental.py +++ b/nwb_linkml/models/hdmf_experimental.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "0.5.0" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -29,5 +25,6 @@ class ConfiguredBaseModel(WeakRefShimBaseModel, -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_experimental_experimental.py b/nwb_linkml/models/hdmf_experimental_experimental.py index 3b6b113..faa9c91 100644 --- a/nwb_linkml/models/hdmf_experimental_experimental.py +++ b/nwb_linkml/models/hdmf_experimental_experimental.py @@ -19,13 +19,9 @@ from .hdmf_common_table import ( metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -36,12 +32,19 @@ class EnumData(VectorData): """ Data that come from a fixed set of values. A data value of i corresponds to the i-th value in the VectorData referenced by the 'elements' attribute. """ + name: str = Field(...) elements: Optional[VectorData] = Field(None, description="""Reference to the VectorData object that contains the enumerable elements""") description: Optional[str] = Field(None, description="""Description of what these vectors represent.""") - array: Optional[NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], ]] = Field(None) + array: Optional[Union[ + NDArray[Shape["* dim0"], Any], + NDArray[Shape["* dim0, * dim1"], Any], + NDArray[Shape["* dim0, * dim1, * dim2"], Any], + NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any] + ]] = Field(None) -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -EnumData.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +EnumData.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_experimental_experimental_include.py b/nwb_linkml/models/hdmf_experimental_experimental_include.py deleted file mode 100644 index c923ad6..0000000 --- a/nwb_linkml/models/hdmf_experimental_experimental_include.py +++ /dev/null @@ -1,33 +0,0 @@ -from __future__ import annotations -from datetime import datetime, date -from enum import Enum -from typing import List, Dict, Optional, Any, Union -from pydantic import BaseModel as BaseModel, Field -from nptyping import NDArray, Shape, Float, Float32, Double, Float64, LongLong, Int64, Int, Int32, Int16, Short, Int8, UInt, UInt32, UInt16, UInt8, UInt64, Number, String, Unicode, Unicode, Unicode, String, Bool, Datetime64 -import sys -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - - - -metamodel_version = "None" -version = "None" - -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, - validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, - extra = 'forbid', - arbitrary_types_allowed = True, - use_enum_values = True): - pass - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ diff --git a/nwb_linkml/models/hdmf_experimental_resources.py b/nwb_linkml/models/hdmf_experimental_resources.py index 4fd7aa1..16bf15c 100644 --- a/nwb_linkml/models/hdmf_experimental_resources.py +++ b/nwb_linkml/models/hdmf_experimental_resources.py @@ -15,26 +15,13 @@ from .hdmf_common_base import ( Container ) -from .hdmf_experimental_resources_include import ( - HERDObjectKeys, - HERDObjects, - HERDEntities, - HERDKeys, - HERDFiles, - HERDEntityKeys -) - metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -45,15 +32,17 @@ class HERD(Container): """ HDMF External Resources Data Structure. A set of six tables for tracking external resource references in a file or across multiple files. """ - keys: HERDKeys = Field(, description="""A table for storing user terms that are used to refer to external resources.""") - files: HERDFiles = Field(..., description="""A table for storing object ids of files used in external resources.""") - entities: HERDEntities = Field(..., description="""A table for mapping user terms (i.e., keys) to resource entities.""") - objects: HERDObjects = Field(..., description="""A table for identifying which objects in a file contain references to external resources.""") - object_keys: HERDObjectKeys = Field(..., description="""A table for identifying which objects use which keys.""") - entity_keys: HERDEntityKeys = Field(..., description="""A table for identifying which keys use which entity.""") + name: str = Field(...) + keys: List[Any] = Field(default_factory=list, description="""A table for storing user terms that are used to refer to external resources.""") + files: List[Any] = Field(default_factory=list, description="""A table for storing object ids of files used in external resources.""") + entities: List[Any] = Field(default_factory=list, description="""A table for mapping user terms (i.e., keys) to resource entities.""") + objects: List[Any] = Field(default_factory=list, description="""A table for identifying which objects in a file contain references to external resources.""") + object_keys: List[Any] = Field(default_factory=list, description="""A table for identifying which objects use which keys.""") + entity_keys: List[Any] = Field(default_factory=list, description="""A table for identifying which keys use which entity.""") -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -HERD.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +HERD.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/models/hdmf_experimental_resources_include.py b/nwb_linkml/models/hdmf_experimental_resources_include.py deleted file mode 100644 index f4b3937..0000000 --- a/nwb_linkml/models/hdmf_experimental_resources_include.py +++ /dev/null @@ -1,85 +0,0 @@ -from __future__ import annotations -from datetime import datetime, date -from enum import Enum -from typing import List, Dict, Optional, Any, Union -from pydantic import BaseModel as BaseModel, Field -from nptyping import NDArray, Shape, Float, Float32, Double, Float64, LongLong, Int64, Int, Int32, Int16, Short, Int8, UInt, UInt32, UInt16, UInt8, UInt64, Number, String, Unicode, Unicode, Unicode, String, Bool, Datetime64 -import sys -if sys.version_info >= (3, 8): - from typing import Literal -else: - from typing_extensions import Literal - - -from .hdmf_common_base import ( - Data -) - - -metamodel_version = "None" -version = "None" - -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, - validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, - extra = 'forbid', - arbitrary_types_allowed = True, - use_enum_values = True): - pass - - -class HERDKeys(Data): - """ - A table for storing user terms that are used to refer to external resources. - """ - keys: List[Any] = Field(default_factory=list, description="""A table for storing user terms that are used to refer to external resources.""") - - -class HERDFiles(Data): - """ - A table for storing object ids of files used in external resources. - """ - files: List[Any] = Field(default_factory=list, description="""A table for storing object ids of files used in external resources.""") - - -class HERDEntities(Data): - """ - A table for mapping user terms (i.e., keys) to resource entities. - """ - entities: List[Any] = Field(default_factory=list, description="""A table for mapping user terms (i.e., keys) to resource entities.""") - - -class HERDObjects(Data): - """ - A table for identifying which objects in a file contain references to external resources. - """ - objects: List[Any] = Field(default_factory=list, description="""A table for identifying which objects in a file contain references to external resources.""") - - -class HERDObjectKeys(Data): - """ - A table for identifying which objects use which keys. - """ - object_keys: List[Any] = Field(default_factory=list, description="""A table for identifying which objects use which keys.""") - - -class HERDEntityKeys(Data): - """ - A table for identifying which keys use which entity. - """ - entity_keys: List[Any] = Field(default_factory=list, description="""A table for identifying which keys use which entity.""") - - - -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -HERDKeys.update_forward_refs() -HERDFiles.update_forward_refs() -HERDEntities.update_forward_refs() -HERDObjects.update_forward_refs() -HERDObjectKeys.update_forward_refs() -HERDEntityKeys.update_forward_refs() diff --git a/nwb_linkml/models/nwb_language.py b/nwb_linkml/models/nwb_language.py index 2709a31..c2064e5 100644 --- a/nwb_linkml/models/nwb_language.py +++ b/nwb_linkml/models/nwb_language.py @@ -15,13 +15,9 @@ else: metamodel_version = "None" version = "None" -class WeakRefShimBaseModel(BaseModel): - __slots__ = '__weakref__' - -class ConfiguredBaseModel(WeakRefShimBaseModel, +class ConfiguredBaseModel(BaseModel, validate_assignment = True, - validate_all = True, - underscore_attrs_are_private = True, + validate_default = True, extra = 'forbid', arbitrary_types_allowed = True, use_enum_values = True): @@ -36,6 +32,7 @@ class Arraylike(ConfiguredBaseModel): -# Update forward refs -# see https://pydantic-docs.helpmanual.io/usage/postponed_annotations/ -Arraylike.update_forward_refs() +# Model rebuild +# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model +Arraylike.model_rebuild() + \ No newline at end of file diff --git a/nwb_linkml/namespaces.py b/nwb_linkml/namespaces.py index eed6226..1eab629 100644 --- a/nwb_linkml/namespaces.py +++ b/nwb_linkml/namespaces.py @@ -121,7 +121,7 @@ class GitRepo: # Check that the remote matches if self.remote.strip('.git') != self.namespace.repository: - warnings.warn('Repository exists, but has the wrong remote URL') + warnings.warn(f'Repository exists, but has the wrong remote URL.\nExpected: {self.namespace.repository}\nGot:{self.remote.strip(".git")}') return False # otherwise we're good diff --git a/nwb_linkml/schema/core.nwb.base.include.yaml b/nwb_linkml/schema/core.nwb.base.include.yaml index 71646b5..5a2c7d6 100644 --- a/nwb_linkml/schema/core.nwb.base.include.yaml +++ b/nwb_linkml/schema/core.nwb.base.include.yaml @@ -46,6 +46,12 @@ classes: should always represent time. This can also be used to store binary data (e.g., image frames). This can also be a link to data stored in an external file. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data conversion: name: conversion description: Scalar to multiply each element in data to convert it to the @@ -120,6 +126,12 @@ classes: spaced, the timestamp of the first sample can be specified and all subsequent ones calculated from the sampling rate attribute. attributes: + name: + name: name + ifabsent: string(starting_time) + range: string + required: true + equals_string: starting_time rate: name: rate description: Sampling rate, in Hz. @@ -128,54 +140,6 @@ classes: name: unit description: Unit of measurement for time, which is fixed to 'seconds'. range: text - TimeSeries__timestamps: - name: TimeSeries__timestamps - description: Timestamps for samples stored in data, in seconds, relative to the - common experiment master-clock stored in NWBFile.timestamps_reference_time. - attributes: - interval: - name: interval - description: Value is '1' - range: int32 - unit: - name: unit - description: Unit of measurement for timestamps, which is fixed to 'seconds'. - range: text - timestamps: - name: timestamps - description: Timestamps for samples stored in data, in seconds, relative to - the common experiment master-clock stored in NWBFile.timestamps_reference_time. - multivalued: true - range: float64 - required: false - TimeSeries__control: - name: TimeSeries__control - description: Numerical labels that apply to each time point in data for the purpose - of querying and slicing data by these values. If present, the length of this - array should be the same size as the first dimension of data. - attributes: - control: - name: control - description: Numerical labels that apply to each time point in data for the - purpose of querying and slicing data by these values. If present, the length - of this array should be the same size as the first dimension of data. - multivalued: true - range: uint8 - required: false - TimeSeries__control_description: - name: TimeSeries__control_description - description: Description of each control value. Must be present if control is - present. If present, control_description[0] should describe time points where - control == 0. - attributes: - control_description: - name: control_description - description: Description of each control value. Must be present if control - is present. If present, control_description[0] should describe time points - where control == 0. - multivalued: true - range: text - required: false TimeSeries__sync: name: TimeSeries__sync description: Lab-specific time and sync information as provided directly from @@ -184,9 +148,23 @@ classes: This group will usually only be populated in TimeSeries that are stored external to the NWB file, in files storing raw data. Once timestamp data is calculated, the contents of 'sync' are mostly for archival purposes. + attributes: + name: + name: name + ifabsent: string(sync) + range: string + required: true + equals_string: sync Images__order_of_images: name: Images__order_of_images description: Ordered dataset of references to Image objects stored in the parent group. Each Image object in the Images group should be stored once and only once, so the dataset should have the same length as the number of images. is_a: ImageReferences + attributes: + name: + name: name + ifabsent: string(order_of_images) + range: string + required: true + equals_string: order_of_images diff --git a/nwb_linkml/schema/core.nwb.base.yaml b/nwb_linkml/schema/core.nwb.base.yaml index 2a31e48..b870da6 100644 --- a/nwb_linkml/schema/core.nwb.base.yaml +++ b/nwb_linkml/schema/core.nwb.base.yaml @@ -12,12 +12,24 @@ classes: name: NWBData description: An abstract data type for a dataset. is_a: Data + attributes: + name: + name: name + range: string + required: true + tree_root: true TimeSeriesReferenceVectorData: name: TimeSeriesReferenceVectorData description: 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. is_a: VectorData + attributes: + name: + name: name + range: string + required: true + tree_root: true Image: name: Image description: An abstract data type for an image. Shape can be 2-D (x, y), or 3-D @@ -25,6 +37,10 @@ classes: b)) or (x, y, (r, g, b, a)). is_a: NWBData attributes: + name: + name: name + range: string + required: true resolution: name: resolution description: Pixel resolution of the image, in pixels per centimeter. @@ -36,29 +52,51 @@ classes: array: name: array range: Image__Array + tree_root: true ImageReferences: name: ImageReferences description: Ordered dataset of references to Image objects. is_a: NWBData attributes: + name: + name: name + range: string + required: true array: name: array range: ImageReferences__Array + tree_root: true NWBContainer: name: NWBContainer description: An abstract data type for a generic container storing collections of data and metadata. Base type for all data and metadata containers. is_a: Container + attributes: + name: + name: name + range: string + required: true + tree_root: true NWBDataInterface: name: NWBDataInterface description: An abstract data type for a generic container storing collections of data, as opposed to metadata. is_a: NWBContainer + attributes: + name: + name: name + range: string + required: true + tree_root: true TimeSeries: name: TimeSeries description: General purpose time series. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true description: name: description description: Description of the time series. @@ -90,24 +128,24 @@ classes: name: timestamps description: Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time. - multivalued: false - range: TimeSeries__timestamps + multivalued: true + range: float64 required: false control: name: control description: Numerical labels that apply to each time point in data for the purpose of querying and slicing data by these values. If present, the length of this array should be the same size as the first dimension of data. - multivalued: false - range: TimeSeries__control + multivalued: true + range: uint8 required: false control_description: name: control_description description: Description of each control value. Must be present if control is present. If present, control_description[0] should describe time points where control == 0. - multivalued: false - range: TimeSeries__control_description + multivalued: true + range: text required: false sync: name: sync @@ -120,27 +158,33 @@ classes: multivalued: false range: TimeSeries__sync required: false + tree_root: true ProcessingModule: name: ProcessingModule description: A collection of processed data. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description of this collection of processed data. range: text - NWBDataInterface: - name: NWBDataInterface + nwb_data_interface: + name: nwb_data_interface description: Data objects stored in this collection. multivalued: true range: NWBDataInterface required: false - DynamicTable: - name: DynamicTable + dynamic_table: + name: dynamic_table description: Tables stored in this collection. multivalued: true range: DynamicTable required: false + tree_root: true Images: name: Images description: A collection of images with an optional way to specify the order @@ -148,6 +192,10 @@ classes: if the images are referenced by index, e.g., from an IndexSeries. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true description: name: description description: Description of this collection of images. @@ -167,3 +215,4 @@ classes: multivalued: false range: Images__order_of_images required: false + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.behavior.include.yaml b/nwb_linkml/schema/core.nwb.behavior.include.yaml index 443d975..007abf0 100644 --- a/nwb_linkml/schema/core.nwb.behavior.include.yaml +++ b/nwb_linkml/schema/core.nwb.behavior.include.yaml @@ -13,6 +13,12 @@ classes: description: 1-D or 2-D array storing position or direction relative to some reference frame. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. The default diff --git a/nwb_linkml/schema/core.nwb.behavior.yaml b/nwb_linkml/schema/core.nwb.behavior.yaml index 05179cc..acba134 100644 --- a/nwb_linkml/schema/core.nwb.behavior.yaml +++ b/nwb_linkml/schema/core.nwb.behavior.yaml @@ -21,6 +21,10 @@ classes: SpatialSeries values.' is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: 1-D or 2-D array storing position or direction relative to some @@ -34,6 +38,7 @@ classes: multivalued: false range: text required: false + tree_root: true BehavioralEpochs: name: BehavioralEpochs description: TimeSeries for storing behavioral epochs. The objective of this @@ -50,58 +55,83 @@ classes: events. BehavioralTimeSeries is for continuous data. is_a: NWBDataInterface attributes: - IntervalSeries: - name: IntervalSeries + name: + name: name + range: string + required: true + interval_series: + name: interval_series description: IntervalSeries object containing start and stop times of epochs. multivalued: true range: IntervalSeries required: false + tree_root: true BehavioralEvents: name: BehavioralEvents description: TimeSeries for storing behavioral events. See description of BehavioralEpochs for more details. is_a: NWBDataInterface attributes: - TimeSeries: - name: TimeSeries + name: + name: name + range: string + required: true + time_series: + name: time_series description: TimeSeries object containing behavioral events. multivalued: true range: TimeSeries required: false + tree_root: true BehavioralTimeSeries: name: BehavioralTimeSeries description: TimeSeries for storing Behavoioral time series data. See description of BehavioralEpochs for more details. is_a: NWBDataInterface attributes: - TimeSeries: - name: TimeSeries + name: + name: name + range: string + required: true + time_series: + name: time_series description: TimeSeries object containing continuous behavioral data. multivalued: true range: TimeSeries required: false + tree_root: true PupilTracking: name: PupilTracking description: Eye-tracking data, representing pupil size. is_a: NWBDataInterface attributes: - TimeSeries: - name: TimeSeries + name: + name: name + range: string + required: true + time_series: + name: time_series description: TimeSeries object containing time series data on pupil size. multivalued: true range: TimeSeries required: true + tree_root: true EyeTracking: name: EyeTracking description: Eye-tracking data, representing direction of gaze. is_a: NWBDataInterface attributes: - SpatialSeries: - name: SpatialSeries + name: + name: name + range: string + required: true + spatial_series: + name: spatial_series description: SpatialSeries object containing data measuring direction of gaze. multivalued: true range: SpatialSeries required: false + tree_root: true CompassDirection: name: CompassDirection description: With a CompassDirection interface, a module publishes a SpatialSeries @@ -111,20 +141,30 @@ classes: be radians or degrees. is_a: NWBDataInterface attributes: - SpatialSeries: - name: SpatialSeries + name: + name: name + range: string + required: true + spatial_series: + name: spatial_series description: SpatialSeries object containing direction of gaze travel. multivalued: true range: SpatialSeries required: false + tree_root: true Position: name: Position description: Position data, whether along the x, x/y or x/y/z axis. is_a: NWBDataInterface attributes: - SpatialSeries: - name: SpatialSeries + name: + name: name + range: string + required: true + spatial_series: + name: spatial_series description: SpatialSeries object containing position data. multivalued: true range: SpatialSeries required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.device.include.yaml b/nwb_linkml/schema/core.nwb.device.include.yaml deleted file mode 100644 index 21c602f..0000000 --- a/nwb_linkml/schema/core.nwb.device.include.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: core.nwb.device.include -id: core.nwb.device.include -imports: -- core.nwb.base -- nwb.language -- core.nwb.device.include -- core.nwb.device -default_prefix: core.nwb.device.include/ diff --git a/nwb_linkml/schema/core.nwb.device.yaml b/nwb_linkml/schema/core.nwb.device.yaml index be9727d..6914cdf 100644 --- a/nwb_linkml/schema/core.nwb.device.yaml +++ b/nwb_linkml/schema/core.nwb.device.yaml @@ -3,7 +3,6 @@ id: core.nwb.device imports: - core.nwb.base - nwb.language -- core.nwb.device.include - core.nwb.device default_prefix: core.nwb.device/ classes: @@ -13,6 +12,10 @@ classes: electrode, microscope. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description of the device (e.g., model, firmware version, processing @@ -22,3 +25,4 @@ classes: name: manufacturer description: The name of the manufacturer of the device. range: text + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.ecephys.include.yaml b/nwb_linkml/schema/core.nwb.ecephys.include.yaml index bacdea1..0a58bbb 100644 --- a/nwb_linkml/schema/core.nwb.ecephys.include.yaml +++ b/nwb_linkml/schema/core.nwb.ecephys.include.yaml @@ -13,6 +13,12 @@ classes: name: ElectricalSeries__data description: Recorded voltage data. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. This value @@ -44,41 +50,23 @@ classes: description: DynamicTableRegion pointer to the electrodes that this time series was generated from. is_a: DynamicTableRegion - ElectricalSeries__channel_conversion: - name: ElectricalSeries__channel_conversion - description: Channel-specific conversion factor. Multiply the data in the 'data' - dataset by these values along the channel axis (as indicated by axis attribute) - AND by the global conversion factor in the 'conversion' attribute of 'data' - to get the data values in Volts, i.e, data in Volts = data * data.conversion - * channel_conversion. This approach allows for both global and per-channel data - conversion factors needed to support the storage of electrical recordings as - native values generated by data acquisition systems. If this dataset is not - present, then there is no channel-specific conversion factor, i.e. it is 1 for - all channels. attributes: - axis: - name: axis - description: The zero-indexed axis of the 'data' dataset that the channel-specific - conversion factor corresponds to. This value is fixed to 1. - range: int32 - channel_conversion: - name: channel_conversion - description: Channel-specific conversion factor. Multiply the data in the - 'data' dataset by these values along the channel axis (as indicated by axis - attribute) AND by the global conversion factor in the 'conversion' attribute - of 'data' to get the data values in Volts, i.e, data in Volts = data * data.conversion - * channel_conversion. This approach allows for both global and per-channel - data conversion factors needed to support the storage of electrical recordings - as native values generated by data acquisition systems. If this dataset - is not present, then there is no channel-specific conversion factor, i.e. - it is 1 for all channels. - multivalued: true - range: float32 - required: false + name: + name: name + ifabsent: string(electrodes) + range: string + required: true + equals_string: electrodes SpikeEventSeries__data: name: SpikeEventSeries__data description: Spike waveforms. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Unit of measurement for waveforms, which is fixed to 'volts'. @@ -102,45 +90,16 @@ classes: name: num_channels range: numeric required: false - SpikeEventSeries__timestamps: - name: SpikeEventSeries__timestamps - description: Timestamps for samples stored in data, in seconds, relative to the - common experiment master-clock stored in NWBFile.timestamps_reference_time. - Timestamps are required for the events. Unlike for TimeSeries, timestamps are - required for SpikeEventSeries and are thus re-specified here. - attributes: - interval: - name: interval - description: Value is '1' - range: int32 - unit: - name: unit - description: Unit of measurement for timestamps, which is fixed to 'seconds'. - range: text - timestamps: - name: timestamps - description: Timestamps for samples stored in data, in seconds, relative to - the common experiment master-clock stored in NWBFile.timestamps_reference_time. - Timestamps are required for the events. Unlike for TimeSeries, timestamps - are required for SpikeEventSeries and are thus re-specified here. - multivalued: true - range: float64 - required: true - FeatureExtraction__description: - name: FeatureExtraction__description - description: Description of features (eg, ''PC1'') for each of the extracted features. - attributes: - description: - name: description - description: Description of features (eg, ''PC1'') for each of the extracted - features. - multivalued: true - range: text - required: true FeatureExtraction__features: name: FeatureExtraction__features description: Multi-dimensional array of features extracted from each event. attributes: + name: + name: name + ifabsent: string(features) + range: string + required: true + equals_string: features array: name: array range: FeatureExtraction__features__Array @@ -151,60 +110,27 @@ classes: num_events: name: num_events range: float32 - required: false + required: true num_channels: name: num_channels range: float32 - required: false + required: true num_features: name: num_features range: float32 - required: false - FeatureExtraction__times: - name: FeatureExtraction__times - description: Times of events that features correspond to (can be a link). - attributes: - times: - name: times - description: Times of events that features correspond to (can be a link). - multivalued: true - range: float64 required: true FeatureExtraction__electrodes: name: FeatureExtraction__electrodes description: DynamicTableRegion pointer to the electrodes that this time series was generated from. is_a: DynamicTableRegion - EventDetection__source_idx: - name: EventDetection__source_idx - description: Indices (zero-based) into source ElectricalSeries::data array corresponding - to time of event. ''description'' should define what is meant by time of event - (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index - points to each event from the raw data. attributes: - source_idx: - name: source_idx - description: Indices (zero-based) into source ElectricalSeries::data array - corresponding to time of event. ''description'' should define what is meant - by time of event (e.g., .25 ms before action potential peak, zero-crossing - time, etc). The index points to each event from the raw data. - multivalued: true - range: int32 - required: true - EventDetection__times: - name: EventDetection__times - description: Timestamps of events, in seconds. - attributes: - unit: - name: unit - description: Unit of measurement for event times, which is fixed to 'seconds'. - range: text - times: - name: times - description: Timestamps of events, in seconds. - multivalued: true - range: float64 + name: + name: name + ifabsent: string(electrodes) + range: string required: true + equals_string: electrodes ClusterWaveforms__waveform_mean: name: ClusterWaveforms__waveform_mean description: The mean waveform for each cluster, using the same indices for each @@ -212,6 +138,12 @@ classes: is in array slot [3]). Waveforms corresponding to gaps in cluster sequence should be empty (e.g., zero- filled) attributes: + name: + name: name + ifabsent: string(waveform_mean) + range: string + required: true + equals_string: waveform_mean array: name: array range: ClusterWaveforms__waveform_mean__Array @@ -222,16 +154,22 @@ classes: num_clusters: name: num_clusters range: float32 - required: false + required: true num_samples: name: num_samples range: float32 - required: false + required: true ClusterWaveforms__waveform_sd: name: ClusterWaveforms__waveform_sd description: Stdev of waveforms for each cluster, using the same indices as in mean attributes: + name: + name: name + ifabsent: string(waveform_sd) + range: string + required: true + equals_string: waveform_sd array: name: array range: ClusterWaveforms__waveform_sd__Array @@ -242,42 +180,8 @@ classes: num_clusters: name: num_clusters range: float32 - required: false + required: true num_samples: name: num_samples range: float32 - required: false - Clustering__num: - name: Clustering__num - description: Cluster number of each event - attributes: - num: - name: num - description: Cluster number of each event - multivalued: true - range: int32 - required: true - Clustering__peak_over_rms: - name: Clustering__peak_over_rms - description: Maximum ratio of waveform peak to RMS on any channel in the cluster - (provides a basic clustering metric). - attributes: - peak_over_rms: - name: peak_over_rms - description: Maximum ratio of waveform peak to RMS on any channel in the cluster - (provides a basic clustering metric). - multivalued: true - range: float32 - required: true - Clustering__times: - name: Clustering__times - description: Times of clustered events, in seconds. This may be a link to times - field in associated FeatureExtraction module. - attributes: - times: - name: times - description: Times of clustered events, in seconds. This may be a link to - times field in associated FeatureExtraction module. - multivalued: true - range: float64 required: true diff --git a/nwb_linkml/schema/core.nwb.ecephys.yaml b/nwb_linkml/schema/core.nwb.ecephys.yaml index 20d9905..326b7d6 100644 --- a/nwb_linkml/schema/core.nwb.ecephys.yaml +++ b/nwb_linkml/schema/core.nwb.ecephys.yaml @@ -17,6 +17,10 @@ classes: channels. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true filtering: name: filtering description: Filtering applied to all channels of the data. For example, if @@ -51,9 +55,10 @@ classes: as native values generated by data acquisition systems. If this dataset is not present, then there is no channel-specific conversion factor, i.e. it is 1 for all channels. - multivalued: false - range: ElectricalSeries__channel_conversion + multivalued: true + range: float32 required: false + tree_root: true SpikeEventSeries: name: SpikeEventSeries description: 'Stores snapshots/snippets of recorded spike events (i.e., threshold @@ -66,6 +71,10 @@ classes: [num samples] for single electrode).' is_a: ElectricalSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Spike waveforms. @@ -78,21 +87,26 @@ classes: the common experiment master-clock stored in NWBFile.timestamps_reference_time. Timestamps are required for the events. Unlike for TimeSeries, timestamps are required for SpikeEventSeries and are thus re-specified here. - multivalued: false - range: SpikeEventSeries__timestamps + multivalued: true + range: float64 required: true + tree_root: true FeatureExtraction: name: FeatureExtraction description: Features, such as PC1 and PC2, that are extracted from signals stored in a SpikeEventSeries or other source. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true description: name: description description: Description of features (eg, ''PC1'') for each of the extracted features. - multivalued: false - range: FeatureExtraction__description + multivalued: true + range: text required: true features: name: features @@ -103,8 +117,8 @@ classes: times: name: times description: Times of events that features correspond to (can be a link). - multivalued: false - range: FeatureExtraction__times + multivalued: true + range: float64 required: true electrodes: name: electrodes @@ -113,11 +127,16 @@ classes: multivalued: false range: FeatureExtraction__electrodes required: true + tree_root: true EventDetection: name: EventDetection description: Detected spike events from voltage trace(s). is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true detection_method: name: detection_method description: Description of how events were detected, such as voltage threshold, @@ -131,15 +150,16 @@ classes: corresponding to time of event. ''description'' should define what is meant by time of event (e.g., .25 ms before action potential peak, zero-crossing time, etc). The index points to each event from the raw data. - multivalued: false - range: EventDetection__source_idx + multivalued: true + range: int32 required: true times: name: times description: Timestamps of events, in seconds. - multivalued: false - range: EventDetection__times + multivalued: true + range: float64 required: true + tree_root: true EventWaveform: name: EventWaveform description: Represents either the waveforms of detected events, as extracted @@ -147,12 +167,17 @@ classes: during experiment acquisition. is_a: NWBDataInterface attributes: - SpikeEventSeries: - name: SpikeEventSeries + name: + name: name + range: string + required: true + spike_event_series: + name: spike_event_series description: SpikeEventSeries object(s) containing detected spike event waveforms. multivalued: true range: SpikeEventSeries required: false + tree_root: true FilteredEphys: name: FilteredEphys description: Electrophysiology data from one or more channels that has been subjected @@ -168,13 +193,18 @@ classes: the ElectricalSeries 'filtering' attribute. is_a: NWBDataInterface attributes: - ElectricalSeries: - name: ElectricalSeries + name: + name: name + range: string + required: true + electrical_series: + name: electrical_series description: ElectricalSeries object(s) containing filtered electrophysiology data. multivalued: true range: ElectricalSeries required: true + tree_root: true LFP: name: LFP description: LFP data from one or more channels. The electrode map in each published @@ -182,18 +212,27 @@ classes: properties should be noted in the ElectricalSeries 'filtering' attribute. is_a: NWBDataInterface attributes: - ElectricalSeries: - name: ElectricalSeries + name: + name: name + range: string + required: true + electrical_series: + name: electrical_series description: ElectricalSeries object(s) containing LFP data for one or more channels. multivalued: true range: ElectricalSeries required: true + tree_root: true ElectrodeGroup: name: ElectrodeGroup description: A physical grouping of electrodes, e.g. a shank of an array. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description of this electrode group. @@ -210,6 +249,7 @@ classes: multivalued: false range: AnyType required: false + tree_root: true ClusterWaveforms: name: ClusterWaveforms description: DEPRECATED The mean waveform shape, including standard deviation, @@ -220,6 +260,10 @@ classes: or an extension of this one. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true waveform_filtering: name: waveform_filtering description: Filtering applied to data before generating mean/sd @@ -242,12 +286,17 @@ classes: multivalued: false range: ClusterWaveforms__waveform_sd required: true + tree_root: true Clustering: name: Clustering description: DEPRECATED Clustered spike data, whether from automatic clustering tools (e.g., klustakwik) or as a result of manual sorting. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true description: name: description description: Description of clusters or clustering, (e.g. cluster 0 is noise, @@ -258,20 +307,21 @@ classes: num: name: num description: Cluster number of each event - multivalued: false - range: Clustering__num + multivalued: true + range: int32 required: true peak_over_rms: name: peak_over_rms description: Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric). - multivalued: false - range: Clustering__peak_over_rms + multivalued: true + range: float32 required: true times: name: times description: Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module. - multivalued: false - range: Clustering__times + multivalued: true + range: float64 required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.epoch.include.yaml b/nwb_linkml/schema/core.nwb.epoch.include.yaml index cfcded2..0fb19ac 100644 --- a/nwb_linkml/schema/core.nwb.epoch.include.yaml +++ b/nwb_linkml/schema/core.nwb.epoch.include.yaml @@ -12,11 +12,32 @@ classes: name: TimeIntervals__tags_index description: Index for tags. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(tags_index) + range: string + required: true + equals_string: tags_index TimeIntervals__timeseries: name: TimeIntervals__timeseries description: An index into a TimeSeries object. is_a: TimeSeriesReferenceVectorData + attributes: + name: + name: name + ifabsent: string(timeseries) + range: string + required: true + equals_string: timeseries TimeIntervals__timeseries_index: name: TimeIntervals__timeseries_index description: Index for timeseries. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(timeseries_index) + range: string + required: true + equals_string: timeseries_index diff --git a/nwb_linkml/schema/core.nwb.epoch.yaml b/nwb_linkml/schema/core.nwb.epoch.yaml index 70e900d..211c2bc 100644 --- a/nwb_linkml/schema/core.nwb.epoch.yaml +++ b/nwb_linkml/schema/core.nwb.epoch.yaml @@ -14,6 +14,10 @@ classes: epoch applies to. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true start_time: name: start_time description: Start time of epoch, in seconds. @@ -47,3 +51,4 @@ classes: multivalued: false range: TimeIntervals__timeseries_index required: false + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.file.include.yaml b/nwb_linkml/schema/core.nwb.file.include.yaml index 1ee679c..1889d2f 100644 --- a/nwb_linkml/schema/core.nwb.file.include.yaml +++ b/nwb_linkml/schema/core.nwb.file.include.yaml @@ -15,116 +15,6 @@ imports: - core.nwb.file default_prefix: core.nwb.file.include/ classes: - NWBFile__file_create_date: - name: NWBFile__file_create_date - description: 'A record of the date the file was created and of subsequent modifications. - The date is stored in UTC with local timezone offset as ISO 8601 extended formatted - strings: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in "Z" with - no timezone offset. Date accuracy is up to milliseconds. The file can be created - after the experiment was run, so this may differ from the experiment start time. - Each modification to the nwb file adds a new entry to the array.' - attributes: - file_create_date: - name: file_create_date - description: 'A record of the date the file was created and of subsequent - modifications. The date is stored in UTC with local timezone offset as ISO - 8601 extended formatted strings: 2018-09-28T14:43:54.123+02:00. Dates stored - in UTC end in "Z" with no timezone offset. Date accuracy is up to milliseconds. - The file can be created after the experiment was run, so this may differ - from the experiment start time. Each modification to the nwb file adds a - new entry to the array.' - multivalued: true - range: isodatetime - required: true - NWBFile__acquisition: - name: NWBFile__acquisition - description: Data streams recorded from the system, including ephys, ophys, tracking, - etc. This group should be read-only after the experiment is completed and timestamps - are corrected to a common timebase. The data stored here may be links to raw - data stored in external NWB files. This will allow keeping bulky raw data out - of the file while preserving the option of keeping some/all in the file. Acquired - data includes tracking and experimental data streams (i.e., everything measured - from the system). If bulky data is stored in the /acquisition group, the data - can exist in a separate NWB file that is linked to by the file being used for - processing and analysis. - attributes: - NWBDataInterface: - name: NWBDataInterface - description: Acquired, raw data. - multivalued: true - range: NWBDataInterface - required: false - DynamicTable: - name: DynamicTable - description: Tabular data that is relevant to acquisition - multivalued: true - range: DynamicTable - required: false - NWBFile__analysis: - name: NWBFile__analysis - description: Lab-specific and custom scientific analysis of data. There is no - defined format for the content of this group - the format is up to the individual - user/lab. To facilitate sharing analysis data between labs, the contents here - should be stored in standard types (e.g., neurodata_types) and appropriately - documented. The file can store lab-specific and custom data analysis without - restriction on its form or schema, reducing data formatting restrictions on - end users. Such data should be placed in the analysis group. The analysis data - should be documented so that it could be shared with other labs. - attributes: - NWBContainer: - name: NWBContainer - description: Custom analysis results. - multivalued: true - range: NWBContainer - required: false - DynamicTable: - name: DynamicTable - description: Tabular data that is relevant to data stored in analysis - multivalued: true - range: DynamicTable - required: false - NWBFile__scratch: - name: NWBFile__scratch - description: A place to store one-off analysis results. Data placed here is not - intended for sharing. By placing data here, users acknowledge that there is - no guarantee that their data meets any standard. - attributes: - ScratchData: - name: ScratchData - description: Any one-off datasets - multivalued: true - range: ScratchData - required: false - NWBContainer: - name: NWBContainer - description: Any one-off containers - multivalued: true - range: NWBContainer - required: false - DynamicTable: - name: DynamicTable - description: Any one-off tables - multivalued: true - range: DynamicTable - required: false - NWBFile__processing: - name: NWBFile__processing - description: The home for ProcessingModules. These modules perform intermediate - analysis of data that is necessary to perform before scientific analysis. Examples - include spike clustering, extracting position from tracking data, stitching - together image slices. ProcessingModules can be large and express many data - sets from relatively complex analysis (e.g., spike detection and clustering) - or small, representing extraction of position information from tracking video, - or even binary lick/no-lick decisions. Common software tools (e.g., klustakwik, - MClust) are expected to read/write data here. 'Processing' refers to intermediate - analysis of the acquired data to make it more amenable to scientific analysis. - attributes: - ProcessingModule: - name: ProcessingModule - description: Intermediate analysis of acquired data. - multivalued: true - range: ProcessingModule - required: false NWBFile__stimulus: name: NWBFile__stimulus description: Data pushed into the system (eg, video stimulus, sound, voltage, @@ -140,50 +30,28 @@ classes: times. These templates can exist in the present file or can be linked to a remote library file. attributes: + name: + name: name + ifabsent: string(stimulus) + range: string + required: true + equals_string: stimulus presentation: name: presentation description: Stimuli presented during the experiment. - multivalued: false - range: NWBFile__stimulus__presentation - required: true + multivalued: true + any_of: + - range: TimeSeries templates: name: templates description: Template stimuli. Timestamps in templates are based on stimulus design and are relative to the beginning of the stimulus. When templates are used, the stimulus instances must convert presentation times to the experiment`s time reference frame. - multivalued: false - range: NWBFile__stimulus__templates - required: true - NWBFile__stimulus__presentation: - name: NWBFile__stimulus__presentation - description: Stimuli presented during the experiment. - attributes: - TimeSeries: - name: TimeSeries - description: TimeSeries objects containing data of presented stimuli. multivalued: true - range: TimeSeries - required: false - NWBFile__stimulus__templates: - name: NWBFile__stimulus__templates - description: Template stimuli. Timestamps in templates are based on stimulus design - and are relative to the beginning of the stimulus. When templates are used, - the stimulus instances must convert presentation times to the experiment`s time - reference frame. - attributes: - TimeSeries: - name: TimeSeries - description: TimeSeries objects containing template data of presented stimuli. - multivalued: true - range: TimeSeries - required: false - Images: - name: Images - description: Images objects containing images of presented stimuli. - multivalued: true - range: Images - required: false + any_of: + - range: TimeSeries + - range: Images NWBFile__general: name: NWBFile__general description: Experimental metadata, including protocol, notes and description @@ -201,6 +69,12 @@ classes: when data is present. Unused groups (e.g., intracellular_ephys in an optophysiology experiment) should not be created unless there is data to store within them. attributes: + name: + name: name + ifabsent: string(general) + range: string + required: true + equals_string: general data_collection: name: data_collection description: Notes about data collection and analysis. @@ -217,8 +91,8 @@ classes: name: experimenter description: Name of person(s) who performed the experiment. Can also specify roles of different people involved. - multivalued: false - range: NWBFile__general__experimenter + multivalued: true + range: text required: false institution: name: institution @@ -229,8 +103,8 @@ classes: keywords: name: keywords description: Terms to search over. - multivalued: false - range: NWBFile__general__keywords + multivalued: true + range: text required: false lab: name: lab @@ -261,8 +135,8 @@ classes: related_publications: name: related_publications description: Publication information. PMID, DOI, URL, etc. - multivalued: false - range: NWBFile__general__related_publications + multivalued: true + range: text required: false session_id: name: session_id @@ -304,8 +178,8 @@ classes: multivalued: false range: text required: false - LabMetaData: - name: LabMetaData + lab_meta_data: + name: lab_meta_data description: Place-holder than can be extended so that lab-specific meta-data can be placed in /general. multivalued: true @@ -315,15 +189,15 @@ classes: name: devices description: Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc. - multivalued: false - range: NWBFile__general__devices - required: false + multivalued: true + any_of: + - range: Device subject: name: subject description: Information about the animal or person from which the data was measured. multivalued: false - range: NWBFile__general__subject + range: Subject required: false extracellular_ephys: name: extracellular_ephys @@ -340,77 +214,42 @@ classes: optogenetics: name: optogenetics description: Metadata describing optogenetic stimuluation. - multivalued: false - range: NWBFile__general__optogenetics - required: false + multivalued: true + any_of: + - range: OptogeneticStimulusSite optophysiology: name: optophysiology description: Metadata related to optophysiology. - multivalued: false - range: NWBFile__general__optophysiology - required: false - NWBFile__general__experimenter: - name: NWBFile__general__experimenter - description: Name of person(s) who performed the experiment. Can also specify - roles of different people involved. - attributes: - experimenter: - name: experimenter - description: Name of person(s) who performed the experiment. Can also specify - roles of different people involved. multivalued: true - range: text - required: false - NWBFile__general__keywords: - name: NWBFile__general__keywords - description: Terms to search over. - attributes: - keywords: - name: keywords - description: Terms to search over. - multivalued: true - range: text - required: false - NWBFile__general__related_publications: - name: NWBFile__general__related_publications - description: Publication information. PMID, DOI, URL, etc. - attributes: - related_publications: - name: related_publications - description: Publication information. PMID, DOI, URL, etc. - multivalued: true - range: text - required: false + any_of: + - range: ImagingPlane NWBFile__general__source_script: name: NWBFile__general__source_script description: Script file or link to public source code used to create this NWB file. attributes: + name: + name: name + ifabsent: string(source_script) + range: string + required: true + equals_string: source_script file_name: name: file_name description: Name of script file. range: text - NWBFile__general__devices: - name: NWBFile__general__devices - description: Description of hardware devices used during experiment, e.g., monitors, - ADC boards, microscopes, etc. - attributes: - Device: - name: Device - description: Data acquisition devices. - multivalued: true - range: Device - required: false - NWBFile__general__subject: - name: NWBFile__general__subject - description: Information about the animal or person from which the data was measured. - is_a: Subject NWBFile__general__extracellular_ephys: name: NWBFile__general__extracellular_ephys description: Metadata related to extracellular electrophysiology. attributes: - ElectrodeGroup: - name: ElectrodeGroup + name: + name: name + ifabsent: string(extracellular_ephys) + range: string + required: true + equals_string: extracellular_ephys + electrode_group: + name: electrode_group description: Physical group of electrodes. multivalued: true range: ElectrodeGroup @@ -419,82 +258,18 @@ classes: name: electrodes description: A table of all electrodes (i.e. channels) used for recording. multivalued: false - range: NWBFile__general__extracellular_ephys__electrodes + range: DynamicTable required: false - NWBFile__general__extracellular_ephys__electrodes: - name: NWBFile__general__extracellular_ephys__electrodes - description: A table of all electrodes (i.e. channels) used for recording. - is_a: DynamicTable - attributes: - x: - name: x - description: x coordinate of the channel location in the brain (+x is posterior). - multivalued: true - range: float32 - y: - name: y - description: y coordinate of the channel location in the brain (+y is inferior). - multivalued: true - range: float32 - z: - name: z - description: z coordinate of the channel location in the brain (+z is right). - multivalued: true - range: float32 - imp: - name: imp - description: Impedance of the channel, in ohms. - multivalued: true - range: float32 - location: - name: location - description: Location of the electrode (channel). Specify the area, layer, - comments on estimation of area/layer, stereotaxic coordinates if in vivo, - etc. Use standard atlas names for anatomical regions when possible. - multivalued: true - range: text - filtering: - name: filtering - description: Description of hardware filtering, including the filter name - and frequency cutoffs. - multivalued: true - range: text - group: - name: group - description: Reference to the ElectrodeGroup this electrode is a part of. - multivalued: true - range: ElectrodeGroup - group_name: - name: group_name - description: Name of the ElectrodeGroup this electrode is a part of. - multivalued: true - range: text - rel_x: - name: rel_x - description: x coordinate in electrode group - multivalued: true - range: float32 - rel_y: - name: rel_y - description: y coordinate in electrode group - multivalued: true - range: float32 - rel_z: - name: rel_z - description: z coordinate in electrode group - multivalued: true - range: float32 - reference: - name: reference - description: Description of the reference electrode and/or reference scheme - used for this electrode, e.g., "stainless steel skull screw" or "online - common average referencing". - multivalued: true - range: text NWBFile__general__intracellular_ephys: name: NWBFile__general__intracellular_ephys description: Metadata related to intracellular electrophysiology. attributes: + name: + name: name + ifabsent: string(intracellular_ephys) + range: string + required: true + equals_string: intracellular_ephys filtering: name: filtering description: '[DEPRECATED] Use IntracellularElectrode.filtering instead. Description @@ -504,8 +279,8 @@ classes: multivalued: false range: text required: false - IntracellularElectrode: - name: IntracellularElectrode + intracellular_electrode: + name: intracellular_electrode description: An intracellular electrode. multivalued: true range: IntracellularElectrode @@ -517,7 +292,7 @@ classes: tables. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions tables provide enhanced support for experiment metadata.' multivalued: false - range: NWBFile__general__intracellular_ephys__sweep_table + range: SweepTable required: false intracellular_recordings: name: intracellular_recordings @@ -534,7 +309,7 @@ classes: to an electrode is also common in intracellular electrophysiology, in which case other TimeSeries may be used. multivalued: false - range: NWBFile__general__intracellular_ephys__intracellular_recordings + range: IntracellularRecordingsTable required: false simultaneous_recordings: name: simultaneous_recordings @@ -542,7 +317,7 @@ classes: the IntracellularRecordingsTable table together that were recorded simultaneously from different electrodes multivalued: false - range: NWBFile__general__intracellular_ephys__simultaneous_recordings + range: SimultaneousRecordingsTable required: false sequential_recordings: name: sequential_recordings @@ -551,7 +326,7 @@ classes: together sequential recordings where the a sequence of stimuli of the same type with varying parameters have been presented in a sequence. multivalued: false - range: NWBFile__general__intracellular_ephys__sequential_recordings + range: SequentialRecordingsTable required: false repetitions: name: repetitions @@ -560,80 +335,14 @@ classes: type of stimulus, the RepetitionsTable table is typically used to group sets of stimuli applied in sequence. multivalued: false - range: NWBFile__general__intracellular_ephys__repetitions + range: RepetitionsTable required: false experimental_conditions: name: experimental_conditions description: A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions. multivalued: false - range: NWBFile__general__intracellular_ephys__experimental_conditions - required: false - NWBFile__general__intracellular_ephys__sweep_table: - name: NWBFile__general__intracellular_ephys__sweep_table - description: '[DEPRECATED] Table used to group different PatchClampSeries. SweepTable - is being replaced by IntracellularRecordingsTable and SimultaneousRecordingsTable - tables. Additional SequentialRecordingsTable, RepetitionsTable and ExperimentalConditions - tables provide enhanced support for experiment metadata.' - is_a: SweepTable - NWBFile__general__intracellular_ephys__intracellular_recordings: - name: NWBFile__general__intracellular_ephys__intracellular_recordings - description: 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. - is_a: IntracellularRecordingsTable - NWBFile__general__intracellular_ephys__simultaneous_recordings: - name: NWBFile__general__intracellular_ephys__simultaneous_recordings - description: A table for grouping different intracellular recordings from the - IntracellularRecordingsTable table together that were recorded simultaneously - from different electrodes - is_a: SimultaneousRecordingsTable - NWBFile__general__intracellular_ephys__sequential_recordings: - name: NWBFile__general__intracellular_ephys__sequential_recordings - description: 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. - is_a: SequentialRecordingsTable - NWBFile__general__intracellular_ephys__repetitions: - name: NWBFile__general__intracellular_ephys__repetitions - description: 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. - is_a: RepetitionsTable - NWBFile__general__intracellular_ephys__experimental_conditions: - name: NWBFile__general__intracellular_ephys__experimental_conditions - description: A table for grouping different intracellular recording repetitions - together that belong to the same experimental experimental_conditions. - is_a: ExperimentalConditionsTable - NWBFile__general__optogenetics: - name: NWBFile__general__optogenetics - description: Metadata describing optogenetic stimuluation. - attributes: - OptogeneticStimulusSite: - name: OptogeneticStimulusSite - description: An optogenetic stimulation site. - multivalued: true - range: OptogeneticStimulusSite - required: false - NWBFile__general__optophysiology: - name: NWBFile__general__optophysiology - description: Metadata related to optophysiology. - attributes: - ImagingPlane: - name: ImagingPlane - description: An imaging plane. - multivalued: true - range: ImagingPlane + range: ExperimentalConditionsTable required: false NWBFile__intervals: name: NWBFile__intervals @@ -641,53 +350,48 @@ classes: having a particular scientific goal, trials (see trials subgroup) during an experiment, or epochs (see epochs subgroup) deriving from analysis of data. attributes: + name: + name: name + ifabsent: string(intervals) + range: string + required: true + equals_string: intervals epochs: name: epochs description: Divisions in time marking experimental stages or sub-divisions of a single recording session. multivalued: false - range: NWBFile__intervals__epochs + range: TimeIntervals required: false trials: name: trials description: Repeated experimental events that have a logical grouping. multivalued: false - range: NWBFile__intervals__trials + range: TimeIntervals required: false invalid_times: name: invalid_times description: Time intervals that should be removed from analysis. multivalued: false - range: NWBFile__intervals__invalid_times + range: TimeIntervals required: false - TimeIntervals: - name: TimeIntervals + time_intervals: + name: time_intervals description: Optional additional table(s) for describing other experimental time intervals. multivalued: true range: TimeIntervals required: false - NWBFile__intervals__epochs: - name: NWBFile__intervals__epochs - description: Divisions in time marking experimental stages or sub-divisions of - a single recording session. - is_a: TimeIntervals - NWBFile__intervals__trials: - name: NWBFile__intervals__trials - description: Repeated experimental events that have a logical grouping. - is_a: TimeIntervals - NWBFile__intervals__invalid_times: - name: NWBFile__intervals__invalid_times - description: Time intervals that should be removed from analysis. - is_a: TimeIntervals - NWBFile__units: - name: NWBFile__units - description: Data about sorted spike units. - is_a: Units Subject__age: name: Subject__age description: Age of subject. Can be supplied instead of 'date_of_birth'. attributes: + name: + name: name + ifabsent: string(age) + range: string + required: true + equals_string: age reference: name: reference description: Age is with reference to this event. Can be 'birth' or 'gestational'. diff --git a/nwb_linkml/schema/core.nwb.file.yaml b/nwb_linkml/schema/core.nwb.file.yaml index 2772059..ef4a16f 100644 --- a/nwb_linkml/schema/core.nwb.file.yaml +++ b/nwb_linkml/schema/core.nwb.file.yaml @@ -20,16 +20,27 @@ classes: description: Any one-off datasets is_a: NWBData attributes: + name: + name: name + range: string + required: true notes: name: notes description: Any notes the user has about the dataset being stored range: text + tree_root: true NWBFile: name: NWBFile description: An NWB file storing cellular-based neurophysiology data from a single experimental session. is_a: NWBContainer attributes: + name: + name: name + ifabsent: string(root) + range: string + required: true + equals_string: root nwb_version: name: nwb_version description: File version string. Use semantic versioning, e.g. 1.2.1. This @@ -44,8 +55,8 @@ classes: The file can be created after the experiment was run, so this may differ from the experiment start time. Each modification to the nwb file adds a new entry to the array.' - multivalued: false - range: NWBFile__file_create_date + multivalued: true + range: isodatetime required: true identifier: name: identifier @@ -92,9 +103,10 @@ classes: (i.e., everything measured from the system). If bulky data is stored in the /acquisition group, the data can exist in a separate NWB file that is linked to by the file being used for processing and analysis. - multivalued: false - range: NWBFile__acquisition - required: true + multivalued: true + any_of: + - range: NWBDataInterface + - range: DynamicTable analysis: name: analysis description: Lab-specific and custom scientific analysis of data. There is @@ -106,17 +118,19 @@ classes: restrictions on end users. Such data should be placed in the analysis group. The analysis data should be documented so that it could be shared with other labs. - multivalued: false - range: NWBFile__analysis - required: true + multivalued: true + any_of: + - range: NWBContainer + - range: DynamicTable scratch: name: scratch description: A place to store one-off analysis results. Data placed here is not intended for sharing. By placing data here, users acknowledge that there is no guarantee that their data meets any standard. - multivalued: false - range: NWBFile__scratch - required: false + multivalued: true + any_of: + - range: NWBContainer + - range: DynamicTable processing: name: processing description: The home for ProcessingModules. These modules perform intermediate @@ -129,9 +143,9 @@ classes: (e.g., klustakwik, MClust) are expected to read/write data here. 'Processing' refers to intermediate analysis of the acquired data to make it more amenable to scientific analysis. - multivalued: false - range: NWBFile__processing - required: true + multivalued: true + any_of: + - range: ProcessingModule stimulus: name: stimulus description: Data pushed into the system (eg, video stimulus, sound, voltage, @@ -182,17 +196,28 @@ classes: name: units description: Data about sorted spike units. multivalued: false - range: NWBFile__units + range: Units required: false + tree_root: true LabMetaData: name: LabMetaData description: Lab-specific meta-data. is_a: NWBContainer + attributes: + name: + name: name + range: string + required: true + tree_root: true Subject: name: Subject description: Information about the animal or person from which the data was measured. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true age: name: age description: Age of subject. Can be supplied instead of 'date_of_birth'. @@ -249,3 +274,4 @@ classes: multivalued: false range: text required: false + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.icephys.include.yaml b/nwb_linkml/schema/core.nwb.icephys.include.yaml index c18a818..d9c0cc2 100644 --- a/nwb_linkml/schema/core.nwb.icephys.include.yaml +++ b/nwb_linkml/schema/core.nwb.icephys.include.yaml @@ -9,26 +9,16 @@ imports: - core.nwb.icephys default_prefix: core.nwb.icephys.include/ classes: - PatchClampSeries__data: - name: PatchClampSeries__data - description: Recorded voltage or current. - attributes: - unit: - name: unit - description: Base unit of measurement for working with the data. Actual stored - values are not necessarily stored in these units. To access the data in - these units, multiply 'data' by 'conversion' and add 'offset'. - range: text - data: - name: data - description: Recorded voltage or current. - multivalued: true - range: numeric - required: true CurrentClampSeries__data: name: CurrentClampSeries__data description: Recorded voltage. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. which is @@ -40,6 +30,12 @@ classes: name: CurrentClampStimulusSeries__data description: Stimulus current applied. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. which is @@ -51,6 +47,12 @@ classes: name: VoltageClampSeries__data description: Recorded current. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. which is @@ -62,6 +64,12 @@ classes: name: VoltageClampSeries__capacitance_fast description: Fast capacitance, in farads. attributes: + name: + name: name + ifabsent: string(capacitance_fast) + range: string + required: true + equals_string: capacitance_fast unit: name: unit description: Unit of measurement for capacitance_fast, which is fixed to 'farads'. @@ -70,6 +78,12 @@ classes: name: VoltageClampSeries__capacitance_slow description: Slow capacitance, in farads. attributes: + name: + name: name + ifabsent: string(capacitance_slow) + range: string + required: true + equals_string: capacitance_slow unit: name: unit description: Unit of measurement for capacitance_fast, which is fixed to 'farads'. @@ -78,6 +92,12 @@ classes: name: VoltageClampSeries__resistance_comp_bandwidth description: Resistance compensation bandwidth, in hertz. attributes: + name: + name: name + ifabsent: string(resistance_comp_bandwidth) + range: string + required: true + equals_string: resistance_comp_bandwidth unit: name: unit description: Unit of measurement for resistance_comp_bandwidth, which is fixed @@ -87,6 +107,12 @@ classes: name: VoltageClampSeries__resistance_comp_correction description: Resistance compensation correction, in percent. attributes: + name: + name: name + ifabsent: string(resistance_comp_correction) + range: string + required: true + equals_string: resistance_comp_correction unit: name: unit description: Unit of measurement for resistance_comp_correction, which is @@ -96,6 +122,12 @@ classes: name: VoltageClampSeries__resistance_comp_prediction description: Resistance compensation prediction, in percent. attributes: + name: + name: name + ifabsent: string(resistance_comp_prediction) + range: string + required: true + equals_string: resistance_comp_prediction unit: name: unit description: Unit of measurement for resistance_comp_prediction, which is @@ -105,6 +137,12 @@ classes: name: VoltageClampSeries__whole_cell_capacitance_comp description: Whole cell capacitance compensation, in farads. attributes: + name: + name: name + ifabsent: string(whole_cell_capacitance_comp) + range: string + required: true + equals_string: whole_cell_capacitance_comp unit: name: unit description: Unit of measurement for whole_cell_capacitance_comp, which is @@ -114,6 +152,12 @@ classes: name: VoltageClampSeries__whole_cell_series_resistance_comp description: Whole cell series resistance compensation, in ohms. attributes: + name: + name: name + ifabsent: string(whole_cell_series_resistance_comp) + range: string + required: true + equals_string: whole_cell_series_resistance_comp unit: name: unit description: Unit of measurement for whole_cell_series_resistance_comp, which @@ -123,6 +167,12 @@ classes: name: VoltageClampStimulusSeries__data description: Stimulus voltage applied. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. which is @@ -134,34 +184,49 @@ classes: name: SweepTable__series_index description: Index for series. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(series_index) + range: string + required: true + equals_string: series_index IntracellularStimuliTable__stimulus: name: IntracellularStimuliTable__stimulus description: Column storing the reference to the recorded stimulus for the recording (rows). is_a: TimeSeriesReferenceVectorData + attributes: + name: + name: name + ifabsent: string(stimulus) + range: string + required: true + equals_string: stimulus IntracellularResponsesTable__response: name: IntracellularResponsesTable__response description: Column storing the reference to the recorded response for the recording (rows) is_a: TimeSeriesReferenceVectorData - IntracellularRecordingsTable__electrodes: - name: IntracellularRecordingsTable__electrodes - description: Table for storing intracellular electrode related metadata. - is_a: IntracellularElectrodesTable - IntracellularRecordingsTable__stimuli: - name: IntracellularRecordingsTable__stimuli - description: Table for storing intracellular stimulus related metadata. - is_a: IntracellularStimuliTable - IntracellularRecordingsTable__responses: - name: IntracellularRecordingsTable__responses - description: Table for storing intracellular response related metadata. - is_a: IntracellularResponsesTable + attributes: + name: + name: name + ifabsent: string(response) + range: string + required: true + equals_string: response SimultaneousRecordingsTable__recordings: name: SimultaneousRecordingsTable__recordings description: A reference to one or more rows in the IntracellularRecordingsTable table. is_a: DynamicTableRegion attributes: + name: + name: name + ifabsent: string(recordings) + range: string + required: true + equals_string: recordings table: name: table description: Reference to the IntracellularRecordingsTable table that this @@ -172,12 +237,25 @@ classes: name: SimultaneousRecordingsTable__recordings_index description: Index dataset for the recordings column. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(recordings_index) + range: string + required: true + equals_string: recordings_index SequentialRecordingsTable__simultaneous_recordings: name: SequentialRecordingsTable__simultaneous_recordings description: A reference to one or more rows in the SimultaneousRecordingsTable table. is_a: DynamicTableRegion attributes: + name: + name: name + ifabsent: string(simultaneous_recordings) + range: string + required: true + equals_string: simultaneous_recordings table: name: table description: Reference to the SimultaneousRecordingsTable table that this @@ -188,12 +266,25 @@ classes: name: SequentialRecordingsTable__simultaneous_recordings_index description: Index dataset for the simultaneous_recordings column. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(simultaneous_recordings_index) + range: string + required: true + equals_string: simultaneous_recordings_index RepetitionsTable__sequential_recordings: name: RepetitionsTable__sequential_recordings description: A reference to one or more rows in the SequentialRecordingsTable table. is_a: DynamicTableRegion attributes: + name: + name: name + ifabsent: string(sequential_recordings) + range: string + required: true + equals_string: sequential_recordings table: name: table description: Reference to the SequentialRecordingsTable table that this table @@ -204,11 +295,24 @@ classes: name: RepetitionsTable__sequential_recordings_index description: Index dataset for the sequential_recordings column. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(sequential_recordings_index) + range: string + required: true + equals_string: sequential_recordings_index ExperimentalConditionsTable__repetitions: name: ExperimentalConditionsTable__repetitions description: A reference to one or more rows in the RepetitionsTable table. is_a: DynamicTableRegion attributes: + name: + name: name + ifabsent: string(repetitions) + range: string + required: true + equals_string: repetitions table: name: table description: Reference to the RepetitionsTable table that this table region @@ -219,3 +323,10 @@ classes: name: ExperimentalConditionsTable__repetitions_index description: Index dataset for the repetitions column. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(repetitions_index) + range: string + required: true + equals_string: repetitions_index diff --git a/nwb_linkml/schema/core.nwb.icephys.yaml b/nwb_linkml/schema/core.nwb.icephys.yaml index 0dabfe2..078a9f1 100644 --- a/nwb_linkml/schema/core.nwb.icephys.yaml +++ b/nwb_linkml/schema/core.nwb.icephys.yaml @@ -15,6 +15,10 @@ classes: current or voltage. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true stimulus_description: name: stimulus_description description: Protocol/stimulus name for this patch-clamp dataset. @@ -26,8 +30,8 @@ classes: data: name: data description: Recorded voltage or current. - multivalued: false - range: PatchClampSeries__data + multivalued: true + range: numeric required: true gain: name: gain @@ -36,6 +40,7 @@ classes: multivalued: false range: float32 required: false + tree_root: true CurrentClampSeries: name: CurrentClampSeries description: Voltage data from an intracellular current-clamp recording. A corresponding @@ -43,6 +48,10 @@ classes: the current injected. is_a: PatchClampSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Recorded voltage. @@ -67,6 +76,7 @@ classes: multivalued: false range: float32 required: false + tree_root: true IZeroClampSeries: name: IZeroClampSeries description: Voltage data from an intracellular recording when all current and @@ -75,6 +85,10 @@ classes: amplifier is disconnected and no stimulus can reach the cell. is_a: CurrentClampSeries attributes: + name: + name: name + range: string + required: true stimulus_description: name: stimulus_description description: An IZeroClampSeries has no stimulus, so this attribute is automatically @@ -98,17 +112,23 @@ classes: multivalued: false range: float32 required: true + tree_root: true CurrentClampStimulusSeries: name: CurrentClampStimulusSeries description: Stimulus current applied during current clamp recording. is_a: PatchClampSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Stimulus current applied. multivalued: false range: CurrentClampStimulusSeries__data required: true + tree_root: true VoltageClampSeries: name: VoltageClampSeries description: Current data from an intracellular voltage-clamp recording. A corresponding @@ -116,6 +136,10 @@ classes: the voltage injected. is_a: PatchClampSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Recorded current. @@ -164,22 +188,32 @@ classes: multivalued: false range: VoltageClampSeries__whole_cell_series_resistance_comp required: false + tree_root: true VoltageClampStimulusSeries: name: VoltageClampStimulusSeries description: Stimulus voltage applied during a voltage clamp recording. is_a: PatchClampSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Stimulus voltage applied. multivalued: false range: VoltageClampStimulusSeries__data required: true + tree_root: true IntracellularElectrode: name: IntracellularElectrode description: An intracellular electrode and its metadata. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true cell_id: name: cell_id description: unique ID of the cell @@ -230,6 +264,7 @@ classes: multivalued: false range: text required: false + tree_root: true SweepTable: name: SweepTable description: '[DEPRECATED] Table used to group different PatchClampSeries. SweepTable @@ -238,6 +273,10 @@ classes: tables provide enhanced support for experiment metadata.' is_a: DynamicTable attributes: + name: + name: name + range: string + required: true sweep_number: name: sweep_number description: Sweep number of the PatchClampSeries in that row. @@ -254,11 +293,16 @@ classes: multivalued: false range: SweepTable__series_index required: true + tree_root: true IntracellularElectrodesTable: name: IntracellularElectrodesTable description: Table for storing intracellular electrode related metadata. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true description: name: description description: Description of what is in this dynamic table. @@ -268,11 +312,16 @@ classes: description: Column for storing the reference to the intracellular electrode. multivalued: true range: IntracellularElectrode + tree_root: true IntracellularStimuliTable: name: IntracellularStimuliTable description: Table for storing intracellular stimulus related metadata. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true description: name: description description: Description of what is in this dynamic table. @@ -284,11 +333,16 @@ classes: multivalued: false range: IntracellularStimuliTable__stimulus required: true + tree_root: true IntracellularResponsesTable: name: IntracellularResponsesTable description: Table for storing intracellular response related metadata. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true description: name: description description: Description of what is in this dynamic table. @@ -300,6 +354,7 @@ classes: multivalued: false range: IntracellularResponsesTable__response required: true + tree_root: true IntracellularRecordingsTable: name: IntracellularRecordingsTable description: A table to group together a stimulus and response from a single electrode @@ -315,6 +370,12 @@ classes: electrophysiology, in which case other TimeSeries may be used. is_a: AlignedDynamicTable attributes: + name: + name: name + ifabsent: string(intracellular_recordings) + range: string + required: true + equals_string: intracellular_recordings description: name: description description: Description of the contents of this table. Inherited from AlignedDynamicTable @@ -324,20 +385,21 @@ classes: name: electrodes description: Table for storing intracellular electrode related metadata. multivalued: false - range: IntracellularRecordingsTable__electrodes + range: IntracellularElectrodesTable required: true stimuli: name: stimuli description: Table for storing intracellular stimulus related metadata. multivalued: false - range: IntracellularRecordingsTable__stimuli + range: IntracellularStimuliTable required: true responses: name: responses description: Table for storing intracellular response related metadata. multivalued: false - range: IntracellularRecordingsTable__responses + range: IntracellularResponsesTable required: true + tree_root: true SimultaneousRecordingsTable: name: SimultaneousRecordingsTable description: A table for grouping different intracellular recordings from the @@ -345,6 +407,12 @@ classes: from different electrodes. is_a: DynamicTable attributes: + name: + name: name + ifabsent: string(simultaneous_recordings) + range: string + required: true + equals_string: simultaneous_recordings recordings: name: recordings description: A reference to one or more rows in the IntracellularRecordingsTable @@ -358,6 +426,7 @@ classes: multivalued: false range: SimultaneousRecordingsTable__recordings_index required: true + tree_root: true SequentialRecordingsTable: name: SequentialRecordingsTable description: A table for grouping different sequential recordings from the SimultaneousRecordingsTable @@ -366,6 +435,12 @@ classes: presented in a sequence. is_a: DynamicTable attributes: + name: + name: name + ifabsent: string(sequential_recordings) + range: string + required: true + equals_string: sequential_recordings simultaneous_recordings: name: simultaneous_recordings description: A reference to one or more rows in the SimultaneousRecordingsTable @@ -384,6 +459,7 @@ classes: description: The type of stimulus used for the sequential recording. multivalued: true range: text + tree_root: true RepetitionsTable: name: RepetitionsTable description: A table for grouping different sequential intracellular recordings @@ -392,6 +468,12 @@ classes: of stimuli applied in sequence. is_a: DynamicTable attributes: + name: + name: name + ifabsent: string(repetitions) + range: string + required: true + equals_string: repetitions sequential_recordings: name: sequential_recordings description: A reference to one or more rows in the SequentialRecordingsTable @@ -405,12 +487,19 @@ classes: multivalued: false range: RepetitionsTable__sequential_recordings_index required: true + tree_root: true ExperimentalConditionsTable: name: ExperimentalConditionsTable description: A table for grouping different intracellular recording repetitions together that belong to the same experimental condition. is_a: DynamicTable attributes: + name: + name: name + ifabsent: string(experimental_conditions) + range: string + required: true + equals_string: experimental_conditions repetitions: name: repetitions description: A reference to one or more rows in the RepetitionsTable table. @@ -423,3 +512,4 @@ classes: multivalued: false range: ExperimentalConditionsTable__repetitions_index required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.image.include.yaml b/nwb_linkml/schema/core.nwb.image.include.yaml index 5c14f9d..8eec5ca 100644 --- a/nwb_linkml/schema/core.nwb.image.include.yaml +++ b/nwb_linkml/schema/core.nwb.image.include.yaml @@ -15,11 +15,11 @@ classes: x: name: x range: numeric - required: false + required: true y: name: y range: numeric - required: false + required: true RGBImage__Array: name: RGBImage__Array is_a: Arraylike @@ -27,15 +27,15 @@ classes: x: name: x range: numeric - required: false + required: true y: name: y range: numeric - required: false + required: true r, g, b: name: r, g, b range: numeric - required: false + required: true minimum_cardinality: 3 maximum_cardinality: 3 RGBAImage__Array: @@ -45,15 +45,15 @@ classes: x: name: x range: numeric - required: false + required: true y: name: y range: numeric - required: false + required: true r, g, b, a: name: r, g, b, a range: numeric - required: false + required: true minimum_cardinality: 4 maximum_cardinality: 4 ImageSeries__data: @@ -61,6 +61,12 @@ classes: description: Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data array: name: array range: ImageSeries__data__Array @@ -84,52 +90,16 @@ classes: name: z range: numeric required: false - ImageSeries__dimension: - name: ImageSeries__dimension - description: Number of pixels on x, y, (and z) axes. - attributes: - dimension: - name: dimension - description: Number of pixels on x, y, (and z) axes. - multivalued: true - range: int32 - required: false - ImageSeries__external_file: - name: ImageSeries__external_file - description: Paths to one or more external file(s). The field is only present - if format='external'. This is only relevant if the image series is stored in - the file system as one or more image file(s). This field should NOT be used - if the image is stored in another NWB file and that file is linked to this file. - attributes: - starting_frame: - name: starting_frame - description: Each external image may contain one or more consecutive frames - of the full ImageSeries. This attribute serves as an index to indicate which - frames each file contains, to facilitate random access. The 'starting_frame' - attribute, hence, contains a list of frame numbers within the full ImageSeries - of the first frame of each file listed in the parent 'external_file' dataset. - Zero-based indexing is used (hence, the first element will always be zero). - For example, if the 'external_file' dataset has three paths to files and - the first file has 5 frames, the second file has 10 frames, and the third - file has 20 frames, then this attribute will have values [0, 5, 15]. If - there is a single external file that holds all of the frames of the ImageSeries - (and so there is a single element in the 'external_file' dataset), then - this attribute should have value [0]. - range: int32 - external_file: - name: external_file - description: Paths to one or more external file(s). The field is only present - if format='external'. This is only relevant if the image series is stored - in the file system as one or more image file(s). This field should NOT be - used if the image is stored in another NWB file and that file is linked - to this file. - multivalued: true - range: text - required: false OpticalSeries__field_of_view: name: OpticalSeries__field_of_view description: Width, height and depth of image, or imaged area, in meters. attributes: + name: + name: name + ifabsent: string(field_of_view) + range: string + required: true + equals_string: field_of_view array: name: array range: OpticalSeries__field_of_view__Array @@ -153,6 +123,12 @@ classes: name: OpticalSeries__data description: Images presented to subject, either grayscale or RGB attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data array: name: array range: OpticalSeries__data__Array @@ -178,30 +154,3 @@ classes: required: false minimum_cardinality: 3 maximum_cardinality: 3 - IndexSeries__data: - name: IndexSeries__data - description: Index of the image (using zero-indexing) in the linked Images object. - attributes: - conversion: - name: conversion - description: This field is unused by IndexSeries. - range: float32 - resolution: - name: resolution - description: This field is unused by IndexSeries. - range: float32 - offset: - name: offset - description: This field is unused by IndexSeries. - range: float32 - unit: - name: unit - description: This field is unused by IndexSeries and has the value N/A. - range: text - data: - name: data - description: Index of the image (using zero-indexing) in the linked Images - object. - multivalued: true - range: uint32 - required: true diff --git a/nwb_linkml/schema/core.nwb.image.yaml b/nwb_linkml/schema/core.nwb.image.yaml index c3c9131..9a4e11a 100644 --- a/nwb_linkml/schema/core.nwb.image.yaml +++ b/nwb_linkml/schema/core.nwb.image.yaml @@ -13,25 +13,40 @@ classes: description: A grayscale image. is_a: Image attributes: + name: + name: name + range: string + required: true array: name: array range: GrayscaleImage__Array + tree_root: true RGBImage: name: RGBImage description: A color image. is_a: Image attributes: + name: + name: name + range: string + required: true array: name: array range: RGBImage__Array + tree_root: true RGBAImage: name: RGBAImage description: A color image with transparency. is_a: Image attributes: + name: + name: name + range: string + required: true array: name: array range: RGBAImage__Array + tree_root: true ImageSeries: name: ImageSeries description: General image data that is common between acquisition and stimulus @@ -42,6 +57,10 @@ classes: stack. [frame][x][y] or [frame][x][y][z]. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Binary data representing images across frames. If data are stored @@ -52,8 +71,8 @@ classes: dimension: name: dimension description: Number of pixels on x, y, (and z) axes. - multivalued: false - range: ImageSeries__dimension + multivalued: true + range: int32 required: false external_file: name: external_file @@ -62,8 +81,8 @@ classes: in the file system as one or more image file(s). This field should NOT be used if the image is stored in another NWB file and that file is linked to this file. - multivalued: false - range: ImageSeries__external_file + multivalued: true + range: text required: false format: name: format @@ -74,6 +93,7 @@ classes: multivalued: false range: text required: false + tree_root: true ImageMaskSeries: name: ImageMaskSeries description: An alpha mask that is applied to a presented visual stimulus. The @@ -82,6 +102,12 @@ classes: array indicates the starting time of a mask, and that mask pattern continues until it's explicitly changed. is_a: ImageSeries + attributes: + name: + name: name + range: string + required: true + tree_root: true OpticalSeries: name: OpticalSeries description: Image data that is presented or recorded. A stimulus template movie @@ -91,6 +117,10 @@ classes: OpticalSeries represents acquired imaging data, orientation is also important. is_a: ImageSeries attributes: + name: + name: name + range: string + required: true distance: name: distance description: Distance from camera/monitor to target/eye. @@ -116,6 +146,7 @@ classes: multivalued: false range: text required: false + tree_root: true IndexSeries: name: IndexSeries description: Stores indices to image frames stored in an ImageSeries. The purpose @@ -127,10 +158,15 @@ classes: was displayed. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Index of the image (using zero-indexing) in the linked Images object. - multivalued: false - range: IndexSeries__data + multivalued: true + range: uint32 required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.misc.include.yaml b/nwb_linkml/schema/core.nwb.misc.include.yaml index 943bde5..b0c0319 100644 --- a/nwb_linkml/schema/core.nwb.misc.include.yaml +++ b/nwb_linkml/schema/core.nwb.misc.include.yaml @@ -13,6 +13,12 @@ classes: name: AbstractFeatureSeries__data description: Values of each feature at each time. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Since there can be different units for different features, store @@ -34,70 +40,16 @@ classes: name: num_features range: numeric required: false - AbstractFeatureSeries__feature_units: - name: AbstractFeatureSeries__feature_units - description: Units of each feature. - attributes: - feature_units: - name: feature_units - description: Units of each feature. - multivalued: true - range: text - required: false - AbstractFeatureSeries__features: - name: AbstractFeatureSeries__features - description: Description of the features represented in TimeSeries::data. - attributes: - features: - name: features - description: Description of the features represented in TimeSeries::data. - multivalued: true - range: text - required: true - AnnotationSeries__data: - name: AnnotationSeries__data - description: Annotations made during an experiment. - attributes: - resolution: - name: resolution - description: Smallest meaningful difference between values in data. Annotations - have no units, so the value is fixed to -1.0. - range: float32 - unit: - name: unit - description: Base unit of measurement for working with the data. Annotations - have no units, so the value is fixed to 'n/a'. - range: text - data: - name: data - description: Annotations made during an experiment. - multivalued: true - range: text - required: true - IntervalSeries__data: - name: IntervalSeries__data - description: Use values >0 if interval started, <0 if interval ended. - attributes: - resolution: - name: resolution - description: Smallest meaningful difference between values in data. Annotations - have no units, so the value is fixed to -1.0. - range: float32 - unit: - name: unit - description: Base unit of measurement for working with the data. Annotations - have no units, so the value is fixed to 'n/a'. - range: text - data: - name: data - description: Use values >0 if interval started, <0 if interval ended. - multivalued: true - range: int8 - required: true DecompositionSeries__data: name: DecompositionSeries__data description: Data decomposed into frequency bands. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data unit: name: unit description: Base unit of measurement for working with the data. Actual stored @@ -114,72 +66,49 @@ classes: num_times: name: num_times range: numeric - required: false + required: true num_channels: name: num_channels range: numeric - required: false + required: true num_bands: name: num_bands range: numeric - required: false + required: true DecompositionSeries__source_channels: name: DecompositionSeries__source_channels description: DynamicTableRegion pointer to the channels that this decomposition series was generated from. is_a: DynamicTableRegion - DecompositionSeries__bands: - name: DecompositionSeries__bands - description: Table for describing the bands that this series was generated from. - There should be one row in this table for each band. - is_a: DynamicTable attributes: - band_name: - name: band_name - description: Name of the band, e.g. theta. - multivalued: true - range: text - band_limits: - name: band_limits - description: Low and high limit of each band in Hz. If it is a Gaussian filter, - use 2 SD on either side of the center. - multivalued: false - range: DecompositionSeries__bands__band_limits + name: + name: name + ifabsent: string(source_channels) + range: string required: true - band_mean: - name: band_mean - description: The mean Gaussian filters, in Hz. - multivalued: false - range: DecompositionSeries__bands__band_mean - required: true - band_stdev: - name: band_stdev - description: The standard deviation of Gaussian filters, in Hz. - multivalued: false - range: DecompositionSeries__bands__band_stdev - required: true - DecompositionSeries__bands__band_limits: - name: DecompositionSeries__bands__band_limits - description: Low and high limit of each band in Hz. If it is a Gaussian filter, - use 2 SD on either side of the center. - is_a: VectorData - DecompositionSeries__bands__band_mean: - name: DecompositionSeries__bands__band_mean - description: The mean Gaussian filters, in Hz. - is_a: VectorData - DecompositionSeries__bands__band_stdev: - name: DecompositionSeries__bands__band_stdev - description: The standard deviation of Gaussian filters, in Hz. - is_a: VectorData + equals_string: source_channels Units__spike_times_index: name: Units__spike_times_index description: Index into the spike_times dataset. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(spike_times_index) + range: string + required: true + equals_string: spike_times_index Units__spike_times: name: Units__spike_times description: Spike times for each unit in seconds. is_a: VectorData attributes: + name: + name: name + ifabsent: string(spike_times) + range: string + required: true + equals_string: spike_times resolution: name: resolution description: The smallest possible difference between two spike times. Usually @@ -192,23 +121,57 @@ classes: name: Units__obs_intervals_index description: Index into the obs_intervals dataset. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(obs_intervals_index) + range: string + required: true + equals_string: obs_intervals_index Units__obs_intervals: name: Units__obs_intervals description: Observation intervals for each unit. is_a: VectorData + attributes: + name: + name: name + ifabsent: string(obs_intervals) + range: string + required: true + equals_string: obs_intervals Units__electrodes_index: name: Units__electrodes_index description: Index into electrodes. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(electrodes_index) + range: string + required: true + equals_string: electrodes_index Units__electrodes: name: Units__electrodes description: Electrode that each spike unit came from, specified using a DynamicTableRegion. is_a: DynamicTableRegion + attributes: + name: + name: name + ifabsent: string(electrodes) + range: string + required: true + equals_string: electrodes Units__waveform_mean: name: Units__waveform_mean description: Spike waveform mean for each spike unit. is_a: VectorData attributes: + name: + name: name + ifabsent: string(waveform_mean) + range: string + required: true + equals_string: waveform_mean sampling_rate: name: sampling_rate description: Sampling rate, in hertz. @@ -222,6 +185,12 @@ classes: description: Spike waveform standard deviation for each spike unit. is_a: VectorData attributes: + name: + name: name + ifabsent: string(waveform_sd) + range: string + required: true + equals_string: waveform_sd sampling_rate: name: sampling_rate description: Sampling rate, in hertz. @@ -257,6 +226,12 @@ classes: each waveform must be the same. is_a: VectorData attributes: + name: + name: name + ifabsent: string(waveforms) + range: string + required: true + equals_string: waveforms sampling_rate: name: sampling_rate description: Sampling rate, in hertz. @@ -270,8 +245,22 @@ classes: description: Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(waveforms_index) + range: string + required: true + equals_string: waveforms_index Units__waveforms_index_index: name: Units__waveforms_index_index description: Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(waveforms_index_index) + range: string + required: true + equals_string: waveforms_index_index diff --git a/nwb_linkml/schema/core.nwb.misc.yaml b/nwb_linkml/schema/core.nwb.misc.yaml index 06559d5..bea0419 100644 --- a/nwb_linkml/schema/core.nwb.misc.yaml +++ b/nwb_linkml/schema/core.nwb.misc.yaml @@ -22,6 +22,10 @@ classes: is impractical. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Values of each feature at each time. @@ -31,15 +35,16 @@ classes: feature_units: name: feature_units description: Units of each feature. - multivalued: false - range: AbstractFeatureSeries__feature_units + multivalued: true + range: text required: false features: name: features description: Description of the features represented in TimeSeries::data. - multivalued: false - range: AbstractFeatureSeries__features + multivalued: true + range: text required: true + tree_root: true AnnotationSeries: name: AnnotationSeries description: Stores user annotations made during an experiment. The data[] field @@ -48,12 +53,17 @@ classes: is identifiable as storing annotations in a machine-readable way. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Annotations made during an experiment. - multivalued: false - range: AnnotationSeries__data + multivalued: true + range: text required: true + tree_root: true IntervalSeries: name: IntervalSeries description: Stores intervals of data. The timestamps field stores the beginning @@ -65,17 +75,26 @@ classes: time intervals in a machine-readable way. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Use values >0 if interval started, <0 if interval ended. - multivalued: false - range: IntervalSeries__data + multivalued: true + range: int8 required: true + tree_root: true DecompositionSeries: name: DecompositionSeries description: Spectral analysis of a time series, e.g. of an LFP or a speech signal. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Data decomposed into frequency bands. @@ -100,14 +119,19 @@ classes: description: Table for describing the bands that this series was generated from. There should be one row in this table for each band. multivalued: false - range: DecompositionSeries__bands + range: DynamicTable required: true + tree_root: true Units: name: Units description: Data about spiking units. Event times of observed units (e.g. cell, synapse, etc.) should be concatenated and stored in spike_times. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true spike_times_index: name: spike_times_index description: Index into the spike_times dataset. @@ -203,3 +227,4 @@ classes: multivalued: false range: Units__waveforms_index_index required: false + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.ogen.include.yaml b/nwb_linkml/schema/core.nwb.ogen.include.yaml deleted file mode 100644 index 575659b..0000000 --- a/nwb_linkml/schema/core.nwb.ogen.include.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: core.nwb.ogen.include -id: core.nwb.ogen.include -imports: -- core.nwb.base -- core.nwb.device -- nwb.language -- core.nwb.ogen.include -- core.nwb.ogen -default_prefix: core.nwb.ogen.include/ -classes: - OptogeneticSeries__data: - name: OptogeneticSeries__data - description: Applied power for optogenetic stimulus, in watts. - attributes: - unit: - name: unit - description: Unit of measurement for data, which is fixed to 'watts'. - range: text - data: - name: data - description: Applied power for optogenetic stimulus, in watts. - multivalued: true - range: numeric - required: true diff --git a/nwb_linkml/schema/core.nwb.ogen.yaml b/nwb_linkml/schema/core.nwb.ogen.yaml index 328fbe5..aa0ef82 100644 --- a/nwb_linkml/schema/core.nwb.ogen.yaml +++ b/nwb_linkml/schema/core.nwb.ogen.yaml @@ -4,7 +4,6 @@ imports: - core.nwb.base - core.nwb.device - nwb.language -- core.nwb.ogen.include - core.nwb.ogen default_prefix: core.nwb.ogen/ classes: @@ -13,17 +12,26 @@ classes: description: An optogenetic stimulus. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Applied power for optogenetic stimulus, in watts. - multivalued: false - range: OptogeneticSeries__data + multivalued: true + range: numeric required: true + tree_root: true OptogeneticStimulusSite: name: OptogeneticStimulusSite description: A site of optogenetic stimulation. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description of stimulation site. @@ -44,3 +52,4 @@ classes: multivalued: false range: text required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.ophys.include.yaml b/nwb_linkml/schema/core.nwb.ophys.include.yaml index 21e9b8d..a870f55 100644 --- a/nwb_linkml/schema/core.nwb.ophys.include.yaml +++ b/nwb_linkml/schema/core.nwb.ophys.include.yaml @@ -14,6 +14,12 @@ classes: name: TwoPhotonSeries__field_of_view description: Width, height and depth of image, or imaged area, in meters. attributes: + name: + name: name + ifabsent: string(field_of_view) + range: string + required: true + equals_string: field_of_view array: name: array range: TwoPhotonSeries__field_of_view__Array @@ -37,6 +43,12 @@ classes: name: RoiResponseSeries__data description: Signals from ROIs. attributes: + name: + name: name + ifabsent: string(data) + range: string + required: true + equals_string: data array: name: array range: RoiResponseSeries__data__Array @@ -57,36 +69,59 @@ classes: description: DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries. is_a: DynamicTableRegion + attributes: + name: + name: name + ifabsent: string(rois) + range: string + required: true + equals_string: rois PlaneSegmentation__image_mask: name: PlaneSegmentation__image_mask description: ROI masks for each ROI. Each image mask is the size of the original imaging plane (or volume) and members of the ROI are finite non-zero. is_a: VectorData + attributes: + name: + name: name + ifabsent: string(image_mask) + range: string + required: true + equals_string: image_mask PlaneSegmentation__pixel_mask_index: name: PlaneSegmentation__pixel_mask_index description: Index into pixel_mask. is_a: VectorIndex + attributes: + name: + name: name + ifabsent: string(pixel_mask_index) + range: string + required: true + equals_string: pixel_mask_index PlaneSegmentation__voxel_mask_index: name: PlaneSegmentation__voxel_mask_index description: Index into voxel_mask. is_a: VectorIndex - PlaneSegmentation__reference_images: - name: PlaneSegmentation__reference_images - description: Image stacks that the segmentation masks apply to. attributes: - ImageSeries: - name: ImageSeries - description: One or more image stacks that the masks apply to (can be one-element - stack). - multivalued: true - range: ImageSeries - required: false + name: + name: name + ifabsent: string(voxel_mask_index) + range: string + required: true + equals_string: voxel_mask_index ImagingPlane__manifold: name: ImagingPlane__manifold description: DEPRECATED Physical position of each pixel. 'xyz' represents the position of the pixel relative to the defined coordinate space. Deprecated in favor of origin_coords and grid_spacing. attributes: + name: + name: name + ifabsent: string(manifold) + range: string + required: true + equals_string: manifold conversion: name: conversion description: Scalar to multiply each element in data to convert it to the @@ -134,6 +169,12 @@ classes: for 2-D data or (0, 0, 0) for 3-D data. See also reference_frame for what the physical location is relative to (e.g., bregma). attributes: + name: + name: name + ifabsent: string(origin_coords) + range: string + required: true + equals_string: origin_coords unit: name: unit description: Measurement units for origin_coords. The default value is 'meters'. @@ -163,6 +204,12 @@ classes: in the specified unit. Assumes imaging plane is a regular grid. See also reference_frame to interpret the grid. attributes: + name: + name: name + ifabsent: string(grid_spacing) + range: string + required: true + equals_string: grid_spacing unit: name: unit description: Measurement units for grid_spacing. The default value is 'meters'. @@ -186,12 +233,3 @@ classes: required: false minimum_cardinality: 3 maximum_cardinality: 3 - CorrectedImageStack__corrected: - name: CorrectedImageStack__corrected - description: Image stack with frames shifted to the common coordinates. - is_a: ImageSeries - CorrectedImageStack__xy_translation: - name: CorrectedImageStack__xy_translation - description: Stores the x,y delta necessary to align each frame to the common - coordinates, for example, to align each frame to a reference image. - is_a: TimeSeries diff --git a/nwb_linkml/schema/core.nwb.ophys.yaml b/nwb_linkml/schema/core.nwb.ophys.yaml index 0720056..ea43fcc 100644 --- a/nwb_linkml/schema/core.nwb.ophys.yaml +++ b/nwb_linkml/schema/core.nwb.ophys.yaml @@ -15,6 +15,10 @@ classes: description: Image stack recorded over time from 1-photon microscope. is_a: ImageSeries attributes: + name: + name: name + range: string + required: true pmt_gain: name: pmt_gain description: Photomultiplier gain. @@ -41,11 +45,16 @@ classes: name: intensity description: Intensity of the excitation in mW/mm^2, if known. range: float32 + tree_root: true TwoPhotonSeries: name: TwoPhotonSeries description: Image stack recorded over time from 2-photon microscope. is_a: ImageSeries attributes: + name: + name: name + range: string + required: true pmt_gain: name: pmt_gain description: Photomultiplier gain. @@ -62,12 +71,17 @@ classes: multivalued: false range: TwoPhotonSeries__field_of_view required: false + tree_root: true RoiResponseSeries: name: RoiResponseSeries description: ROI responses over an imaging plane. The first dimension represents time. The second dimension, if present, represents ROIs. is_a: TimeSeries attributes: + name: + name: name + range: string + required: true data: name: data description: Signals from ROIs. @@ -81,6 +95,7 @@ classes: multivalued: false range: RoiResponseSeries__rois required: true + tree_root: true DfOverF: name: DfOverF description: dF/F information about a region of interest (ROI). Storage hierarchy @@ -88,12 +103,17 @@ classes: for image planes). is_a: NWBDataInterface attributes: - RoiResponseSeries: - name: RoiResponseSeries + name: + name: name + range: string + required: true + roi_response_series: + name: roi_response_series description: RoiResponseSeries object(s) containing dF/F for a ROI. multivalued: true range: RoiResponseSeries required: true + tree_root: true Fluorescence: name: Fluorescence description: Fluorescence information about a region of interest (ROI). Storage @@ -101,13 +121,18 @@ classes: for ROIs and for image planes). is_a: NWBDataInterface attributes: - RoiResponseSeries: - name: RoiResponseSeries + name: + name: name + range: string + required: true + roi_response_series: + name: roi_response_series description: RoiResponseSeries object(s) containing fluorescence data for a ROI. multivalued: true range: RoiResponseSeries required: true + tree_root: true ImageSegmentation: name: ImageSegmentation description: Stores pixels in an image that represent different regions of interest @@ -119,17 +144,26 @@ classes: is required and ROI names should remain consistent between them. is_a: NWBDataInterface attributes: - PlaneSegmentation: - name: PlaneSegmentation + name: + name: name + range: string + required: true + plane_segmentation: + name: plane_segmentation description: Results from image segmentation of a specific imaging plane. multivalued: true range: PlaneSegmentation required: true + tree_root: true PlaneSegmentation: name: PlaneSegmentation description: Results from image segmentation of a specific imaging plane. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true image_mask: name: image_mask description: ROI masks for each ROI. Each image mask is the size of the original @@ -166,14 +200,19 @@ classes: reference_images: name: reference_images description: Image stacks that the segmentation masks apply to. - multivalued: false - range: PlaneSegmentation__reference_images - required: true + multivalued: true + any_of: + - range: ImageSeries + tree_root: true ImagingPlane: name: ImagingPlane description: An imaging plane and its metadata. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description of the imaging plane. @@ -253,17 +292,22 @@ classes: multivalued: false range: text required: false - OpticalChannel: - name: OpticalChannel + optical_channel: + name: optical_channel description: An optical channel used to record from an imaging plane. multivalued: true range: OpticalChannel required: true + tree_root: true OpticalChannel: name: OpticalChannel description: An optical channel used to record from an imaging plane. is_a: NWBContainer attributes: + name: + name: name + range: string + required: true description: name: description description: Description or other notes about the channel. @@ -276,6 +320,7 @@ classes: multivalued: false range: float32 required: true + tree_root: true MotionCorrection: name: MotionCorrection description: 'An image stack where all frames are shifted (registered) to a common @@ -283,27 +328,37 @@ classes: frame at each point in time is assumed to be 2-D (has only x & y dimensions).' is_a: NWBDataInterface attributes: - CorrectedImageStack: - name: CorrectedImageStack + name: + name: name + range: string + required: true + corrected_image_stack: + name: corrected_image_stack description: Reuslts from motion correction of an image stack. multivalued: true range: CorrectedImageStack required: true + tree_root: true CorrectedImageStack: name: CorrectedImageStack description: Reuslts from motion correction of an image stack. is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true corrected: name: corrected description: Image stack with frames shifted to the common coordinates. multivalued: false - range: CorrectedImageStack__corrected + range: ImageSeries required: true xy_translation: name: xy_translation description: Stores the x,y delta necessary to align each frame to the common coordinates, for example, to align each frame to a reference image. multivalued: false - range: CorrectedImageStack__xy_translation + range: TimeSeries required: true + tree_root: true diff --git a/nwb_linkml/schema/core.nwb.retinotopy.include.yaml b/nwb_linkml/schema/core.nwb.retinotopy.include.yaml index 7b9460d..123fabf 100644 --- a/nwb_linkml/schema/core.nwb.retinotopy.include.yaml +++ b/nwb_linkml/schema/core.nwb.retinotopy.include.yaml @@ -11,6 +11,12 @@ classes: name: ImagingRetinotopy__axis_1_phase_map description: Phase response to stimulus on the first measured axis. attributes: + name: + name: name + ifabsent: string(axis_1_phase_map) + range: string + required: true + equals_string: axis_1_phase_map dimension: name: dimension description: 'Number of rows and columns in the image. NOTE: row, column representation @@ -34,16 +40,22 @@ classes: num_rows: name: num_rows range: float32 - required: false + required: true num_cols: name: num_cols range: float32 - required: false + required: true ImagingRetinotopy__axis_1_power_map: name: ImagingRetinotopy__axis_1_power_map description: Power response on the first measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power. attributes: + name: + name: name + ifabsent: string(axis_1_power_map) + range: string + required: true + equals_string: axis_1_power_map dimension: name: dimension description: 'Number of rows and columns in the image. NOTE: row, column representation @@ -67,15 +79,21 @@ classes: num_rows: name: num_rows range: float32 - required: false + required: true num_cols: name: num_cols range: float32 - required: false + required: true ImagingRetinotopy__axis_2_phase_map: name: ImagingRetinotopy__axis_2_phase_map description: Phase response to stimulus on the second measured axis. attributes: + name: + name: name + ifabsent: string(axis_2_phase_map) + range: string + required: true + equals_string: axis_2_phase_map dimension: name: dimension description: 'Number of rows and columns in the image. NOTE: row, column representation @@ -99,16 +117,22 @@ classes: num_rows: name: num_rows range: float32 - required: false + required: true num_cols: name: num_cols range: float32 - required: false + required: true ImagingRetinotopy__axis_2_power_map: name: ImagingRetinotopy__axis_2_power_map description: Power response on the second measured axis. Response is scaled so 0.0 is no power in the response and 1.0 is maximum relative power. attributes: + name: + name: name + ifabsent: string(axis_2_power_map) + range: string + required: true + equals_string: axis_2_power_map dimension: name: dimension description: 'Number of rows and columns in the image. NOTE: row, column representation @@ -132,30 +156,22 @@ classes: num_rows: name: num_rows range: float32 - required: false + required: true num_cols: name: num_cols range: float32 - required: false - ImagingRetinotopy__axis_descriptions: - name: ImagingRetinotopy__axis_descriptions - description: Two-element array describing the contents of the two response axis - fields. Description should be something like ['altitude', 'azimuth'] or '['radius', - 'theta']. - attributes: - axis_descriptions: - name: axis_descriptions - description: Two-element array describing the contents of the two response - axis fields. Description should be something like ['altitude', 'azimuth'] - or '['radius', 'theta']. - multivalued: true - range: text required: true ImagingRetinotopy__focal_depth_image: name: ImagingRetinotopy__focal_depth_image description: 'Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns].' attributes: + name: + name: name + ifabsent: string(focal_depth_image) + range: string + required: true + equals_string: focal_depth_image bits_per_pixel: name: bits_per_pixel description: Number of bits used to represent each value. This is necessary @@ -188,16 +204,22 @@ classes: num_rows: name: num_rows range: uint16 - required: false + required: true num_cols: name: num_cols range: uint16 - required: false + required: true ImagingRetinotopy__sign_map: name: ImagingRetinotopy__sign_map description: Sine of the angle between the direction of the gradient in axis_1 and axis_2. attributes: + name: + name: name + ifabsent: string(sign_map) + range: string + required: true + equals_string: sign_map dimension: name: dimension description: 'Number of rows and columns in the image. NOTE: row, column representation @@ -217,16 +239,22 @@ classes: num_rows: name: num_rows range: float32 - required: false + required: true num_cols: name: num_cols range: float32 - required: false + required: true ImagingRetinotopy__vasculature_image: name: ImagingRetinotopy__vasculature_image description: 'Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]' attributes: + name: + name: name + ifabsent: string(vasculature_image) + range: string + required: true + equals_string: vasculature_image bits_per_pixel: name: bits_per_pixel description: Number of bits used to represent each value. This is necessary @@ -255,8 +283,8 @@ classes: num_rows: name: num_rows range: uint16 - required: false + required: true num_cols: name: num_cols range: uint16 - required: false + required: true diff --git a/nwb_linkml/schema/core.nwb.retinotopy.yaml b/nwb_linkml/schema/core.nwb.retinotopy.yaml index 1fda29d..2d03658 100644 --- a/nwb_linkml/schema/core.nwb.retinotopy.yaml +++ b/nwb_linkml/schema/core.nwb.retinotopy.yaml @@ -20,6 +20,10 @@ classes: appear backward (i.e., y before x).' is_a: NWBDataInterface attributes: + name: + name: name + range: string + required: true axis_1_phase_map: name: axis_1_phase_map description: Phase response to stimulus on the first measured axis. @@ -51,8 +55,8 @@ classes: description: Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta']. - multivalued: false - range: ImagingRetinotopy__axis_descriptions + multivalued: true + range: text required: true focal_depth_image: name: focal_depth_image @@ -75,3 +79,4 @@ classes: multivalued: false range: ImagingRetinotopy__vasculature_image required: true + tree_root: true diff --git a/nwb_linkml/schema/hdmf-common.base.include.yaml b/nwb_linkml/schema/hdmf-common.base.include.yaml deleted file mode 100644 index 25fef03..0000000 --- a/nwb_linkml/schema/hdmf-common.base.include.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: hdmf-common.base.include -id: hdmf-common.base.include -imports: -- nwb.language -- hdmf-common.base.include -- hdmf-common.base -default_prefix: hdmf-common.base.include/ diff --git a/nwb_linkml/schema/hdmf-common.base.yaml b/nwb_linkml/schema/hdmf-common.base.yaml index cd0f04c..a1cd455 100644 --- a/nwb_linkml/schema/hdmf-common.base.yaml +++ b/nwb_linkml/schema/hdmf-common.base.yaml @@ -2,31 +2,47 @@ name: hdmf-common.base id: hdmf-common.base imports: - nwb.language -- hdmf-common.base.include - hdmf-common.base default_prefix: hdmf-common.base/ classes: Data: name: Data description: An abstract data type for a dataset. + attributes: + name: + name: name + range: string + required: true + tree_root: true Container: name: Container description: An abstract data type for a group storing collections of data and metadata. Base type for all data and metadata containers. + attributes: + name: + name: name + range: string + required: true + tree_root: true SimpleMultiContainer: name: SimpleMultiContainer description: A simple Container for holding onto multiple containers. is_a: Container attributes: + name: + name: name + range: string + required: true Data: name: Data description: Data objects held within this SimpleMultiContainer. multivalued: true range: Data required: false - Container: - name: Container + container: + name: container description: Container objects held within this SimpleMultiContainer. multivalued: true range: Container required: false + tree_root: true diff --git a/nwb_linkml/schema/hdmf-common.sparse.include.yaml b/nwb_linkml/schema/hdmf-common.sparse.include.yaml deleted file mode 100644 index 33afefc..0000000 --- a/nwb_linkml/schema/hdmf-common.sparse.include.yaml +++ /dev/null @@ -1,39 +0,0 @@ -name: hdmf-common.sparse.include -id: hdmf-common.sparse.include -imports: -- hdmf-common.base -- nwb.language -- hdmf-common.sparse.include -- hdmf-common.sparse -default_prefix: hdmf-common.sparse.include/ -classes: - CSRMatrix__indices: - name: CSRMatrix__indices - description: The column indices. - attributes: - indices: - name: indices - description: The column indices. - multivalued: true - range: uint - required: true - CSRMatrix__indptr: - name: CSRMatrix__indptr - description: The row index pointer. - attributes: - indptr: - name: indptr - description: The row index pointer. - multivalued: true - range: uint - required: true - CSRMatrix__data: - name: CSRMatrix__data - description: The non-zero values in the matrix. - attributes: - data: - name: data - description: The non-zero values in the matrix. - multivalued: true - range: AnyType - required: true diff --git a/nwb_linkml/schema/hdmf-common.sparse.yaml b/nwb_linkml/schema/hdmf-common.sparse.yaml index aeb171e..594723d 100644 --- a/nwb_linkml/schema/hdmf-common.sparse.yaml +++ b/nwb_linkml/schema/hdmf-common.sparse.yaml @@ -3,7 +3,6 @@ id: hdmf-common.sparse imports: - hdmf-common.base - nwb.language -- hdmf-common.sparse.include - hdmf-common.sparse default_prefix: hdmf-common.sparse/ classes: @@ -14,6 +13,10 @@ classes: and their corresponding values are stored in data[indptr[i]:indptr[i+1]]. is_a: Container attributes: + name: + name: name + range: string + required: true shape: name: shape description: The shape (number of rows, number of columns) of this sparse @@ -22,18 +25,19 @@ classes: indices: name: indices description: The column indices. - multivalued: false - range: CSRMatrix__indices + multivalued: true + range: uint required: true indptr: name: indptr description: The row index pointer. - multivalued: false - range: CSRMatrix__indptr + multivalued: true + range: uint required: true data: name: data description: The non-zero values in the matrix. - multivalued: false - range: CSRMatrix__data + multivalued: true + range: AnyType required: true + tree_root: true diff --git a/nwb_linkml/schema/hdmf-common.table.include.yaml b/nwb_linkml/schema/hdmf-common.table.include.yaml index c5e3786..dac1fa9 100644 --- a/nwb_linkml/schema/hdmf-common.table.include.yaml +++ b/nwb_linkml/schema/hdmf-common.table.include.yaml @@ -35,14 +35,3 @@ classes: name: num_elements range: int required: true - DynamicTable__id: - name: DynamicTable__id - description: Array of unique identifiers for the rows of this dynamic table. - is_a: ElementIdentifiers - attributes: - id: - name: id - description: Array of unique identifiers for the rows of this dynamic table. - multivalued: true - range: int - required: true diff --git a/nwb_linkml/schema/hdmf-common.table.yaml b/nwb_linkml/schema/hdmf-common.table.yaml index 0dcb0f8..d3b94fd 100644 --- a/nwb_linkml/schema/hdmf-common.table.yaml +++ b/nwb_linkml/schema/hdmf-common.table.yaml @@ -19,6 +19,10 @@ classes: and so on. is_a: Data attributes: + name: + name: name + range: string + required: true description: name: description description: Description of what these vectors represent. @@ -26,6 +30,7 @@ classes: array: name: array range: VectorData__Array + tree_root: true VectorIndex: name: VectorIndex description: Used with VectorData to encode a ragged array. An array of indices @@ -35,19 +40,29 @@ classes: by "_index". is_a: VectorData attributes: + name: + name: name + range: string + required: true target: name: target description: Reference to the target dataset that this index applies to. range: VectorData + tree_root: true ElementIdentifiers: name: ElementIdentifiers description: A list of unique identifiers for values within a dataset, e.g. rows of a DynamicTable. is_a: Data attributes: + name: + name: name + range: string + required: true array: name: array range: ElementIdentifiers__Array + tree_root: true DynamicTableRegion: name: DynamicTableRegion description: DynamicTableRegion provides a link from one table to an index or @@ -61,6 +76,10 @@ classes: of another `DynamicTable`. is_a: VectorData attributes: + name: + name: name + range: string + required: true table: name: table description: Reference to the DynamicTable object that this region applies @@ -70,6 +89,7 @@ classes: name: description description: Description of what this table region points to. range: text + tree_root: true DynamicTable: name: DynamicTable description: A group containing multiple datasets that are aligned on the first @@ -92,6 +112,10 @@ classes: may be an acceptable trade-off for the flexibility of a DynamicTable. is_a: Container attributes: + name: + name: name + range: string + required: true colnames: name: colnames description: The names of the columns in this table. This should be used to @@ -104,8 +128,8 @@ classes: id: name: id description: Array of unique identifiers for the rows of this dynamic table. - multivalued: false - range: DynamicTable__id + multivalued: true + range: int required: true VectorData: name: VectorData @@ -113,6 +137,7 @@ classes: multivalued: true range: VectorData required: false + tree_root: true AlignedDynamicTable: name: AlignedDynamicTable description: DynamicTable container that supports storing a collection of sub-tables. @@ -124,6 +149,10 @@ classes: by a separate DynamicTable stored within the group. is_a: DynamicTable attributes: + name: + name: name + range: string + required: true categories: name: categories description: The names of the categories in this AlignedDynamicTable. Each @@ -132,8 +161,8 @@ classes: category names must match the names of the corresponding DynamicTable in the group. range: text - DynamicTable: - name: DynamicTable + dynamic_table: + name: dynamic_table description: 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 @@ -143,3 +172,4 @@ classes: multivalued: true range: DynamicTable required: false + tree_root: true diff --git a/nwb_linkml/schema/hdmf-experimental.experimental.include.yaml b/nwb_linkml/schema/hdmf-experimental.experimental.include.yaml deleted file mode 100644 index d7fcc65..0000000 --- a/nwb_linkml/schema/hdmf-experimental.experimental.include.yaml +++ /dev/null @@ -1,8 +0,0 @@ -name: hdmf-experimental.experimental.include -id: hdmf-experimental.experimental.include -imports: -- hdmf-common.table -- nwb.language -- hdmf-experimental.experimental.include -- hdmf-experimental.experimental -default_prefix: hdmf-experimental.experimental.include/ diff --git a/nwb_linkml/schema/hdmf-experimental.experimental.yaml b/nwb_linkml/schema/hdmf-experimental.experimental.yaml index a6bd6b7..cbfce79 100644 --- a/nwb_linkml/schema/hdmf-experimental.experimental.yaml +++ b/nwb_linkml/schema/hdmf-experimental.experimental.yaml @@ -3,7 +3,6 @@ id: hdmf-experimental.experimental imports: - hdmf-common.table - nwb.language -- hdmf-experimental.experimental.include - hdmf-experimental.experimental default_prefix: hdmf-experimental.experimental/ classes: @@ -13,8 +12,13 @@ classes: to the i-th value in the VectorData referenced by the 'elements' attribute. is_a: VectorData attributes: + name: + name: name + range: string + required: true elements: name: elements description: Reference to the VectorData object that contains the enumerable elements range: VectorData + tree_root: true diff --git a/nwb_linkml/schema/hdmf-experimental.resources.include.yaml b/nwb_linkml/schema/hdmf-experimental.resources.include.yaml deleted file mode 100644 index 9613105..0000000 --- a/nwb_linkml/schema/hdmf-experimental.resources.include.yaml +++ /dev/null @@ -1,79 +0,0 @@ -name: hdmf-experimental.resources.include -id: hdmf-experimental.resources.include -imports: -- hdmf-common.base -- nwb.language -- hdmf-experimental.resources.include -- hdmf-experimental.resources -default_prefix: hdmf-experimental.resources.include/ -classes: - HERD__keys: - name: HERD__keys - description: A table for storing user terms that are used to refer to external - resources. - is_a: Data - attributes: - keys: - name: keys - description: A table for storing user terms that are used to refer to external - resources. - multivalued: true - range: AnyType - required: true - HERD__files: - name: HERD__files - description: A table for storing object ids of files used in external resources. - is_a: Data - attributes: - files: - name: files - description: A table for storing object ids of files used in external resources. - multivalued: true - range: AnyType - required: true - HERD__entities: - name: HERD__entities - description: A table for mapping user terms (i.e., keys) to resource entities. - is_a: Data - attributes: - entities: - name: entities - description: A table for mapping user terms (i.e., keys) to resource entities. - multivalued: true - range: AnyType - required: true - HERD__objects: - name: HERD__objects - description: A table for identifying which objects in a file contain references - to external resources. - is_a: Data - attributes: - objects: - name: objects - description: A table for identifying which objects in a file contain references - to external resources. - multivalued: true - range: AnyType - required: true - HERD__object_keys: - name: HERD__object_keys - description: A table for identifying which objects use which keys. - is_a: Data - attributes: - object_keys: - name: object_keys - description: A table for identifying which objects use which keys. - multivalued: true - range: AnyType - required: true - HERD__entity_keys: - name: HERD__entity_keys - description: A table for identifying which keys use which entity. - is_a: Data - attributes: - entity_keys: - name: entity_keys - description: A table for identifying which keys use which entity. - multivalued: true - range: AnyType - required: true diff --git a/nwb_linkml/schema/hdmf-experimental.resources.yaml b/nwb_linkml/schema/hdmf-experimental.resources.yaml index 104d212..b8f3960 100644 --- a/nwb_linkml/schema/hdmf-experimental.resources.yaml +++ b/nwb_linkml/schema/hdmf-experimental.resources.yaml @@ -3,7 +3,6 @@ id: hdmf-experimental.resources imports: - hdmf-common.base - nwb.language -- hdmf-experimental.resources.include - hdmf-experimental.resources default_prefix: hdmf-experimental.resources/ classes: @@ -13,41 +12,46 @@ classes: external resource references in a file or across multiple files. is_a: Container attributes: + name: + name: name + range: string + required: true keys: name: keys description: A table for storing user terms that are used to refer to external resources. - multivalued: false - range: HERD__keys + multivalued: true + range: AnyType required: true files: name: files description: A table for storing object ids of files used in external resources. - multivalued: false - range: HERD__files + multivalued: true + range: AnyType required: true entities: name: entities description: A table for mapping user terms (i.e., keys) to resource entities. - multivalued: false - range: HERD__entities + multivalued: true + range: AnyType required: true objects: name: objects description: A table for identifying which objects in a file contain references to external resources. - multivalued: false - range: HERD__objects + multivalued: true + range: AnyType required: true object_keys: name: object_keys description: A table for identifying which objects use which keys. - multivalued: false - range: HERD__object_keys + multivalued: true + range: AnyType required: true entity_keys: name: entity_keys description: A table for identifying which keys use which entity. - multivalued: false - range: HERD__entity_keys + multivalued: true + range: AnyType required: true + tree_root: true diff --git a/nwb_linkml/schema/nwb.language.yaml b/nwb_linkml/schema/nwb.language.yaml index 53c02e6..ae86525 100644 --- a/nwb_linkml/schema/nwb.language.yaml +++ b/nwb_linkml/schema/nwb.language.yaml @@ -85,7 +85,7 @@ types: typeof: boolean isodatetime: name: isodatetime - typeof: date + typeof: datetime enums: FlatDType: name: FlatDType diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..133ec0e --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] + +testpaths = + tests \ No newline at end of file diff --git a/scripts/generate_core.py b/scripts/generate_core.py index 9ba8d8c..03367e1 100644 --- a/scripts/generate_core.py +++ b/scripts/generate_core.py @@ -19,7 +19,7 @@ def generate_core_pydantic(yaml_path:Path, output_path:Path): generator = NWBPydanticGenerator( str(schema), - pydantic_version='1', + pydantic_version='2', emit_metadata=True, gen_classvars=True, gen_slots=True diff --git a/tests/test_adapter.py b/tests/test_adapter.py new file mode 100644 index 0000000..cecd1f0 --- /dev/null +++ b/tests/test_adapter.py @@ -0,0 +1,22 @@ +import pytest +from .fixtures import nwb_core_fixture + +from nwb_schema_language import Dataset, Group, Schema + +@pytest.mark.parametrize( + ['walk_class', 'known_number'], + [ + (Dataset, 211), + (Group, 144), + ((Dataset, Group), 355), + (Schema, 19) + ] +) +def test_walk_types(nwb_core_fixture, walk_class, known_number): + classes = nwb_core_fixture.walk_types(nwb_core_fixture, walk_class) + class_list = list(classes) + assert len(class_list) == known_number + + # pdb.set_trace() + + diff --git a/tests/test_adapter_dataset.py b/tests/test_adapter_dataset.py new file mode 100644 index 0000000..d835e88 --- /dev/null +++ b/tests/test_adapter_dataset.py @@ -0,0 +1,4 @@ +import pytest + +def test_nothing(): + pass \ No newline at end of file diff --git a/tests/test_adapter_group.py b/tests/test_adapter_group.py new file mode 100644 index 0000000..411d879 --- /dev/null +++ b/tests/test_adapter_group.py @@ -0,0 +1,4 @@ +import pytest + +from .fixtures import nwb_core_fixture + diff --git a/tests/test_adapters/test_adapter.py b/tests/test_adapter_namespaces.py similarity index 57% rename from tests/test_adapters/test_adapter.py rename to tests/test_adapter_namespaces.py index eab6fd5..ebfad7d 100644 --- a/tests/test_adapters/test_adapter.py +++ b/tests/test_adapter_namespaces.py @@ -1,19 +1,5 @@ import pytest -from rich import print -import pdb - from .fixtures import nwb_core_fixture -from nwb_schema_language import Attribute - -def test_walk_adapter(nwb_core_fixture): - base = nwb_core_fixture.schemas[0] - assert base.path.name == "nwb.base.yaml" - # type_incs = [inc for inc in base.walk(base)] - type_incs = [inc for inc in base.walk_fields(base, 'neurodata_type_inc')] - - attributes = [a for a in base.walk_types(base, Attribute)] - - # pdb.set_trace() @pytest.mark.parametrize( ['class_name','schema_file','namespace_name'], @@ -31,6 +17,4 @@ def test_find_type_source(nwb_core_fixture, class_name, schema_file, namespace_n def test_populate_imports(nwb_core_fixture): - nwb_core_fixture.populate_imports() - - pdb.set_trace() \ No newline at end of file + nwb_core_fixture.populate_imports() \ No newline at end of file diff --git a/tests/test_adapter_schema.py b/tests/test_adapter_schema.py new file mode 100644 index 0000000..5d8b735 --- /dev/null +++ b/tests/test_adapter_schema.py @@ -0,0 +1,14 @@ +import pytest +from .fixtures import nwb_core_fixture + +from nwb_schema_language import Dataset, Group, Schema + +@pytest.mark.parametrize( + ['schema_name'], + [ + ['core.nwb.file'] + ] +) +def test_schema_build(nwb_core_fixture, schema_name): + schema = [sch for sch in nwb_core_fixture.schemas if sch.name == schema_name][0] + res = schema.build() \ No newline at end of file diff --git a/tests/test_adapters/__init__.py b/tests/test_adapters/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_adapters/test_adapter_dataset.py b/tests/test_adapters/test_adapter_dataset.py deleted file mode 100644 index 5871ed8..0000000 --- a/tests/test_adapters/test_adapter_dataset.py +++ /dev/null @@ -1 +0,0 @@ -import pytest diff --git a/tests/test_generate.py b/tests/test_generate.py index b17ae51..b029993 100644 --- a/tests/test_generate.py +++ b/tests/test_generate.py @@ -33,6 +33,8 @@ def test_generate_pydantic(tmp_output_dir): (tmp_output_dir / 'models').mkdir(exist_ok=True) for schema in (tmp_output_dir / 'schema').glob('*.yaml'): + if not schema.exists(): + continue # python friendly name python_name = schema.stem.replace('.', '_').replace('-','_')