cedalion.dataclasses.schemas

Data array schemas and utilities to build labeled data arrays.

Functions

build_labeled_points([coordinates, crs, ...])

Build a labeled point cloud data array.

build_stim_dataframe()

build_timeseries(data, dims, time, channel, ...)

Build a labeled time series data array.

validate_schemas(func)

validate_stim_schema(df)

Classes

DataArraySchema(dims, coords)

Exceptions

ValidationError

exception cedalion.dataclasses.schemas.ValidationError[source]

Bases: Exception

class cedalion.dataclasses.schemas.DataArraySchema(dims: tuple[str], coords: tuple[tuple[str, tuple[str]]])[source]

Bases: object

dims: tuple[str][source]
coords: tuple[tuple[str, tuple[str]]][source]
validate(data_array: DataArray)[source]
cedalion.dataclasses.schemas.validate_schemas(func)[source]
cedalion.dataclasses.schemas.build_timeseries(
data: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes],
dims: List[str],
time: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes],
channel: List[str],
value_units: str,
time_units: str,
other_coords: dict[str, _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]] = {},
)[source]

Build a labeled time series data array.

Parameters:
  • data (ArrayLike) – The data values.

  • dims (List[str]) – The dimension names.

  • time (ArrayLike) – The time values.

  • channel (List[str]) – The channel names.

  • value_units (str) – The units of the data values.

  • time_units (str) – The units of the time values.

  • other_coords (dict[str, ArrayLike]) – Additional coordinates.

Returns:

The labeled time series data array.

Return type:

da (xr.DataArray)

cedalion.dataclasses.schemas.build_labeled_points(
coordinates: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] | None = None,
crs: str = 'pos',
units: Unit | str | None = '1',
labels: list[str] | None = None,
types: list[str] | None = None,
)[source]

Build a labeled point cloud data array.

Parameters:
  • coordinates (ArrayLike, optional) – The coordinates of the points. Default: None.

  • crs (str, optional) – The coordinate system. Defaults to “pos”.

  • units (Optional[pint.Unit | str], optional) – The units of the coordinates. Defaults to “1”.

  • labels (Optional[list[str]], optional) – The labels of the points. Defaults to None.

  • types (Optional[list[str]], optional) – The types of the points. Defaults to None.

Returns:

The labeled point cloud data array.

Return type:

xr.DataArray

cedalion.dataclasses.schemas.validate_stim_schema(df: DataFrame)[source]
cedalion.dataclasses.schemas.build_stim_dataframe()[source]