Modality#

class myoverse.datasets.Modality(data=None, path=None, dims=('channel', 'time'), attrs=<factory>, transform=None)[source]#

Configuration for a data modality.

A modality represents a single data stream (EMG, kinematics, EEG, etc.) with its dimensionality and optional preprocessing.

Parameters:
  • data (np.ndarray | dict[str, np.ndarray] | None) – Data array or dict of arrays per task.

  • path (Path | str | None) – Path to pickle file containing data.

  • dims (tuple[str, ...]) – Dimension names (last must be ‘time’).

  • attrs (dict) – Optional attributes to store with the data.

  • transform (Callable | None) – Transform to apply after loading (receives tensor, returns tensor).

Examples

>>> emg = Modality(
...     path="emg.pkl",
...     dims=("channel", "time"),
... )
>>> # With preprocessing transform
>>> from myoverse.transforms import Compose, Flatten, Index
>>> kinematics = Modality(
...     path="kinematics.pkl",
...     dims=("dof", "time"),
...     transform=Compose([
...         Flatten(0, 1),  # (21, 3, time) -> (63, time)
...         Index(slice(3, None), dim="channel"),  # Remove wrist -> (60, time)
...     ]),
... )

Methods

__eq__(other)

Return self==value.

__init__([data, path, dims, attrs, transform])

__post_init__()

__repr__()

Return repr(self).

load()

Load data from path or return data dict, applying transform if set.

load()[source]#

Load data from path or return data dict, applying transform if set.

Returns:

Dict mapping task names to data arrays.

Return type:

dict[str, np.ndarray]