calibrain.SourceEstimator#

class calibrain.SourceEstimator(solver, solver_params=None, noise_var=None, n_orient=1, logger=None)[source]#

Methods

fit(L, y)

Fit the inverse solver to the data.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

predict([y])

score(X, y[, sample_weight])

Return accuracy on provided data and labels.

set_fit_request(*[, L])

Configure whether metadata should be requested to be passed to the fit method.

set_params(**params)

Set the parameters of this estimator.

set_score_request(*[, sample_weight])

Configure whether metadata should be requested to be passed to the score method.

__init__(solver, solver_params=None, noise_var=None, n_orient=1, logger=None)[source]#

Initialize the SourceEstimator class.

Parameters:
  • solver (callable) – The inverse solver function (e.g., gamma_map_sflex, BMN).

  • solver_params (dict, optional) – Parameters for the solver function.

  • noise_var (float, optional) – Noise variance for the solver.

  • logger (logging.Logger, optional) – Logger instance for logging messages.

  • n_orient (int, optional) – Number of orientations for the sources. Default is 1 (for fixed orientation) or 3 (for free orientation).

fit(L, y)[source]#

Fit the inverse solver to the data.

Parameters:
  • L (np.ndarray) – Leadfield matrix of shape (n_sensors, n_sources) for fixed orientation or (n_sensors, n_sources, n_orient) for free orientation.

  • y (np.ndarray) – Observed EEG/MEG signals of shape (n_sensors, n_times).

Returns:

The fitted estimator.

Return type:

self

predict(y=None)[source]#
set_fit_request(*, L: bool | None | str = '$UNCHANGED$') SourceEstimator#

Configure whether metadata should be requested to be passed to the fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

L (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for L parameter in fit.

Returns:

self – The updated object.

Return type:

object

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') SourceEstimator#

Configure whether metadata should be requested to be passed to the score method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters:

sample_weight (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for sample_weight parameter in score.

Returns:

self – The updated object.

Return type:

object