update models round 2 for how pycharm always misses half the files for some reason...

This commit is contained in:
sneakers-the-rat 2024-07-29 16:18:23 -07:00
parent 76fb58e783
commit 011902d2cb
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
48 changed files with 7694 additions and 5468 deletions

View file

@ -1,57 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_1_3.hdmf_common_table import Data, Container, DynamicTable
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.base/",
"id": "core.nwb.base",
"imports": ["../../hdmf_common/v1_1_3/namespace", "core.nwb.language"],
"name": "core.nwb.base",
}
)
class NWBData(Data):
@ -59,6 +79,8 @@ class NWBData(Data):
An abstract data type for a dataset.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -67,16 +89,18 @@ 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)).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -86,6 +110,8 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -94,6 +120,8 @@ class NWBDataInterface(NWBContainer):
An abstract data type for a generic container storing collections of data, as opposed to metadata.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -102,33 +130,38 @@ class TimeSeries(NWBDataInterface):
General purpose time series.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
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: str = Field(
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -139,12 +172,16 @@ 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: Literal["data"] = Field("data")
conversion: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
conversion: Optional[np.float32] = 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.""",
)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = 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.""",
)
@ -167,13 +204,15 @@ 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: Literal["starting_time"] = Field("starting_time")
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'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["starting_time"] = Field(
"starting_time",
json_schema_extra={"linkml_meta": {"equals_string": "starting_time", "ifabsent": "string(starting_time)"}},
)
value: float = Field(...)
rate: Optional[np.float32] = Field(None, description="""Sampling rate, in Hz.""")
unit: Optional[str] = Field(None, description="""Unit of measurement for time, which is fixed to 'seconds'.""")
value: np.float64 = Field(...)
class TimeSeriesSync(ConfiguredBaseModel):
@ -181,7 +220,11 @@ 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.
"""
name: Literal["sync"] = Field("sync")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["sync"] = Field(
"sync", json_schema_extra={"linkml_meta": {"equals_string": "sync", "ifabsent": "string(sync)"}}
)
class ProcessingModule(NWBContainer):
@ -189,10 +232,11 @@ class ProcessingModule(NWBContainer):
A collection of processed data.
"""
children: Optional[
List[Union[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
children: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}}
)
name: str = Field(...)
@ -201,10 +245,22 @@ class Images(NWBDataInterface):
A collection of images.
"""
name: str = Field("Images")
description: Optional[str] = Field(
None, description="""Description of this collection of images."""
)
image: List[str] | str = Field(
default_factory=list, description="""Images stored in this collection."""
)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: Optional[str] = Field(None, description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
NWBData.model_rebuild()
Image.model_rebuild()
NWBContainer.model_rebuild()
NWBDataInterface.model_rebuild()
TimeSeries.model_rebuild()
TimeSeriesData.model_rebuild()
TimeSeriesStartingTime.model_rebuild()
TimeSeriesSync.model_rebuild()
ProcessingModule.model_rebuild()
Images.model_rebuild()

View file

@ -1,64 +1,124 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeriesSync,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_2_4.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from .core_nwb_misc import IntervalSeries
from ...core.v2_2_4.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_2_4.core_nwb_device import Device
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
Data,
Index,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
Container,
DynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.behavior/",
"id": "core.nwb.behavior",
"imports": ["core.nwb.base", "core.nwb.misc", "core.nwb.language"],
"name": "core.nwb.behavior",
}
)
class SpatialSeries(TimeSeries):
@ -66,37 +126,40 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
name: str = Field(...)
data: str = Field(
...,
description="""1-D or 2-D array storing position or direction relative to some reference frame.""",
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.""",
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -107,16 +170,17 @@ class SpatialSeriesData(ConfiguredBaseModel):
1-D or 2-D array storing position or direction relative to some reference frame.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
)
array: Optional[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_features"], float],
]
Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_features"], np.number]]
] = Field(None)
@ -125,7 +189,11 @@ 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.
"""
children: Optional[List[IntervalSeries] | IntervalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -134,7 +202,11 @@ class BehavioralEvents(NWBDataInterface):
TimeSeries for storing behavioral events. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -143,7 +215,11 @@ class BehavioralTimeSeries(NWBDataInterface):
TimeSeries for storing Behavoioral time series data. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -152,7 +228,11 @@ class PupilTracking(NWBDataInterface):
Eye-tracking data, representing pupil size.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -161,7 +241,11 @@ class EyeTracking(NWBDataInterface):
Eye-tracking data, representing direction of gaze.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -170,7 +254,11 @@ 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.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -179,5 +267,22 @@ class Position(NWBDataInterface):
Position data, whether along the x, x/y or x/y/z axis.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
SpatialSeries.model_rebuild()
SpatialSeriesData.model_rebuild()
BehavioralEpochs.model_rebuild()
BehavioralEvents.model_rebuild()
BehavioralTimeSeries.model_rebuild()
PupilTracking.model_rebuild()
EyeTracking.model_rebuild()
CompassDirection.model_rebuild()
Position.model_rebuild()

View file

@ -1,57 +1,60 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBContainer
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_2_4.core_nwb_base import NWBContainer
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.device/",
"id": "core.nwb.device",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.device",
}
)
class Device(NWBContainer):
@ -59,11 +62,16 @@ class Device(NWBContainer):
Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.device", "tree_root": True})
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."""
)
manufacturer: Optional[str] = Field(None, description="""The name of the manufacturer of the device.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
Device.model_rebuild()

View file

@ -1,65 +1,84 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_table import DynamicTableRegion, DynamicTable
from .core_nwb_base import (
NWBContainer,
TimeSeriesStartingTime,
NWBDataInterface,
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_table import DynamicTableRegion
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from ...core.v2_2_4.core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
TimeSeriesSync,
NWBDataInterface,
NWBContainer,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
NUMPYDANTIC_VERSION = "1.2.1"
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ecephys/",
"id": "core.nwb.ecephys",
"imports": ["core.nwb.base", "../../hdmf_common/v1_1_3/namespace", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ecephys",
}
)
class ElectricalSeries(TimeSeries):
@ -67,110 +86,101 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_channels"], float],
NDArray[Shape["* num_times, * num_channels, * num_samples"], float],
NDArray[Shape["* num_times"], np.number],
NDArray[Shape["* num_times, * num_channels"], np.number],
NDArray[Shape["* num_times, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Recorded voltage data.""")
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 ElectricalSeriesElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 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).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_events, * num_channels, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], np.number],
NDArray[Shape["* num_events, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Spike waveforms.""")
timestamps: NDArray[Shape["* num_times"], float] = Field(
timestamps: NDArray[Shape["* num_times"], np.float64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -181,64 +191,56 @@ class FeatureExtraction(NWBDataInterface):
Features, such as PC1 and PC2, that are extracted from signals stored in a SpikeEventSeries or other source.
"""
name: str = Field("FeatureExtraction")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("FeatureExtraction", json_schema_extra={"linkml_meta": {"ifabsent": "string(FeatureExtraction)"}})
description: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of features (eg, ''PC1'') for each of the extracted features.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_events, * num_channels, * num_features"], float] = Field(
features: NDArray[Shape["* num_events, * num_channels, * num_features"], np.float32] = Field(
...,
description="""Multi-dimensional array of features extracted from each event.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_events"}, {"alias": "num_channels"}, {"alias": "num_features"}]}
}
},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of events that features correspond to (can be a link).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
class FeatureExtractionElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 EventDetection(NWBDataInterface):
"""
Detected spike events from voltage trace(s).
"""
name: str = Field("EventDetection")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("EventDetection", json_schema_extra={"linkml_meta": {"ifabsent": "string(EventDetection)"}})
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: NDArray[Shape["* num_events"], int] = Field(
source_idx: NDArray[Shape["* num_events"], np.int32] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
..., description="""Timestamps of events, in seconds."""
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Timestamps of events, in seconds.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
@ -247,7 +249,11 @@ 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.
"""
children: Optional[List[SpikeEventSeries] | SpikeEventSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -256,7 +262,11 @@ 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.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -265,7 +275,11 @@ 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 description or comments field.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -274,13 +288,15 @@ class ElectrodeGroup(NWBContainer):
A physical grouping of electrodes, e.g. a shank of an array.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
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[str] = Field(
position: Optional[ElectrodeGroupPosition] = Field(
None, description="""stereotaxic or common framework coordinates"""
)
@ -290,10 +306,14 @@ class ElectrodeGroupPosition(ConfiguredBaseModel):
stereotaxic or common framework coordinates
"""
name: Literal["position"] = Field("position")
x: Optional[float] = Field(None, description="""x coordinate""")
y: Optional[float] = Field(None, description="""y coordinate""")
z: Optional[float] = Field(None, description="""z coordinate""")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys"})
name: Literal["position"] = Field(
"position", json_schema_extra={"linkml_meta": {"equals_string": "position", "ifabsent": "string(position)"}}
)
x: Optional[np.float32] = Field(None, description="""x coordinate""")
y: Optional[np.float32] = Field(None, description="""y coordinate""")
z: Optional[np.float32] = Field(None, description="""z coordinate""")
class ClusterWaveforms(NWBDataInterface):
@ -301,17 +321,23 @@ 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("ClusterWaveforms")
waveform_filtering: str = Field(
..., description="""Filtering applied to data before generating mean/sd"""
)
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("ClusterWaveforms", json_schema_extra={"linkml_meta": {"ifabsent": "string(ClusterWaveforms)"}})
waveform_filtering: str = Field(..., description="""Filtering applied to data before generating mean/sd""")
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = 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)""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = Field(
...,
description="""Stdev of waveforms for each cluster, using the same indices as in mean""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
@ -320,19 +346,40 @@ 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("Clustering")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("Clustering", json_schema_extra={"linkml_meta": {"ifabsent": "string(Clustering)"}})
description: str = Field(
...,
description="""Description of clusters or clustering, (e.g. cluster 0 is noise, clusters curated using Klusters, etc)""",
)
num: NDArray[Shape["* num_events"], int] = Field(
..., description="""Cluster number of each event"""
num: NDArray[Shape["* num_events"], np.int32] = Field(
...,
description="""Cluster number of each event""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
peak_over_rms: NDArray[Shape["* num_clusters"], float] = Field(
peak_over_rms: NDArray[Shape["* num_clusters"], np.float32] = Field(
...,
description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
# 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()
ElectrodeGroupPosition.model_rebuild()
ClusterWaveforms.model_rebuild()
Clustering.model_rebuild()

View file

@ -1,63 +1,78 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_table import (
VectorIndex,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeries
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_1_3.hdmf_common_table import DynamicTable, VectorIndex, VectorData
from ...core.v2_2_4.core_nwb_base import TimeSeries
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.epoch/",
"id": "core.nwb.epoch",
"imports": ["../../hdmf_common/v1_1_3/namespace", "core.nwb.base", "core.nwb.language"],
"name": "core.nwb.epoch",
}
)
class TimeIntervals(DynamicTable):
@ -65,51 +80,55 @@ class TimeIntervals(DynamicTable):
A container for aggregating epoch data and the TimeSeries that each epoch applies to.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.epoch", "tree_root": True})
name: str = Field(...)
start_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Start time of epoch, in seconds."""
start_time: NDArray[Any, np.float32] = Field(
...,
description="""Start time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
stop_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Stop time of epoch, in seconds."""
stop_time: NDArray[Any, np.float32] = Field(
...,
description="""Stop time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags: Optional[List[str] | str] = Field(
default_factory=list,
tags: Optional[NDArray[Any, str]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
timeseries: Optional[TimeIntervalsTimeseries] = Field(None, description="""An index into a TimeSeries object.""")
timeseries_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
tags_index: Optional[str] = Field(None, description="""Index for tags.""")
timeseries: Optional[str] = Field(None, description="""An index into a TimeSeries object.""")
timeseries_index: Optional[str] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
)
class TimeIntervalsTagsIndex(VectorIndex):
"""
Index for tags.
"""
name: Literal["tags_index"] = Field("tags_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
class TimeIntervalsTimeseries(VectorData):
@ -117,21 +136,21 @@ class TimeIntervalsTimeseries(VectorData):
An index into a TimeSeries object.
"""
name: Literal["timeseries"] = Field("timeseries")
idx_start: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.epoch"})
name: Literal["timeseries"] = Field(
"timeseries",
json_schema_extra={"linkml_meta": {"equals_string": "timeseries", "ifabsent": "string(timeseries)"}},
)
idx_start: Optional[np.int32] = Field(
None,
description="""Start index into the TimeSeries 'data' and 'timestamp' datasets of the referenced TimeSeries. The first dimension of those arrays is always time.""",
)
count: Optional[int] = Field(
None,
description="""Number of data samples available in this time series, during this epoch.""",
)
timeseries: Optional[str] = Field(
None, description="""the TimeSeries that this index applies to."""
)
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
count: Optional[np.int32] = Field(
None, description="""Number of data samples available in this time series, during this epoch."""
)
timeseries: Optional[TimeSeries] = Field(None, description="""the TimeSeries that this index applies to.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -142,14 +161,7 @@ class TimeIntervalsTimeseries(VectorData):
] = Field(None)
class TimeIntervalsTimeseriesIndex(VectorIndex):
"""
Index for timeseries.
"""
name: Literal["timeseries_index"] = Field("timeseries_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
TimeIntervals.model_rebuild()
TimeIntervalsTimeseries.model_rebuild()

View file

@ -1,83 +1,184 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_icephys import SweepTable, IntracellularElectrode
from .core_nwb_epoch import TimeIntervals
from .core_nwb_ecephys import ElectrodeGroup
from .core_nwb_base import (
NWBContainer,
ProcessingModule,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_2_4.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from ...core.v2_2_4.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_2_4.core_nwb_device import Device
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from .core_nwb_device import Device
from .core_nwb_misc import Units
from .core_nwb_ogen import OptogeneticStimulusSite
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
VectorIndex,
DynamicTable,
Data,
Index,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
Container,
DynamicTable,
)
from .core_nwb_ophys import ImagingPlane
from ...core.v2_2_4.core_nwb_epoch import TimeIntervals, TimeIntervalsTimeseries
from ...core.v2_2_4.core_nwb_ophys import (
TwoPhotonSeries,
RoiResponseSeries,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from ...core.v2_2_4.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from ...core.v2_2_4.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_2_4.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
CurrentClampSeriesData,
IZeroClampSeries,
CurrentClampStimulusSeries,
CurrentClampStimulusSeriesData,
VoltageClampSeries,
VoltageClampSeriesData,
VoltageClampSeriesCapacitanceFast,
VoltageClampSeriesCapacitanceSlow,
VoltageClampSeriesResistanceCompBandwidth,
VoltageClampSeriesResistanceCompCorrection,
VoltageClampSeriesResistanceCompPrediction,
VoltageClampSeriesWholeCellCapacitanceComp,
VoltageClampSeriesWholeCellSeriesResistanceComp,
VoltageClampStimulusSeries,
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.file/",
"id": "core.nwb.file",
"imports": [
"core.nwb.base",
"../../hdmf_common/v1_1_3/namespace",
"core.nwb.device",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.epoch",
"core.nwb.misc",
"core.nwb.language",
],
"name": "core.nwb.file",
}
)
class ScratchData(NWBData):
@ -85,10 +186,10 @@ class ScratchData(NWBData):
Any one-off datasets
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
notes: Optional[str] = Field(
None, description="""Any notes the user has about the dataset being stored"""
)
notes: Optional[str] = Field(None, description="""Any notes the user has about the dataset being stored""")
class NWBFile(NWBContainer):
@ -96,69 +197,78 @@ class NWBFile(NWBContainer):
An NWB:N file storing cellular-based neurophysiology data from a single experimental session.
"""
name: Literal["root"] = Field("root")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: Literal["root"] = Field(
"root", json_schema_extra={"linkml_meta": {"equals_string": "root", "ifabsent": "string(root)"}}
)
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: NDArray[Shape["* num_modifications"], datetime] = Field(
file_create_date: NDArray[Shape["* num_modifications"], np.datetime64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_modifications"}]}}},
)
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.""",
..., description="""A description of the experimental session and data in the file."""
)
session_start_time: datetime = Field(
session_start_time: np.datetime64 = 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(
timestamps_reference_time: np.datetime64 = 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[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(
default_factory=dict,
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}},
)
analysis: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
analysis: Optional[List[Union[DynamicTable, NWBContainer]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
scratch: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
scratch: Optional[List[Union[DynamicTable, NWBContainer]]] = 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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
processing: Optional[List[ProcessingModule] | ProcessingModule] = Field(
default_factory=dict,
processing: Optional[List[ProcessingModule]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ProcessingModule"}]}},
)
stimulus: str = Field(
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: str = Field(
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[List[TimeIntervals] | TimeIntervals] = Field(
default_factory=dict,
intervals: Optional[List[TimeIntervals]] = 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.""",
json_schema_extra={
"linkml_meta": {
"any_of": [
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
]
}
},
)
units: Optional[str] = Field(None, description="""Data about sorted spike units.""")
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
class NWBFileStimulus(ConfiguredBaseModel):
@ -166,13 +276,20 @@ 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.
"""
name: Literal["stimulus"] = Field("stimulus")
presentation: Optional[List[TimeSeries] | TimeSeries] = Field(
default_factory=dict, description="""Stimuli presented during the experiment."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["stimulus"] = Field(
"stimulus", json_schema_extra={"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}}
)
templates: Optional[List[TimeSeries] | TimeSeries] = Field(
default_factory=dict,
presentation: Optional[List[TimeSeries]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
templates: Optional[List[TimeSeries]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
@ -181,22 +298,23 @@ 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: Literal["general"] = Field("general")
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."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["general"] = Field(
"general", json_schema_extra={"linkml_meta": {"equals_string": "general", "ifabsent": "string(general)"}}
)
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[NDArray[Shape["* num_experimenters"], str]] = Field(
None,
description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_experimenters"}]}}},
)
institution: Optional[str] = Field(
None, description="""Institution(s) where experiment was performed."""
)
institution: Optional[str] = Field(None, description="""Institution(s) where experiment was performed.""")
keywords: Optional[NDArray[Shape["* num_keywords"], str]] = Field(
None, description="""Terms to search over."""
None,
description="""Terms to search over.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_keywords"}]}}},
)
lab: Optional[str] = Field(None, description="""Laboratory where experiment was performed.""")
notes: Optional[str] = Field(None, description="""Notes about the experiment.""")
@ -205,24 +323,23 @@ class NWBFileGeneral(ConfiguredBaseModel):
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.""",
None, description="""Experimental protocol, if applicable. e.g., include IACUC protocol number."""
)
related_publications: Optional[NDArray[Shape["* num_publications"], str]] = Field(
None, description="""Publication information. PMID, DOI, URL, etc."""
None,
description="""Publication information. PMID, DOI, URL, etc.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_publications"}]}}},
)
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[str] = Field(
None,
description="""Script file or link to public source code used to create this NWB file.""",
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.""",
None, description="""Notes about stimuli, such as how and where they were presented."""
)
surgery: Optional[str] = Field(
None,
@ -232,30 +349,33 @@ class NWBFileGeneral(ConfiguredBaseModel):
None,
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
)
lab_meta_data: Optional[List[str] | str] = Field(
default_factory=list,
lab_meta_data: Optional[List[LabMetaData]] = Field(
None,
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
)
devices: Optional[List[Device] | Device] = Field(
default_factory=dict,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
)
subject: Optional[str] = Field(
devices: Optional[List[Device]] = Field(
None,
description="""Information about the animal or person from which the data was measured.""",
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
)
extracellular_ephys: Optional[str] = Field(
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[str] = Field(
intracellular_ephys: Optional[NWBFileGeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite] | OptogeneticStimulusSite] = Field(
default_factory=dict,
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane] | ImagingPlane] = Field(
default_factory=dict, description="""Metadata related to optophysiology."""
optophysiology: Optional[List[ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
)
@ -264,7 +384,12 @@ class NWBFileGeneralSourceScript(ConfiguredBaseModel):
Script file or link to public source code used to create this NWB file.
"""
name: Literal["source_script"] = Field("source_script")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["source_script"] = Field(
"source_script",
json_schema_extra={"linkml_meta": {"equals_string": "source_script", "ifabsent": "string(source_script)"}},
)
file_name: Optional[str] = Field(None, description="""Name of script file.""")
value: str = Field(...)
@ -274,13 +399,17 @@ class NWBFileGeneralExtracellularEphys(ConfiguredBaseModel):
Metadata related to extracellular electrophysiology.
"""
name: Literal["extracellular_ephys"] = Field("extracellular_ephys")
electrode_group: Optional[List[str] | str] = Field(
default_factory=list, description="""Physical group of electrodes."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["extracellular_ephys"] = Field(
"extracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "extracellular_ephys", "ifabsent": "string(extracellular_ephys)"}
},
)
electrodes: Optional[str] = Field(
None,
description="""A table of all electrodes (i.e. channels) used for recording.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(None, description="""Physical group of electrodes.""")
electrodes: Optional[NWBFileGeneralExtracellularEphysElectrodes] = Field(
None, description="""A table of all electrodes (i.e. channels) used for recording."""
)
@ -289,67 +418,105 @@ class NWBFileGeneralExtracellularEphysElectrodes(DynamicTable):
A table of all electrodes (i.e. channels) used for recording.
"""
name: Literal["electrodes"] = Field("electrodes")
x: Optional[List[float] | float] = Field(
default_factory=list,
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["electrodes"] = Field(
"electrodes",
json_schema_extra={"linkml_meta": {"equals_string": "electrodes", "ifabsent": "string(electrodes)"}},
)
x: NDArray[Any, np.float32] = Field(
...,
description="""x coordinate of the channel location in the brain (+x is posterior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
y: Optional[List[float] | float] = Field(
default_factory=list,
y: NDArray[Any, np.float32] = Field(
...,
description="""y coordinate of the channel location in the brain (+y is inferior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
z: Optional[List[float] | float] = Field(
default_factory=list,
z: NDArray[Any, np.float32] = Field(
...,
description="""z coordinate of the channel location in the brain (+z is right).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
imp: Optional[List[float] | float] = Field(
default_factory=list, description="""Impedance of the channel."""
imp: NDArray[Any, np.float32] = Field(
...,
description="""Impedance of the channel.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
location: Optional[List[str] | str] = Field(
default_factory=list,
location: NDArray[Any, str] = Field(
...,
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.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
filtering: Optional[List[float] | float] = Field(
default_factory=list, description="""Description of hardware filtering."""
filtering: NDArray[Any, np.float32] = Field(
...,
description="""Description of hardware filtering.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
)
group_name: Optional[List[str] | str] = Field(
default_factory=list,
group_name: NDArray[Any, str] = Field(
...,
description="""Name of the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_x: Optional[List[float] | float] = Field(
default_factory=list, description="""x coordinate in electrode group"""
rel_x: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_y: Optional[List[float] | float] = Field(
default_factory=list, description="""y coordinate in electrode group"""
rel_y: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_z: Optional[List[float] | float] = Field(
default_factory=list, description="""z coordinate in electrode group"""
rel_z: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
reference: Optional[List[str] | str] = Field(
default_factory=list,
reference: Optional[NDArray[Any, str]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
@ -358,17 +525,23 @@ class NWBFileGeneralIntracellularEphys(ConfiguredBaseModel):
Metadata related to intracellular electrophysiology.
"""
name: Literal["intracellular_ephys"] = Field("intracellular_ephys")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["intracellular_ephys"] = Field(
"intracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "intracellular_ephys", "ifabsent": "string(intracellular_ephys)"}
},
)
filtering: Optional[str] = Field(
None,
description="""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.""",
)
intracellular_electrode: Optional[List[str] | str] = Field(
default_factory=list, description="""An intracellular electrode."""
intracellular_electrode: Optional[List[IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[str] = Field(
None,
description="""The table which groups different PatchClampSeries together.""",
sweep_table: Optional[SweepTable] = Field(
None, description="""The table which groups different PatchClampSeries together."""
)
@ -377,6 +550,8 @@ class LabMetaData(NWBContainer):
Lab-specific meta-data.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
@ -385,29 +560,36 @@ class Subject(NWBContainer):
Information about the animal or person from which the data was measured.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
age: Optional[str] = Field(
None,
description="""Age of subject. Can be supplied instead of 'date_of_birth'.""",
)
date_of_birth: Optional[datetime] = Field(
None,
description="""Date of birth of subject. Can be supplied instead of 'age'.""",
age: Optional[str] = Field(None, description="""Age of subject. Can be supplied instead of 'date_of_birth'.""")
date_of_birth: Optional[np.datetime64] = 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)."""
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.""")
subject_id: Optional[str] = Field(
None,
description="""ID of animal/person used/participating in experiment (lab convention).""",
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.""",
None, description="""Weight at time of experiment, at time of surgery and at other important times."""
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ScratchData.model_rebuild()
NWBFile.model_rebuild()
NWBFileStimulus.model_rebuild()
NWBFileGeneral.model_rebuild()
NWBFileGeneralSourceScript.model_rebuild()
NWBFileGeneralExtracellularEphys.model_rebuild()
NWBFileGeneralExtracellularEphysElectrodes.model_rebuild()
NWBFileGeneralIntracellularEphys.model_rebuild()
LabMetaData.model_rebuild()
Subject.model_rebuild()

View file

@ -1,68 +1,100 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
NWBContainer,
TimeSeriesSync,
TimeSeriesStartingTime,
TimeSeries,
)
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
VectorIndex,
DynamicTable,
Data,
Index,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
Container,
DynamicTable,
)
from ...core.v2_2_4.core_nwb_device import Device
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.icephys/",
"id": "core.nwb.icephys",
"imports": ["core.nwb.base", "core.nwb.device", "../../hdmf_common/v1_1_3/namespace", "core.nwb.language"],
"name": "core.nwb.icephys",
}
)
class PatchClampSeries(TimeSeries):
@ -70,41 +102,44 @@ class PatchClampSeries(TimeSeries):
An abstract base class for patch-clamp data - stimulus or response, current or voltage.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
data: str = Field(..., 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).""",
data: PatchClampSeriesData = Field(..., description="""Recorded voltage or current.""")
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -115,12 +150,18 @@ class PatchClampSeriesData(ConfiguredBaseModel):
Recorded voltage or current.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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"], float]] = Field(None)
array: Optional[NDArray[Shape["* num_times"], np.number]] = Field(
None, json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}}
)
class CurrentClampSeries(PatchClampSeries):
@ -128,46 +169,47 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = 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.""")
capacitance_compensation: Optional[float] = Field(
None, description="""Capacitance compensation, in farads."""
)
data: CurrentClampSeriesData = Field(..., description="""Recorded voltage.""")
bias_current: Optional[np.float32] = Field(None, description="""Bias current, in amps.""")
bridge_balance: Optional[np.float32] = Field(None, description="""Bridge balance, in ohms.""")
capacitance_compensation: Optional[np.float32] = Field(None, description="""Capacitance compensation, in farads.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -178,7 +220,11 @@ class CurrentClampSeriesData(ConfiguredBaseModel):
Recorded voltage.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -191,46 +237,49 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
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.""")
capacitance_compensation: float = Field(
bias_current: np.float32 = Field(..., description="""Bias current, in amps, fixed to 0.0.""")
bridge_balance: np.float32 = Field(..., description="""Bridge balance, in ohms, fixed to 0.0.""")
capacitance_compensation: np.float32 = Field(
..., description="""Capacitance compensation, in farads, fixed to 0.0."""
)
data: str = Field(..., description="""Recorded voltage.""")
data: CurrentClampSeriesData = Field(..., description="""Recorded voltage.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -241,41 +290,44 @@ class CurrentClampStimulusSeries(PatchClampSeries):
Stimulus current applied during current clamp recording.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Stimulus current applied.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -286,7 +338,11 @@ class CurrentClampStimulusSeriesData(ConfiguredBaseModel):
Stimulus current applied.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -299,58 +355,65 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Recorded current.""")
capacitance_fast: Optional[str] = Field(None, description="""Fast capacitance, in farads.""")
capacitance_slow: Optional[str] = Field(None, description="""Slow capacitance, in farads.""")
resistance_comp_bandwidth: Optional[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."""
)
resistance_comp_bandwidth: Optional[VoltageClampSeriesResistanceCompBandwidth] = Field(
None, description="""Resistance compensation bandwidth, in hertz."""
)
resistance_comp_correction: Optional[str] = Field(
resistance_comp_correction: Optional[VoltageClampSeriesResistanceCompCorrection] = Field(
None, description="""Resistance compensation correction, in percent."""
)
resistance_comp_prediction: Optional[str] = Field(
resistance_comp_prediction: Optional[VoltageClampSeriesResistanceCompPrediction] = Field(
None, description="""Resistance compensation prediction, in percent."""
)
whole_cell_capacitance_comp: Optional[str] = Field(
whole_cell_capacitance_comp: Optional[VoltageClampSeriesWholeCellCapacitanceComp] = Field(
None, description="""Whole cell capacitance compensation, in farads."""
)
whole_cell_series_resistance_comp: Optional[str] = Field(
whole_cell_series_resistance_comp: Optional[VoltageClampSeriesWholeCellSeriesResistanceComp] = Field(
None, description="""Whole cell series resistance compensation, in ohms."""
)
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -361,7 +424,11 @@ class VoltageClampSeriesData(ConfiguredBaseModel):
Recorded current.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -374,12 +441,18 @@ class VoltageClampSeriesCapacitanceFast(ConfiguredBaseModel):
Fast capacitance, in farads.
"""
name: Literal["capacitance_fast"] = Field("capacitance_fast")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["capacitance_fast"] = Field(
"capacitance_fast",
json_schema_extra={
"linkml_meta": {"equals_string": "capacitance_fast", "ifabsent": "string(capacitance_fast)"}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesCapacitanceSlow(ConfiguredBaseModel):
@ -387,12 +460,18 @@ class VoltageClampSeriesCapacitanceSlow(ConfiguredBaseModel):
Slow capacitance, in farads.
"""
name: Literal["capacitance_slow"] = Field("capacitance_slow")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["capacitance_slow"] = Field(
"capacitance_slow",
json_schema_extra={
"linkml_meta": {"equals_string": "capacitance_slow", "ifabsent": "string(capacitance_slow)"}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompBandwidth(ConfiguredBaseModel):
@ -400,12 +479,21 @@ class VoltageClampSeriesResistanceCompBandwidth(ConfiguredBaseModel):
Resistance compensation bandwidth, in hertz.
"""
name: Literal["resistance_comp_bandwidth"] = Field("resistance_comp_bandwidth")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_bandwidth, which is fixed to 'hertz'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_bandwidth"] = Field(
"resistance_comp_bandwidth",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_bandwidth",
"ifabsent": "string(resistance_comp_bandwidth)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_bandwidth, which is fixed to 'hertz'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompCorrection(ConfiguredBaseModel):
@ -413,12 +501,21 @@ class VoltageClampSeriesResistanceCompCorrection(ConfiguredBaseModel):
Resistance compensation correction, in percent.
"""
name: Literal["resistance_comp_correction"] = Field("resistance_comp_correction")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_correction, which is fixed to 'percent'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_correction"] = Field(
"resistance_comp_correction",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_correction",
"ifabsent": "string(resistance_comp_correction)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_correction, which is fixed to 'percent'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompPrediction(ConfiguredBaseModel):
@ -426,12 +523,21 @@ class VoltageClampSeriesResistanceCompPrediction(ConfiguredBaseModel):
Resistance compensation prediction, in percent.
"""
name: Literal["resistance_comp_prediction"] = Field("resistance_comp_prediction")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_prediction, which is fixed to 'percent'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_prediction"] = Field(
"resistance_comp_prediction",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_prediction",
"ifabsent": "string(resistance_comp_prediction)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_prediction, which is fixed to 'percent'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesWholeCellCapacitanceComp(ConfiguredBaseModel):
@ -439,12 +545,21 @@ class VoltageClampSeriesWholeCellCapacitanceComp(ConfiguredBaseModel):
Whole cell capacitance compensation, in farads.
"""
name: Literal["whole_cell_capacitance_comp"] = Field("whole_cell_capacitance_comp")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for whole_cell_capacitance_comp, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["whole_cell_capacitance_comp"] = Field(
"whole_cell_capacitance_comp",
json_schema_extra={
"linkml_meta": {
"equals_string": "whole_cell_capacitance_comp",
"ifabsent": "string(whole_cell_capacitance_comp)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for whole_cell_capacitance_comp, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesWholeCellSeriesResistanceComp(ConfiguredBaseModel):
@ -452,12 +567,21 @@ class VoltageClampSeriesWholeCellSeriesResistanceComp(ConfiguredBaseModel):
Whole cell series resistance compensation, in ohms.
"""
name: Literal["whole_cell_series_resistance_comp"] = Field("whole_cell_series_resistance_comp")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for whole_cell_series_resistance_comp, which is fixed to 'ohms'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["whole_cell_series_resistance_comp"] = Field(
"whole_cell_series_resistance_comp",
json_schema_extra={
"linkml_meta": {
"equals_string": "whole_cell_series_resistance_comp",
"ifabsent": "string(whole_cell_series_resistance_comp)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for whole_cell_series_resistance_comp, which is fixed to 'ohms'."""
)
value: np.float32 = Field(...)
class VoltageClampStimulusSeries(PatchClampSeries):
@ -465,41 +589,44 @@ class VoltageClampStimulusSeries(PatchClampSeries):
Stimulus voltage applied during a voltage clamp recording.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Stimulus voltage applied.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -510,7 +637,11 @@ class VoltageClampStimulusSeriesData(ConfiguredBaseModel):
Stimulus voltage applied.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -523,24 +654,19 @@ class IntracellularElectrode(NWBContainer):
An intracellular electrode and its metadata.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
description: str = Field(
...,
description="""Description of electrode (e.g., whole-cell, sharp, etc.).""",
)
description: str = Field(..., description="""Description of electrode (e.g., whole-cell, sharp, etc.).""")
filtering: Optional[str] = Field(None, description="""Electrode specific filtering.""")
initial_access_resistance: Optional[str] = Field(
None, description="""Initial access resistance."""
)
initial_access_resistance: Optional[str] = Field(None, description="""Initial access resistance.""")
location: Optional[str] = Field(
None,
description="""Location of the electrode. 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.""",
)
resistance: Optional[str] = Field(None, description="""Electrode resistance, in ohms.""")
seal: Optional[str] = Field(None, description="""Information about seal used for recording.""")
slice: Optional[str] = Field(
None, description="""Information about slice used for recording."""
)
slice: Optional[str] = Field(None, description="""Information about slice used for recording.""")
class SweepTable(DynamicTable):
@ -548,44 +674,59 @@ class SweepTable(DynamicTable):
The table which groups different PatchClampSeries together.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
sweep_number: Optional[List[int] | int] = Field(
default_factory=list,
sweep_number: NDArray[Any, np.uint32] = Field(
...,
description="""Sweep number of the PatchClampSeries in that row.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
series: Optional[List[str] | str] = Field(
default_factory=list,
description="""The PatchClampSeries with the sweep number in that row.""",
series: List[PatchClampSeries] = Field(
..., description="""The PatchClampSeries with the sweep number in that row."""
)
series_index: Named[VectorIndex] = Field(
...,
description="""Index for series.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
series_index: str = 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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
class SweepTableSeriesIndex(VectorIndex):
"""
Index for series.
"""
name: Literal["series_index"] = Field("series_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
PatchClampSeries.model_rebuild()
PatchClampSeriesData.model_rebuild()
CurrentClampSeries.model_rebuild()
CurrentClampSeriesData.model_rebuild()
IZeroClampSeries.model_rebuild()
CurrentClampStimulusSeries.model_rebuild()
CurrentClampStimulusSeriesData.model_rebuild()
VoltageClampSeries.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()
VoltageClampStimulusSeries.model_rebuild()
VoltageClampStimulusSeriesData.model_rebuild()
IntracellularElectrode.model_rebuild()
SweepTable.model_rebuild()

View file

@ -1,57 +1,99 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import Image, TimeSeriesStartingTime, TimeSeries, TimeSeriesSync
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
Data,
Index,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
Container,
DynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.image/",
"id": "core.nwb.image",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.image",
}
)
class GrayscaleImage(Image):
@ -59,16 +101,18 @@ class GrayscaleImage(Image):
A grayscale image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -78,16 +122,18 @@ class RGBImage(Image):
A color image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -97,16 +143,18 @@ class RGBAImage(Image):
A color image with transparency.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -116,17 +164,18 @@ 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].
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -139,23 +188,26 @@ class ImageSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -166,12 +218,19 @@ 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.
"""
name: Literal["external_file"] = Field("external_file")
starting_frame: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image"})
name: Literal["external_file"] = Field(
"external_file",
json_schema_extra={"linkml_meta": {"equals_string": "external_file", "ifabsent": "string(external_file)"}},
)
starting_frame: Optional[np.int32] = 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 faciliate 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].""",
)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(None)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(
None, json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_files"}]}}}
)
class ImageMaskSeries(ImageSeries):
@ -179,17 +238,18 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -202,23 +262,26 @@ class ImageMaskSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -229,31 +292,26 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
distance: Optional[float] = Field(
None, description="""Distance from camera/monitor to target/eye."""
)
distance: Optional[np.float32] = Field(None, description="""Distance from camera/monitor to target/eye.""")
field_of_view: Optional[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height_depth"], float],
]
] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
)
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height_depth"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, 3 r_g_b"], float],
NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, 3 r_g_b"], np.number]
] = 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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -266,23 +324,26 @@ class OpticalSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -293,32 +354,51 @@ class IndexSeries(TimeSeries):
Stores indices to image frames stored in an ImageSeries. The purpose of the ImageIndexSeries is to allow a static image stack to be stored somewhere, 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 ImageSeries, and the timestamps array indicates when that image was displayed.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
..., description="""Index of the frame in the referenced ImageSeries."""
data: NDArray[Shape["* num_times"], np.int32] = Field(
...,
description="""Index of the frame in the referenced ImageSeries.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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()
ImageSeriesExternalFile.model_rebuild()
ImageMaskSeries.model_rebuild()
OpticalSeries.model_rebuild()
IndexSeries.model_rebuild()

View file

@ -1,66 +1,79 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_table import (
VectorIndex,
DynamicTableRegion,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeriesStartingTime, TimeSeries, TimeSeriesSync
from .core_nwb_ecephys import ElectrodeGroup
import numpy as np
from ...core.v2_2_4.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from ...core.v2_2_4.core_nwb_ecephys import ElectrodeGroup
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_1_3.hdmf_common_table import DynamicTable, VectorData, VectorIndex, DynamicTableRegion
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.misc/",
"id": "core.nwb.misc",
"imports": ["core.nwb.base", "../../hdmf_common/v1_1_3/namespace", "core.nwb.ecephys", "core.nwb.language"],
"name": "core.nwb.misc",
}
)
class AbstractFeatureSeries(TimeSeries):
@ -68,37 +81,45 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Values of each feature at each time.""")
data: AbstractFeatureSeriesData = Field(..., description="""Values of each feature at each time.""")
feature_units: Optional[NDArray[Shape["* num_features"], str]] = Field(
None, description="""Units of each feature."""
None,
description="""Units of each feature.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of the features represented in TimeSeries::data.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -109,16 +130,17 @@ class AbstractFeatureSeriesData(ConfiguredBaseModel):
Values of each feature at each time.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_features"], float],
]
Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_features"], np.number]]
] = Field(None)
@ -127,32 +149,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], str] = Field(
..., description="""Annotations made during an experiment."""
...,
description="""Annotations made during an experiment.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -163,32 +192,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
..., description="""Use values >0 if interval started, <0 if interval ended."""
data: NDArray[Shape["* num_times"], np.int8] = Field(
...,
description="""Use values >0 if interval started, <0 if interval ended.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -199,10 +235,12 @@ class DecompositionSeries(TimeSeries):
Spectral analysis of a time series, e.g. of an LFP or a speech signal.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Data decomposed into frequency bands.""")
data: DecompositionSeriesData = Field(..., description="""Data decomposed into frequency bands.""")
metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""")
bands: str = Field(
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.""",
)
@ -211,23 +249,26 @@ class DecompositionSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -238,12 +279,23 @@ class DecompositionSeriesData(ConfiguredBaseModel):
Data decomposed into frequency bands.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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"], float]] = Field(None)
array: Optional[NDArray[Shape["* num_times, * num_channels, * num_bands"], np.number]] = Field(
None,
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_times"}, {"alias": "num_channels"}, {"alias": "num_bands"}]}
}
},
)
class DecompositionSeriesBands(DynamicTable):
@ -251,37 +303,50 @@ 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.
"""
name: Literal["bands"] = Field("bands")
band_name: Optional[List[str] | str] = Field(
default_factory=list, description="""Name of the band, e.g. theta."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["bands"] = Field(
"bands", json_schema_extra={"linkml_meta": {"equals_string": "bands", "ifabsent": "string(bands)"}}
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], float] = Field(
band_name: NDArray[Any, str] = Field(
...,
description="""Name of the band, e.g. theta.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], np.float32] = 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.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_bands"}, {"alias": "low_high", "exact_cardinality": 2}]}
}
},
)
band_mean: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The mean Gaussian filters, in Hz."""
band_mean: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The mean Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
band_stdev: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The standard deviation of Gaussian filters, in Hz."""
band_stdev: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The standard deviation of Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
@ -290,69 +355,68 @@ 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("Units")
spike_times_index: Optional[str] = Field(
None, description="""Index into the spike_times dataset."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
spike_times: Optional[str] = Field(None, description="""Spike times for each unit.""")
obs_intervals_index: Optional[str] = Field(
None, description="""Index into the obs_intervals dataset."""
spike_times: Optional[UnitsSpikeTimes] = Field(None, description="""Spike times for each unit.""")
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]] = Field(
None, description="""Observation intervals for each unit."""
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], np.float64]] = Field(
None,
description="""Observation intervals for each unit.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_intervals"}, {"alias": "start_end", "exact_cardinality": 2}]}
}
},
)
electrodes_index: Optional[str] = Field(None, description="""Index into electrodes.""")
electrodes: Optional[str] = Field(
electrodes_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrode_group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Electrode group that each spike unit came from.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform standard deviation for each spike unit.""")
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
)
class UnitsSpikeTimesIndex(VectorIndex):
"""
Index into the spike_times dataset.
"""
name: Literal["spike_times_index"] = Field("spike_times_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
class UnitsSpikeTimes(VectorData):
@ -360,14 +424,17 @@ class UnitsSpikeTimes(VectorData):
Spike times for each unit.
"""
name: Literal["spike_times"] = Field("spike_times")
resolution: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["spike_times"] = Field(
"spike_times",
json_schema_extra={"linkml_meta": {"equals_string": "spike_times", "ifabsent": "string(spike_times)"}},
)
resolution: Optional[np.float64] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -378,50 +445,14 @@ class UnitsSpikeTimes(VectorData):
] = Field(None)
class UnitsObsIntervalsIndex(VectorIndex):
"""
Index into the obs_intervals dataset.
"""
name: Literal["obs_intervals_index"] = Field("obs_intervals_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
class UnitsElectrodesIndex(VectorIndex):
"""
Index into electrodes.
"""
name: Literal["electrodes_index"] = Field("electrodes_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
class UnitsElectrodes(DynamicTableRegion):
"""
Electrode that each spike unit came from, specified using a DynamicTableRegion.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
AbstractFeatureSeries.model_rebuild()
AbstractFeatureSeriesData.model_rebuild()
AnnotationSeries.model_rebuild()
IntervalSeries.model_rebuild()
DecompositionSeries.model_rebuild()
DecompositionSeriesData.model_rebuild()
DecompositionSeriesBands.model_rebuild()
Units.model_rebuild()
UnitsSpikeTimes.model_rebuild()

View file

@ -1,62 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeriesSync,
NWBContainer,
TimeSeriesStartingTime,
TimeSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from numpydantic import NDArray, Shape
from ...core.v2_2_4.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync, NWBContainer
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ogen/",
"id": "core.nwb.ogen",
"imports": ["core.nwb.base", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ogen",
}
)
class OptogeneticSeries(TimeSeries):
@ -64,32 +79,39 @@ class OptogeneticSeries(TimeSeries):
An optogenetic stimulus.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], float] = Field(
..., description="""Applied power for optogenetic stimulus, in watts."""
data: NDArray[Shape["* num_times"], np.number] = Field(
...,
description="""Applied power for optogenetic stimulus, in watts.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -100,10 +122,18 @@ class OptogeneticStimulusSite(NWBContainer):
A site of optogenetic stimulation.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
description: str = Field(..., description="""Description of stimulation site.""")
excitation_lambda: float = Field(..., description="""Excitation wavelength, in nm.""")
excitation_lambda: np.float32 = 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.""",
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
OptogeneticSeries.model_rebuild()
OptogeneticStimulusSite.model_rebuild()

View file

@ -1,72 +1,116 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
import numpy as np
from ...core.v2_2_4.core_nwb_device import Device
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
TimeSeriesSync,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
DynamicTableRegion,
VectorIndex,
DynamicTable,
Data,
Index,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
Container,
DynamicTable,
)
from .core_nwb_image import ImageSeries, ImageSeriesExternalFile
from ...core.v2_2_4.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ophys/",
"id": "core.nwb.ophys",
"imports": [
"core.nwb.image",
"core.nwb.base",
"../../hdmf_common/v1_1_3/namespace",
"core.nwb.device",
"core.nwb.language",
],
"name": "core.nwb.ophys",
}
)
class TwoPhotonSeries(ImageSeries):
@ -74,31 +118,26 @@ class TwoPhotonSeries(ImageSeries):
Image stack recorded over time from 2-photon microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[float] = Field(
pmt_gain: Optional[np.float32] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[np.float32] = 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[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height"], float],
]
] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
)
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -111,23 +150,26 @@ class TwoPhotonSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -138,71 +180,57 @@ class RoiResponseSeries(TimeSeries):
ROI responses over an imaging plane. The first dimension represents time. The second dimension, if present, represents ROIs.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_rois"], float],
] = Field(..., description="""Signals from ROIs.""")
rois: str = Field(
data: Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_rois"], np.number]] = Field(
..., description="""Signals from ROIs."""
)
rois: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 RoiResponseSeriesRois(DynamicTableRegion):
"""
DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.
"""
name: Literal["rois"] = Field("rois")
table: Optional[str] = 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 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -211,7 +239,11 @@ 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -220,7 +252,11 @@ 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.
"""
children: Optional[List[PlaneSegmentation] | PlaneSegmentation] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[PlaneSegmentation]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "PlaneSegmentation"}]}}
)
name: str = Field(...)
@ -229,75 +265,64 @@ class PlaneSegmentation(DynamicTable):
Results from image segmentation of a specific imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
image_mask: Optional[
Union[
NDArray[Shape["* num_roi, * num_x, * num_y"], Any],
NDArray[Shape["* num_roi, * num_x, * num_y, * num_z"], Any],
]
] = 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[str] = Field(None, description="""Index into pixel_mask.""")
pixel_mask: Optional[str] = Field(
pixel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
pixel_mask: Optional[PlaneSegmentationPixelMask] = Field(
None,
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[str] = Field(None, description="""Index into voxel_mask.""")
voxel_mask: Optional[str] = Field(
voxel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
voxel_mask: Optional[PlaneSegmentationVoxelMask] = Field(
None,
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: Optional[List[ImageSeries] | ImageSeries] = Field(
default_factory=dict,
reference_images: Optional[List[ImageSeries]] = Field(
None,
description="""Image stacks that the segmentation masks apply to.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImageSeries"}]}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list, description="""Vector columns of this dynamic table."""
)
vector_index: Optional[List[str] | str] = Field(
default_factory=list,
description="""Indices for the vector columns of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(None, description="""Vector columns of this dynamic table.""")
vector_index: Optional[List[VectorIndex]] = Field(
None, description="""Indices for the vector columns of this dynamic table."""
)
class PlaneSegmentationPixelMaskIndex(VectorIndex):
class PlaneSegmentationImageMask(VectorData):
"""
Index into pixel_mask.
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: Literal["pixel_mask_index"] = Field("pixel_mask_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
class PlaneSegmentationPixelMask(VectorData):
"""
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
"""
name: Literal["pixel_mask"] = Field("pixel_mask")
x: Optional[int] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[int] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the pixel.""")
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["image_mask"] = Field(
"image_mask",
json_schema_extra={"linkml_meta": {"equals_string": "image_mask", "ifabsent": "string(image_mask)"}},
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -308,17 +333,29 @@ class PlaneSegmentationPixelMask(VectorData):
] = Field(None)
class PlaneSegmentationVoxelMaskIndex(VectorIndex):
class PlaneSegmentationPixelMask(VectorData):
"""
Index into voxel_mask.
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
"""
name: Literal["voxel_mask_index"] = Field("voxel_mask_index")
target: Optional[str] = Field(
None,
description="""Reference to the target dataset that this index applies to.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["pixel_mask"] = Field(
"pixel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "pixel_mask", "ifabsent": "string(pixel_mask)"}},
)
array: Optional[NDArray[Shape["* num_rows"], Any]] = Field(None)
x: Optional[np.uint32] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the pixel.""")
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 PlaneSegmentationVoxelMask(VectorData):
@ -326,14 +363,17 @@ class PlaneSegmentationVoxelMask(VectorData):
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
"""
name: Literal["voxel_mask"] = Field("voxel_mask")
x: Optional[int] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[int] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[int] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["voxel_mask"] = Field(
"voxel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "voxel_mask", "ifabsent": "string(voxel_mask)"}},
)
x: Optional[np.uint32] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[np.uint32] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -349,7 +389,11 @@ class ImagingPlane(NWBContainer):
An imaging plane and its metadata.
"""
children: Optional[List[OpticalChannel] | OpticalChannel] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[OpticalChannel]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "OpticalChannel"}]}}
)
name: str = Field(...)
@ -358,9 +402,11 @@ class OpticalChannel(NWBContainer):
An optical channel used to record from an imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
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.""")
emission_lambda: np.float32 = Field(..., description="""Emission wavelength for channel, in nm.""")
class MotionCorrection(NWBDataInterface):
@ -368,8 +414,10 @@ 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).
"""
children: Optional[List[CorrectedImageStack] | CorrectedImageStack] = Field(
default_factory=dict
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[CorrectedImageStack]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "CorrectedImageStack"}]}}
)
name: str = Field(...)
@ -379,12 +427,28 @@ class CorrectedImageStack(NWBDataInterface):
Reuslts from motion correction of an image stack.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
corrected: str = Field(
...,
description="""Image stack with frames shifted to the common coordinates.""",
)
xy_translation: 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.""",
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
TwoPhotonSeries.model_rebuild()
RoiResponseSeries.model_rebuild()
DfOverF.model_rebuild()
Fluorescence.model_rebuild()
ImageSegmentation.model_rebuild()
PlaneSegmentation.model_rebuild()
PlaneSegmentationImageMask.model_rebuild()
PlaneSegmentationPixelMask.model_rebuild()
PlaneSegmentationVoxelMask.model_rebuild()
ImagingPlane.model_rebuild()
OpticalChannel.model_rebuild()
MotionCorrection.model_rebuild()
CorrectedImageStack.model_rebuild()

View file

@ -1,57 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBDataInterface
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_2_4.core_nwb_base import NWBDataInterface
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.retinotopy/",
"id": "core.nwb.retinotopy",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.retinotopy",
}
)
class ImagingRetinotopy(NWBDataInterface):
@ -59,36 +79,39 @@ 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("ImagingRetinotopy")
axis_1_phase_map: str = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy", "tree_root": True})
name: str = Field("ImagingRetinotopy", json_schema_extra={"linkml_meta": {"ifabsent": "string(ImagingRetinotopy)"}})
axis_1_phase_map: ImagingRetinotopyAxis1PhaseMap = Field(
..., description="""Phase response to stimulus on the first measured axis."""
)
axis_1_power_map: Optional[str] = Field(
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: str = Field(
axis_2_phase_map: ImagingRetinotopyAxis2PhaseMap = Field(
..., description="""Phase response to stimulus on the second measured axis."""
)
axis_2_power_map: Optional[str] = Field(
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: NDArray[Shape["2 axis_1_axis_2"], str] = Field(
...,
description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "axis_1_axis_2", "exact_cardinality": 2}]}}
},
)
focal_depth_image: Optional[str] = Field(
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[str] = Field(
None,
description="""Sine of the angle between the direction of the gradient in axis_1 and axis_2.""",
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: str = Field(
...,
description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]""",
vasculature_image: ImagingRetinotopyVasculatureImage = Field(
..., description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]"""
)
@ -97,16 +120,24 @@ class ImagingRetinotopyAxis1PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the first measured axis.
"""
name: Literal["axis_1_phase_map"] = Field("axis_1_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_phase_map"] = Field(
"axis_1_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_phase_map", "ifabsent": "string(axis_1_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis1PowerMap(ConfiguredBaseModel):
@ -114,16 +145,24 @@ 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: Literal["axis_1_power_map"] = Field("axis_1_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_power_map"] = Field(
"axis_1_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_power_map", "ifabsent": "string(axis_1_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
@ -131,16 +170,24 @@ class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the second measured axis.
"""
name: Literal["axis_2_phase_map"] = Field("axis_2_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_phase_map"] = Field(
"axis_2_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_phase_map", "ifabsent": "string(axis_2_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PowerMap(ConfiguredBaseModel):
@ -148,16 +195,24 @@ 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: Literal["axis_2_power_map"] = Field("axis_2_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_power_map"] = Field(
"axis_2_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_power_map", "ifabsent": "string(axis_2_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
@ -165,21 +220,29 @@ class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns].
"""
name: Literal["focal_depth_image"] = Field("focal_depth_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["focal_depth_image"] = Field(
"focal_depth_image",
json_schema_extra={
"linkml_meta": {"equals_string": "focal_depth_image", "ifabsent": "string(focal_depth_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value.""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
focal_depth: Optional[float] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
focal_depth: Optional[np.float32] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
class ImagingRetinotopySignMap(ConfiguredBaseModel):
@ -187,13 +250,20 @@ class ImagingRetinotopySignMap(ConfiguredBaseModel):
Sine of the angle between the direction of the gradient in axis_1 and axis_2.
"""
name: Literal["sign_map"] = Field("sign_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["sign_map"] = Field(
"sign_map", json_schema_extra={"linkml_meta": {"equals_string": "sign_map", "ifabsent": "string(sign_map)"}}
)
dimension: Optional[np.int32] = 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"], float]] = Field(None)
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
@ -201,17 +271,37 @@ class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]
"""
name: Literal["vasculature_image"] = Field("vasculature_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["vasculature_image"] = Field(
"vasculature_image",
json_schema_extra={
"linkml_meta": {"equals_string": "vasculature_image", "ifabsent": "string(vasculature_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ImagingRetinotopy.model_rebuild()
ImagingRetinotopyAxis1PhaseMap.model_rebuild()
ImagingRetinotopyAxis1PowerMap.model_rebuild()
ImagingRetinotopyAxis2PhaseMap.model_rebuild()
ImagingRetinotopyAxis2PowerMap.model_rebuild()
ImagingRetinotopyFocalDepthImage.model_rebuild()
ImagingRetinotopySignMap.model_rebuild()
ImagingRetinotopyVasculatureImage.model_rebuild()

View file

@ -1,39 +1,13 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_sparse import (
CSRMatrix,
CSRMatrixIndices,
CSRMatrixIndptr,
CSRMatrixData,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_1_3.hdmf_common_sparse import CSRMatrix, CSRMatrixIndices, CSRMatrixIndptr, CSRMatrixData
from ...hdmf_common.v1_1_3.hdmf_common_table import (
Data,
Index,
@ -44,8 +18,7 @@ from ...hdmf_common.v1_1_3.hdmf_common_table import (
Container,
DynamicTable,
)
from .core_nwb_retinotopy import (
from ...core.v2_2_4.core_nwb_retinotopy import (
ImagingRetinotopy,
ImagingRetinotopyAxis1PhaseMap,
ImagingRetinotopyAxis1PowerMap,
@ -55,8 +28,7 @@ from .core_nwb_retinotopy import (
ImagingRetinotopySignMap,
ImagingRetinotopyVasculatureImage,
)
from .core_nwb_base import (
from ...core.v2_2_4.core_nwb_base import (
NWBData,
Image,
NWBContainer,
@ -68,28 +40,23 @@ from .core_nwb_base import (
ProcessingModule,
Images,
)
from .core_nwb_ophys import (
from ...core.v2_2_4.core_nwb_ophys import (
TwoPhotonSeries,
RoiResponseSeries,
RoiResponseSeriesRois,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationPixelMaskIndex,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMaskIndex,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from .core_nwb_device import Device
from .core_nwb_image import (
from ...core.v2_2_4.core_nwb_device import Device
from ...core.v2_2_4.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
@ -99,10 +66,8 @@ from .core_nwb_image import (
OpticalSeries,
IndexSeries,
)
from .core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from .core_nwb_icephys import (
from ...core.v2_2_4.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_2_4.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
@ -123,15 +88,11 @@ from .core_nwb_icephys import (
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
SweepTableSeriesIndex,
)
from .core_nwb_ecephys import (
from ...core.v2_2_4.core_nwb_ecephys import (
ElectricalSeries,
ElectricalSeriesElectrodes,
SpikeEventSeries,
FeatureExtraction,
FeatureExtractionElectrodes,
EventDetection,
EventWaveform,
FilteredEphys,
@ -141,8 +102,7 @@ from .core_nwb_ecephys import (
ClusterWaveforms,
Clustering,
)
from .core_nwb_behavior import (
from ...core.v2_2_4.core_nwb_behavior import (
SpatialSeries,
SpatialSeriesData,
BehavioralEpochs,
@ -153,8 +113,7 @@ from .core_nwb_behavior import (
CompassDirection,
Position,
)
from .core_nwb_misc import (
from ...core.v2_2_4.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
@ -163,14 +122,9 @@ from .core_nwb_misc import (
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimesIndex,
UnitsSpikeTimes,
UnitsObsIntervalsIndex,
UnitsElectrodesIndex,
UnitsElectrodes,
)
from .core_nwb_file import (
from ...core.v2_2_4.core_nwb_file import (
ScratchData,
NWBFile,
NWBFileStimulus,
@ -182,34 +136,71 @@ from .core_nwb_file import (
LabMetaData,
Subject,
)
from .core_nwb_epoch import (
TimeIntervals,
TimeIntervalsTagsIndex,
TimeIntervalsTimeseries,
TimeIntervalsTimeseriesIndex,
)
from ...core.v2_2_4.core_nwb_epoch import TimeIntervals, TimeIntervalsTimeseries
metamodel_version = "None"
version = "2.2.4"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": True},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core/",
"description": "NWB namespace",
"id": "core",
"imports": [
"core.nwb.base",
"core.nwb.device",
"core.nwb.epoch",
"core.nwb.image",
"core.nwb.file",
"core.nwb.misc",
"core.nwb.behavior",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.retinotopy",
"core.nwb.language",
"../../hdmf_common/v1_1_3/namespace",
],
"name": "core",
}
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model

View file

@ -1,59 +1,78 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTable
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.base/",
"id": "core.nwb.base",
"imports": ["../../hdmf_common/v1_5_0/namespace", "../../hdmf_common/v1_5_0/namespace", "core.nwb.language"],
"name": "core.nwb.base",
}
)
class NWBData(Data):
@ -61,6 +80,8 @@ class NWBData(Data):
An abstract data type for a dataset.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -69,16 +90,18 @@ 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)).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -88,6 +111,8 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -96,6 +121,8 @@ class NWBDataInterface(NWBContainer):
An abstract data type for a generic container storing collections of data, as opposed to metadata.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -104,33 +131,38 @@ class TimeSeries(NWBDataInterface):
General purpose time series.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
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: str = Field(
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -141,12 +173,16 @@ 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: Literal["data"] = Field("data")
conversion: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
conversion: Optional[np.float32] = 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.""",
)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = 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.""",
)
@ -173,13 +209,15 @@ 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: Literal["starting_time"] = Field("starting_time")
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'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["starting_time"] = Field(
"starting_time",
json_schema_extra={"linkml_meta": {"equals_string": "starting_time", "ifabsent": "string(starting_time)"}},
)
value: float = Field(...)
rate: Optional[np.float32] = Field(None, description="""Sampling rate, in Hz.""")
unit: Optional[str] = Field(None, description="""Unit of measurement for time, which is fixed to 'seconds'.""")
value: np.float64 = Field(...)
class TimeSeriesSync(ConfiguredBaseModel):
@ -187,7 +225,11 @@ 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.
"""
name: Literal["sync"] = Field("sync")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["sync"] = Field(
"sync", json_schema_extra={"linkml_meta": {"equals_string": "sync", "ifabsent": "string(sync)"}}
)
class ProcessingModule(NWBContainer):
@ -195,10 +237,11 @@ class ProcessingModule(NWBContainer):
A collection of processed data.
"""
children: Optional[
List[Union[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
children: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}}
)
name: str = Field(...)
@ -207,10 +250,22 @@ class Images(NWBDataInterface):
A collection of images.
"""
name: str = Field("Images")
description: Optional[str] = Field(
None, description="""Description of this collection of images."""
)
image: List[str] | str = Field(
default_factory=list, description="""Images stored in this collection."""
)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: Optional[str] = Field(None, description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
NWBData.model_rebuild()
Image.model_rebuild()
NWBContainer.model_rebuild()
NWBDataInterface.model_rebuild()
TimeSeries.model_rebuild()
TimeSeriesData.model_rebuild()
TimeSeriesStartingTime.model_rebuild()
TimeSeriesSync.model_rebuild()
ProcessingModule.model_rebuild()
Images.model_rebuild()

View file

@ -1,64 +1,123 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeriesSync,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_3_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from .core_nwb_misc import IntervalSeries
from ...core.v2_3_0.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.behavior/",
"id": "core.nwb.behavior",
"imports": ["core.nwb.base", "core.nwb.misc", "core.nwb.language"],
"name": "core.nwb.behavior",
}
)
class SpatialSeries(TimeSeries):
@ -66,37 +125,40 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
name: str = Field(...)
data: str = Field(
...,
description="""1-D or 2-D array storing position or direction relative to some reference frame.""",
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.""",
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -107,16 +169,17 @@ class SpatialSeriesData(ConfiguredBaseModel):
1-D or 2-D array storing position or direction relative to some reference frame.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
)
array: Optional[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_features"], float],
]
Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_features"], np.number]]
] = Field(None)
@ -125,7 +188,11 @@ 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.
"""
children: Optional[List[IntervalSeries] | IntervalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -134,7 +201,11 @@ class BehavioralEvents(NWBDataInterface):
TimeSeries for storing behavioral events. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -143,7 +214,11 @@ class BehavioralTimeSeries(NWBDataInterface):
TimeSeries for storing Behavoioral time series data. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -152,7 +227,11 @@ class PupilTracking(NWBDataInterface):
Eye-tracking data, representing pupil size.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -161,7 +240,11 @@ class EyeTracking(NWBDataInterface):
Eye-tracking data, representing direction of gaze.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -170,7 +253,11 @@ 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.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -179,5 +266,22 @@ class Position(NWBDataInterface):
Position data, whether along the x, x/y or x/y/z axis.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
SpatialSeries.model_rebuild()
SpatialSeriesData.model_rebuild()
BehavioralEpochs.model_rebuild()
BehavioralEvents.model_rebuild()
BehavioralTimeSeries.model_rebuild()
PupilTracking.model_rebuild()
EyeTracking.model_rebuild()
CompassDirection.model_rebuild()
Position.model_rebuild()

View file

@ -1,57 +1,60 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBContainer
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_3_0.core_nwb_base import NWBContainer
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.device/",
"id": "core.nwb.device",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.device",
}
)
class Device(NWBContainer):
@ -59,11 +62,16 @@ class Device(NWBContainer):
Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.device", "tree_root": True})
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."""
)
manufacturer: Optional[str] = Field(None, description="""The name of the manufacturer of the device.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
Device.model_rebuild()

View file

@ -1,65 +1,84 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTableRegion, DynamicTable
from .core_nwb_base import (
NWBContainer,
TimeSeriesStartingTime,
NWBDataInterface,
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTableRegion
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from ...core.v2_3_0.core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
TimeSeriesSync,
NWBDataInterface,
NWBContainer,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
NUMPYDANTIC_VERSION = "1.2.1"
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ecephys/",
"id": "core.nwb.ecephys",
"imports": ["core.nwb.base", "../../hdmf_common/v1_5_0/namespace", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ecephys",
}
)
class ElectricalSeries(TimeSeries):
@ -67,118 +86,109 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
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: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_channels"], float],
NDArray[Shape["* num_times, * num_channels, * num_samples"], float],
NDArray[Shape["* num_times"], np.number],
NDArray[Shape["* num_times, * num_channels"], np.number],
NDArray[Shape["* num_times, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Recorded voltage data.""")
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 ElectricalSeriesElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 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).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_events, * num_channels, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], np.number],
NDArray[Shape["* num_events, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Spike waveforms.""")
timestamps: NDArray[Shape["* num_times"], float] = Field(
timestamps: NDArray[Shape["* num_times"], np.float64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -189,64 +199,56 @@ class FeatureExtraction(NWBDataInterface):
Features, such as PC1 and PC2, that are extracted from signals stored in a SpikeEventSeries or other source.
"""
name: str = Field("FeatureExtraction")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("FeatureExtraction", json_schema_extra={"linkml_meta": {"ifabsent": "string(FeatureExtraction)"}})
description: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of features (eg, ''PC1'') for each of the extracted features.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_events, * num_channels, * num_features"], float] = Field(
features: NDArray[Shape["* num_events, * num_channels, * num_features"], np.float32] = Field(
...,
description="""Multi-dimensional array of features extracted from each event.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_events"}, {"alias": "num_channels"}, {"alias": "num_features"}]}
}
},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of events that features correspond to (can be a link).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
class FeatureExtractionElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 EventDetection(NWBDataInterface):
"""
Detected spike events from voltage trace(s).
"""
name: str = Field("EventDetection")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("EventDetection", json_schema_extra={"linkml_meta": {"ifabsent": "string(EventDetection)"}})
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: NDArray[Shape["* num_events"], int] = Field(
source_idx: NDArray[Shape["* num_events"], np.int32] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
..., description="""Timestamps of events, in seconds."""
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Timestamps of events, in seconds.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
@ -255,7 +257,11 @@ 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.
"""
children: Optional[List[SpikeEventSeries] | SpikeEventSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -264,7 +270,11 @@ 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.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -273,7 +283,11 @@ 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.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -282,13 +296,15 @@ class ElectrodeGroup(NWBContainer):
A physical grouping of electrodes, e.g. a shank of an array.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
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[str] = Field(
position: Optional[ElectrodeGroupPosition] = Field(
None, description="""stereotaxic or common framework coordinates"""
)
@ -298,10 +314,14 @@ class ElectrodeGroupPosition(ConfiguredBaseModel):
stereotaxic or common framework coordinates
"""
name: Literal["position"] = Field("position")
x: Optional[float] = Field(None, description="""x coordinate""")
y: Optional[float] = Field(None, description="""y coordinate""")
z: Optional[float] = Field(None, description="""z coordinate""")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys"})
name: Literal["position"] = Field(
"position", json_schema_extra={"linkml_meta": {"equals_string": "position", "ifabsent": "string(position)"}}
)
x: Optional[np.float32] = Field(None, description="""x coordinate""")
y: Optional[np.float32] = Field(None, description="""y coordinate""")
z: Optional[np.float32] = Field(None, description="""z coordinate""")
class ClusterWaveforms(NWBDataInterface):
@ -309,17 +329,23 @@ 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("ClusterWaveforms")
waveform_filtering: str = Field(
..., description="""Filtering applied to data before generating mean/sd"""
)
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("ClusterWaveforms", json_schema_extra={"linkml_meta": {"ifabsent": "string(ClusterWaveforms)"}})
waveform_filtering: str = Field(..., description="""Filtering applied to data before generating mean/sd""")
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = 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)""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = Field(
...,
description="""Stdev of waveforms for each cluster, using the same indices as in mean""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
@ -328,19 +354,40 @@ 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("Clustering")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("Clustering", json_schema_extra={"linkml_meta": {"ifabsent": "string(Clustering)"}})
description: str = Field(
...,
description="""Description of clusters or clustering, (e.g. cluster 0 is noise, clusters curated using Klusters, etc)""",
)
num: NDArray[Shape["* num_events"], int] = Field(
..., description="""Cluster number of each event"""
num: NDArray[Shape["* num_events"], np.int32] = Field(
...,
description="""Cluster number of each event""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
peak_over_rms: NDArray[Shape["* num_clusters"], float] = Field(
peak_over_rms: NDArray[Shape["* num_clusters"], np.float32] = Field(
...,
description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
# 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()
ElectrodeGroupPosition.model_rebuild()
ClusterWaveforms.model_rebuild()
Clustering.model_rebuild()

View file

@ -1,63 +1,78 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorIndex,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeries
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTable, VectorIndex, VectorData
from ...core.v2_3_0.core_nwb_base import TimeSeries
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.epoch/",
"id": "core.nwb.epoch",
"imports": ["../../hdmf_common/v1_5_0/namespace", "core.nwb.base", "core.nwb.language"],
"name": "core.nwb.epoch",
}
)
class TimeIntervals(DynamicTable):
@ -65,80 +80,76 @@ class TimeIntervals(DynamicTable):
A container for aggregating epoch data and the TimeSeries that each epoch applies to.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.epoch", "tree_root": True})
name: str = Field(...)
start_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Start time of epoch, in seconds."""
start_time: NDArray[Any, np.float32] = Field(
...,
description="""Start time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
stop_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Stop time of epoch, in seconds."""
stop_time: NDArray[Any, np.float32] = Field(
...,
description="""Stop time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags: Optional[List[str] | str] = Field(
default_factory=list,
tags: Optional[NDArray[Any, str]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
timeseries: Optional[TimeIntervalsTimeseries] = Field(None, description="""An index into a TimeSeries object.""")
timeseries_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
tags_index: Optional[str] = Field(None, description="""Index for tags.""")
timeseries: Optional[str] = Field(None, description="""An index into a TimeSeries object.""")
timeseries_index: Optional[str] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class TimeIntervalsTagsIndex(VectorIndex):
"""
Index for tags.
"""
name: Literal["tags_index"] = Field("tags_index")
target: Optional[str] = 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[
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(VectorData):
"""
An index into a TimeSeries object.
"""
name: Literal["timeseries"] = Field("timeseries")
idx_start: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.epoch"})
name: Literal["timeseries"] = Field(
"timeseries",
json_schema_extra={"linkml_meta": {"equals_string": "timeseries", "ifabsent": "string(timeseries)"}},
)
idx_start: Optional[np.int32] = Field(
None,
description="""Start index into the TimeSeries 'data' and 'timestamp' datasets of the referenced TimeSeries. The first dimension of those arrays is always time.""",
)
count: Optional[int] = Field(
None,
description="""Number of data samples available in this time series, during this epoch.""",
)
timeseries: Optional[str] = Field(
None, description="""the TimeSeries that this index applies to."""
)
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
count: Optional[np.int32] = Field(
None, description="""Number of data samples available in this time series, during this epoch."""
)
timeseries: Optional[TimeSeries] = Field(None, description="""the TimeSeries that this index applies to.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -149,24 +160,7 @@ class TimeIntervalsTimeseries(VectorData):
] = Field(None)
class TimeIntervalsTimeseriesIndex(VectorIndex):
"""
Index for timeseries.
"""
name: Literal["timeseries_index"] = Field("timeseries_index")
target: Optional[str] = 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[
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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
TimeIntervals.model_rebuild()
TimeIntervalsTimeseries.model_rebuild()

View file

@ -1,79 +1,183 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_icephys import SweepTable, IntracellularElectrode
from .core_nwb_epoch import TimeIntervals
from .core_nwb_ecephys import ElectrodeGroup
from .core_nwb_base import (
NWBContainer,
ProcessingModule,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_3_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from ...core.v2_3_0.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from .core_nwb_device import Device
from .core_nwb_misc import Units
from .core_nwb_ogen import OptogeneticStimulusSite
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTable, VectorData
from .core_nwb_ophys import ImagingPlane
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from ...core.v2_3_0.core_nwb_epoch import TimeIntervals, TimeIntervalsTimeseries
from ...core.v2_3_0.core_nwb_ophys import (
TwoPhotonSeries,
RoiResponseSeries,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from ...core.v2_3_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from ...core.v2_3_0.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_3_0.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
CurrentClampSeriesData,
IZeroClampSeries,
CurrentClampStimulusSeries,
CurrentClampStimulusSeriesData,
VoltageClampSeries,
VoltageClampSeriesData,
VoltageClampSeriesCapacitanceFast,
VoltageClampSeriesCapacitanceSlow,
VoltageClampSeriesResistanceCompBandwidth,
VoltageClampSeriesResistanceCompCorrection,
VoltageClampSeriesResistanceCompPrediction,
VoltageClampSeriesWholeCellCapacitanceComp,
VoltageClampSeriesWholeCellSeriesResistanceComp,
VoltageClampStimulusSeries,
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.file/",
"id": "core.nwb.file",
"imports": [
"core.nwb.base",
"../../hdmf_common/v1_5_0/namespace",
"core.nwb.device",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.epoch",
"core.nwb.misc",
"core.nwb.language",
],
"name": "core.nwb.file",
}
)
class ScratchData(NWBData):
@ -81,10 +185,10 @@ class ScratchData(NWBData):
Any one-off datasets
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
notes: Optional[str] = Field(
None, description="""Any notes the user has about the dataset being stored"""
)
notes: Optional[str] = Field(None, description="""Any notes the user has about the dataset being stored""")
class NWBFile(NWBContainer):
@ -92,69 +196,78 @@ class NWBFile(NWBContainer):
An NWB:N file storing cellular-based neurophysiology data from a single experimental session.
"""
name: Literal["root"] = Field("root")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: Literal["root"] = Field(
"root", json_schema_extra={"linkml_meta": {"equals_string": "root", "ifabsent": "string(root)"}}
)
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: NDArray[Shape["* num_modifications"], datetime] = Field(
file_create_date: NDArray[Shape["* num_modifications"], np.datetime64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_modifications"}]}}},
)
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.""",
..., description="""A description of the experimental session and data in the file."""
)
session_start_time: datetime = Field(
session_start_time: np.datetime64 = 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(
timestamps_reference_time: np.datetime64 = 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[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(
default_factory=dict,
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}},
)
analysis: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
analysis: Optional[List[Union[DynamicTable, NWBContainer]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
scratch: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
scratch: Optional[List[Union[DynamicTable, NWBContainer]]] = 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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
processing: Optional[List[ProcessingModule] | ProcessingModule] = Field(
default_factory=dict,
processing: Optional[List[ProcessingModule]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ProcessingModule"}]}},
)
stimulus: str = Field(
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: str = Field(
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[List[TimeIntervals] | TimeIntervals] = Field(
default_factory=dict,
intervals: Optional[List[TimeIntervals]] = 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.""",
json_schema_extra={
"linkml_meta": {
"any_of": [
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
]
}
},
)
units: Optional[str] = Field(None, description="""Data about sorted spike units.""")
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
class NWBFileStimulus(ConfiguredBaseModel):
@ -162,13 +275,20 @@ 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.
"""
name: Literal["stimulus"] = Field("stimulus")
presentation: Optional[List[TimeSeries] | TimeSeries] = Field(
default_factory=dict, description="""Stimuli presented during the experiment."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["stimulus"] = Field(
"stimulus", json_schema_extra={"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}}
)
templates: Optional[List[TimeSeries] | TimeSeries] = Field(
default_factory=dict,
presentation: Optional[List[TimeSeries]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
templates: Optional[List[TimeSeries]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
@ -177,22 +297,23 @@ 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: Literal["general"] = Field("general")
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."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["general"] = Field(
"general", json_schema_extra={"linkml_meta": {"equals_string": "general", "ifabsent": "string(general)"}}
)
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[NDArray[Shape["* num_experimenters"], str]] = Field(
None,
description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_experimenters"}]}}},
)
institution: Optional[str] = Field(
None, description="""Institution(s) where experiment was performed."""
)
institution: Optional[str] = Field(None, description="""Institution(s) where experiment was performed.""")
keywords: Optional[NDArray[Shape["* num_keywords"], str]] = Field(
None, description="""Terms to search over."""
None,
description="""Terms to search over.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_keywords"}]}}},
)
lab: Optional[str] = Field(None, description="""Laboratory where experiment was performed.""")
notes: Optional[str] = Field(None, description="""Notes about the experiment.""")
@ -201,24 +322,23 @@ class NWBFileGeneral(ConfiguredBaseModel):
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.""",
None, description="""Experimental protocol, if applicable. e.g., include IACUC protocol number."""
)
related_publications: Optional[NDArray[Shape["* num_publications"], str]] = Field(
None, description="""Publication information. PMID, DOI, URL, etc."""
None,
description="""Publication information. PMID, DOI, URL, etc.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_publications"}]}}},
)
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[str] = Field(
None,
description="""Script file or link to public source code used to create this NWB file.""",
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.""",
None, description="""Notes about stimuli, such as how and where they were presented."""
)
surgery: Optional[str] = Field(
None,
@ -228,30 +348,33 @@ class NWBFileGeneral(ConfiguredBaseModel):
None,
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
)
lab_meta_data: Optional[List[str] | str] = Field(
default_factory=list,
lab_meta_data: Optional[List[LabMetaData]] = Field(
None,
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
)
devices: Optional[List[Device] | Device] = Field(
default_factory=dict,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
)
subject: Optional[str] = Field(
devices: Optional[List[Device]] = Field(
None,
description="""Information about the animal or person from which the data was measured.""",
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
)
extracellular_ephys: Optional[str] = Field(
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[str] = Field(
intracellular_ephys: Optional[NWBFileGeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite] | OptogeneticStimulusSite] = Field(
default_factory=dict,
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane] | ImagingPlane] = Field(
default_factory=dict, description="""Metadata related to optophysiology."""
optophysiology: Optional[List[ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
)
@ -260,7 +383,12 @@ class NWBFileGeneralSourceScript(ConfiguredBaseModel):
Script file or link to public source code used to create this NWB file.
"""
name: Literal["source_script"] = Field("source_script")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["source_script"] = Field(
"source_script",
json_schema_extra={"linkml_meta": {"equals_string": "source_script", "ifabsent": "string(source_script)"}},
)
file_name: Optional[str] = Field(None, description="""Name of script file.""")
value: str = Field(...)
@ -270,13 +398,17 @@ class NWBFileGeneralExtracellularEphys(ConfiguredBaseModel):
Metadata related to extracellular electrophysiology.
"""
name: Literal["extracellular_ephys"] = Field("extracellular_ephys")
electrode_group: Optional[List[str] | str] = Field(
default_factory=list, description="""Physical group of electrodes."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["extracellular_ephys"] = Field(
"extracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "extracellular_ephys", "ifabsent": "string(extracellular_ephys)"}
},
)
electrodes: Optional[str] = Field(
None,
description="""A table of all electrodes (i.e. channels) used for recording.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(None, description="""Physical group of electrodes.""")
electrodes: Optional[NWBFileGeneralExtracellularEphysElectrodes] = Field(
None, description="""A table of all electrodes (i.e. channels) used for recording."""
)
@ -285,65 +417,104 @@ class NWBFileGeneralExtracellularEphysElectrodes(DynamicTable):
A table of all electrodes (i.e. channels) used for recording.
"""
name: Literal["electrodes"] = Field("electrodes")
x: Optional[List[float] | float] = Field(
default_factory=list,
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["electrodes"] = Field(
"electrodes",
json_schema_extra={"linkml_meta": {"equals_string": "electrodes", "ifabsent": "string(electrodes)"}},
)
x: NDArray[Any, np.float32] = Field(
...,
description="""x coordinate of the channel location in the brain (+x is posterior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
y: Optional[List[float] | float] = Field(
default_factory=list,
y: NDArray[Any, np.float32] = Field(
...,
description="""y coordinate of the channel location in the brain (+y is inferior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
z: Optional[List[float] | float] = Field(
default_factory=list,
z: NDArray[Any, np.float32] = Field(
...,
description="""z coordinate of the channel location in the brain (+z is right).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
imp: Optional[List[float] | float] = Field(
default_factory=list, description="""Impedance of the channel, in ohms."""
imp: NDArray[Any, np.float32] = Field(
...,
description="""Impedance of the channel, in ohms.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
location: Optional[List[str] | str] = Field(
default_factory=list,
location: NDArray[Any, str] = Field(
...,
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.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
filtering: Optional[List[float] | float] = Field(
default_factory=list,
filtering: NDArray[Any, np.float32] = Field(
...,
description="""Description of hardware filtering, including the filter name and frequency cutoffs.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
)
group_name: Optional[List[str] | str] = Field(
default_factory=list,
group_name: NDArray[Any, str] = Field(
...,
description="""Name of the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_x: Optional[List[float] | float] = Field(
default_factory=list, description="""x coordinate in electrode group"""
rel_x: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_y: Optional[List[float] | float] = Field(
default_factory=list, description="""y coordinate in electrode group"""
rel_y: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_z: Optional[List[float] | float] = Field(
default_factory=list, description="""z coordinate in electrode group"""
rel_z: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
reference: Optional[List[str] | str] = Field(
default_factory=list,
reference: Optional[NDArray[Any, str]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
@ -352,17 +523,23 @@ class NWBFileGeneralIntracellularEphys(ConfiguredBaseModel):
Metadata related to intracellular electrophysiology.
"""
name: Literal["intracellular_ephys"] = Field("intracellular_ephys")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["intracellular_ephys"] = Field(
"intracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "intracellular_ephys", "ifabsent": "string(intracellular_ephys)"}
},
)
filtering: Optional[str] = Field(
None,
description="""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.""",
)
intracellular_electrode: Optional[List[str] | str] = Field(
default_factory=list, description="""An intracellular electrode."""
intracellular_electrode: Optional[List[IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[str] = Field(
None,
description="""The table which groups different PatchClampSeries together.""",
sweep_table: Optional[SweepTable] = Field(
None, description="""The table which groups different PatchClampSeries together."""
)
@ -371,6 +548,8 @@ class LabMetaData(NWBContainer):
Lab-specific meta-data.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
@ -379,30 +558,37 @@ class Subject(NWBContainer):
Information about the animal or person from which the data was measured.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
age: Optional[str] = Field(
None,
description="""Age of subject. Can be supplied instead of 'date_of_birth'.""",
)
date_of_birth: Optional[datetime] = Field(
None,
description="""Date of birth of subject. Can be supplied instead of 'age'.""",
age: Optional[str] = Field(None, description="""Age of subject. Can be supplied instead of 'date_of_birth'.""")
date_of_birth: Optional[np.datetime64] = 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)."""
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).""",
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.""",
None, description="""Weight at time of experiment, at time of surgery and at other important times."""
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ScratchData.model_rebuild()
NWBFile.model_rebuild()
NWBFileStimulus.model_rebuild()
NWBFileGeneral.model_rebuild()
NWBFileGeneralSourceScript.model_rebuild()
NWBFileGeneralExtracellularEphys.model_rebuild()
NWBFileGeneralExtracellularEphysElectrodes.model_rebuild()
NWBFileGeneralIntracellularEphys.model_rebuild()
LabMetaData.model_rebuild()
Subject.model_rebuild()

View file

@ -1,68 +1,99 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
NWBContainer,
TimeSeriesSync,
TimeSeriesStartingTime,
TimeSeries,
)
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorIndex,
DynamicTable,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.icephys/",
"id": "core.nwb.icephys",
"imports": ["core.nwb.base", "core.nwb.device", "../../hdmf_common/v1_5_0/namespace", "core.nwb.language"],
"name": "core.nwb.icephys",
}
)
class PatchClampSeries(TimeSeries):
@ -70,41 +101,44 @@ class PatchClampSeries(TimeSeries):
An abstract base class for patch-clamp data - stimulus or response, current or voltage.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
data: str = Field(..., 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).""",
data: PatchClampSeriesData = Field(..., description="""Recorded voltage or current.""")
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -115,12 +149,18 @@ class PatchClampSeriesData(ConfiguredBaseModel):
Recorded voltage or current.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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"], float]] = Field(None)
array: Optional[NDArray[Shape["* num_times"], np.number]] = Field(
None, json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}}
)
class CurrentClampSeries(PatchClampSeries):
@ -128,46 +168,47 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = 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.""")
capacitance_compensation: Optional[float] = Field(
None, description="""Capacitance compensation, in farads."""
)
data: CurrentClampSeriesData = Field(..., description="""Recorded voltage.""")
bias_current: Optional[np.float32] = Field(None, description="""Bias current, in amps.""")
bridge_balance: Optional[np.float32] = Field(None, description="""Bridge balance, in ohms.""")
capacitance_compensation: Optional[np.float32] = Field(None, description="""Capacitance compensation, in farads.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -178,7 +219,11 @@ class CurrentClampSeriesData(ConfiguredBaseModel):
Recorded voltage.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -191,47 +236,49 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
stimulus_description: Optional[str] = Field(
None,
description="""An IZeroClampSeries has no stimulus, so this attribute is automatically set to \"N/A\"""",
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.""")
capacitance_compensation: float = Field(
bias_current: np.float32 = Field(..., description="""Bias current, in amps, fixed to 0.0.""")
bridge_balance: np.float32 = Field(..., description="""Bridge balance, in ohms, fixed to 0.0.""")
capacitance_compensation: np.float32 = Field(
..., description="""Capacitance compensation, in farads, fixed to 0.0."""
)
data: str = Field(..., description="""Recorded voltage.""")
sweep_number: Optional[int] = Field(
None,
description="""Sweep number, allows to group different PatchClampSeries together.""",
data: CurrentClampSeriesData = Field(..., description="""Recorded voltage.""")
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -242,41 +289,44 @@ class CurrentClampStimulusSeries(PatchClampSeries):
Stimulus current applied during current clamp recording.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Stimulus current applied.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -287,7 +337,11 @@ class CurrentClampStimulusSeriesData(ConfiguredBaseModel):
Stimulus current applied.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -300,58 +354,65 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Recorded current.""")
capacitance_fast: Optional[str] = Field(None, description="""Fast capacitance, in farads.""")
capacitance_slow: Optional[str] = Field(None, description="""Slow capacitance, in farads.""")
resistance_comp_bandwidth: Optional[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."""
)
resistance_comp_bandwidth: Optional[VoltageClampSeriesResistanceCompBandwidth] = Field(
None, description="""Resistance compensation bandwidth, in hertz."""
)
resistance_comp_correction: Optional[str] = Field(
resistance_comp_correction: Optional[VoltageClampSeriesResistanceCompCorrection] = Field(
None, description="""Resistance compensation correction, in percent."""
)
resistance_comp_prediction: Optional[str] = Field(
resistance_comp_prediction: Optional[VoltageClampSeriesResistanceCompPrediction] = Field(
None, description="""Resistance compensation prediction, in percent."""
)
whole_cell_capacitance_comp: Optional[str] = Field(
whole_cell_capacitance_comp: Optional[VoltageClampSeriesWholeCellCapacitanceComp] = Field(
None, description="""Whole cell capacitance compensation, in farads."""
)
whole_cell_series_resistance_comp: Optional[str] = Field(
whole_cell_series_resistance_comp: Optional[VoltageClampSeriesWholeCellSeriesResistanceComp] = Field(
None, description="""Whole cell series resistance compensation, in ohms."""
)
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -362,7 +423,11 @@ class VoltageClampSeriesData(ConfiguredBaseModel):
Recorded current.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -375,12 +440,18 @@ class VoltageClampSeriesCapacitanceFast(ConfiguredBaseModel):
Fast capacitance, in farads.
"""
name: Literal["capacitance_fast"] = Field("capacitance_fast")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["capacitance_fast"] = Field(
"capacitance_fast",
json_schema_extra={
"linkml_meta": {"equals_string": "capacitance_fast", "ifabsent": "string(capacitance_fast)"}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesCapacitanceSlow(ConfiguredBaseModel):
@ -388,12 +459,18 @@ class VoltageClampSeriesCapacitanceSlow(ConfiguredBaseModel):
Slow capacitance, in farads.
"""
name: Literal["capacitance_slow"] = Field("capacitance_slow")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["capacitance_slow"] = Field(
"capacitance_slow",
json_schema_extra={
"linkml_meta": {"equals_string": "capacitance_slow", "ifabsent": "string(capacitance_slow)"}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for capacitance_fast, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompBandwidth(ConfiguredBaseModel):
@ -401,12 +478,21 @@ class VoltageClampSeriesResistanceCompBandwidth(ConfiguredBaseModel):
Resistance compensation bandwidth, in hertz.
"""
name: Literal["resistance_comp_bandwidth"] = Field("resistance_comp_bandwidth")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_bandwidth, which is fixed to 'hertz'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_bandwidth"] = Field(
"resistance_comp_bandwidth",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_bandwidth",
"ifabsent": "string(resistance_comp_bandwidth)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_bandwidth, which is fixed to 'hertz'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompCorrection(ConfiguredBaseModel):
@ -414,12 +500,21 @@ class VoltageClampSeriesResistanceCompCorrection(ConfiguredBaseModel):
Resistance compensation correction, in percent.
"""
name: Literal["resistance_comp_correction"] = Field("resistance_comp_correction")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_correction, which is fixed to 'percent'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_correction"] = Field(
"resistance_comp_correction",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_correction",
"ifabsent": "string(resistance_comp_correction)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_correction, which is fixed to 'percent'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesResistanceCompPrediction(ConfiguredBaseModel):
@ -427,12 +522,21 @@ class VoltageClampSeriesResistanceCompPrediction(ConfiguredBaseModel):
Resistance compensation prediction, in percent.
"""
name: Literal["resistance_comp_prediction"] = Field("resistance_comp_prediction")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for resistance_comp_prediction, which is fixed to 'percent'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["resistance_comp_prediction"] = Field(
"resistance_comp_prediction",
json_schema_extra={
"linkml_meta": {
"equals_string": "resistance_comp_prediction",
"ifabsent": "string(resistance_comp_prediction)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for resistance_comp_prediction, which is fixed to 'percent'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesWholeCellCapacitanceComp(ConfiguredBaseModel):
@ -440,12 +544,21 @@ class VoltageClampSeriesWholeCellCapacitanceComp(ConfiguredBaseModel):
Whole cell capacitance compensation, in farads.
"""
name: Literal["whole_cell_capacitance_comp"] = Field("whole_cell_capacitance_comp")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for whole_cell_capacitance_comp, which is fixed to 'farads'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["whole_cell_capacitance_comp"] = Field(
"whole_cell_capacitance_comp",
json_schema_extra={
"linkml_meta": {
"equals_string": "whole_cell_capacitance_comp",
"ifabsent": "string(whole_cell_capacitance_comp)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for whole_cell_capacitance_comp, which is fixed to 'farads'."""
)
value: np.float32 = Field(...)
class VoltageClampSeriesWholeCellSeriesResistanceComp(ConfiguredBaseModel):
@ -453,12 +566,21 @@ class VoltageClampSeriesWholeCellSeriesResistanceComp(ConfiguredBaseModel):
Whole cell series resistance compensation, in ohms.
"""
name: Literal["whole_cell_series_resistance_comp"] = Field("whole_cell_series_resistance_comp")
unit: Optional[str] = Field(
None,
description="""Unit of measurement for whole_cell_series_resistance_comp, which is fixed to 'ohms'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["whole_cell_series_resistance_comp"] = Field(
"whole_cell_series_resistance_comp",
json_schema_extra={
"linkml_meta": {
"equals_string": "whole_cell_series_resistance_comp",
"ifabsent": "string(whole_cell_series_resistance_comp)",
}
},
)
value: float = Field(...)
unit: Optional[str] = Field(
None, description="""Unit of measurement for whole_cell_series_resistance_comp, which is fixed to 'ohms'."""
)
value: np.float32 = Field(...)
class VoltageClampStimulusSeries(PatchClampSeries):
@ -466,41 +588,44 @@ class VoltageClampStimulusSeries(PatchClampSeries):
Stimulus voltage applied during a voltage clamp recording.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Stimulus voltage applied.""")
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.""",
sweep_number: Optional[np.uint32] = Field(
None, description="""Sweep number, allows to group different PatchClampSeries together."""
)
gain: Optional[float] = Field(
None,
description="""Gain of the recording, in units Volt/Amp (v-clamp) or Volt/Volt (c-clamp).""",
gain: Optional[np.float32] = 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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -511,7 +636,11 @@ class VoltageClampStimulusSeriesData(ConfiguredBaseModel):
Stimulus voltage applied.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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'.""",
@ -524,24 +653,19 @@ class IntracellularElectrode(NWBContainer):
An intracellular electrode and its metadata.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
description: str = Field(
...,
description="""Description of electrode (e.g., whole-cell, sharp, etc.).""",
)
description: str = Field(..., description="""Description of electrode (e.g., whole-cell, sharp, etc.).""")
filtering: Optional[str] = Field(None, description="""Electrode specific filtering.""")
initial_access_resistance: Optional[str] = Field(
None, description="""Initial access resistance."""
)
initial_access_resistance: Optional[str] = Field(None, description="""Initial access resistance.""")
location: Optional[str] = Field(
None,
description="""Location of the electrode. 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.""",
)
resistance: Optional[str] = Field(None, description="""Electrode resistance, in ohms.""")
seal: Optional[str] = Field(None, description="""Information about seal used for recording.""")
slice: Optional[str] = Field(
None, description="""Information about slice used for recording."""
)
slice: Optional[str] = Field(None, description="""Information about slice used for recording.""")
class SweepTable(DynamicTable):
@ -549,51 +673,58 @@ class SweepTable(DynamicTable):
The table which groups different PatchClampSeries together.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.icephys", "tree_root": True})
name: str = Field(...)
sweep_number: Optional[List[int] | int] = Field(
default_factory=list,
sweep_number: NDArray[Any, np.uint32] = Field(
...,
description="""Sweep number of the PatchClampSeries in that row.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
series: Optional[List[str] | str] = Field(
default_factory=list,
description="""The PatchClampSeries with the sweep number in that row.""",
series: List[PatchClampSeries] = Field(
..., description="""The PatchClampSeries with the sweep number in that row."""
)
series_index: Named[VectorIndex] = Field(
...,
description="""Index for series.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
series_index: str = 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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SweepTableSeriesIndex(VectorIndex):
"""
Index for series.
"""
name: Literal["series_index"] = Field("series_index")
target: Optional[str] = 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[
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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
PatchClampSeries.model_rebuild()
PatchClampSeriesData.model_rebuild()
CurrentClampSeries.model_rebuild()
CurrentClampSeriesData.model_rebuild()
IZeroClampSeries.model_rebuild()
CurrentClampStimulusSeries.model_rebuild()
CurrentClampStimulusSeriesData.model_rebuild()
VoltageClampSeries.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()
VoltageClampStimulusSeries.model_rebuild()
VoltageClampStimulusSeriesData.model_rebuild()
IntracellularElectrode.model_rebuild()
SweepTable.model_rebuild()

View file

@ -1,57 +1,99 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import Image, TimeSeriesStartingTime, TimeSeries, TimeSeriesSync
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.image/",
"id": "core.nwb.image",
"imports": ["core.nwb.base", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.image",
}
)
class GrayscaleImage(Image):
@ -59,16 +101,18 @@ class GrayscaleImage(Image):
A grayscale image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -78,16 +122,18 @@ class RGBImage(Image):
A color image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -97,16 +143,18 @@ class RGBAImage(Image):
A color image with transparency.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -116,17 +164,18 @@ 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].
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -139,23 +188,26 @@ class ImageSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -166,12 +218,19 @@ 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.
"""
name: Literal["external_file"] = Field("external_file")
starting_frame: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image"})
name: Literal["external_file"] = Field(
"external_file",
json_schema_extra={"linkml_meta": {"equals_string": "external_file", "ifabsent": "string(external_file)"}},
)
starting_frame: Optional[np.int32] = 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 faciliate 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].""",
)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(None)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(
None, json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_files"}]}}}
)
class ImageMaskSeries(ImageSeries):
@ -179,17 +238,18 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -202,23 +262,26 @@ class ImageMaskSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -229,31 +292,26 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
distance: Optional[float] = Field(
None, description="""Distance from camera/monitor to target/eye."""
)
distance: Optional[np.float32] = Field(None, description="""Distance from camera/monitor to target/eye.""")
field_of_view: Optional[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height_depth"], float],
]
] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
)
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height_depth"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, 3 r_g_b"], float],
NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, 3 r_g_b"], np.number]
] = 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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -266,23 +324,26 @@ class OpticalSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -293,32 +354,51 @@ class IndexSeries(TimeSeries):
Stores indices to image frames stored in an ImageSeries. The purpose of the ImageIndexSeries is to allow a static image stack to be stored somewhere, 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 ImageSeries, and the timestamps array indicates when that image was displayed.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
..., description="""Index of the frame in the referenced ImageSeries."""
data: NDArray[Shape["* num_times"], np.int32] = Field(
...,
description="""Index of the frame in the referenced ImageSeries.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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()
ImageSeriesExternalFile.model_rebuild()
ImageMaskSeries.model_rebuild()
OpticalSeries.model_rebuild()
IndexSeries.model_rebuild()

View file

@ -1,66 +1,79 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_ecephys import ElectrodeGroup
from ...hdmf_common.v1_5_0.hdmf_common_table import (
DynamicTableRegion,
VectorIndex,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeriesSync, TimeSeriesStartingTime, TimeSeries
import numpy as np
from ...core.v2_3_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
from ...core.v2_3_0.core_nwb_ecephys import ElectrodeGroup
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_5_0.hdmf_common_table import DynamicTableRegion, DynamicTable, VectorData, VectorIndex
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.misc/",
"id": "core.nwb.misc",
"imports": ["core.nwb.base", "../../hdmf_common/v1_5_0/namespace", "core.nwb.ecephys", "core.nwb.language"],
"name": "core.nwb.misc",
}
)
class AbstractFeatureSeries(TimeSeries):
@ -68,37 +81,45 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Values of each feature at each time.""")
data: AbstractFeatureSeriesData = Field(..., description="""Values of each feature at each time.""")
feature_units: Optional[NDArray[Shape["* num_features"], str]] = Field(
None, description="""Units of each feature."""
None,
description="""Units of each feature.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of the features represented in TimeSeries::data.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -109,16 +130,17 @@ class AbstractFeatureSeriesData(ConfiguredBaseModel):
Values of each feature at each time.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_features"], float],
]
Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_features"], np.number]]
] = Field(None)
@ -127,32 +149,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], str] = Field(
..., description="""Annotations made during an experiment."""
...,
description="""Annotations made during an experiment.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -163,32 +192,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
..., description="""Use values >0 if interval started, <0 if interval ended."""
data: NDArray[Shape["* num_times"], np.int8] = Field(
...,
description="""Use values >0 if interval started, <0 if interval ended.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -199,14 +235,17 @@ class DecompositionSeries(TimeSeries):
Spectral analysis of a time series, e.g. of an LFP or a speech signal.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Data decomposed into frequency bands.""")
data: DecompositionSeriesData = Field(..., description="""Data decomposed into frequency bands.""")
metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""")
source_channels: Optional[str] = Field(
source_channels: Named[Optional[DynamicTableRegion]] = Field(
None,
description="""DynamicTableRegion pointer to the channels that this decomposition series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
bands: str = Field(
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.""",
)
@ -215,23 +254,26 @@ class DecompositionSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -242,35 +284,23 @@ class DecompositionSeriesData(ConfiguredBaseModel):
Data decomposed into frequency bands.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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"], float]] = Field(None)
class DecompositionSeriesSourceChannels(DynamicTableRegion):
"""
DynamicTableRegion pointer to the channels that this decomposition series was generated from.
"""
name: Literal["source_channels"] = Field("source_channels")
table: Optional[str] = Field(
array: Optional[NDArray[Shape["* num_times, * num_channels, * num_bands"], np.number]] = Field(
None,
description="""Reference to the DynamicTable object that this region applies to.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_times"}, {"alias": "num_channels"}, {"alias": "num_bands"}]}
}
},
)
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 DecompositionSeriesBands(DynamicTable):
@ -278,34 +308,49 @@ 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.
"""
name: Literal["bands"] = Field("bands")
band_name: Optional[List[str] | str] = Field(
default_factory=list, description="""Name of the band, e.g. theta."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["bands"] = Field(
"bands", json_schema_extra={"linkml_meta": {"equals_string": "bands", "ifabsent": "string(bands)"}}
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], float] = Field(
band_name: NDArray[Any, str] = Field(
...,
description="""Name of the band, e.g. theta.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], np.float32] = 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.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_bands"}, {"alias": "low_high", "exact_cardinality": 2}]}
}
},
)
band_mean: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The mean Gaussian filters, in Hz."""
band_mean: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The mean Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
band_stdev: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The standard deviation of Gaussian filters, in Hz."""
band_stdev: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The standard deviation of Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
@ -314,103 +359,102 @@ 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("Units")
spike_times_index: Optional[str] = Field(
None, description="""Index into the spike_times dataset."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
spike_times: Optional[str] = Field(None, description="""Spike times for each unit.""")
obs_intervals_index: Optional[str] = Field(
None, description="""Index into the obs_intervals dataset."""
spike_times: Optional[UnitsSpikeTimes] = Field(None, description="""Spike times for each unit.""")
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]] = Field(
None, description="""Observation intervals for each unit."""
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], np.float64]] = Field(
None,
description="""Observation intervals for each unit.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_intervals"}, {"alias": "start_end", "exact_cardinality": 2}]}
}
},
)
electrodes_index: Optional[str] = Field(None, description="""Index into electrodes.""")
electrodes: Optional[str] = Field(
electrodes_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrode_group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Electrode group that each spike unit came from.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform standard deviation for each spike unit.""")
waveforms: Optional[NDArray[Shape["* num_waveforms, * num_samples"], float]] = Field(
waveforms: Optional[NDArray[Shape["* num_waveforms, * num_samples"], np.number]] = 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.""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_waveforms"}, {"alias": "num_samples"}]}}
},
)
waveforms_index: Optional[str] = Field(
waveforms_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
waveforms_index_index: Optional[str] = Field(
waveforms_index_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class UnitsSpikeTimesIndex(VectorIndex):
"""
Index into the spike_times dataset.
"""
name: Literal["spike_times_index"] = Field("spike_times_index")
target: Optional[str] = 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[
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.
"""
name: Literal["spike_times"] = Field("spike_times")
resolution: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["spike_times"] = Field(
"spike_times",
json_schema_extra={"linkml_meta": {"equals_string": "spike_times", "ifabsent": "string(spike_times)"}},
)
resolution: Optional[np.float64] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -421,116 +465,14 @@ class UnitsSpikeTimes(VectorData):
] = Field(None)
class UnitsObsIntervalsIndex(VectorIndex):
"""
Index into the obs_intervals dataset.
"""
name: Literal["obs_intervals_index"] = Field("obs_intervals_index")
target: Optional[str] = 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[
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: Literal["electrodes_index"] = Field("electrodes_index")
target: Optional[str] = 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[
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: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 UnitsWaveformsIndex(VectorIndex):
"""
Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.
"""
name: Literal["waveforms_index"] = Field("waveforms_index")
target: Optional[str] = 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[
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: Literal["waveforms_index_index"] = Field("waveforms_index_index")
target: Optional[str] = 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[
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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
AbstractFeatureSeries.model_rebuild()
AbstractFeatureSeriesData.model_rebuild()
AnnotationSeries.model_rebuild()
IntervalSeries.model_rebuild()
DecompositionSeries.model_rebuild()
DecompositionSeriesData.model_rebuild()
DecompositionSeriesBands.model_rebuild()
Units.model_rebuild()
UnitsSpikeTimes.model_rebuild()

View file

@ -1,62 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeriesSync,
NWBContainer,
TimeSeriesStartingTime,
TimeSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from numpydantic import NDArray, Shape
from ...core.v2_3_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync, NWBContainer
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ogen/",
"id": "core.nwb.ogen",
"imports": ["core.nwb.base", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ogen",
}
)
class OptogeneticSeries(TimeSeries):
@ -64,32 +79,39 @@ class OptogeneticSeries(TimeSeries):
An optogenetic stimulus.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], float] = Field(
..., description="""Applied power for optogenetic stimulus, in watts."""
data: NDArray[Shape["* num_times"], np.number] = Field(
...,
description="""Applied power for optogenetic stimulus, in watts.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -100,10 +122,18 @@ class OptogeneticStimulusSite(NWBContainer):
A site of optogenetic stimulation.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
description: str = Field(..., description="""Description of stimulation site.""")
excitation_lambda: float = Field(..., description="""Excitation wavelength, in nm.""")
excitation_lambda: np.float32 = 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.""",
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
OptogeneticSeries.model_rebuild()
OptogeneticStimulusSite.model_rebuild()

View file

@ -1,72 +1,115 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
import numpy as np
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
TimeSeriesSync,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
DynamicTableRegion,
VectorIndex,
DynamicTable,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from .core_nwb_image import ImageSeries, ImageSeriesExternalFile
from ...core.v2_3_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ophys/",
"id": "core.nwb.ophys",
"imports": [
"core.nwb.image",
"core.nwb.base",
"../../hdmf_common/v1_5_0/namespace",
"core.nwb.device",
"core.nwb.language",
],
"name": "core.nwb.ophys",
}
)
class TwoPhotonSeries(ImageSeries):
@ -74,31 +117,26 @@ class TwoPhotonSeries(ImageSeries):
Image stack recorded over time from 2-photon microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[float] = Field(
pmt_gain: Optional[np.float32] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[np.float32] = 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[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height_depth"], float],
]
] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
)
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height_depth"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Optional[
Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
]
Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]]
] = Field(None, description="""Binary data representing images across frames.""")
dimension: Optional[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -111,23 +149,26 @@ class TwoPhotonSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -138,71 +179,57 @@ class RoiResponseSeries(TimeSeries):
ROI responses over an imaging plane. The first dimension represents time. The second dimension, if present, represents ROIs.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_rois"], float],
] = Field(..., description="""Signals from ROIs.""")
rois: str = Field(
data: Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_rois"], np.number]] = Field(
..., description="""Signals from ROIs."""
)
rois: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 RoiResponseSeriesRois(DynamicTableRegion):
"""
DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.
"""
name: Literal["rois"] = Field("rois")
table: Optional[str] = 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 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -211,7 +238,11 @@ 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -220,7 +251,11 @@ 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.
"""
children: Optional[List[PlaneSegmentation] | PlaneSegmentation] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[PlaneSegmentation]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "PlaneSegmentation"}]}}
)
name: str = Field(...)
@ -229,60 +264,63 @@ class PlaneSegmentation(DynamicTable):
Results from image segmentation of a specific imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
image_mask: Optional[
Union[
NDArray[Shape["* num_roi, * num_x, * num_y"], Any],
NDArray[Shape["* num_roi, * num_x, * num_y, * num_z"], Any],
]
] = 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[str] = Field(None, description="""Index into pixel_mask.""")
pixel_mask: Optional[str] = Field(
pixel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
pixel_mask: Optional[PlaneSegmentationPixelMask] = Field(
None,
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[str] = Field(None, description="""Index into voxel_mask.""")
voxel_mask: Optional[str] = Field(
voxel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
voxel_mask: Optional[PlaneSegmentationVoxelMask] = Field(
None,
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: Optional[List[ImageSeries] | ImageSeries] = Field(
default_factory=dict,
reference_images: Optional[List[ImageSeries]] = Field(
None,
description="""Image stacks that the segmentation masks apply to.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImageSeries"}]}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class PlaneSegmentationPixelMaskIndex(VectorIndex):
class PlaneSegmentationImageMask(VectorData):
"""
Index into pixel_mask.
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: Literal["pixel_mask_index"] = Field("pixel_mask_index")
target: Optional[str] = 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."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["image_mask"] = Field(
"image_mask",
json_schema_extra={"linkml_meta": {"equals_string": "image_mask", "ifabsent": "string(image_mask)"}},
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -298,36 +336,16 @@ class PlaneSegmentationPixelMask(VectorData):
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
"""
name: Literal["pixel_mask"] = Field("pixel_mask")
x: Optional[int] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[int] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the pixel.""")
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)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
class PlaneSegmentationVoxelMaskIndex(VectorIndex):
"""
Index into voxel_mask.
"""
name: Literal["voxel_mask_index"] = Field("voxel_mask_index")
target: Optional[str] = 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."""
name: Literal["pixel_mask"] = Field(
"pixel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "pixel_mask", "ifabsent": "string(pixel_mask)"}},
)
x: Optional[np.uint32] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the pixel.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -343,14 +361,17 @@ class PlaneSegmentationVoxelMask(VectorData):
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
"""
name: Literal["voxel_mask"] = Field("voxel_mask")
x: Optional[int] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[int] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[int] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["voxel_mask"] = Field(
"voxel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "voxel_mask", "ifabsent": "string(voxel_mask)"}},
)
x: Optional[np.uint32] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[np.uint32] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -366,7 +387,11 @@ class ImagingPlane(NWBContainer):
An imaging plane and its metadata.
"""
children: Optional[List[OpticalChannel] | OpticalChannel] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[OpticalChannel]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "OpticalChannel"}]}}
)
name: str = Field(...)
@ -375,9 +400,11 @@ class OpticalChannel(NWBContainer):
An optical channel used to record from an imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
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.""")
emission_lambda: np.float32 = Field(..., description="""Emission wavelength for channel, in nm.""")
class MotionCorrection(NWBDataInterface):
@ -385,8 +412,10 @@ 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).
"""
children: Optional[List[CorrectedImageStack] | CorrectedImageStack] = Field(
default_factory=dict
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[CorrectedImageStack]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "CorrectedImageStack"}]}}
)
name: str = Field(...)
@ -396,12 +425,28 @@ class CorrectedImageStack(NWBDataInterface):
Reuslts from motion correction of an image stack.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
corrected: str = Field(
...,
description="""Image stack with frames shifted to the common coordinates.""",
)
xy_translation: 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.""",
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
TwoPhotonSeries.model_rebuild()
RoiResponseSeries.model_rebuild()
DfOverF.model_rebuild()
Fluorescence.model_rebuild()
ImageSegmentation.model_rebuild()
PlaneSegmentation.model_rebuild()
PlaneSegmentationImageMask.model_rebuild()
PlaneSegmentationPixelMask.model_rebuild()
PlaneSegmentationVoxelMask.model_rebuild()
ImagingPlane.model_rebuild()
OpticalChannel.model_rebuild()
MotionCorrection.model_rebuild()
CorrectedImageStack.model_rebuild()

View file

@ -1,57 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBDataInterface
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_3_0.core_nwb_base import NWBDataInterface
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.retinotopy/",
"id": "core.nwb.retinotopy",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.retinotopy",
}
)
class ImagingRetinotopy(NWBDataInterface):
@ -59,36 +79,39 @@ 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("ImagingRetinotopy")
axis_1_phase_map: str = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy", "tree_root": True})
name: str = Field("ImagingRetinotopy", json_schema_extra={"linkml_meta": {"ifabsent": "string(ImagingRetinotopy)"}})
axis_1_phase_map: ImagingRetinotopyAxis1PhaseMap = Field(
..., description="""Phase response to stimulus on the first measured axis."""
)
axis_1_power_map: Optional[str] = Field(
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: str = Field(
axis_2_phase_map: ImagingRetinotopyAxis2PhaseMap = Field(
..., description="""Phase response to stimulus on the second measured axis."""
)
axis_2_power_map: Optional[str] = Field(
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: NDArray[Shape["2 axis_1_axis_2"], str] = Field(
...,
description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "axis_1_axis_2", "exact_cardinality": 2}]}}
},
)
focal_depth_image: Optional[str] = Field(
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[str] = Field(
None,
description="""Sine of the angle between the direction of the gradient in axis_1 and axis_2.""",
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: str = Field(
...,
description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]""",
vasculature_image: ImagingRetinotopyVasculatureImage = Field(
..., description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]"""
)
@ -97,16 +120,24 @@ class ImagingRetinotopyAxis1PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the first measured axis.
"""
name: Literal["axis_1_phase_map"] = Field("axis_1_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_phase_map"] = Field(
"axis_1_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_phase_map", "ifabsent": "string(axis_1_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis1PowerMap(ConfiguredBaseModel):
@ -114,16 +145,24 @@ 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: Literal["axis_1_power_map"] = Field("axis_1_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_power_map"] = Field(
"axis_1_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_power_map", "ifabsent": "string(axis_1_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
@ -131,16 +170,24 @@ class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the second measured axis.
"""
name: Literal["axis_2_phase_map"] = Field("axis_2_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_phase_map"] = Field(
"axis_2_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_phase_map", "ifabsent": "string(axis_2_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PowerMap(ConfiguredBaseModel):
@ -148,16 +195,24 @@ 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: Literal["axis_2_power_map"] = Field("axis_2_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_power_map"] = Field(
"axis_2_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_power_map", "ifabsent": "string(axis_2_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
@ -165,21 +220,29 @@ class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns].
"""
name: Literal["focal_depth_image"] = Field("focal_depth_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["focal_depth_image"] = Field(
"focal_depth_image",
json_schema_extra={
"linkml_meta": {"equals_string": "focal_depth_image", "ifabsent": "string(focal_depth_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value.""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
focal_depth: Optional[float] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
focal_depth: Optional[np.float32] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
class ImagingRetinotopySignMap(ConfiguredBaseModel):
@ -187,13 +250,20 @@ class ImagingRetinotopySignMap(ConfiguredBaseModel):
Sine of the angle between the direction of the gradient in axis_1 and axis_2.
"""
name: Literal["sign_map"] = Field("sign_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["sign_map"] = Field(
"sign_map", json_schema_extra={"linkml_meta": {"equals_string": "sign_map", "ifabsent": "string(sign_map)"}}
)
dimension: Optional[np.int32] = 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"], float]] = Field(None)
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
@ -201,17 +271,37 @@ class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]
"""
name: Literal["vasculature_image"] = Field("vasculature_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["vasculature_image"] = Field(
"vasculature_image",
json_schema_extra={
"linkml_meta": {"equals_string": "vasculature_image", "ifabsent": "string(vasculature_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ImagingRetinotopy.model_rebuild()
ImagingRetinotopyAxis1PhaseMap.model_rebuild()
ImagingRetinotopyAxis1PowerMap.model_rebuild()
ImagingRetinotopyAxis2PhaseMap.model_rebuild()
ImagingRetinotopyAxis2PowerMap.model_rebuild()
ImagingRetinotopyFocalDepthImage.model_rebuild()
ImagingRetinotopySignMap.model_rebuild()
ImagingRetinotopyVasculatureImage.model_rebuild()

View file

@ -1,32 +1,12 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_experimental.v0_1_0.hdmf_experimental_resources import (
ExternalResources,
ExternalResourcesKeys,
@ -35,11 +15,8 @@ from ...hdmf_experimental.v0_1_0.hdmf_experimental_resources import (
ExternalResourcesObjects,
ExternalResourcesObjectKeys,
)
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
@ -48,10 +25,8 @@ from ...hdmf_common.v1_5_0.hdmf_common_table import (
DynamicTable,
AlignedDynamicTable,
)
from ...hdmf_experimental.v0_1_0.hdmf_experimental_experimental import EnumData
from .core_nwb_retinotopy import (
from ...core.v2_3_0.core_nwb_retinotopy import (
ImagingRetinotopy,
ImagingRetinotopyAxis1PhaseMap,
ImagingRetinotopyAxis1PowerMap,
@ -61,8 +36,7 @@ from .core_nwb_retinotopy import (
ImagingRetinotopySignMap,
ImagingRetinotopyVasculatureImage,
)
from .core_nwb_base import (
from ...core.v2_3_0.core_nwb_base import (
NWBData,
Image,
NWBContainer,
@ -74,28 +48,23 @@ from .core_nwb_base import (
ProcessingModule,
Images,
)
from .core_nwb_ophys import (
from ...core.v2_3_0.core_nwb_ophys import (
TwoPhotonSeries,
RoiResponseSeries,
RoiResponseSeriesRois,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationPixelMaskIndex,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMaskIndex,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from .core_nwb_device import Device
from .core_nwb_image import (
from ...core.v2_3_0.core_nwb_device import Device
from ...core.v2_3_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
@ -105,10 +74,8 @@ from .core_nwb_image import (
OpticalSeries,
IndexSeries,
)
from .core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from .core_nwb_icephys import (
from ...core.v2_3_0.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_3_0.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
@ -129,15 +96,11 @@ from .core_nwb_icephys import (
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
SweepTableSeriesIndex,
)
from .core_nwb_ecephys import (
from ...core.v2_3_0.core_nwb_ecephys import (
ElectricalSeries,
ElectricalSeriesElectrodes,
SpikeEventSeries,
FeatureExtraction,
FeatureExtractionElectrodes,
EventDetection,
EventWaveform,
FilteredEphys,
@ -147,8 +110,7 @@ from .core_nwb_ecephys import (
ClusterWaveforms,
Clustering,
)
from .core_nwb_behavior import (
from ...core.v2_3_0.core_nwb_behavior import (
SpatialSeries,
SpatialSeriesData,
BehavioralEpochs,
@ -159,27 +121,18 @@ from .core_nwb_behavior import (
CompassDirection,
Position,
)
from .core_nwb_misc import (
from ...core.v2_3_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesSourceChannels,
DecompositionSeriesBands,
Units,
UnitsSpikeTimesIndex,
UnitsSpikeTimes,
UnitsObsIntervalsIndex,
UnitsElectrodesIndex,
UnitsElectrodes,
UnitsWaveformsIndex,
UnitsWaveformsIndexIndex,
)
from .core_nwb_file import (
from ...core.v2_3_0.core_nwb_file import (
ScratchData,
NWBFile,
NWBFileStimulus,
@ -191,34 +144,72 @@ from .core_nwb_file import (
LabMetaData,
Subject,
)
from .core_nwb_epoch import (
TimeIntervals,
TimeIntervalsTagsIndex,
TimeIntervalsTimeseries,
TimeIntervalsTimeseriesIndex,
)
from ...core.v2_3_0.core_nwb_epoch import TimeIntervals, TimeIntervalsTimeseries
metamodel_version = "None"
version = "2.3.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": True},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core/",
"description": "NWB namespace",
"id": "core",
"imports": [
"core.nwb.base",
"core.nwb.device",
"core.nwb.epoch",
"core.nwb.image",
"core.nwb.file",
"core.nwb.misc",
"core.nwb.behavior",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.retinotopy",
"core.nwb.language",
"../../hdmf_common/v1_5_0/namespace",
"../../hdmf_experimental/v0_1_0/namespace",
],
"name": "core",
}
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model

View file

@ -1,59 +1,78 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTable, VectorData
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_8_0.hdmf_common_table import VectorData, DynamicTable
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.base/",
"id": "core.nwb.base",
"imports": ["../../hdmf_common/v1_8_0/namespace", "../../hdmf_common/v1_8_0/namespace", "core.nwb.language"],
"name": "core.nwb.base",
}
)
class NWBData(Data):
@ -61,6 +80,8 @@ class NWBData(Data):
An abstract data type for a dataset.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -69,19 +90,18 @@ 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("timeseries")
idx_start: int = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field("timeseries", json_schema_extra={"linkml_meta": {"ifabsent": "string(timeseries)"}})
idx_start: np.int32 = Field(
...,
description="""Start index into the TimeSeries 'data' and 'timestamp' datasets of the referenced TimeSeries. The first dimension of those arrays is always time.""",
)
count: int = Field(
...,
description="""Number of data samples available in this time series, during this epoch""",
)
timeseries: str = Field(..., description="""The TimeSeries that this index applies to""")
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
count: np.int32 = Field(
..., description="""Number of data samples available in this time series, during this epoch"""
)
timeseries: TimeSeries = Field(..., description="""The TimeSeries that this index applies to""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -97,16 +117,18 @@ 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)).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -116,11 +138,9 @@ class ImageReferences(NWBData):
Ordered dataset of references to Image objects.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
image: List[str] | str = Field(
default_factory=list,
description="""Ordered dataset of references to Image objects.""",
)
class NWBContainer(Container):
@ -128,6 +148,8 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -136,6 +158,8 @@ class NWBDataInterface(NWBContainer):
An abstract data type for a generic container storing collections of data, as opposed to metadata.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field(...)
@ -144,33 +168,38 @@ class TimeSeries(NWBDataInterface):
General purpose time series.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
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: str = Field(
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -181,16 +210,20 @@ 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: Literal["data"] = Field("data")
conversion: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
conversion: Optional[np.float32] = 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(
offset: Optional[np.float32] = 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(
resolution: Optional[np.float32] = 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.""",
)
@ -217,13 +250,15 @@ 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: Literal["starting_time"] = Field("starting_time")
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'.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["starting_time"] = Field(
"starting_time",
json_schema_extra={"linkml_meta": {"equals_string": "starting_time", "ifabsent": "string(starting_time)"}},
)
value: float = Field(...)
rate: Optional[np.float32] = Field(None, description="""Sampling rate, in Hz.""")
unit: Optional[str] = Field(None, description="""Unit of measurement for time, which is fixed to 'seconds'.""")
value: np.float64 = Field(...)
class TimeSeriesSync(ConfiguredBaseModel):
@ -231,7 +266,11 @@ 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.
"""
name: Literal["sync"] = Field("sync")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base"})
name: Literal["sync"] = Field(
"sync", json_schema_extra={"linkml_meta": {"equals_string": "sync", "ifabsent": "string(sync)"}}
)
class ProcessingModule(NWBContainer):
@ -239,10 +278,11 @@ class ProcessingModule(NWBContainer):
A collection of processed data.
"""
children: Optional[
List[Union[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
children: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}}
)
name: str = Field(...)
@ -251,26 +291,29 @@ 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("Images")
description: Optional[str] = Field(
None, description="""Description of this collection of images."""
)
image: List[str] | str = Field(
default_factory=list, description="""Images stored in this collection."""
)
order_of_images: Optional[str] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.base", "tree_root": True})
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: Optional[str] = Field(None, description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
order_of_images: Named[Optional[ImageReferences]] = 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.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": 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.
"""
name: Literal["order_of_images"] = Field("order_of_images")
image: List[str] | str = Field(
default_factory=list,
description="""Ordered dataset of references to Image objects.""",
)
# 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()
TimeSeriesData.model_rebuild()
TimeSeriesStartingTime.model_rebuild()
TimeSeriesSync.model_rebuild()
ProcessingModule.model_rebuild()
Images.model_rebuild()

View file

@ -1,64 +1,125 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeriesSync,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_7_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from .core_nwb_misc import IntervalSeries
from ...core.v2_7_0.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_7_0.core_nwb_device import Device
from ...core.v2_7_0.core_nwb_base import (
NWBData,
TimeSeriesReferenceVectorData,
Image,
ImageReferences,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.behavior/",
"id": "core.nwb.behavior",
"imports": ["core.nwb.base", "core.nwb.misc", "core.nwb.language"],
"name": "core.nwb.behavior",
}
)
class SpatialSeries(TimeSeries):
@ -66,37 +127,40 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
name: str = Field(...)
data: str = Field(
...,
description="""1-D or 2-D array storing position or direction relative to some reference frame.""",
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.""",
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -107,17 +171,21 @@ class SpatialSeriesData(ConfiguredBaseModel):
1-D or 2-D array storing position or direction relative to some reference frame.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, 1 x"], float],
NDArray[Shape["* num_times, 2 x_y"], float],
NDArray[Shape["* num_times, 3 x_y_z"], float],
NDArray[Shape["* num_times"], np.number],
NDArray[Shape["* num_times, 1 x"], np.number],
NDArray[Shape["* num_times, 2 x_y"], np.number],
NDArray[Shape["* num_times, 3 x_y_z"], np.number],
]
] = Field(None)
@ -127,7 +195,11 @@ 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.
"""
children: Optional[List[IntervalSeries] | IntervalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -136,7 +208,11 @@ class BehavioralEvents(NWBDataInterface):
TimeSeries for storing behavioral events. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -145,7 +221,11 @@ class BehavioralTimeSeries(NWBDataInterface):
TimeSeries for storing Behavoioral time series data. See description of <a href=\"#BehavioralEpochs\">BehavioralEpochs</a> for more details.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -154,7 +234,11 @@ class PupilTracking(NWBDataInterface):
Eye-tracking data, representing pupil size.
"""
children: Optional[List[TimeSeries] | TimeSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -163,7 +247,11 @@ class EyeTracking(NWBDataInterface):
Eye-tracking data, representing direction of gaze.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -172,7 +260,11 @@ 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.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -181,5 +273,22 @@ class Position(NWBDataInterface):
Position data, whether along the x, x/y or x/y/z axis.
"""
children: Optional[List[SpatialSeries] | SpatialSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.behavior", "tree_root": True})
children: Optional[List[SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
SpatialSeries.model_rebuild()
SpatialSeriesData.model_rebuild()
BehavioralEpochs.model_rebuild()
BehavioralEvents.model_rebuild()
BehavioralTimeSeries.model_rebuild()
PupilTracking.model_rebuild()
EyeTracking.model_rebuild()
CompassDirection.model_rebuild()
Position.model_rebuild()

View file

@ -1,57 +1,60 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBContainer
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_7_0.core_nwb_base import NWBContainer
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.device/",
"id": "core.nwb.device",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.device",
}
)
class Device(NWBContainer):
@ -59,11 +62,16 @@ class Device(NWBContainer):
Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.device", "tree_root": True})
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."""
)
manufacturer: Optional[str] = Field(None, description="""The name of the manufacturer of the device.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
Device.model_rebuild()

View file

@ -1,65 +1,84 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTableRegion, DynamicTable
from .core_nwb_base import (
NWBContainer,
TimeSeriesStartingTime,
NWBDataInterface,
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTableRegion
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from ...core.v2_7_0.core_nwb_base import (
TimeSeries,
TimeSeriesStartingTime,
TimeSeriesSync,
NWBDataInterface,
NWBContainer,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
NUMPYDANTIC_VERSION = "1.2.1"
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ecephys/",
"id": "core.nwb.ecephys",
"imports": ["core.nwb.base", "../../hdmf_common/v1_8_0/namespace", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ecephys",
}
)
class ElectricalSeries(TimeSeries):
@ -67,118 +86,109 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
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: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_channels"], float],
NDArray[Shape["* num_times, * num_channels, * num_samples"], float],
NDArray[Shape["* num_times"], np.number],
NDArray[Shape["* num_times, * num_channels"], np.number],
NDArray[Shape["* num_times, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Recorded voltage data.""")
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 ElectricalSeriesElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 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).
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_events, * num_channels, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], float],
NDArray[Shape["* num_events, * num_samples"], np.number],
NDArray[Shape["* num_events, * num_channels, * num_samples"], np.number],
] = Field(..., description="""Spike waveforms.""")
timestamps: NDArray[Shape["* num_times"], float] = Field(
timestamps: NDArray[Shape["* num_times"], np.float64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
channel_conversion: Optional[NDArray[Shape["* num_channels"], float]] = Field(
channel_conversion: Optional[NDArray[Shape["* num_channels"], np.float32]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_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[str] = Field(
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[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -189,64 +199,56 @@ class FeatureExtraction(NWBDataInterface):
Features, such as PC1 and PC2, that are extracted from signals stored in a SpikeEventSeries or other source.
"""
name: str = Field("FeatureExtraction")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("FeatureExtraction", json_schema_extra={"linkml_meta": {"ifabsent": "string(FeatureExtraction)"}})
description: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of features (eg, ''PC1'') for each of the extracted features.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_events, * num_channels, * num_features"], float] = Field(
features: NDArray[Shape["* num_events, * num_channels, * num_features"], np.float32] = Field(
...,
description="""Multi-dimensional array of features extracted from each event.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_events"}, {"alias": "num_channels"}, {"alias": "num_features"}]}
}
},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of events that features correspond to (can be a link).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
electrodes: str = Field(
electrodes: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion pointer to the electrodes that this time series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
class FeatureExtractionElectrodes(DynamicTableRegion):
"""
DynamicTableRegion pointer to the electrodes that this time series was generated from.
"""
name: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 EventDetection(NWBDataInterface):
"""
Detected spike events from voltage trace(s).
"""
name: str = Field("EventDetection")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("EventDetection", json_schema_extra={"linkml_meta": {"ifabsent": "string(EventDetection)"}})
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: NDArray[Shape["* num_events"], int] = Field(
source_idx: NDArray[Shape["* num_events"], np.int32] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
..., description="""Timestamps of events, in seconds."""
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Timestamps of events, in seconds.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
@ -255,7 +257,11 @@ 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.
"""
children: Optional[List[SpikeEventSeries] | SpikeEventSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -264,7 +270,11 @@ 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.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -273,7 +283,11 @@ 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.
"""
children: Optional[List[ElectricalSeries] | ElectricalSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
children: Optional[List[ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -282,13 +296,15 @@ class ElectrodeGroup(NWBContainer):
A physical grouping of electrodes, e.g. a shank of an array.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
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[str] = Field(
position: Optional[ElectrodeGroupPosition] = Field(
None, description="""stereotaxic or common framework coordinates"""
)
@ -298,10 +314,14 @@ class ElectrodeGroupPosition(ConfiguredBaseModel):
stereotaxic or common framework coordinates
"""
name: Literal["position"] = Field("position")
x: Optional[float] = Field(None, description="""x coordinate""")
y: Optional[float] = Field(None, description="""y coordinate""")
z: Optional[float] = Field(None, description="""z coordinate""")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys"})
name: Literal["position"] = Field(
"position", json_schema_extra={"linkml_meta": {"equals_string": "position", "ifabsent": "string(position)"}}
)
x: Optional[np.float32] = Field(None, description="""x coordinate""")
y: Optional[np.float32] = Field(None, description="""y coordinate""")
z: Optional[np.float32] = Field(None, description="""z coordinate""")
class ClusterWaveforms(NWBDataInterface):
@ -309,17 +329,23 @@ 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("ClusterWaveforms")
waveform_filtering: str = Field(
..., description="""Filtering applied to data before generating mean/sd"""
)
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("ClusterWaveforms", json_schema_extra={"linkml_meta": {"ifabsent": "string(ClusterWaveforms)"}})
waveform_filtering: str = Field(..., description="""Filtering applied to data before generating mean/sd""")
waveform_mean: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = 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)""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], float] = Field(
waveform_sd: NDArray[Shape["* num_clusters, * num_samples"], np.float32] = Field(
...,
description="""Stdev of waveforms for each cluster, using the same indices as in mean""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}, {"alias": "num_samples"}]}}
},
)
@ -328,19 +354,40 @@ 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("Clustering")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ecephys", "tree_root": True})
name: str = Field("Clustering", json_schema_extra={"linkml_meta": {"ifabsent": "string(Clustering)"}})
description: str = Field(
...,
description="""Description of clusters or clustering, (e.g. cluster 0 is noise, clusters curated using Klusters, etc)""",
)
num: NDArray[Shape["* num_events"], int] = Field(
..., description="""Cluster number of each event"""
num: NDArray[Shape["* num_events"], np.int32] = Field(
...,
description="""Cluster number of each event""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
peak_over_rms: NDArray[Shape["* num_clusters"], float] = Field(
peak_over_rms: NDArray[Shape["* num_clusters"], np.float32] = Field(
...,
description="""Maximum ratio of waveform peak to RMS on any channel in the cluster (provides a basic clustering metric).""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_clusters"}]}}},
)
times: NDArray[Shape["* num_events"], float] = Field(
times: NDArray[Shape["* num_events"], np.float64] = Field(
...,
description="""Times of clustered events, in seconds. This may be a link to times field in associated FeatureExtraction module.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_events"}]}}},
)
# 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()
ElectrodeGroupPosition.model_rebuild()
ClusterWaveforms.model_rebuild()
Clustering.model_rebuild()

View file

@ -1,63 +1,78 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorIndex,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeriesReferenceVectorData, TimeSeries
import numpy as np
from ...core.v2_7_0.core_nwb_base import TimeSeriesReferenceVectorData
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTable, VectorIndex, VectorData
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.epoch/",
"id": "core.nwb.epoch",
"imports": ["../../hdmf_common/v1_8_0/namespace", "core.nwb.base", "core.nwb.language"],
"name": "core.nwb.epoch",
}
)
class TimeIntervals(DynamicTable):
@ -65,106 +80,60 @@ class TimeIntervals(DynamicTable):
A container for aggregating epoch data and the TimeSeries that each epoch applies to.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.epoch", "tree_root": True})
name: str = Field(...)
start_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Start time of epoch, in seconds."""
start_time: NDArray[Any, np.float32] = Field(
...,
description="""Start time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
stop_time: Optional[List[float] | float] = Field(
default_factory=list, description="""Stop time of epoch, in seconds."""
stop_time: NDArray[Any, np.float32] = Field(
...,
description="""Stop time of epoch, in seconds.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags: Optional[List[str] | str] = Field(
default_factory=list,
tags: Optional[NDArray[Any, str]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
timeseries: Named[Optional[TimeSeriesReferenceVectorData]] = Field(
None,
description="""An index into a TimeSeries object.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
tags_index: Optional[str] = Field(None, description="""Index for tags.""")
timeseries: Optional[str] = Field(None, description="""An index into a TimeSeries object.""")
timeseries_index: Optional[str] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class TimeIntervalsTagsIndex(VectorIndex):
"""
Index for tags.
"""
name: Literal["tags_index"] = Field("tags_index")
target: Optional[str] = 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[
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: Literal["timeseries"] = Field("timeseries")
idx_start: int = Field(
...,
description="""Start index into the TimeSeries 'data' and 'timestamp' datasets of the referenced TimeSeries. The first dimension of those arrays is always time.""",
)
count: int = Field(
...,
description="""Number of data samples available in this time series, during this epoch""",
)
timeseries: str = Field(..., description="""The TimeSeries that this index applies to""")
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 TimeIntervalsTimeseriesIndex(VectorIndex):
"""
Index for timeseries.
"""
name: Literal["timeseries_index"] = Field("timeseries_index")
target: Optional[str] = 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[
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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
TimeIntervals.model_rebuild()

View file

@ -1,88 +1,198 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_icephys import (
SweepTable,
SimultaneousRecordingsTable,
SequentialRecordingsTable,
RepetitionsTable,
ExperimentalConditionsTable,
IntracellularElectrode,
IntracellularRecordingsTable,
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_7_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesBands,
Units,
UnitsSpikeTimes,
)
from .core_nwb_epoch import TimeIntervals
from .core_nwb_ecephys import ElectrodeGroup
from .core_nwb_base import (
NWBContainer,
ProcessingModule,
Images,
from ...core.v2_7_0.core_nwb_ecephys import (
ElectricalSeries,
SpikeEventSeries,
FeatureExtraction,
EventDetection,
EventWaveform,
FilteredEphys,
LFP,
ElectrodeGroup,
ElectrodeGroupPosition,
ClusterWaveforms,
Clustering,
)
from ...core.v2_7_0.core_nwb_device import Device
from ...core.v2_7_0.core_nwb_base import (
NWBData,
TimeSeriesReferenceVectorData,
Image,
ImageReferences,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from .core_nwb_device import Device
from .core_nwb_misc import Units
from .core_nwb_ogen import OptogeneticStimulusSite
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTable, VectorData
from .core_nwb_ophys import ImagingPlane
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from ...core.v2_7_0.core_nwb_epoch import TimeIntervals
from ...core.v2_7_0.core_nwb_ophys import (
OnePhotonSeries,
TwoPhotonSeries,
RoiResponseSeries,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from ...core.v2_7_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from ...core.v2_7_0.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_7_0.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
CurrentClampSeriesData,
IZeroClampSeries,
CurrentClampStimulusSeries,
CurrentClampStimulusSeriesData,
VoltageClampSeries,
VoltageClampSeriesData,
VoltageClampSeriesCapacitanceFast,
VoltageClampSeriesCapacitanceSlow,
VoltageClampSeriesResistanceCompBandwidth,
VoltageClampSeriesResistanceCompCorrection,
VoltageClampSeriesResistanceCompPrediction,
VoltageClampSeriesWholeCellCapacitanceComp,
VoltageClampSeriesWholeCellSeriesResistanceComp,
VoltageClampStimulusSeries,
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
IntracellularElectrodesTable,
IntracellularStimuliTable,
IntracellularResponsesTable,
IntracellularRecordingsTable,
SimultaneousRecordingsTable,
SimultaneousRecordingsTableRecordings,
SequentialRecordingsTable,
SequentialRecordingsTableSimultaneousRecordings,
RepetitionsTable,
RepetitionsTableSequentialRecordings,
ExperimentalConditionsTable,
ExperimentalConditionsTableRepetitions,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.file/",
"id": "core.nwb.file",
"imports": [
"core.nwb.base",
"../../hdmf_common/v1_8_0/namespace",
"core.nwb.device",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.epoch",
"core.nwb.misc",
"core.nwb.language",
],
"name": "core.nwb.file",
}
)
class ScratchData(NWBData):
@ -90,10 +200,10 @@ class ScratchData(NWBData):
Any one-off datasets
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
notes: Optional[str] = Field(
None, description="""Any notes the user has about the dataset being stored"""
)
notes: Optional[str] = Field(None, description="""Any notes the user has about the dataset being stored""")
class NWBFile(NWBContainer):
@ -101,69 +211,78 @@ class NWBFile(NWBContainer):
An NWB file storing cellular-based neurophysiology data from a single experimental session.
"""
name: Literal["root"] = Field("root")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: Literal["root"] = Field(
"root", json_schema_extra={"linkml_meta": {"equals_string": "root", "ifabsent": "string(root)"}}
)
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: NDArray[Shape["* num_modifications"], datetime] = Field(
file_create_date: NDArray[Shape["* num_modifications"], np.datetime64] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_modifications"}]}}},
)
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.""",
..., description="""A description of the experimental session and data in the file."""
)
session_start_time: datetime = Field(
session_start_time: np.datetime64 = 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(
timestamps_reference_time: np.datetime64 = 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[BaseModel, DynamicTable, NWBDataInterface]]
| Union[BaseModel, DynamicTable, NWBDataInterface]
] = Field(
default_factory=dict,
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}},
)
analysis: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
analysis: Optional[List[Union[DynamicTable, NWBContainer]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
scratch: Optional[
List[Union[BaseModel, DynamicTable, NWBContainer]]
| Union[BaseModel, DynamicTable, NWBContainer]
] = Field(
default_factory=dict,
scratch: Optional[List[Union[DynamicTable, NWBContainer]]] = 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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "NWBContainer"}, {"range": "DynamicTable"}]}},
)
processing: Optional[List[ProcessingModule] | ProcessingModule] = Field(
default_factory=dict,
processing: Optional[List[ProcessingModule]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ProcessingModule"}]}},
)
stimulus: str = Field(
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: str = Field(
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[List[TimeIntervals] | TimeIntervals] = Field(
default_factory=dict,
intervals: Optional[List[TimeIntervals]] = 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.""",
json_schema_extra={
"linkml_meta": {
"any_of": [
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
{"range": "TimeIntervals"},
]
}
},
)
units: Optional[str] = Field(None, description="""Data about sorted spike units.""")
units: Optional[Units] = Field(None, description="""Data about sorted spike units.""")
class NWBFileStimulus(ConfiguredBaseModel):
@ -171,14 +290,24 @@ 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.
"""
name: Literal["stimulus"] = Field("stimulus")
presentation: Optional[
List[Union[BaseModel, DynamicTable, NWBDataInterface, TimeSeries]]
| Union[BaseModel, DynamicTable, NWBDataInterface, TimeSeries]
] = Field(default_factory=dict, description="""Stimuli presented during the experiment.""")
templates: Optional[List[Union[Images, TimeSeries]] | Union[Images, TimeSeries]] = Field(
default_factory=dict,
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["stimulus"] = Field(
"stimulus", json_schema_extra={"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}}
)
presentation: Optional[List[Union[DynamicTable, NWBDataInterface, TimeSeries]]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={
"linkml_meta": {
"any_of": [{"range": "TimeSeries"}, {"range": "NWBDataInterface"}, {"range": "DynamicTable"}]
}
},
)
templates: Optional[List[Union[Images, TimeSeries]]] = Field(
None,
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.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}, {"range": "Images"}]}},
)
@ -187,22 +316,23 @@ 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: Literal["general"] = Field("general")
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."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["general"] = Field(
"general", json_schema_extra={"linkml_meta": {"equals_string": "general", "ifabsent": "string(general)"}}
)
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[NDArray[Shape["* num_experimenters"], str]] = Field(
None,
description="""Name of person(s) who performed the experiment. Can also specify roles of different people involved.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_experimenters"}]}}},
)
institution: Optional[str] = Field(
None, description="""Institution(s) where experiment was performed."""
)
institution: Optional[str] = Field(None, description="""Institution(s) where experiment was performed.""")
keywords: Optional[NDArray[Shape["* num_keywords"], str]] = Field(
None, description="""Terms to search over."""
None,
description="""Terms to search over.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_keywords"}]}}},
)
lab: Optional[str] = Field(None, description="""Laboratory where experiment was performed.""")
notes: Optional[str] = Field(None, description="""Notes about the experiment.""")
@ -211,24 +341,23 @@ class NWBFileGeneral(ConfiguredBaseModel):
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.""",
None, description="""Experimental protocol, if applicable. e.g., include IACUC protocol number."""
)
related_publications: Optional[NDArray[Shape["* num_publications"], str]] = Field(
None, description="""Publication information. PMID, DOI, URL, etc."""
None,
description="""Publication information. PMID, DOI, URL, etc.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_publications"}]}}},
)
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[str] = Field(
None,
description="""Script file or link to public source code used to create this NWB file.""",
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.""",
None, description="""Notes about stimuli, such as how and where they were presented."""
)
surgery: Optional[str] = Field(
None,
@ -238,30 +367,33 @@ class NWBFileGeneral(ConfiguredBaseModel):
None,
description="""Information about virus(es) used in experiments, including virus ID, source, date made, injection location, volume, etc.""",
)
lab_meta_data: Optional[List[str] | str] = Field(
default_factory=list,
lab_meta_data: Optional[List[LabMetaData]] = Field(
None,
description="""Place-holder than can be extended so that lab-specific meta-data can be placed in /general.""",
)
devices: Optional[List[Device] | Device] = Field(
default_factory=dict,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
)
subject: Optional[str] = Field(
devices: Optional[List[Device]] = Field(
None,
description="""Information about the animal or person from which the data was measured.""",
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
)
extracellular_ephys: Optional[str] = Field(
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[str] = Field(
intracellular_ephys: Optional[NWBFileGeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite] | OptogeneticStimulusSite] = Field(
default_factory=dict,
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane] | ImagingPlane] = Field(
default_factory=dict, description="""Metadata related to optophysiology."""
optophysiology: Optional[List[ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
)
@ -270,7 +402,12 @@ class NWBFileGeneralSourceScript(ConfiguredBaseModel):
Script file or link to public source code used to create this NWB file.
"""
name: Literal["source_script"] = Field("source_script")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["source_script"] = Field(
"source_script",
json_schema_extra={"linkml_meta": {"equals_string": "source_script", "ifabsent": "string(source_script)"}},
)
file_name: Optional[str] = Field(None, description="""Name of script file.""")
value: str = Field(...)
@ -280,13 +417,17 @@ class NWBFileGeneralExtracellularEphys(ConfiguredBaseModel):
Metadata related to extracellular electrophysiology.
"""
name: Literal["extracellular_ephys"] = Field("extracellular_ephys")
electrode_group: Optional[List[str] | str] = Field(
default_factory=list, description="""Physical group of electrodes."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["extracellular_ephys"] = Field(
"extracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "extracellular_ephys", "ifabsent": "string(extracellular_ephys)"}
},
)
electrodes: Optional[str] = Field(
None,
description="""A table of all electrodes (i.e. channels) used for recording.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(None, description="""Physical group of electrodes.""")
electrodes: Optional[NWBFileGeneralExtracellularEphysElectrodes] = Field(
None, description="""A table of all electrodes (i.e. channels) used for recording."""
)
@ -295,65 +436,104 @@ class NWBFileGeneralExtracellularEphysElectrodes(DynamicTable):
A table of all electrodes (i.e. channels) used for recording.
"""
name: Literal["electrodes"] = Field("electrodes")
x: Optional[List[float] | float] = Field(
default_factory=list,
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["electrodes"] = Field(
"electrodes",
json_schema_extra={"linkml_meta": {"equals_string": "electrodes", "ifabsent": "string(electrodes)"}},
)
x: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""x coordinate of the channel location in the brain (+x is posterior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
y: Optional[List[float] | float] = Field(
default_factory=list,
y: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""y coordinate of the channel location in the brain (+y is inferior).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
z: Optional[List[float] | float] = Field(
default_factory=list,
z: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""z coordinate of the channel location in the brain (+z is right).""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
imp: Optional[List[float] | float] = Field(
default_factory=list, description="""Impedance of the channel, in ohms."""
imp: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""Impedance of the channel, in ohms.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
location: Optional[List[str] | str] = Field(
default_factory=list,
location: NDArray[Any, str] = Field(
...,
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.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
filtering: Optional[List[str] | str] = Field(
default_factory=list,
filtering: Optional[NDArray[Any, str]] = Field(
None,
description="""Description of hardware filtering, including the filter name and frequency cutoffs.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
)
group_name: Optional[List[str] | str] = Field(
default_factory=list,
group_name: NDArray[Any, str] = Field(
...,
description="""Name of the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_x: Optional[List[float] | float] = Field(
default_factory=list, description="""x coordinate in electrode group"""
rel_x: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_y: Optional[List[float] | float] = Field(
default_factory=list, description="""y coordinate in electrode group"""
rel_y: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
rel_z: Optional[List[float] | float] = Field(
default_factory=list, description="""z coordinate in electrode group"""
rel_z: Optional[NDArray[Any, np.float32]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
reference: Optional[List[str] | str] = Field(
default_factory=list,
reference: Optional[NDArray[Any, str]] = Field(
None,
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\".""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
@ -362,35 +542,42 @@ class NWBFileGeneralIntracellularEphys(ConfiguredBaseModel):
Metadata related to intracellular electrophysiology.
"""
name: Literal["intracellular_ephys"] = Field("intracellular_ephys")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["intracellular_ephys"] = Field(
"intracellular_ephys",
json_schema_extra={
"linkml_meta": {"equals_string": "intracellular_ephys", "ifabsent": "string(intracellular_ephys)"}
},
)
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.""",
)
intracellular_electrode: Optional[List[str] | str] = Field(
default_factory=list, description="""An intracellular electrode."""
intracellular_electrode: Optional[List[IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[str] = Field(
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[str] = Field(
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[str] = Field(
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[str] = Field(
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[str] = Field(
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[str] = Field(
experimental_conditions: Optional[ExperimentalConditionsTable] = Field(
None,
description="""A table for grouping different intracellular recording repetitions together that belong to the same experimental experimental_conditions.""",
)
@ -401,6 +588,8 @@ class LabMetaData(NWBContainer):
Lab-specific meta-data.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
@ -409,32 +598,27 @@ class Subject(NWBContainer):
Information about the animal or person from which the data was measured.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file", "tree_root": True})
name: str = Field(...)
age: Optional[str] = Field(
None,
description="""Age of subject. Can be supplied instead of 'date_of_birth'.""",
age: Optional[SubjectAge] = Field(
None, description="""Age of subject. Can be supplied instead of 'date_of_birth'."""
)
date_of_birth: Optional[datetime] = Field(
None,
description="""Date of birth of subject. Can be supplied instead of 'age'.""",
date_of_birth: Optional[np.datetime64] = 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)."""
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).""",
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.""",
None, description="""Weight at time of experiment, at time of surgery and at other important times."""
)
@ -443,9 +627,28 @@ class SubjectAge(ConfiguredBaseModel):
Age of subject. Can be supplied instead of 'date_of_birth'.
"""
name: Literal["age"] = Field("age")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.file"})
name: Literal["age"] = Field(
"age", json_schema_extra={"linkml_meta": {"equals_string": "age", "ifabsent": "string(age)"}}
)
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.""",
)
value: str = Field(...)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ScratchData.model_rebuild()
NWBFile.model_rebuild()
NWBFileStimulus.model_rebuild()
NWBFileGeneral.model_rebuild()
NWBFileGeneralSourceScript.model_rebuild()
NWBFileGeneralExtracellularEphys.model_rebuild()
NWBFileGeneralExtracellularEphysElectrodes.model_rebuild()
NWBFileGeneralIntracellularEphys.model_rebuild()
LabMetaData.model_rebuild()
Subject.model_rebuild()
SubjectAge.model_rebuild()

View file

@ -1,57 +1,101 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import Image, TimeSeriesStartingTime, TimeSeries, TimeSeriesSync
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_7_0.core_nwb_device import Device
from ...core.v2_7_0.core_nwb_base import (
NWBData,
TimeSeriesReferenceVectorData,
Image,
ImageReferences,
NWBContainer,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.image/",
"id": "core.nwb.image",
"imports": ["core.nwb.base", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.image",
}
)
class GrayscaleImage(Image):
@ -59,16 +103,18 @@ class GrayscaleImage(Image):
A grayscale image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -78,16 +124,18 @@ class RGBImage(Image):
A color image.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -97,16 +145,18 @@ class RGBAImage(Image):
A color image with transparency.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
resolution: Optional[float] = Field(
resolution: Optional[np.float32] = Field(
None, description="""Pixel resolution of the image, in pixels per centimeter."""
)
description: Optional[str] = Field(None, description="""Description of the image.""")
array: Optional[
Union[
NDArray[Shape["* x, * y"], float],
NDArray[Shape["* x, * y, 3 r_g_b"], float],
NDArray[Shape["* x, * y, 4 r_g_b_a"], float],
NDArray[Shape["* x, * y"], np.number],
NDArray[Shape["* x, * y, 3 r_g_b"], np.number],
NDArray[Shape["* x, * y, 4 r_g_b_a"], np.number],
]
] = Field(None)
@ -116,18 +166,21 @@ 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].
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
] = Field(
...,
description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""",
data: Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]] = (
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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -140,23 +193,26 @@ class ImageSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -167,12 +223,19 @@ 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.
"""
name: Literal["external_file"] = Field("external_file")
starting_frame: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image"})
name: Literal["external_file"] = Field(
"external_file",
json_schema_extra={"linkml_meta": {"equals_string": "external_file", "ifabsent": "string(external_file)"}},
)
starting_frame: Optional[np.int32] = 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].""",
)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(None)
array: Optional[NDArray[Shape["* num_files"], str]] = Field(
None, json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_files"}]}}}
)
class ImageMaskSeries(ImageSeries):
@ -180,18 +243,21 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
] = Field(
...,
description="""Binary data representing images across frames. If data are stored in an external file, this should be an empty 3D array.""",
data: Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]] = (
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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -204,23 +270,26 @@ class ImageMaskSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -231,31 +300,26 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
distance: Optional[float] = Field(
None, description="""Distance from camera/monitor to target/eye."""
)
distance: Optional[np.float32] = Field(None, description="""Distance from camera/monitor to target/eye.""")
field_of_view: Optional[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height_depth"], float],
]
] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
)
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height_depth"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, 3 r_g_b"], float],
NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, 3 r_g_b"], np.number]
] = 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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
dimension: Optional[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
external_file: Optional[str] = Field(
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.""",
)
@ -268,23 +332,26 @@ class OpticalSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -295,33 +362,51 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.image", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
data: NDArray[Shape["* num_times"], np.uint32] = Field(
...,
description="""Index of the image (using zero-indexing) in the linked Images object.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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()
ImageSeriesExternalFile.model_rebuild()
ImageMaskSeries.model_rebuild()
OpticalSeries.model_rebuild()
IndexSeries.model_rebuild()

View file

@ -1,66 +1,79 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_ecephys import ElectrodeGroup
from ...hdmf_common.v1_8_0.hdmf_common_table import (
DynamicTableRegion,
VectorIndex,
DynamicTable,
VectorData,
)
from .core_nwb_base import TimeSeriesSync, TimeSeriesStartingTime, TimeSeries
import numpy as np
from ...core.v2_7_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync
from ...core.v2_7_0.core_nwb_ecephys import ElectrodeGroup
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
from ...hdmf_common.v1_8_0.hdmf_common_table import DynamicTableRegion, DynamicTable, VectorData, VectorIndex
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.misc/",
"id": "core.nwb.misc",
"imports": ["core.nwb.base", "../../hdmf_common/v1_8_0/namespace", "core.nwb.ecephys", "core.nwb.language"],
"name": "core.nwb.misc",
}
)
class AbstractFeatureSeries(TimeSeries):
@ -68,37 +81,45 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Values of each feature at each time.""")
data: AbstractFeatureSeriesData = Field(..., description="""Values of each feature at each time.""")
feature_units: Optional[NDArray[Shape["* num_features"], str]] = Field(
None, description="""Units of each feature."""
None,
description="""Units of each feature.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
features: NDArray[Shape["* num_features"], str] = Field(
...,
description="""Description of the features represented in TimeSeries::data.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_features"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -109,16 +130,17 @@ class AbstractFeatureSeriesData(ConfiguredBaseModel):
Values of each feature at each time.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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[
Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_features"], float],
]
Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_features"], np.number]]
] = Field(None)
@ -127,32 +149,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], str] = Field(
..., description="""Annotations made during an experiment."""
...,
description="""Annotations made during an experiment.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -163,32 +192,39 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: NDArray[Shape["* num_times"], int] = Field(
..., description="""Use values >0 if interval started, <0 if interval ended."""
data: NDArray[Shape["* num_times"], np.int8] = Field(
...,
description="""Use values >0 if interval started, <0 if interval ended.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -199,14 +235,17 @@ class DecompositionSeries(TimeSeries):
Spectral analysis of a time series, e.g. of an LFP or a speech signal.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field(...)
data: str = Field(..., description="""Data decomposed into frequency bands.""")
data: DecompositionSeriesData = Field(..., description="""Data decomposed into frequency bands.""")
metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""")
source_channels: Optional[str] = Field(
source_channels: Named[Optional[DynamicTableRegion]] = Field(
None,
description="""DynamicTableRegion pointer to the channels that this decomposition series was generated from.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
bands: str = Field(
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.""",
)
@ -215,23 +254,26 @@ class DecompositionSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -242,35 +284,23 @@ class DecompositionSeriesData(ConfiguredBaseModel):
Data decomposed into frequency bands.
"""
name: Literal["data"] = Field("data")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["data"] = Field(
"data", json_schema_extra={"linkml_meta": {"equals_string": "data", "ifabsent": "string(data)"}}
)
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"], float]] = Field(None)
class DecompositionSeriesSourceChannels(DynamicTableRegion):
"""
DynamicTableRegion pointer to the channels that this decomposition series was generated from.
"""
name: Literal["source_channels"] = Field("source_channels")
table: Optional[str] = Field(
array: Optional[NDArray[Shape["* num_times, * num_channels, * num_bands"], np.number]] = Field(
None,
description="""Reference to the DynamicTable object that this region applies to.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_times"}, {"alias": "num_channels"}, {"alias": "num_bands"}]}
}
},
)
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 DecompositionSeriesBands(DynamicTable):
@ -278,34 +308,49 @@ 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.
"""
name: Literal["bands"] = Field("bands")
band_name: Optional[List[str] | str] = Field(
default_factory=list, description="""Name of the band, e.g. theta."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["bands"] = Field(
"bands", json_schema_extra={"linkml_meta": {"equals_string": "bands", "ifabsent": "string(bands)"}}
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], float] = Field(
band_name: NDArray[Any, str] = Field(
...,
description="""Name of the band, e.g. theta.""",
json_schema_extra={
"linkml_meta": {"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}}
},
)
band_limits: NDArray[Shape["* num_bands, 2 low_high"], np.float32] = 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.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_bands"}, {"alias": "low_high", "exact_cardinality": 2}]}
}
},
)
band_mean: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The mean Gaussian filters, in Hz."""
band_mean: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The mean Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
band_stdev: NDArray[Shape["* num_bands"], float] = Field(
..., description="""The standard deviation of Gaussian filters, in Hz."""
band_stdev: NDArray[Shape["* num_bands"], np.float32] = Field(
...,
description="""The standard deviation of Gaussian filters, in Hz.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_bands"}]}}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
@ -314,105 +359,102 @@ 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("Units")
spike_times_index: Optional[str] = Field(
None, description="""Index into the spike_times dataset."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc", "tree_root": True})
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
spike_times: Optional[str] = Field(
None, description="""Spike times for each unit in seconds."""
spike_times: Optional[UnitsSpikeTimes] = Field(None, description="""Spike times for each unit in seconds.""")
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
obs_intervals_index: Optional[str] = Field(
None, description="""Index into the obs_intervals dataset."""
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], np.float64]] = Field(
None,
description="""Observation intervals for each unit.""",
json_schema_extra={
"linkml_meta": {
"array": {"dimensions": [{"alias": "num_intervals"}, {"alias": "start_end", "exact_cardinality": 2}]}
}
},
)
obs_intervals: Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]] = Field(
None, description="""Observation intervals for each unit."""
electrodes_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrodes_index: Optional[str] = Field(None, description="""Index into electrodes.""")
electrodes: Optional[str] = Field(
electrodes: Named[Optional[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
electrode_group: Optional[List[str] | str] = Field(
default_factory=list,
description="""Electrode group that each spike unit came from.""",
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: Optional[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
NDArray[Shape["* num_units, * num_samples"], np.float32],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], np.float32],
]
] = Field(None, description="""Spike waveform standard deviation for each spike unit.""")
waveforms: Optional[NDArray[Shape["* num_waveforms, * num_samples"], float]] = Field(
waveforms: Optional[NDArray[Shape["* num_waveforms, * num_samples"], np.number]] = 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.""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "num_waveforms"}, {"alias": "num_samples"}]}}
},
)
waveforms_index: Optional[str] = Field(
waveforms_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
waveforms_index_index: Optional[str] = Field(
waveforms_index_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into the waveforms_index dataset. One value for every unit (row in the table). See 'waveforms' for more detail.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class UnitsSpikeTimesIndex(VectorIndex):
"""
Index into the spike_times dataset.
"""
name: Literal["spike_times_index"] = Field("spike_times_index")
target: Optional[str] = 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[
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: Literal["spike_times"] = Field("spike_times")
resolution: Optional[float] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.misc"})
name: Literal["spike_times"] = Field(
"spike_times",
json_schema_extra={"linkml_meta": {"equals_string": "spike_times", "ifabsent": "string(spike_times)"}},
)
resolution: Optional[np.float64] = 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."""
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -423,116 +465,14 @@ class UnitsSpikeTimes(VectorData):
] = Field(None)
class UnitsObsIntervalsIndex(VectorIndex):
"""
Index into the obs_intervals dataset.
"""
name: Literal["obs_intervals_index"] = Field("obs_intervals_index")
target: Optional[str] = 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[
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: Literal["electrodes_index"] = Field("electrodes_index")
target: Optional[str] = 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[
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: Literal["electrodes"] = Field("electrodes")
table: Optional[str] = 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 UnitsWaveformsIndex(VectorIndex):
"""
Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.
"""
name: Literal["waveforms_index"] = Field("waveforms_index")
target: Optional[str] = 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[
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: Literal["waveforms_index_index"] = Field("waveforms_index_index")
target: Optional[str] = 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[
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)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
AbstractFeatureSeries.model_rebuild()
AbstractFeatureSeriesData.model_rebuild()
AnnotationSeries.model_rebuild()
IntervalSeries.model_rebuild()
DecompositionSeries.model_rebuild()
DecompositionSeriesData.model_rebuild()
DecompositionSeriesBands.model_rebuild()
Units.model_rebuild()
UnitsSpikeTimes.model_rebuild()

View file

@ -1,62 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
TimeSeriesSync,
NWBContainer,
TimeSeriesStartingTime,
TimeSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from numpydantic import NDArray, Shape
from ...core.v2_7_0.core_nwb_base import TimeSeries, TimeSeriesStartingTime, TimeSeriesSync, NWBContainer
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ogen/",
"id": "core.nwb.ogen",
"imports": ["core.nwb.base", "core.nwb.device", "core.nwb.language"],
"name": "core.nwb.ogen",
}
)
class OptogeneticSeries(TimeSeries):
@ -64,11 +79,10 @@ class OptogeneticSeries(TimeSeries):
An optogenetic stimulus.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_rois"], float],
] = Field(
data: Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_rois"], np.number]] = Field(
...,
description="""Applied power for optogenetic stimulus, in watts. Shape can be 1D or 2D. 2D data is meant to be used in an extension of OptogeneticSeries that defines what the second dimension represents.""",
)
@ -77,23 +91,26 @@ class OptogeneticSeries(TimeSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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,10 +121,18 @@ class OptogeneticStimulusSite(NWBContainer):
A site of optogenetic stimulation.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ogen", "tree_root": True})
name: str = Field(...)
description: str = Field(..., description="""Description of stimulation site.""")
excitation_lambda: float = Field(..., description="""Excitation wavelength, in nm.""")
excitation_lambda: np.float32 = 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.""",
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
OptogeneticSeries.model_rebuild()
OptogeneticStimulusSite.model_rebuild()

View file

@ -1,72 +1,117 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import (
import numpy as np
from ...core.v2_7_0.core_nwb_device import Device
from ...core.v2_7_0.core_nwb_base import (
NWBData,
TimeSeriesReferenceVectorData,
Image,
ImageReferences,
NWBContainer,
TimeSeriesSync,
TimeSeriesStartingTime,
NWBDataInterface,
TimeSeries,
TimeSeriesData,
TimeSeriesStartingTime,
TimeSeriesSync,
ProcessingModule,
Images,
)
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
DynamicTableRegion,
VectorIndex,
DynamicTable,
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
from .core_nwb_image import ImageSeries, ImageSeriesExternalFile
from ...core.v2_7_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
ImageSeries,
ImageSeriesExternalFile,
ImageMaskSeries,
OpticalSeries,
IndexSeries,
)
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union, Annotated, Type, TypeVar
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator, ValidationInfo, BeforeValidator
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.ophys/",
"id": "core.nwb.ophys",
"imports": [
"core.nwb.image",
"core.nwb.base",
"../../hdmf_common/v1_8_0/namespace",
"core.nwb.device",
"core.nwb.language",
],
"name": "core.nwb.ophys",
}
)
class OnePhotonSeries(ImageSeries):
@ -74,35 +119,34 @@ class OnePhotonSeries(ImageSeries):
Image stack recorded over time from 1-photon microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[float] = Field(
pmt_gain: Optional[np.float32] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[np.float32] = 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(
exposure_time: Optional[np.float32] = Field(
None, description="""Exposure time of the sample; often the inverse of the frequency."""
)
binning: Optional[np.uint8] = Field(
None, description="""Amount of pixels combined into 'bins'; could be 1, 2, 4, 8, etc."""
)
power: Optional[np.float32] = Field(None, description="""Power of the excitation in mW, if known.""")
intensity: Optional[np.float32] = Field(None, description="""Intensity of the excitation in mW/mm^2, if known.""")
data: Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]] = (
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[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Exposure time of the sample; often the inverse of the frequency.""",
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
binning: Optional[int] = Field(
None,
description="""Amount of pixels combined into 'bins'; could be 1, 2, 4, 8, etc.""",
)
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: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
] = 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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
)
external_file: Optional[str] = Field(
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.""",
)
@ -115,23 +159,26 @@ class OnePhotonSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -142,32 +189,29 @@ class TwoPhotonSeries(ImageSeries):
Image stack recorded over time from 2-photon microscope.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
pmt_gain: Optional[float] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[float] = Field(
pmt_gain: Optional[np.float32] = Field(None, description="""Photomultiplier gain.""")
scan_line_rate: Optional[np.float32] = 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[
Union[
NDArray[Shape["2 width_height"], float],
NDArray[Shape["3 width_height_depth"], float],
]
] = Field(
Union[NDArray[Shape["2 width_height"], np.float32], NDArray[Shape["3 width_height_depth"], np.float32]]
] = Field(None, description="""Width, height and depth of image, or imaged area, in meters.""")
data: Union[NDArray[Shape["* frame, * x, * y"], np.number], NDArray[Shape["* frame, * x, * y, * z"], np.number]] = (
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[NDArray[Shape["* rank"], np.int32]] = Field(
None,
description="""Width, height and depth of image, or imaged area, in meters.""",
description="""Number of pixels on x, y, (and z) axes.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "rank"}]}}},
)
data: Union[
NDArray[Shape["* frame, * x, * y"], float],
NDArray[Shape["* frame, * x, * y, * z"], float],
] = 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[NDArray[Shape["* rank"], int]] = Field(
None, description="""Number of pixels on x, y, (and z) axes."""
)
external_file: Optional[str] = Field(
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.""",
)
@ -180,23 +224,26 @@ class TwoPhotonSeries(ImageSeries):
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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.""",
)
@ -207,71 +254,57 @@ class RoiResponseSeries(TimeSeries):
ROI responses over an imaging plane. The first dimension represents time. The second dimension, if present, represents ROIs.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
data: Union[
NDArray[Shape["* num_times"], float],
NDArray[Shape["* num_times, * num_rois"], float],
] = Field(..., description="""Signals from ROIs.""")
rois: str = Field(
data: Union[NDArray[Shape["* num_times"], np.number], NDArray[Shape["* num_times, * num_rois"], np.number]] = Field(
..., description="""Signals from ROIs."""
)
rois: Named[DynamicTableRegion] = Field(
...,
description="""DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
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[str] = Field(
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[NDArray[Shape["* num_times"], float]] = Field(
timestamps: Optional[NDArray[Shape["* num_times"], np.float64]] = Field(
None,
description="""Timestamps for samples stored in data, in seconds, relative to the common experiment master-clock stored in NWBFile.timestamps_reference_time.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control: Optional[NDArray[Shape["* num_times"], int]] = Field(
control: Optional[NDArray[Shape["* num_times"], np.uint8]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_times"}]}}},
)
control_description: Optional[NDArray[Shape["* num_control_values"], str]] = 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.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_control_values"}]}}},
)
sync: Optional[str] = Field(
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 RoiResponseSeriesRois(DynamicTableRegion):
"""
DynamicTableRegion referencing into an ROITable containing information on the ROIs stored in this timeseries.
"""
name: Literal["rois"] = Field("rois")
table: Optional[str] = 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 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -280,7 +313,11 @@ 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).
"""
children: Optional[List[RoiResponseSeries] | RoiResponseSeries] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -289,7 +326,11 @@ 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.
"""
children: Optional[List[PlaneSegmentation] | PlaneSegmentation] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[PlaneSegmentation]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "PlaneSegmentation"}]}}
)
name: str = Field(...)
@ -298,60 +339,63 @@ class PlaneSegmentation(DynamicTable):
Results from image segmentation of a specific imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
image_mask: Optional[
Union[
NDArray[Shape["* num_roi, * num_x, * num_y"], Any],
NDArray[Shape["* num_roi, * num_x, * num_y, * num_z"], Any],
]
] = 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[str] = Field(None, description="""Index into pixel_mask.""")
pixel_mask: Optional[str] = Field(
pixel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
pixel_mask: Optional[PlaneSegmentationPixelMask] = Field(
None,
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[str] = Field(None, description="""Index into voxel_mask.""")
voxel_mask: Optional[str] = Field(
voxel_mask_index: Named[Optional[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={"linkml_meta": {"annotations": {"named": {"tag": "named", "value": True}}}},
)
voxel_mask: Optional[PlaneSegmentationVoxelMask] = Field(
None,
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: Optional[List[ImageSeries] | ImageSeries] = Field(
default_factory=dict,
reference_images: Optional[List[ImageSeries]] = Field(
None,
description="""Image stacks that the segmentation masks apply to.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImageSeries"}]}},
)
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."""
)
description: Optional[str] = Field(None, description="""Description of what is in this dynamic table.""")
id: NDArray[Shape["* num_rows"], int] = Field(
...,
description="""Array of unique identifiers for the rows of this dynamic table.""",
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}]}}},
)
vector_data: Optional[List[str] | str] = Field(
default_factory=list,
description="""Vector columns, including index columns, of this dynamic table.""",
vector_data: Optional[List[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class PlaneSegmentationPixelMaskIndex(VectorIndex):
class PlaneSegmentationImageMask(VectorData):
"""
Index into pixel_mask.
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: Literal["pixel_mask_index"] = Field("pixel_mask_index")
target: Optional[str] = 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."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["image_mask"] = Field(
"image_mask",
json_schema_extra={"linkml_meta": {"equals_string": "image_mask", "ifabsent": "string(image_mask)"}},
)
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -367,36 +411,16 @@ class PlaneSegmentationPixelMask(VectorData):
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
"""
name: Literal["pixel_mask"] = Field("pixel_mask")
x: Optional[int] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[int] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the pixel.""")
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)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
class PlaneSegmentationVoxelMaskIndex(VectorIndex):
"""
Index into voxel_mask.
"""
name: Literal["voxel_mask_index"] = Field("voxel_mask_index")
target: Optional[str] = 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."""
name: Literal["pixel_mask"] = Field(
"pixel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "pixel_mask", "ifabsent": "string(pixel_mask)"}},
)
x: Optional[np.uint32] = Field(None, description="""Pixel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Pixel y-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the pixel.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -412,14 +436,17 @@ class PlaneSegmentationVoxelMask(VectorData):
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
"""
name: Literal["voxel_mask"] = Field("voxel_mask")
x: Optional[int] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[int] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[int] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[float] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(
None, description="""Description of what these vectors represent."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys"})
name: Literal["voxel_mask"] = Field(
"voxel_mask",
json_schema_extra={"linkml_meta": {"equals_string": "voxel_mask", "ifabsent": "string(voxel_mask)"}},
)
x: Optional[np.uint32] = Field(None, description="""Voxel x-coordinate.""")
y: Optional[np.uint32] = Field(None, description="""Voxel y-coordinate.""")
z: Optional[np.uint32] = Field(None, description="""Voxel z-coordinate.""")
weight: Optional[np.float32] = Field(None, description="""Weight of the voxel.""")
description: Optional[str] = Field(None, description="""Description of what these vectors represent.""")
array: Optional[
Union[
NDArray[Shape["* dim0"], Any],
@ -435,7 +462,11 @@ class ImagingPlane(NWBContainer):
An imaging plane and its metadata.
"""
children: Optional[List[OpticalChannel] | OpticalChannel] = Field(default_factory=dict)
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[OpticalChannel]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "OpticalChannel"}]}}
)
name: str = Field(...)
@ -444,9 +475,11 @@ class OpticalChannel(NWBContainer):
An optical channel used to record from an imaging plane.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
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.""")
emission_lambda: np.float32 = Field(..., description="""Emission wavelength for channel, in nm.""")
class MotionCorrection(NWBDataInterface):
@ -454,8 +487,10 @@ 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).
"""
children: Optional[List[CorrectedImageStack] | CorrectedImageStack] = Field(
default_factory=dict
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
children: Optional[List[CorrectedImageStack]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "CorrectedImageStack"}]}}
)
name: str = Field(...)
@ -465,12 +500,29 @@ class CorrectedImageStack(NWBDataInterface):
Results from motion correction of an image stack.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.ophys", "tree_root": True})
name: str = Field(...)
corrected: str = Field(
...,
description="""Image stack with frames shifted to the common coordinates.""",
)
xy_translation: 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.""",
)
# 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()
PlaneSegmentationImageMask.model_rebuild()
PlaneSegmentationPixelMask.model_rebuild()
PlaneSegmentationVoxelMask.model_rebuild()
ImagingPlane.model_rebuild()
OpticalChannel.model_rebuild()
MotionCorrection.model_rebuild()
CorrectedImageStack.model_rebuild()

View file

@ -1,57 +1,77 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .core_nwb_base import NWBDataInterface
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...core.v2_7_0.core_nwb_base import NWBDataInterface
from numpydantic import NDArray, Shape
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
NUMPYDANTIC_VERSION = "1.2.1"
ModelType = TypeVar("ModelType", bound=Type[BaseModel])
def _get_name(item: BaseModel | dict, info: ValidationInfo):
assert isinstance(item, (BaseModel, dict))
name = info.field_name
if isinstance(item, BaseModel):
item.name = name
else:
item["name"] = name
return item
Named = Annotated[ModelType, BeforeValidator(_get_name)]
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core.nwb.retinotopy/",
"id": "core.nwb.retinotopy",
"imports": ["core.nwb.base", "core.nwb.language"],
"name": "core.nwb.retinotopy",
}
)
class ImagingRetinotopy(NWBDataInterface):
@ -59,36 +79,39 @@ class ImagingRetinotopy(NWBDataInterface):
DEPRECATED. 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("ImagingRetinotopy")
axis_1_phase_map: str = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy", "tree_root": True})
name: str = Field("ImagingRetinotopy", json_schema_extra={"linkml_meta": {"ifabsent": "string(ImagingRetinotopy)"}})
axis_1_phase_map: ImagingRetinotopyAxis1PhaseMap = Field(
..., description="""Phase response to stimulus on the first measured axis."""
)
axis_1_power_map: Optional[str] = Field(
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: str = Field(
axis_2_phase_map: ImagingRetinotopyAxis2PhaseMap = Field(
..., description="""Phase response to stimulus on the second measured axis."""
)
axis_2_power_map: Optional[str] = Field(
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: NDArray[Shape["2 axis_1_axis_2"], str] = Field(
...,
description="""Two-element array describing the contents of the two response axis fields. Description should be something like ['altitude', 'azimuth'] or '['radius', 'theta'].""",
json_schema_extra={
"linkml_meta": {"array": {"dimensions": [{"alias": "axis_1_axis_2", "exact_cardinality": 2}]}}
},
)
focal_depth_image: Optional[str] = Field(
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[str] = Field(
None,
description="""Sine of the angle between the direction of the gradient in axis_1 and axis_2.""",
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: str = Field(
...,
description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]""",
vasculature_image: ImagingRetinotopyVasculatureImage = Field(
..., description="""Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]"""
)
@ -97,16 +120,24 @@ class ImagingRetinotopyAxis1PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the first measured axis.
"""
name: Literal["axis_1_phase_map"] = Field("axis_1_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_phase_map"] = Field(
"axis_1_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_phase_map", "ifabsent": "string(axis_1_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis1PowerMap(ConfiguredBaseModel):
@ -114,16 +145,24 @@ 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: Literal["axis_1_power_map"] = Field("axis_1_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_1_power_map"] = Field(
"axis_1_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_1_power_map", "ifabsent": "string(axis_1_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
@ -131,16 +170,24 @@ class ImagingRetinotopyAxis2PhaseMap(ConfiguredBaseModel):
Phase response to stimulus on the second measured axis.
"""
name: Literal["axis_2_phase_map"] = Field("axis_2_phase_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_phase_map"] = Field(
"axis_2_phase_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_phase_map", "ifabsent": "string(axis_2_phase_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyAxis2PowerMap(ConfiguredBaseModel):
@ -148,16 +195,24 @@ 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: Literal["axis_2_power_map"] = Field("axis_2_power_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["axis_2_power_map"] = Field(
"axis_2_power_map",
json_schema_extra={
"linkml_meta": {"equals_string": "axis_2_power_map", "ifabsent": "string(axis_2_power_map)"}
},
)
dimension: Optional[np.int32] = 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)."""
field_of_view: Optional[np.float32] = 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).""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], float]] = Field(None)
class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
@ -165,21 +220,29 @@ class ImagingRetinotopyFocalDepthImage(ConfiguredBaseModel):
Gray-scale image taken with same settings/parameters (e.g., focal depth, wavelength) as data collection. Array format: [rows][columns].
"""
name: Literal["focal_depth_image"] = Field("focal_depth_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["focal_depth_image"] = Field(
"focal_depth_image",
json_schema_extra={
"linkml_meta": {"equals_string": "focal_depth_image", "ifabsent": "string(focal_depth_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value.""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
focal_depth: Optional[float] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
focal_depth: Optional[np.float32] = Field(None, description="""Focal depth offset, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
class ImagingRetinotopySignMap(ConfiguredBaseModel):
@ -187,13 +250,20 @@ class ImagingRetinotopySignMap(ConfiguredBaseModel):
Sine of the angle between the direction of the gradient in axis_1 and axis_2.
"""
name: Literal["sign_map"] = Field("sign_map")
dimension: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["sign_map"] = Field(
"sign_map", json_schema_extra={"linkml_meta": {"equals_string": "sign_map", "ifabsent": "string(sign_map)"}}
)
dimension: Optional[np.int32] = 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"], float]] = Field(None)
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.float32]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
@ -201,17 +271,37 @@ class ImagingRetinotopyVasculatureImage(ConfiguredBaseModel):
Gray-scale anatomical image of cortical surface. Array structure: [rows][columns]
"""
name: Literal["vasculature_image"] = Field("vasculature_image")
bits_per_pixel: Optional[int] = Field(
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "core.nwb.retinotopy"})
name: Literal["vasculature_image"] = Field(
"vasculature_image",
json_schema_extra={
"linkml_meta": {"equals_string": "vasculature_image", "ifabsent": "string(vasculature_image)"}
},
)
bits_per_pixel: Optional[np.int32] = Field(
None,
description="""Number of bits used to represent each value. This is necessary to determine maximum (white) pixel value""",
)
dimension: Optional[int] = Field(
dimension: Optional[np.int32] = 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.""")
format: Optional[str] = Field(
None, description="""Format of image. Right now only 'raw' is supported."""
field_of_view: Optional[np.float32] = Field(None, description="""Size of viewing area, in meters.""")
format: Optional[str] = Field(None, description="""Format of image. Right now only 'raw' is supported.""")
array: Optional[NDArray[Shape["* num_rows, * num_cols"], np.uint16]] = Field(
None,
json_schema_extra={"linkml_meta": {"array": {"dimensions": [{"alias": "num_rows"}, {"alias": "num_cols"}]}}},
)
array: Optional[NDArray[Shape["* num_rows, * num_cols"], int]] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ImagingRetinotopy.model_rebuild()
ImagingRetinotopyAxis1PhaseMap.model_rebuild()
ImagingRetinotopyAxis1PowerMap.model_rebuild()
ImagingRetinotopyAxis2PhaseMap.model_rebuild()
ImagingRetinotopyAxis2PowerMap.model_rebuild()
ImagingRetinotopyFocalDepthImage.model_rebuild()
ImagingRetinotopySignMap.model_rebuild()
ImagingRetinotopyVasculatureImage.model_rebuild()

View file

@ -1,32 +1,12 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_experimental.v0_5_0.hdmf_experimental_resources import (
HERD,
HERDKeys,
@ -36,11 +16,8 @@ from ...hdmf_experimental.v0_5_0.hdmf_experimental_resources import (
HERDObjectKeys,
HERDEntityKeys,
)
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
@ -49,10 +26,8 @@ from ...hdmf_common.v1_8_0.hdmf_common_table import (
DynamicTable,
AlignedDynamicTable,
)
from ...hdmf_experimental.v0_5_0.hdmf_experimental_experimental import EnumData
from .core_nwb_retinotopy import (
from ...core.v2_7_0.core_nwb_retinotopy import (
ImagingRetinotopy,
ImagingRetinotopyAxis1PhaseMap,
ImagingRetinotopyAxis1PowerMap,
@ -62,8 +37,7 @@ from .core_nwb_retinotopy import (
ImagingRetinotopySignMap,
ImagingRetinotopyVasculatureImage,
)
from .core_nwb_base import (
from ...core.v2_7_0.core_nwb_base import (
NWBData,
TimeSeriesReferenceVectorData,
Image,
@ -76,31 +50,25 @@ from .core_nwb_base import (
TimeSeriesSync,
ProcessingModule,
Images,
ImagesOrderOfImages,
)
from .core_nwb_ophys import (
from ...core.v2_7_0.core_nwb_ophys import (
OnePhotonSeries,
TwoPhotonSeries,
RoiResponseSeries,
RoiResponseSeriesRois,
DfOverF,
Fluorescence,
ImageSegmentation,
PlaneSegmentation,
PlaneSegmentationPixelMaskIndex,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMaskIndex,
PlaneSegmentationVoxelMask,
ImagingPlane,
OpticalChannel,
MotionCorrection,
CorrectedImageStack,
)
from .core_nwb_device import Device
from .core_nwb_image import (
from ...core.v2_7_0.core_nwb_device import Device
from ...core.v2_7_0.core_nwb_image import (
GrayscaleImage,
RGBImage,
RGBAImage,
@ -110,10 +78,8 @@ from .core_nwb_image import (
OpticalSeries,
IndexSeries,
)
from .core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from .core_nwb_icephys import (
from ...core.v2_7_0.core_nwb_ogen import OptogeneticSeries, OptogeneticStimulusSite
from ...core.v2_7_0.core_nwb_icephys import (
PatchClampSeries,
PatchClampSeriesData,
CurrentClampSeries,
@ -134,34 +100,23 @@ from .core_nwb_icephys import (
VoltageClampStimulusSeriesData,
IntracellularElectrode,
SweepTable,
SweepTableSeriesIndex,
IntracellularElectrodesTable,
IntracellularStimuliTable,
IntracellularStimuliTableStimulus,
IntracellularStimuliTableStimulusTemplate,
IntracellularResponsesTable,
IntracellularResponsesTableResponse,
IntracellularRecordingsTable,
SimultaneousRecordingsTable,
SimultaneousRecordingsTableRecordings,
SimultaneousRecordingsTableRecordingsIndex,
SequentialRecordingsTable,
SequentialRecordingsTableSimultaneousRecordings,
SequentialRecordingsTableSimultaneousRecordingsIndex,
RepetitionsTable,
RepetitionsTableSequentialRecordings,
RepetitionsTableSequentialRecordingsIndex,
ExperimentalConditionsTable,
ExperimentalConditionsTableRepetitions,
ExperimentalConditionsTableRepetitionsIndex,
)
from .core_nwb_ecephys import (
from ...core.v2_7_0.core_nwb_ecephys import (
ElectricalSeries,
ElectricalSeriesElectrodes,
SpikeEventSeries,
FeatureExtraction,
FeatureExtractionElectrodes,
EventDetection,
EventWaveform,
FilteredEphys,
@ -171,8 +126,7 @@ from .core_nwb_ecephys import (
ClusterWaveforms,
Clustering,
)
from .core_nwb_behavior import (
from ...core.v2_7_0.core_nwb_behavior import (
SpatialSeries,
SpatialSeriesData,
BehavioralEpochs,
@ -183,27 +137,18 @@ from .core_nwb_behavior import (
CompassDirection,
Position,
)
from .core_nwb_misc import (
from ...core.v2_7_0.core_nwb_misc import (
AbstractFeatureSeries,
AbstractFeatureSeriesData,
AnnotationSeries,
IntervalSeries,
DecompositionSeries,
DecompositionSeriesData,
DecompositionSeriesSourceChannels,
DecompositionSeriesBands,
Units,
UnitsSpikeTimesIndex,
UnitsSpikeTimes,
UnitsObsIntervalsIndex,
UnitsElectrodesIndex,
UnitsElectrodes,
UnitsWaveformsIndex,
UnitsWaveformsIndexIndex,
)
from .core_nwb_file import (
from ...core.v2_7_0.core_nwb_file import (
ScratchData,
NWBFile,
NWBFileStimulus,
@ -216,34 +161,72 @@ from .core_nwb_file import (
Subject,
SubjectAge,
)
from .core_nwb_epoch import (
TimeIntervals,
TimeIntervalsTagsIndex,
TimeIntervalsTimeseries,
TimeIntervalsTimeseriesIndex,
)
from ...core.v2_7_0.core_nwb_epoch import TimeIntervals
metamodel_version = "None"
version = "2.7.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": True},
"namespace": {"tag": "namespace", "value": "core"},
},
"default_prefix": "core/",
"description": "NWB namespace",
"id": "core",
"imports": [
"core.nwb.base",
"core.nwb.device",
"core.nwb.epoch",
"core.nwb.image",
"core.nwb.file",
"core.nwb.misc",
"core.nwb.behavior",
"core.nwb.ecephys",
"core.nwb.icephys",
"core.nwb.ogen",
"core.nwb.ophys",
"core.nwb.retinotopy",
"core.nwb.language",
"../../hdmf_common/v1_8_0/namespace",
"../../hdmf_experimental/v0_5_0/namespace",
],
"name": "core",
}
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model

View file

@ -1,57 +1,69 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_table import VectorData
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
metamodel_version = "None"
version = "0.1.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental.experimental/",
"id": "hdmf-experimental.experimental",
"imports": ["../../hdmf_common/v1_5_0/namespace", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental.experimental",
}
)
class EnumData(VectorData):
@ -59,14 +71,13 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.experimental", "tree_root": True})
name: str = Field(...)
elements: Optional[str] = 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."""
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[
Union[
NDArray[Shape["* dim0"], Any],
@ -75,3 +86,8 @@ class EnumData(VectorData):
NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any],
]
] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
EnumData.model_rebuild()

View file

@ -1,57 +1,69 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
metamodel_version = "None"
version = "0.1.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental.resources/",
"id": "hdmf-experimental.resources",
"imports": ["../../hdmf_common/v1_5_0/namespace", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental.resources",
}
)
class ExternalResources(Container):
@ -59,24 +71,22 @@ class ExternalResources(Container):
A set of four tables for tracking external resource references in a file. NOTE: this data type is in beta testing and is subject to change in a later version.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources", "tree_root": True})
name: str = Field(...)
keys: str = Field(
...,
description="""A table for storing user terms that are used to refer to external resources.""",
keys: ExternalResourcesKeys = Field(
..., description="""A table for storing user terms that are used to refer to external resources."""
)
entities: str = Field(
...,
description="""A table for mapping user terms (i.e., keys) to resource entities.""",
entities: ExternalResourcesEntities = Field(
..., description="""A table for mapping user terms (i.e., keys) to resource entities."""
)
resources: str = Field(
...,
description="""A table for mapping user terms (i.e., keys) to resource entities.""",
resources: ExternalResourcesResources = Field(
..., description="""A table for mapping user terms (i.e., keys) to resource entities."""
)
objects: str = Field(
...,
description="""A table for identifying which objects in a file contain references to external resources.""",
objects: ExternalResourcesObjects = Field(
..., description="""A table for identifying which objects in a file contain references to external resources."""
)
object_keys: str = Field(
object_keys: ExternalResourcesObjectKeys = Field(
..., description="""A table for identifying which objects use which keys."""
)
@ -86,11 +96,12 @@ class ExternalResourcesKeys(Data):
A table for storing user terms that are used to refer to external resources.
"""
name: Literal["keys"] = Field("keys")
key: str = Field(
...,
description="""The user term that maps to one or more resources in the 'resources' table.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["keys"] = Field(
"keys", json_schema_extra={"linkml_meta": {"equals_string": "keys", "ifabsent": "string(keys)"}}
)
key: str = Field(..., description="""The user term that maps to one or more resources in the 'resources' table.""")
class ExternalResourcesEntities(Data):
@ -98,13 +109,16 @@ class ExternalResourcesEntities(Data):
A table for mapping user terms (i.e., keys) to resource entities.
"""
name: Literal["entities"] = Field("entities")
keys_idx: int = Field(..., description="""The index to the key in the 'keys' table.""")
resources_idx: int = Field(..., description="""The index into the 'resources' table""")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["entities"] = Field(
"entities", json_schema_extra={"linkml_meta": {"equals_string": "entities", "ifabsent": "string(entities)"}}
)
keys_idx: np.uint64 = Field(..., description="""The index to the key in the 'keys' table.""")
resources_idx: np.uint64 = Field(..., description="""The index into the 'resources' table""")
entity_id: str = Field(..., description="""The unique identifier entity.""")
entity_uri: str = Field(
...,
description="""The URI for the entity this reference applies to. This can be an empty string.""",
..., description="""The URI for the entity this reference applies to. This can be an empty string."""
)
@ -113,11 +127,13 @@ class ExternalResourcesResources(Data):
A table for mapping user terms (i.e., keys) to resource entities.
"""
name: Literal["resources"] = Field("resources")
resource: str = Field(..., description="""The name of the resource.""")
resource_uri: str = Field(
..., description="""The URI for the resource. This can be an empty string."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["resources"] = Field(
"resources", json_schema_extra={"linkml_meta": {"equals_string": "resources", "ifabsent": "string(resources)"}}
)
resource: str = Field(..., description="""The name of the resource.""")
resource_uri: str = Field(..., description="""The URI for the resource. This can be an empty string.""")
class ExternalResourcesObjects(Data):
@ -125,7 +141,11 @@ class ExternalResourcesObjects(Data):
A table for identifying which objects in a file contain references to external resources.
"""
name: Literal["objects"] = Field("objects")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["objects"] = Field(
"objects", json_schema_extra={"linkml_meta": {"equals_string": "objects", "ifabsent": "string(objects)"}}
)
object_id: str = Field(..., description="""The UUID for the object.""")
field: str = Field(
...,
@ -138,9 +158,23 @@ class ExternalResourcesObjectKeys(Data):
A table for identifying which objects use which keys.
"""
name: Literal["object_keys"] = Field("object_keys")
objects_idx: int = Field(
...,
description="""The index to the 'objects' table for the object that holds the key.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["object_keys"] = Field(
"object_keys",
json_schema_extra={"linkml_meta": {"equals_string": "object_keys", "ifabsent": "string(object_keys)"}},
)
keys_idx: int = Field(..., description="""The index to the 'keys' table for the key.""")
objects_idx: np.uint64 = Field(
..., description="""The index to the 'objects' table for the object that holds the key."""
)
keys_idx: np.uint64 = Field(..., description="""The index to the 'keys' table for the key.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
ExternalResources.model_rebuild()
ExternalResourcesKeys.model_rebuild()
ExternalResourcesEntities.model_rebuild()
ExternalResourcesResources.model_rebuild()
ExternalResourcesObjects.model_rebuild()
ExternalResourcesObjectKeys.model_rebuild()

View file

@ -1,33 +1,13 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .hdmf_experimental_resources import (
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_experimental.v0_1_0.hdmf_experimental_resources import (
ExternalResources,
ExternalResourcesKeys,
ExternalResourcesEntities,
@ -35,11 +15,8 @@ from .hdmf_experimental_resources import (
ExternalResourcesObjects,
ExternalResourcesObjectKeys,
)
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_table import (
VectorData,
VectorIndex,
@ -48,29 +25,57 @@ from ...hdmf_common.v1_5_0.hdmf_common_table import (
DynamicTable,
AlignedDynamicTable,
)
from .hdmf_experimental_experimental import EnumData
from ...hdmf_experimental.v0_1_0.hdmf_experimental_experimental import EnumData
metamodel_version = "None"
version = "0.1.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": True},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental/",
"description": "Experimental data structures provided by HDMF. These are not "
"guaranteed to be available in the future",
"id": "hdmf-experimental",
"imports": ["hdmf-experimental.experimental", "hdmf-experimental.resources", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental",
}
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model

View file

@ -1,57 +1,69 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_table import VectorData
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
metamodel_version = "None"
version = "0.5.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental.experimental/",
"id": "hdmf-experimental.experimental",
"imports": ["../../hdmf_common/v1_8_0/namespace", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental.experimental",
}
)
class EnumData(VectorData):
@ -59,14 +71,13 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.experimental", "tree_root": True})
name: str = Field(...)
elements: Optional[str] = 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."""
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[
Union[
NDArray[Shape["* dim0"], Any],
@ -75,3 +86,8 @@ class EnumData(VectorData):
NDArray[Shape["* dim0, * dim1, * dim2, * dim3"], Any],
]
] = Field(None)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
EnumData.model_rebuild()

View file

@ -1,57 +1,69 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
ElementIdentifiers,
DynamicTableRegion,
DynamicTable,
AlignedDynamicTable,
)
metamodel_version = "None"
version = "0.5.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": False},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental.resources/",
"id": "hdmf-experimental.resources",
"imports": ["../../hdmf_common/v1_8_0/namespace", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental.resources",
}
)
class HERD(Container):
@ -59,29 +71,21 @@ 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.
"""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources", "tree_root": True})
name: str = Field(...)
keys: str = Field(
...,
description="""A table for storing user terms that are used to refer to external resources.""",
keys: HERDKeys = Field(
..., description="""A table for storing user terms that are used to refer to external resources."""
)
files: str = Field(
...,
description="""A table for storing object ids of files used in 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."""
)
entities: str = Field(
...,
description="""A table for mapping user terms (i.e., keys) to resource entities.""",
)
objects: str = Field(
...,
description="""A table for identifying which objects in a file contain references to external resources.""",
)
object_keys: str = Field(
..., description="""A table for identifying which objects use which keys."""
)
entity_keys: str = Field(
..., description="""A table for identifying which keys use which entity."""
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.""")
class HERDKeys(Data):
@ -89,7 +93,11 @@ class HERDKeys(Data):
A table for storing user terms that are used to refer to external resources.
"""
name: Literal["keys"] = Field("keys")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["keys"] = Field(
"keys", json_schema_extra={"linkml_meta": {"equals_string": "keys", "ifabsent": "string(keys)"}}
)
key: str = Field(
...,
description="""The user term that maps to one or more resources in the `resources` table, e.g., \"human\".""",
@ -101,10 +109,13 @@ class HERDFiles(Data):
A table for storing object ids of files used in external resources.
"""
name: Literal["files"] = Field("files")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["files"] = Field(
"files", json_schema_extra={"linkml_meta": {"equals_string": "files", "ifabsent": "string(files)"}}
)
file_object_id: str = Field(
...,
description="""The object id (UUID) of a file that contains objects that refers to external resources.""",
..., description="""The object id (UUID) of a file that contains objects that refers to external resources."""
)
@ -113,7 +124,11 @@ class HERDEntities(Data):
A table for mapping user terms (i.e., keys) to resource entities.
"""
name: Literal["entities"] = Field("entities")
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["entities"] = Field(
"entities", json_schema_extra={"linkml_meta": {"equals_string": "entities", "ifabsent": "string(entities)"}}
)
entity_id: str = Field(
...,
description="""The compact uniform resource identifier (CURIE) of the entity, in the form [prefix]:[unique local identifier], e.g., 'NCBI_TAXON:9606'.""",
@ -129,10 +144,13 @@ class HERDObjects(Data):
A table for identifying which objects in a file contain references to external resources.
"""
name: Literal["objects"] = Field("objects")
files_idx: int = Field(
...,
description="""The row index to the file in the `files` table containing the object.""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["objects"] = Field(
"objects", json_schema_extra={"linkml_meta": {"equals_string": "objects", "ifabsent": "string(objects)"}}
)
files_idx: np.uint64 = Field(
..., description="""The row index to the file in the `files` table containing the object."""
)
object_id: str = Field(..., description="""The object id (UUID) of the object.""")
object_type: str = Field(..., description="""The data type of the object.""")
@ -151,12 +169,16 @@ class HERDObjectKeys(Data):
A table for identifying which objects use which keys.
"""
name: Literal["object_keys"] = Field("object_keys")
objects_idx: int = Field(
...,
description="""The row index to the object in the `objects` table that holds the key""",
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["object_keys"] = Field(
"object_keys",
json_schema_extra={"linkml_meta": {"equals_string": "object_keys", "ifabsent": "string(object_keys)"}},
)
keys_idx: int = Field(..., description="""The row index to the key in the `keys` table.""")
objects_idx: np.uint64 = Field(
..., description="""The row index to the object in the `objects` table that holds the key"""
)
keys_idx: np.uint64 = Field(..., description="""The row index to the key in the `keys` table.""")
class HERDEntityKeys(Data):
@ -164,8 +186,22 @@ class HERDEntityKeys(Data):
A table for identifying which keys use which entity.
"""
name: Literal["entity_keys"] = Field("entity_keys")
entities_idx: int = Field(
..., description="""The row index to the entity in the `entities` table."""
linkml_meta: ClassVar[LinkMLMeta] = LinkMLMeta({"from_schema": "hdmf-experimental.resources"})
name: Literal["entity_keys"] = Field(
"entity_keys",
json_schema_extra={"linkml_meta": {"equals_string": "entity_keys", "ifabsent": "string(entity_keys)"}},
)
keys_idx: int = Field(..., description="""The row index to the key in the `keys` table.""")
entities_idx: np.uint64 = Field(..., description="""The row index to the entity in the `entities` table.""")
keys_idx: np.uint64 = Field(..., description="""The row index to the key in the `keys` table.""")
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model
HERD.model_rebuild()
HERDKeys.model_rebuild()
HERDFiles.model_rebuild()
HERDEntities.model_rebuild()
HERDObjects.model_rebuild()
HERDObjectKeys.model_rebuild()
HERDEntityKeys.model_rebuild()

View file

@ -1,33 +1,13 @@
from __future__ import annotations
from datetime import datetime, date
from decimal import Decimal
from enum import Enum
from typing import (
Dict,
Optional,
Any,
Union,
ClassVar,
Annotated,
TypeVar,
List,
TYPE_CHECKING,
)
from pydantic import BaseModel as BaseModel, Field
from pydantic import ConfigDict, BeforeValidator
from numpydantic import Shape, NDArray
from numpydantic.dtype import *
import re
import sys
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
if TYPE_CHECKING:
import numpy as np
from .hdmf_experimental_resources import (
from typing import Any, ClassVar, List, Literal, Dict, Optional, Union
from pydantic import BaseModel, ConfigDict, Field, RootModel, field_validator
import numpy as np
from ...hdmf_experimental.v0_5_0.hdmf_experimental_resources import (
HERD,
HERDKeys,
HERDFiles,
@ -36,11 +16,8 @@ from .hdmf_experimental_resources import (
HERDObjectKeys,
HERDEntityKeys,
)
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_8_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_8_0.hdmf_common_base import Data, Container, SimpleMultiContainer
from ...hdmf_common.v1_8_0.hdmf_common_table import (
VectorData,
VectorIndex,
@ -49,29 +26,57 @@ from ...hdmf_common.v1_8_0.hdmf_common_table import (
DynamicTable,
AlignedDynamicTable,
)
from .hdmf_experimental_experimental import EnumData
from ...hdmf_experimental.v0_5_0.hdmf_experimental_experimental import EnumData
metamodel_version = "None"
version = "0.5.0"
class ConfiguredBaseModel(BaseModel):
hdf5_path: Optional[str] = Field(
None, description="The absolute path that this object is stored in an NWB file"
model_config = ConfigDict(
validate_assignment=True,
validate_default=True,
extra="forbid",
arbitrary_types_allowed=True,
use_enum_values=True,
strict=False,
)
hdf5_path: Optional[str] = Field(None, description="The absolute path that this object is stored in an NWB file")
object_id: Optional[str] = Field(None, description="Unique UUID for each object")
def __getitem__(self, i: slice | int) -> "np.ndarray":
if hasattr(self, "array"):
return self.array[i]
else:
return super().__getitem__(i)
def __setitem__(self, i: slice | int, value: Any):
if hasattr(self, "array"):
self.array[i] = value
else:
super().__setitem__(i, value)
class LinkMLMeta(RootModel):
root: Dict[str, Any] = {}
model_config = ConfigDict(frozen=True)
def __getattr__(self, key: str):
return getattr(self.root, key)
def __getitem__(self, key: str):
return self.root[key]
def __setitem__(self, key: str, value):
self.root[key] = value
def __contains__(self, key: str) -> bool:
return key in self.root
linkml_meta = LinkMLMeta(
{
"annotations": {
"is_namespace": {"tag": "is_namespace", "value": True},
"namespace": {"tag": "namespace", "value": "hdmf-experimental"},
},
"default_prefix": "hdmf-experimental/",
"description": "Experimental data structures provided by HDMF. These are not "
"guaranteed to be available in the future.",
"id": "hdmf-experimental",
"imports": ["hdmf-experimental.experimental", "hdmf-experimental.resources", "hdmf-experimental.nwb.language"],
"name": "hdmf-experimental",
}
)
# Model rebuild
# see https://pydantic-docs.helpmanual.io/usage/models/#rebuilding-a-model