Uncertainty Estimation#
UE#
- class calibrain.uncertainty_estimation.UncertaintyEstimator(confidence_levels=None, logger=None)[source]#
Bases:
object- __init__(confidence_levels=None, logger=None)[source]#
Initialize the uncertainty estimator.
Parameters:#
- confidence_levelslist, optional
List of confidence levels to compute confidence ellipses. Default is np.arange(0.0, 1.1, 0.1).
- loggerlogging.Logger, optional
Logger instance for logging messages.
- construct_full_covariance(x=None, x_hat_active_indices=None, posterior_cov=None, orientation_type='fixed')[source]#
Create a full covariance matrix corresponding to all source components, embedding the posterior covariance of the active set.
- Return type:
Parameters:#
- xnp.ndarray
Ground truth source activity values for active components. Shape: (n_sources, n_times) for fixed orientation or (n_sources, 3, n_times) for free orientation.
- x_hat_active_indicesnp.ndarray
Indices of the active reconstructed sources in the original x_hat.
- posterior_covnp.ndarray
Full Posterior covariance matrix. Shape: (n_active_sources, n_active_sources) for fixed orientation or
(n_active_sources*3, n_active_sources*3) for free orientation.
- orientation_typestr
Orientation type of the sources, either ‘fixed’ or ‘free’.
Returns:#
: full_posterior_cov : np.ndarray
Full covariance matrix of shape (n_total_components, n_total_components), where n_total_components is the total number of source components.
- get_confidence_intervals_data(x, x_hat, posterior_cov, orientation_type)[source]#
Computes confidence intervals and counts of true values within those intervals.
Parameters:#
- xnp.ndarray
Ground truth source activity. Shape (n_sources, n_times).
- x_hatnp.ndarray
Estimated source activity (posterior mean). Shape (n_sources, n_times).
- posterior_covnp.ndarray
Posterior covariance matrix of shape (n_sources, n_sources).
- orientation_typestr
Orientation type, either ‘free’ or ‘fixed’.
Returns:#
: tuple
- ci_lower_stacked (np.ndarray): Lower bounds of confidence intervals for each confidence level.
Shape (n_confidence_levels, n_active_components, n_times).
- ci_upper_stacked (np.ndarray): Upper bounds of confidence intervals for each confidence level.
Shape (n_confidence_levels, n_active_components, n_times).
- counts_array (np.ndarray): Counts of true values within confidence intervals for each confidence level.
Shape (n_confidence_levels, 3, n_times) for free orientation, or (n_confidence_levels, 1, n_times) for fixed orientation.