torch_brain.registry

DataType

Enum defining possible data types for modalities.

ModalitySpec

Specification class for defining modalities.

register_modality()

Register a new modality specification in the global registry.

get_modality_by_id()

Get a modality specification by its ID.

class DataType(value)[source]

Enum defining the possible data types.

CONTINUOUS

For continuous-valued variables

BINARY

For binary variables

MULTINOMIAL

For multi-class variables

MULTILABEL

For multi-label variables

CONTINUOUS = 0
BINARY = 1
MULTINOMIAL = 2
MULTILABEL = 3
class ModalitySpec(*args, **kwargs)[source]

Specification for a modality.

dim

Dimension for this modality

type

DataType enum specifying the data type

loss_fn

Name of loss function to use for this modality

timestamp_key

Key to access timestamps in the data object

value_key

Key to access values in the data object

id

Unique numeric ID assigned to this modality

id: int
dim: int
type: DataType
timestamp_key: str
value_key: str
loss_fn: Callable
register_modality(name, **kwargs)[source]

Register a new modality specification in the global registry.

Parameters:
  • name (str) – Unique identifier for this modality

  • **kwargs (Any) – Keyword arguments used to construct the ModalitySpec Must include: dim, type, loss_fn, timestamp_key, value_key

Returns:

Unique numeric ID assigned to this modality

Return type:

int

Raises:

ValueError – If a modality with the given name already exists

get_modality_by_id(modality_id)[source]

Get a modality specification by its ID.

Parameters:

modality_id (int) – The numeric ID of the modality to retrieve

Returns:

The modality specification

Return type:

ModalitySpec

Raises:

KeyError – If no modality exists with the given ID