Registry#

class myogestic.utils.config.Registry[source]#

The registry class is used to store different components of a MyoGestic application pipeline.

models_map#

A dictionary that maps model names to tuples of model classes and whether the model is a classifier, by default {}. The tuple is in the form (model_class, is_classifier).

Type:

dict[str, tuple[Any, bool]], optional

models_functions_map#

A dictionary that maps model names to dictionaries of model functions, by default {}. The functions are save, load, train, and predict.

Type:

dict[str, dict[Literal[“save”, “load”, “train”, “predict”], callable]], optional

models_parameters_map#

A dictionary that maps model names to dictionaries of model parameters, by default {}. The parameters are changeable and unchangeable. The changeable parameters are dictionaries of changeable parameters, while the unchangeable parameters are dictionaries of unchangeable parameters. See the ChangeableParameter and UnchangeableParameter types for more information.

Type:

dict[str, dict[Literal[“changeable”, “unchangeable”], Union[ChangeableParameter, UnchangeableParameter]]], optional

features_map#

A dictionary that maps feature names to feature classes, by default {}. The feature class must be subclasses of Transform (TensorTransform).

Type:

dict[str, type[Transform]], optional

real_time_filters_map#

A dictionary that maps filter names to filter functions, by default {}. A filter function is a callable that takes a single argument, which is the data to filter. The data will be a list of floats that represent the regression output of a model.

Type:

dict[str, callable], optional

visual_interfaces_map#

A dictionary that maps visual interface names to tuples of setup and recording interface classes, by default {}. The setup interface class must be a subclass of SetupInterfaceTemplate, while the recording interface class must be a subclass of RecordingInterfaceTemplate.

Type:

dict[str, tuple[type[SetupInterfaceTemplate], type[RecordingInterfaceTemplate]]], optional

output_systems_map#

A dictionary that maps output system names to output system classes, by default {}. The output system class must be a subclass of OutputSystemTemplate.

Type:

dict[str, type[OutputSystemTemplate]], optional

Methods

__init__()

register_feature(name, feature[, ...])

Register a feature in the registry.

register_model(name, model_class, ...[, ...])

Register a model in the registry.

register_output_system(name, output_system)

Register an output system in the registry.

register_real_time_filter(name, function)

Register a real-time filter in the registry.

register_visual_interface(name, ...)

Register a visual interface in the registry.

register_feature(name, feature, requires_temporal_preservation=False)[source]#

Register a feature in the registry.

Note

The feature name must be unique.

Parameters:
  • name (str) – The name of the feature.

  • feature (type[Transform]) – The feature transform class to register.

  • requires_temporal_preservation (bool, optional) – Whether this feature requires temporal preservation (keeps time dimension). Features like RMS Small Window that preserve the time dimension should set this to True. Default is False.

Raises:

ValueError – If the feature is already registered

Return type:

None

register_model(name, model_class, is_classifier, save_function, load_function, train_function, predict_function, changeable_parameters=None, unchangeable_parameters=None, requires_temporal_preservation=False, feature_window_size=None)[source]#

Register a model in the registry.

The model name must be unique.

Parameters:
  • name (str) – The name of the model.

  • model_class (type) – The class of the model.

  • is_classifier (bool) – Whether the model is a classifier.

  • save_function (callable) – The function to save the model.

  • load_function (callable) – The function to load the model.

  • train_function (callable) – The function to train the model.

  • predict_function (callable) – The function to make predictions with the model.

  • changeable_parameters (dict of str to ChangeableParameter, optional) – A dictionary of changeable parameters for the model. Default is None.

  • unchangeable_parameters (dict of str to UnchangeableParameter, optional) – A dictionary of unchangeable parameters for the model. Default is None.

  • requires_temporal_preservation (bool, optional) – Whether the model requires temporal preservation in features. Default is False. Models like RaulNet with CNN layers need multiple temporal samples, so features should use smaller window sizes to preserve time dimension.

  • feature_window_size (int, optional) – The window size to use for feature extraction. Default is None, which uses the full buffer size. For models requiring temporal preservation, this should be smaller than the buffer size (e.g., 120 for RaulNet with buffer of 360).

Raises:

ValueError – If the model is already registered.

Return type:

None

register_output_system(name, output_system)[source]#

Register an output system in the registry.

Note

The output system name must be unique.

Parameters:
  • name (str) – The name of the output system.

  • output_system (callable) – The output system class.

Raises:

ValueError – If the output system is already registered.

Return type:

None

register_real_time_filter(name, function)[source]#

Register a real-time filter in the registry.

Note

The filter name must be unique.

Parameters:
  • name (str) – The name of the filter.

  • function (callable) – The filter function.

Raises:

ValueError – If the filter is already registered.

Return type:

None

register_visual_interface(name, setup_interface_ui, recording_interface_ui)[source]#

Register a visual interface in the registry.

Note

The output modality name must be unique.

Parameters:
Raises:

ValueError – If the visual interface is already registered.

Return type:

None