msqms.qc.metrics_factory module#
Factory class for creating and managing different metrics for MEG data.
Summary#
Classes:#
A factory class for creating and managing metrics for MEG data quality control. |
Reference#
- class msqms.qc.metrics_factory.MetricsFactory[source]#
Bases:
objectA factory class for creating and managing metrics for MEG data quality control.
This class supports registering new metric classes, creating metric instances, and registering custom metric implementations.
- _registry#
A registry that maps metric names to their corresponding classes.
- Type:
dict
- _add_domain#
The name of the most recently added custom domain.
- Type:
str or None
- register_custom_metric(name, func, custom_metrics_name)[source]#
Registers a custom metric class using a user-defined function.
- classmethod register_metric(name, metric_class)[source]#
Register a new metric class.
- Parameters:
name (str) – The name of the metric to register.
metric_class (type) – The metric class to register. Must be a subclass of Metrics.
- Raises:
ValueError – If the provided class is not a subclass of Metrics.
- classmethod create_metric(name, *args, **kwargs)[source]#
Create an instance of a registered metric class.
- Parameters:
name (str) – The name of the registered metric to instantiate.
*args – Positional arguments to pass to the metric class constructor.
**kwargs – Keyword arguments to pass to the metric class constructor.
- Returns:
instance – An instance of the specified metric class.
- Return type:
- Raises:
ValueError – If no metric class is registered under the given name.
- classmethod register_custom_metric(name, func, custom_metrics_name)[source]#
Register a custom metric class using a user-defined function.
- Parameters:
name (str) – The name of the custom metric domain.
func (callable) – A function that defines how to compute the custom metrics. The function should accept a Metrics instance as its first argument and meg_type as a keyword argument.
custom_metrics_name (list of str) – Names of the custom metrics computed by the function.
Notes
The new custom domain is added to METRICS_DOMAIN.
The corresponding metric names are appended to METRICS_COLUMNS.