regenerate models

This commit is contained in:
sneakers-the-rat 2024-09-11 15:50:09 -07:00
parent 000ddde000
commit dfcb395295
Signed by untrusted user who does not match committer: jonny
GPG key ID: 6DCB96EF1E4D232D
280 changed files with 6287 additions and 2260 deletions

View file

@ -602,6 +602,7 @@ class MapClassRange(DatasetMap):
# DynamicTable special cases
# --------------------------------------------------
class MapNVectors(DatasetMap):
"""
An unnamed container that indicates an arbitrary quantity of some other neurodata type.

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[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."""
)

View file

@ -67,12 +67,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -484,7 +500,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -493,7 +509,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -502,7 +518,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -511,7 +527,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -530,9 +546,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[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."""
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -922,9 +938,6 @@ class SweepTable(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -464,9 +480,6 @@ class DecompositionSeriesBands(DynamicTable):
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[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."""
)
@ -482,7 +495,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -497,7 +510,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -509,7 +522,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -525,7 +538,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -537,7 +550,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -552,16 +565,16 @@ class Units(DynamicTable):
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
@ -578,9 +591,6 @@ class Units(DynamicTable):
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[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."""
)

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -66,12 +66,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -58,12 +58,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -218,7 +234,7 @@ class ImagingRetinotopy(NWBDataInterface):
}
},
)
axis_1_power_map: Named[Optional[AxisMap]] = Field(
axis_1_power_map: Optional[Named[AxisMap]] = 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.""",
json_schema_extra={
@ -242,7 +258,7 @@ class ImagingRetinotopy(NWBDataInterface):
}
},
)
axis_2_power_map: Named[Optional[AxisMap]] = Field(
axis_2_power_map: Optional[Named[AxisMap]] = Field(
None,
description="""Power response to stimulus on the second measured axis.""",
json_schema_extra={

View file

@ -176,12 +176,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[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."""
)

View file

@ -67,12 +67,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -484,7 +500,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -493,7 +509,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -502,7 +518,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -511,7 +527,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -530,9 +546,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[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."""
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -922,9 +938,6 @@ class SweepTable(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -464,9 +480,6 @@ class DecompositionSeriesBands(DynamicTable):
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[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."""
)
@ -482,7 +495,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -497,7 +510,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -509,7 +522,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -525,7 +538,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -537,7 +550,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -552,16 +565,16 @@ class Units(DynamicTable):
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
@ -578,9 +591,6 @@ class Units(DynamicTable):
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[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."""
)

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -66,12 +66,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -58,12 +58,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -218,7 +234,7 @@ class ImagingRetinotopy(NWBDataInterface):
}
},
)
axis_1_power_map: Named[Optional[AxisMap]] = Field(
axis_1_power_map: Optional[Named[AxisMap]] = 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.""",
json_schema_extra={
@ -242,7 +258,7 @@ class ImagingRetinotopy(NWBDataInterface):
}
},
)
axis_2_power_map: Named[Optional[AxisMap]] = Field(
axis_2_power_map: Optional[Named[AxisMap]] = Field(
None,
description="""Power response to stimulus on the second measured axis.""",
json_schema_extra={

View file

@ -176,12 +176,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[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."""
)

View file

@ -67,12 +67,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -484,7 +500,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -493,7 +509,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -502,7 +518,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -511,7 +527,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -530,9 +546,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[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."""
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -922,9 +938,6 @@ class SweepTable(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -464,9 +480,6 @@ class DecompositionSeriesBands(DynamicTable):
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[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."""
)
@ -482,7 +495,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -497,7 +510,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -509,7 +522,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -525,7 +538,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -537,7 +550,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -552,16 +565,16 @@ class Units(DynamicTable):
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
@ -578,9 +591,6 @@ class Units(DynamicTable):
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[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."""
)

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -66,12 +66,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -179,12 +179,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[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."""
)

View file

@ -68,12 +68,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -460,7 +476,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -469,7 +485,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -478,7 +494,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -487,7 +503,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -506,9 +522,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[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."""
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -922,9 +938,6 @@ class SweepTable(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -464,9 +480,6 @@ class DecompositionSeriesBands(DynamicTable):
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[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."""
)
@ -482,7 +495,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -497,7 +510,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -509,7 +522,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -525,7 +538,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -537,7 +550,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -552,16 +565,16 @@ class Units(DynamicTable):
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
@ -578,9 +591,6 @@ class Units(DynamicTable):
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[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."""
)

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -338,7 +354,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
pixel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={
@ -354,7 +370,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
voxel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={
@ -394,9 +410,6 @@ class PlaneSegmentation(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -186,12 +186,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[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."""
)

View file

@ -68,12 +68,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -460,7 +476,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -469,7 +485,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -478,7 +494,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -487,7 +503,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -506,9 +522,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[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."""
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -922,9 +938,6 @@ class SweepTable(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -464,9 +480,6 @@ class DecompositionSeriesBands(DynamicTable):
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[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."""
)
@ -482,7 +495,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -497,7 +510,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -509,7 +522,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -525,7 +538,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -537,7 +550,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -552,16 +565,16 @@ class Units(DynamicTable):
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
@ -578,9 +591,6 @@ class Units(DynamicTable):
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[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."""
)

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -340,7 +356,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
pixel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={
@ -356,7 +372,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
voxel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={
@ -396,9 +412,6 @@ class PlaneSegmentation(DynamicTable):
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[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."""
)

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -186,12 +186,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -50,12 +50,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -289,7 +305,7 @@ class ProcessingModule(NWBContainer):
{"from_schema": "core.nwb.base", "tree_root": True}
)
value: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
value: Optional[Dict[str, Union[DynamicTable, NWBDataInterface]]] = Field(
None,
json_schema_extra={
"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}
@ -309,7 +325,7 @@ class Images(NWBDataInterface):
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: str = Field(..., description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
image: List[str] = Field(..., description="""Images stored in this collection.""")
# Model rebuild

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -182,7 +198,7 @@ class BehavioralEpochs(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[IntervalSeries]] = Field(
value: Optional[Dict[str, IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -197,7 +213,7 @@ class BehavioralEvents(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -212,7 +228,7 @@ class BehavioralTimeSeries(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -227,7 +243,7 @@ class PupilTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -242,7 +258,7 @@ class EyeTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -257,7 +273,7 @@ class CompassDirection(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -272,7 +288,7 @@ class Position(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -369,7 +385,7 @@ class EventWaveform(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[SpikeEventSeries]] = Field(
value: Optional[Dict[str, SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -384,7 +400,7 @@ class FilteredEphys(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -399,7 +415,7 @@ class LFP(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class TimeIntervalsTimeseries(VectorData):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -167,28 +183,28 @@ class NWBFile(NWBContainer):
...,
description="""Date and time corresponding to time zero of all timestamps. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. All times stored in the file use this time as reference (i.e., time zero).""",
)
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
acquisition: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
analysis: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
scratch: Optional[Dict[str, 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]] = Field(
processing: Optional[Dict[str, 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"}]}},
@ -221,12 +237,12 @@ class NWBFileStimulus(ConfiguredBaseModel):
"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}
},
)
presentation: Optional[List[TimeSeries]] = Field(
presentation: Optional[Dict[str, TimeSeries]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
templates: Optional[List[TimeSeries]] = Field(
templates: Optional[Dict[str, 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"}]}},
@ -304,11 +320,11 @@ 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[LabMetaData]] = Field(
lab_meta_data: Optional[Dict[str, 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]] = Field(
devices: Optional[Dict[str, Device]] = Field(
None,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
@ -323,12 +339,12 @@ class NWBFileGeneral(ConfiguredBaseModel):
intracellular_ephys: Optional[GeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
optogenetics: Optional[Dict[str, OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane]] = Field(
optophysiology: Optional[Dict[str, ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
@ -368,7 +384,7 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
}
},
)
electrode_group: Optional[List[ElectrodeGroup]] = Field(
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
None, description="""Physical group of electrodes."""
)
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
@ -443,8 +459,14 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
group: VectorData[NDArray[Any, ElectrodeGroup]] = Field(
...,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
group_name: VectorData[NDArray[Any, str]] = Field(
...,
@ -455,7 +477,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -464,7 +486,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -473,7 +495,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -482,7 +504,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -501,9 +523,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class GeneralIntracellularEphys(ConfiguredBaseModel):
@ -526,7 +545,7 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
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[IntracellularElectrode]] = Field(
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[SweepTable] = Field(
@ -557,7 +576,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
invalid_times: Optional[TimeIntervals] = Field(
None, description="""Time intervals that should be removed from analysis."""
)
time_intervals: Optional[List[TimeIntervals]] = Field(
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
None,
description="""Optional additional table(s) for describing other experimental time intervals.""",
)

View file

@ -69,12 +69,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -899,8 +915,14 @@ class SweepTable(DynamicTable):
}
},
)
series: List[PatchClampSeries] = Field(
..., description="""The PatchClampSeries with the sweep number in that row."""
series: VectorData[NDArray[Any, PatchClampSeries]] = Field(
...,
description="""The PatchClampSeries with the sweep number in that row.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
series_index: Named[VectorIndex] = Field(
...,
@ -924,9 +946,6 @@ class SweepTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
# Model rebuild

View file

@ -50,12 +50,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -328,7 +344,7 @@ class DecompositionSeries(TimeSeries):
..., description="""Data decomposed into frequency bands."""
)
metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""")
source_channels: Named[Optional[DynamicTableRegion]] = Field(
source_channels: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""DynamicTableRegion pointer to the channels that this decomposition series was generated from.""",
json_schema_extra={
@ -476,9 +492,6 @@ class DecompositionSeriesBands(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class Units(DynamicTable):
@ -491,7 +504,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -506,7 +519,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -518,7 +531,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -534,7 +547,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -546,7 +559,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -558,26 +571,32 @@ class Units(DynamicTable):
}
},
)
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
electrode_group: Optional[VectorData[NDArray[Any, ElectrodeGroup]]] = Field(
None,
description="""Electrode group that each spike unit came from.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform standard deviation for each spike unit.""")
waveforms: VectorData[Optional[NDArray[Shape["* num_waveforms, * num_samples"], float]]] = (
waveforms: Optional[VectorData[NDArray[Shape["* num_waveforms, * num_samples"], float]]] = (
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.""",
@ -588,7 +607,7 @@ class Units(DynamicTable):
},
)
)
waveforms_index: Named[Optional[VectorIndex]] = Field(
waveforms_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.""",
json_schema_extra={
@ -600,7 +619,7 @@ class Units(DynamicTable):
}
},
)
waveforms_index_index: Named[Optional[VectorIndex]] = Field(
waveforms_index_index: Optional[Named[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={
@ -622,9 +641,6 @@ class Units(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class UnitsSpikeTimes(VectorData):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -299,7 +315,7 @@ class DfOverF(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[RoiResponseSeries]] = Field(
value: Optional[Dict[str, RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -314,7 +330,7 @@ class Fluorescence(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[RoiResponseSeries]] = Field(
value: Optional[Dict[str, RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -329,7 +345,7 @@ class ImageSegmentation(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[PlaneSegmentation]] = Field(
value: Optional[Dict[str, PlaneSegmentation]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "PlaneSegmentation"}]}}
)
name: str = Field(...)
@ -345,11 +361,18 @@ class PlaneSegmentation(DynamicTable):
)
name: str = Field(...)
image_mask: Optional[PlaneSegmentationImageMask] = Field(
image_mask: Optional[
VectorData[
Union[
NDArray[Shape["* num_roi, * num_x, * num_y"], Any],
NDArray[Shape["* num_roi, * num_x, * num_y, * num_z"], Any],
]
]
] = 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: Named[Optional[VectorIndex]] = Field(
pixel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={
@ -365,7 +388,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
voxel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={
@ -381,7 +404,7 @@ class PlaneSegmentation(DynamicTable):
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]] = Field(
reference_images: Optional[Dict[str, ImageSeries]] = Field(
None,
description="""Image stacks that the segmentation masks apply to.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImageSeries"}]}},
@ -405,33 +428,6 @@ class PlaneSegmentation(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class PlaneSegmentationImageMask(VectorData):
"""
ROI masks for each ROI. Each image mask is the size of the original imaging plane (or volume) and members of the ROI are finite non-zero.
"""
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: str = Field(..., description="""Description of what these vectors represent.""")
value: 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 PlaneSegmentationPixelMask(VectorData):
@ -554,7 +550,7 @@ class ImagingPlane(NWBContainer):
None,
description="""Describes reference frame of origin_coords and grid_spacing. For example, this can be a text description of the anatomical location and orientation of the grid defined by origin_coords and grid_spacing or the vectors needed to transform or rotate the grid to a common anatomical axis (e.g., AP/DV/ML). This field is necessary to interpret origin_coords and grid_spacing. If origin_coords and grid_spacing are not present, then this field is not required. For example, if the microscope takes 10 x 10 x 2 images, where the first value of the data matrix (index (0, 0, 0)) corresponds to (-1.2, -0.6, -2) mm relative to bregma, the spacing between pixels is 0.2 mm in x, 0.2 mm in y and 0.5 mm in z, and larger numbers in x means more anterior, larger numbers in y means more rightward, and larger numbers in z means more ventral, then enter the following -- origin_coords = (-1.2, -0.6, -2) grid_spacing = (0.2, 0.2, 0.5) reference_frame = \"Origin coordinates are relative to bregma. First dimension corresponds to anterior-posterior axis (larger index = more anterior). Second dimension corresponds to medial-lateral axis (larger index = more rightward). Third dimension corresponds to dorsal-ventral axis (larger index = more ventral).\"""",
)
optical_channel: List[OpticalChannel] = Field(
optical_channel: Dict[str, OpticalChannel] = Field(
..., description="""An optical channel used to record from an imaging plane."""
)
device: Union[Device, str] = Field(
@ -668,7 +664,7 @@ class MotionCorrection(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[CorrectedImageStack]] = Field(
value: Optional[Dict[str, CorrectedImageStack]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "CorrectedImageStack"}]}}
)
name: str = Field(...)
@ -710,7 +706,6 @@ DfOverF.model_rebuild()
Fluorescence.model_rebuild()
ImageSegmentation.model_rebuild()
PlaneSegmentation.model_rebuild()
PlaneSegmentationImageMask.model_rebuild()
PlaneSegmentationPixelMask.model_rebuild()
PlaneSegmentationVoxelMask.model_rebuild()
ImagingPlane.model_rebuild()

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -117,7 +117,6 @@ from ...core.v2_3_0.core_nwb_ophys import (
MotionCorrection,
OpticalChannel,
PlaneSegmentation,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMask,
RoiResponseSeries,
@ -134,7 +133,7 @@ from ...core.v2_3_0.core_nwb_retinotopy import (
ImagingRetinotopyVasculatureImage,
)
from ...hdmf_common.v1_5_0.hdmf_common_base import Container, Data, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_5_0.hdmf_common_table import (
AlignedDynamicTable,
DynamicTable,
@ -189,12 +188,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -103,7 +119,7 @@ class VectorDataMixin(BaseModel, Generic[T]):
# redefined in `VectorData`, but included here for testing and type checking
value: Optional[T] = None
def __init__(self, value: Optional[NDArray] = None, **kwargs):
def __init__(self, value: Optional[T] = None, **kwargs):
if value is not None and "value" not in kwargs:
kwargs["value"] = value
super().__init__(**kwargs)
@ -484,7 +500,7 @@ class ProcessingModule(NWBContainer):
{"from_schema": "core.nwb.base", "tree_root": True}
)
value: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
value: Optional[Dict[str, Union[DynamicTable, NWBDataInterface]]] = Field(
None,
json_schema_extra={
"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}
@ -504,7 +520,7 @@ class Images(NWBDataInterface):
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: str = Field(..., description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
image: List[str] = Field(..., description="""Images stored in this collection.""")
# Model rebuild

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -182,7 +198,7 @@ class BehavioralEpochs(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[IntervalSeries]] = Field(
value: Optional[Dict[str, IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -197,7 +213,7 @@ class BehavioralEvents(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -212,7 +228,7 @@ class BehavioralTimeSeries(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -227,7 +243,7 @@ class PupilTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -242,7 +258,7 @@ class EyeTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -257,7 +273,7 @@ class CompassDirection(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -272,7 +288,7 @@ class Position(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -369,7 +385,7 @@ class EventWaveform(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[SpikeEventSeries]] = Field(
value: Optional[Dict[str, SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -384,7 +400,7 @@ class FilteredEphys(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -399,7 +415,7 @@ class LFP(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -171,7 +187,7 @@ class TimeIntervals(DynamicTable):
timeseries: Optional[TimeIntervalsTimeseries] = Field(
None, description="""An index into a TimeSeries object."""
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -193,9 +209,6 @@ class TimeIntervals(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class TimeIntervalsTimeseries(VectorData):

View file

@ -71,12 +71,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -175,28 +191,28 @@ class NWBFile(NWBContainer):
...,
description="""Date and time corresponding to time zero of all timestamps. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. All times stored in the file use this time as reference (i.e., time zero).""",
)
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
acquisition: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
analysis: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
scratch: Optional[Dict[str, 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]] = Field(
processing: Optional[Dict[str, 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"}]}},
@ -229,12 +245,12 @@ class NWBFileStimulus(ConfiguredBaseModel):
"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}
},
)
presentation: Optional[List[TimeSeries]] = Field(
presentation: Optional[Dict[str, TimeSeries]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
templates: Optional[List[TimeSeries]] = Field(
templates: Optional[Dict[str, 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"}]}},
@ -312,11 +328,11 @@ 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[LabMetaData]] = Field(
lab_meta_data: Optional[Dict[str, 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]] = Field(
devices: Optional[Dict[str, Device]] = Field(
None,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
@ -331,12 +347,12 @@ class NWBFileGeneral(ConfiguredBaseModel):
intracellular_ephys: Optional[GeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
optogenetics: Optional[Dict[str, OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane]] = Field(
optophysiology: Optional[Dict[str, ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
@ -376,7 +392,7 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
}
},
)
electrode_group: Optional[List[ElectrodeGroup]] = Field(
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
None, description="""Physical group of electrodes."""
)
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
@ -451,8 +467,14 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
group: VectorData[NDArray[Any, ElectrodeGroup]] = Field(
...,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
group_name: VectorData[NDArray[Any, str]] = Field(
...,
@ -463,7 +485,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -472,7 +494,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -481,7 +503,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -490,7 +512,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of the reference used for this electrode.""",
json_schema_extra={
@ -509,9 +531,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class GeneralIntracellularEphys(ConfiguredBaseModel):
@ -534,7 +553,7 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
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[IntracellularElectrode]] = Field(
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[SweepTable] = Field(
@ -586,7 +605,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
invalid_times: Optional[TimeIntervals] = Field(
None, description="""Time intervals that should be removed from analysis."""
)
time_intervals: Optional[List[TimeIntervals]] = Field(
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
None,
description="""Optional additional table(s) for describing other experimental time intervals.""",
)

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -902,8 +918,14 @@ class SweepTable(DynamicTable):
}
},
)
series: List[PatchClampSeries] = Field(
..., description="""The PatchClampSeries with the sweep number in that row."""
series: VectorData[NDArray[Any, PatchClampSeries]] = Field(
...,
description="""The PatchClampSeries with the sweep number in that row.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
series_index: Named[VectorIndex] = Field(
...,
@ -927,9 +949,6 @@ class SweepTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularElectrodesTable(DynamicTable):
@ -952,8 +971,14 @@ class IntracellularElectrodesTable(DynamicTable):
}
},
)
electrode: List[IntracellularElectrode] = Field(
..., description="""Column for storing the reference to the intracellular electrode."""
electrode: VectorData[NDArray[Any, IntracellularElectrode]] = Field(
...,
description="""Column for storing the reference to the intracellular electrode.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
colnames: List[str] = Field(
...,
@ -964,9 +989,6 @@ class IntracellularElectrodesTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularStimuliTable(DynamicTable):
@ -1010,9 +1032,6 @@ class IntracellularStimuliTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularResponsesTable(DynamicTable):
@ -1056,9 +1075,6 @@ class IntracellularResponsesTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularRecordingsTable(AlignedDynamicTable):
@ -1110,7 +1126,7 @@ class IntracellularRecordingsTable(AlignedDynamicTable):
responses: IntracellularResponsesTable = Field(
..., description="""Table for storing intracellular response related metadata."""
)
value: Optional[List[DynamicTable]] = Field(
value: Optional[Dict[str, DynamicTable]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "DynamicTable"}]}}
)
colnames: List[str] = Field(
@ -1122,9 +1138,6 @@ class IntracellularRecordingsTable(AlignedDynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SimultaneousRecordingsTable(DynamicTable):
@ -1171,9 +1184,6 @@ class SimultaneousRecordingsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SimultaneousRecordingsTableRecordings(DynamicTableRegion):
@ -1259,9 +1269,6 @@ class SequentialRecordingsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SequentialRecordingsTableSimultaneousRecordings(DynamicTableRegion):
@ -1338,9 +1345,6 @@ class RepetitionsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class RepetitionsTableSequentialRecordings(DynamicTableRegion):
@ -1419,9 +1423,6 @@ class ExperimentalConditionsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class ExperimentalConditionsTableRepetitions(DynamicTableRegion):

View file

@ -50,12 +50,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -328,7 +344,7 @@ class DecompositionSeries(TimeSeries):
..., description="""Data decomposed into frequency bands."""
)
metric: str = Field(..., description="""The metric used, e.g. phase, amplitude, power.""")
source_channels: Named[Optional[DynamicTableRegion]] = Field(
source_channels: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""DynamicTableRegion pointer to the channels that this decomposition series was generated from.""",
json_schema_extra={
@ -476,9 +492,6 @@ class DecompositionSeriesBands(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class Units(DynamicTable):
@ -491,7 +504,7 @@ class Units(DynamicTable):
)
name: str = Field("Units", json_schema_extra={"linkml_meta": {"ifabsent": "string(Units)"}})
spike_times_index: Named[Optional[VectorIndex]] = Field(
spike_times_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the spike_times dataset.""",
json_schema_extra={
@ -506,7 +519,7 @@ class Units(DynamicTable):
spike_times: Optional[UnitsSpikeTimes] = Field(
None, description="""Spike times for each unit."""
)
obs_intervals_index: Named[Optional[VectorIndex]] = Field(
obs_intervals_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the obs_intervals dataset.""",
json_schema_extra={
@ -518,7 +531,7 @@ class Units(DynamicTable):
}
},
)
obs_intervals: VectorData[Optional[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
obs_intervals: Optional[VectorData[NDArray[Shape["* num_intervals, 2 start_end"], float]]] = (
Field(
None,
description="""Observation intervals for each unit.""",
@ -534,7 +547,7 @@ class Units(DynamicTable):
},
)
)
electrodes_index: Named[Optional[VectorIndex]] = Field(
electrodes_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into electrodes.""",
json_schema_extra={
@ -546,7 +559,7 @@ class Units(DynamicTable):
}
},
)
electrodes: Named[Optional[DynamicTableRegion]] = Field(
electrodes: Optional[Named[DynamicTableRegion]] = Field(
None,
description="""Electrode that each spike unit came from, specified using a DynamicTableRegion.""",
json_schema_extra={
@ -558,26 +571,32 @@ class Units(DynamicTable):
}
},
)
electrode_group: Optional[List[ElectrodeGroup]] = Field(
None, description="""Electrode group that each spike unit came from."""
electrode_group: Optional[VectorData[NDArray[Any, ElectrodeGroup]]] = Field(
None,
description="""Electrode group that each spike unit came from.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
waveform_mean: VectorData[
Optional[
waveform_mean: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform mean for each spike unit.""")
waveform_sd: VectorData[
Optional[
waveform_sd: Optional[
VectorData[
Union[
NDArray[Shape["* num_units, * num_samples"], float],
NDArray[Shape["* num_units, * num_samples, * num_electrodes"], float],
]
]
] = Field(None, description="""Spike waveform standard deviation for each spike unit.""")
waveforms: VectorData[Optional[NDArray[Shape["* num_waveforms, * num_samples"], float]]] = (
waveforms: Optional[VectorData[NDArray[Shape["* num_waveforms, * num_samples"], float]]] = (
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.""",
@ -588,7 +607,7 @@ class Units(DynamicTable):
},
)
)
waveforms_index: Named[Optional[VectorIndex]] = Field(
waveforms_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into the waveforms dataset. One value for every spike event. See 'waveforms' for more detail.""",
json_schema_extra={
@ -600,7 +619,7 @@ class Units(DynamicTable):
}
},
)
waveforms_index_index: Named[Optional[VectorIndex]] = Field(
waveforms_index_index: Optional[Named[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={
@ -622,9 +641,6 @@ class Units(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class UnitsSpikeTimes(VectorData):

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -299,7 +315,7 @@ class DfOverF(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[RoiResponseSeries]] = Field(
value: Optional[Dict[str, RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -314,7 +330,7 @@ class Fluorescence(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[RoiResponseSeries]] = Field(
value: Optional[Dict[str, RoiResponseSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "RoiResponseSeries"}]}}
)
name: str = Field(...)
@ -329,7 +345,7 @@ class ImageSegmentation(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[PlaneSegmentation]] = Field(
value: Optional[Dict[str, PlaneSegmentation]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "PlaneSegmentation"}]}}
)
name: str = Field(...)
@ -345,11 +361,18 @@ class PlaneSegmentation(DynamicTable):
)
name: str = Field(...)
image_mask: Optional[PlaneSegmentationImageMask] = Field(
image_mask: Optional[
VectorData[
Union[
NDArray[Shape["* num_roi, * num_x, * num_y"], Any],
NDArray[Shape["* num_roi, * num_x, * num_y, * num_z"], Any],
]
]
] = 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: Named[Optional[VectorIndex]] = Field(
pixel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into pixel_mask.""",
json_schema_extra={
@ -365,7 +388,7 @@ class PlaneSegmentation(DynamicTable):
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: Named[Optional[VectorIndex]] = Field(
voxel_mask_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index into voxel_mask.""",
json_schema_extra={
@ -381,7 +404,7 @@ class PlaneSegmentation(DynamicTable):
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]] = Field(
reference_images: Optional[Dict[str, ImageSeries]] = Field(
None,
description="""Image stacks that the segmentation masks apply to.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImageSeries"}]}},
@ -405,33 +428,6 @@ class PlaneSegmentation(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class PlaneSegmentationImageMask(VectorData):
"""
ROI masks for each ROI. Each image mask is the size of the original imaging plane (or volume) and members of the ROI are finite non-zero.
"""
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: str = Field(..., description="""Description of what these vectors represent.""")
value: 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 PlaneSegmentationPixelMask(VectorData):
@ -554,7 +550,7 @@ class ImagingPlane(NWBContainer):
None,
description="""Describes reference frame of origin_coords and grid_spacing. For example, this can be a text description of the anatomical location and orientation of the grid defined by origin_coords and grid_spacing or the vectors needed to transform or rotate the grid to a common anatomical axis (e.g., AP/DV/ML). This field is necessary to interpret origin_coords and grid_spacing. If origin_coords and grid_spacing are not present, then this field is not required. For example, if the microscope takes 10 x 10 x 2 images, where the first value of the data matrix (index (0, 0, 0)) corresponds to (-1.2, -0.6, -2) mm relative to bregma, the spacing between pixels is 0.2 mm in x, 0.2 mm in y and 0.5 mm in z, and larger numbers in x means more anterior, larger numbers in y means more rightward, and larger numbers in z means more ventral, then enter the following -- origin_coords = (-1.2, -0.6, -2) grid_spacing = (0.2, 0.2, 0.5) reference_frame = \"Origin coordinates are relative to bregma. First dimension corresponds to anterior-posterior axis (larger index = more anterior). Second dimension corresponds to medial-lateral axis (larger index = more rightward). Third dimension corresponds to dorsal-ventral axis (larger index = more ventral).\"""",
)
optical_channel: List[OpticalChannel] = Field(
optical_channel: Dict[str, OpticalChannel] = Field(
..., description="""An optical channel used to record from an imaging plane."""
)
device: Union[Device, str] = Field(
@ -668,7 +664,7 @@ class MotionCorrection(NWBDataInterface):
{"from_schema": "core.nwb.ophys", "tree_root": True}
)
value: Optional[List[CorrectedImageStack]] = Field(
value: Optional[Dict[str, CorrectedImageStack]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "CorrectedImageStack"}]}}
)
name: str = Field(...)
@ -710,7 +706,6 @@ DfOverF.model_rebuild()
Fluorescence.model_rebuild()
ImageSegmentation.model_rebuild()
PlaneSegmentation.model_rebuild()
PlaneSegmentationImageMask.model_rebuild()
PlaneSegmentationPixelMask.model_rebuild()
PlaneSegmentationVoxelMask.model_rebuild()
ImagingPlane.model_rebuild()

View file

@ -49,12 +49,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -130,7 +130,6 @@ from ...core.v2_4_0.core_nwb_ophys import (
MotionCorrection,
OpticalChannel,
PlaneSegmentation,
PlaneSegmentationImageMask,
PlaneSegmentationPixelMask,
PlaneSegmentationVoxelMask,
RoiResponseSeries,
@ -147,7 +146,7 @@ from ...core.v2_4_0.core_nwb_retinotopy import (
ImagingRetinotopyVasculatureImage,
)
from ...hdmf_common.v1_5_0.hdmf_common_base import Container, Data, SimpleMultiContainer
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix, CSRMatrixData
from ...hdmf_common.v1_5_0.hdmf_common_sparse import CSRMatrix
from ...hdmf_common.v1_5_0.hdmf_common_table import (
AlignedDynamicTable,
DynamicTable,
@ -202,12 +201,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -74,12 +74,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -114,7 +130,7 @@ class VectorDataMixin(BaseModel, Generic[T]):
# redefined in `VectorData`, but included here for testing and type checking
value: Optional[T] = None
def __init__(self, value: Optional[NDArray] = None, **kwargs):
def __init__(self, value: Optional[T] = None, **kwargs):
if value is not None and "value" not in kwargs:
kwargs["value"] = value
super().__init__(**kwargs)
@ -535,7 +551,7 @@ class ProcessingModule(NWBContainer):
{"from_schema": "core.nwb.base", "tree_root": True}
)
value: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
value: Optional[Dict[str, Union[DynamicTable, NWBDataInterface]]] = Field(
None,
json_schema_extra={
"linkml_meta": {"any_of": [{"range": "NWBDataInterface"}, {"range": "DynamicTable"}]}
@ -555,8 +571,8 @@ class Images(NWBDataInterface):
name: str = Field("Images", json_schema_extra={"linkml_meta": {"ifabsent": "string(Images)"}})
description: str = Field(..., description="""Description of this collection of images.""")
image: List[Image] = Field(..., description="""Images stored in this collection.""")
order_of_images: Named[Optional[ImageReferences]] = Field(
image: List[str] = Field(..., description="""Images stored in this collection.""")
order_of_images: Optional[Named[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={

View file

@ -55,12 +55,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -184,7 +200,7 @@ class BehavioralEpochs(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[IntervalSeries]] = Field(
value: Optional[Dict[str, IntervalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "IntervalSeries"}]}}
)
name: str = Field(...)
@ -199,7 +215,7 @@ class BehavioralEvents(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -214,7 +230,7 @@ class BehavioralTimeSeries(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -229,7 +245,7 @@ class PupilTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[TimeSeries]] = Field(
value: Optional[Dict[str, TimeSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}}
)
name: str = Field(...)
@ -244,7 +260,7 @@ class EyeTracking(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -259,7 +275,7 @@ class CompassDirection(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)
@ -274,7 +290,7 @@ class Position(NWBDataInterface):
{"from_schema": "core.nwb.behavior", "tree_root": True}
)
value: Optional[List[SpatialSeries]] = Field(
value: Optional[Dict[str, SpatialSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpatialSeries"}]}}
)
name: str = Field(...)

View file

@ -48,12 +48,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

View file

@ -65,12 +65,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -369,7 +385,7 @@ class EventWaveform(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[SpikeEventSeries]] = Field(
value: Optional[Dict[str, SpikeEventSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "SpikeEventSeries"}]}}
)
name: str = Field(...)
@ -384,7 +400,7 @@ class FilteredEphys(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)
@ -399,7 +415,7 @@ class LFP(NWBDataInterface):
{"from_schema": "core.nwb.ecephys", "tree_root": True}
)
value: Optional[List[ElectricalSeries]] = Field(
value: Optional[Dict[str, ElectricalSeries]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "ElectricalSeries"}]}}
)
name: str = Field(...)

View file

@ -63,12 +63,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -147,7 +163,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags: VectorData[Optional[NDArray[Any, str]]] = Field(
tags: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""User-defined tags that identify or categorize events.""",
json_schema_extra={
@ -156,7 +172,7 @@ class TimeIntervals(DynamicTable):
}
},
)
tags_index: Named[Optional[VectorIndex]] = Field(
tags_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for tags.""",
json_schema_extra={
@ -168,7 +184,7 @@ class TimeIntervals(DynamicTable):
}
},
)
timeseries: Named[Optional[TimeSeriesReferenceVectorData]] = Field(
timeseries: Optional[Named[TimeSeriesReferenceVectorData]] = Field(
None,
description="""An index into a TimeSeries object.""",
json_schema_extra={
@ -180,7 +196,7 @@ class TimeIntervals(DynamicTable):
}
},
)
timeseries_index: Named[Optional[VectorIndex]] = Field(
timeseries_index: Optional[Named[VectorIndex]] = Field(
None,
description="""Index for timeseries.""",
json_schema_extra={
@ -202,9 +218,6 @@ class TimeIntervals(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
# Model rebuild

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -176,28 +192,28 @@ class NWBFile(NWBContainer):
...,
description="""Date and time corresponding to time zero of all timestamps. The date is stored in UTC with local timezone offset as ISO 8601 extended formatted string: 2018-09-28T14:43:54.123+02:00. Dates stored in UTC end in \"Z\" with no timezone offset. Date accuracy is up to milliseconds. All times stored in the file use this time as reference (i.e., time zero).""",
)
acquisition: Optional[List[Union[DynamicTable, NWBDataInterface]]] = Field(
acquisition: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
analysis: Optional[Dict[str, 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[DynamicTable, NWBContainer]]] = Field(
scratch: Optional[Dict[str, 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]] = Field(
processing: Optional[Dict[str, 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"}]}},
@ -230,12 +246,12 @@ class NWBFileStimulus(ConfiguredBaseModel):
"linkml_meta": {"equals_string": "stimulus", "ifabsent": "string(stimulus)"}
},
)
presentation: Optional[List[TimeSeries]] = Field(
presentation: Optional[Dict[str, TimeSeries]] = Field(
None,
description="""Stimuli presented during the experiment.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "TimeSeries"}]}},
)
templates: Optional[List[Union[Images, TimeSeries]]] = Field(
templates: Optional[Dict[str, 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={
@ -315,11 +331,11 @@ 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[LabMetaData]] = Field(
lab_meta_data: Optional[Dict[str, 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]] = Field(
devices: Optional[Dict[str, Device]] = Field(
None,
description="""Description of hardware devices used during experiment, e.g., monitors, ADC boards, microscopes, etc.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "Device"}]}},
@ -334,12 +350,12 @@ class NWBFileGeneral(ConfiguredBaseModel):
intracellular_ephys: Optional[GeneralIntracellularEphys] = Field(
None, description="""Metadata related to intracellular electrophysiology."""
)
optogenetics: Optional[List[OptogeneticStimulusSite]] = Field(
optogenetics: Optional[Dict[str, OptogeneticStimulusSite]] = Field(
None,
description="""Metadata describing optogenetic stimuluation.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "OptogeneticStimulusSite"}]}},
)
optophysiology: Optional[List[ImagingPlane]] = Field(
optophysiology: Optional[Dict[str, ImagingPlane]] = Field(
None,
description="""Metadata related to optophysiology.""",
json_schema_extra={"linkml_meta": {"any_of": [{"range": "ImagingPlane"}]}},
@ -379,7 +395,7 @@ class GeneralExtracellularEphys(ConfiguredBaseModel):
}
},
)
electrode_group: Optional[List[ElectrodeGroup]] = Field(
electrode_group: Optional[Dict[str, ElectrodeGroup]] = Field(
None, description="""Physical group of electrodes."""
)
electrodes: Optional[ExtracellularEphysElectrodes] = Field(
@ -400,7 +416,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
"linkml_meta": {"equals_string": "electrodes", "ifabsent": "string(electrodes)"}
},
)
x: VectorData[Optional[NDArray[Any, float]]] = Field(
x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate of the channel location in the brain (+x is posterior).""",
json_schema_extra={
@ -409,7 +425,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
y: VectorData[Optional[NDArray[Any, float]]] = Field(
y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate of the channel location in the brain (+y is inferior).""",
json_schema_extra={
@ -418,7 +434,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
z: VectorData[Optional[NDArray[Any, float]]] = Field(
z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate of the channel location in the brain (+z is right).""",
json_schema_extra={
@ -427,7 +443,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
imp: VectorData[Optional[NDArray[Any, float]]] = Field(
imp: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""Impedance of the channel, in ohms.""",
json_schema_extra={
@ -445,7 +461,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
filtering: VectorData[Optional[NDArray[Any, str]]] = Field(
filtering: Optional[VectorData[NDArray[Any, str]]] = Field(
None,
description="""Description of hardware filtering, including the filter name and frequency cutoffs.""",
json_schema_extra={
@ -454,8 +470,14 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
group: List[ElectrodeGroup] = Field(
..., description="""Reference to the ElectrodeGroup this electrode is a part of."""
group: VectorData[NDArray[Any, ElectrodeGroup]] = Field(
...,
description="""Reference to the ElectrodeGroup this electrode is a part of.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
group_name: VectorData[NDArray[Any, str]] = Field(
...,
@ -466,7 +488,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_x: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_x: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""x coordinate in electrode group""",
json_schema_extra={
@ -475,7 +497,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_y: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_y: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""y coordinate in electrode group""",
json_schema_extra={
@ -484,7 +506,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
rel_z: VectorData[Optional[NDArray[Any, float]]] = Field(
rel_z: Optional[VectorData[NDArray[Any, float]]] = Field(
None,
description="""z coordinate in electrode group""",
json_schema_extra={
@ -493,7 +515,7 @@ class ExtracellularEphysElectrodes(DynamicTable):
}
},
)
reference: VectorData[Optional[NDArray[Any, str]]] = Field(
reference: Optional[VectorData[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={
@ -512,9 +534,6 @@ class ExtracellularEphysElectrodes(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class GeneralIntracellularEphys(ConfiguredBaseModel):
@ -537,7 +556,7 @@ class GeneralIntracellularEphys(ConfiguredBaseModel):
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[IntracellularElectrode]] = Field(
intracellular_electrode: Optional[Dict[str, IntracellularElectrode]] = Field(
None, description="""An intracellular electrode."""
)
sweep_table: Optional[SweepTable] = Field(
@ -589,7 +608,7 @@ class NWBFileIntervals(ConfiguredBaseModel):
invalid_times: Optional[TimeIntervals] = Field(
None, description="""Time intervals that should be removed from analysis."""
)
time_intervals: Optional[List[TimeIntervals]] = Field(
time_intervals: Optional[Dict[str, TimeIntervals]] = Field(
None,
description="""Optional additional table(s) for describing other experimental time intervals.""",
)

View file

@ -72,12 +72,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):
@ -903,8 +919,14 @@ class SweepTable(DynamicTable):
}
},
)
series: List[PatchClampSeries] = Field(
..., description="""The PatchClampSeries with the sweep number in that row."""
series: VectorData[NDArray[Any, PatchClampSeries]] = Field(
...,
description="""The PatchClampSeries with the sweep number in that row.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
series_index: Named[VectorIndex] = Field(
...,
@ -928,9 +950,6 @@ class SweepTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularElectrodesTable(DynamicTable):
@ -953,8 +972,14 @@ class IntracellularElectrodesTable(DynamicTable):
}
},
)
electrode: List[IntracellularElectrode] = Field(
..., description="""Column for storing the reference to the intracellular electrode."""
electrode: VectorData[NDArray[Any, IntracellularElectrode]] = Field(
...,
description="""Column for storing the reference to the intracellular electrode.""",
json_schema_extra={
"linkml_meta": {
"array": {"maximum_number_dimensions": False, "minimum_number_dimensions": 1}
}
},
)
colnames: List[str] = Field(
...,
@ -965,9 +990,6 @@ class IntracellularElectrodesTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularStimuliTable(DynamicTable):
@ -1011,9 +1033,6 @@ class IntracellularStimuliTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularResponsesTable(DynamicTable):
@ -1057,9 +1076,6 @@ class IntracellularResponsesTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class IntracellularRecordingsTable(AlignedDynamicTable):
@ -1111,7 +1127,7 @@ class IntracellularRecordingsTable(AlignedDynamicTable):
responses: IntracellularResponsesTable = Field(
..., description="""Table for storing intracellular response related metadata."""
)
value: Optional[List[DynamicTable]] = Field(
value: Optional[Dict[str, DynamicTable]] = Field(
None, json_schema_extra={"linkml_meta": {"any_of": [{"range": "DynamicTable"}]}}
)
colnames: List[str] = Field(
@ -1123,9 +1139,6 @@ class IntracellularRecordingsTable(AlignedDynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SimultaneousRecordingsTable(DynamicTable):
@ -1172,9 +1185,6 @@ class SimultaneousRecordingsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SimultaneousRecordingsTableRecordings(DynamicTableRegion):
@ -1260,9 +1270,6 @@ class SequentialRecordingsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class SequentialRecordingsTableSimultaneousRecordings(DynamicTableRegion):
@ -1339,9 +1346,6 @@ class RepetitionsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class RepetitionsTableSequentialRecordings(DynamicTableRegion):
@ -1420,9 +1424,6 @@ class ExperimentalConditionsTable(DynamicTable):
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[VectorData]] = Field(
None, description="""Vector columns, including index columns, of this dynamic table."""
)
class ExperimentalConditionsTableRepetitions(DynamicTableRegion):

View file

@ -56,12 +56,28 @@ class ConfiguredBaseModel(BaseModel):
return handler(v)
except Exception as e1:
try:
if hasattr(v, "value"):
return handler(v.value)
else:
return handler(v.value)
except AttributeError:
try:
return handler(v["value"])
except Exception as e2:
raise e2 from e1
except (IndexError, KeyError, TypeError):
raise e1
@field_validator("*", mode="before")
@classmethod
def coerce_subclass(cls, v: Any, info) -> Any:
"""Recast parent classes into child classes"""
if isinstance(v, BaseModel):
annotation = cls.model_fields[info.field_name].annotation
while hasattr(annotation, "__args__"):
annotation = annotation.__args__[0]
try:
if issubclass(annotation, type(v)) and annotation is not type(v):
v = annotation(**{**v.__dict__, **v.__pydantic_extra__})
except TypeError:
# fine, annotation is a non-class type like a TypeVar
pass
return v
class LinkMLMeta(RootModel):

Some files were not shown because too many files have changed in this diff Show more