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 FilterBaseClass.

Type:

dict[str, type[FilterBaseClass]], 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)[source]#

Register a feature in the registry.

Note

The feature name must be unique and the attribute name of the feature will be set to the feature name.

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

  • feature (Type[FilterBaseClass]) – The feature to register.

Raises:

ValueError – If the feature is already registered

register_model(name, model_class, is_classifier, save_function, load_function, train_function, predict_function, changeable_parameters=None, unchangeable_parameters=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.

Raises:

ValueError – If the model is already registered.

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.

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.

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.