amica.AmicaResult#

class amica.AmicaResult(unmixing_matrix_white_, mixing_matrix_white_, unmixing_matrix_sensor_, mixing_matrix_sensor_, whitener_, dewhitener_, mean_, alpha_, mu_, rho_, sbeta_, c_, gm_, log_likelihood, n_iter, iteration_times=<factory>, elapsed_times=<factory>, converged=False, data_scale=1.0, model_posteriors_=None, sample_mask_=None, n_rejected_=0)[source]#

Bases: object

Container for AMICA results.

Attributes:
unmixing_matrix_white_np.ndarray, shape (n_components, n_components)

Unmixing matrix W in whitened space: sources = W @ x_white.

mixing_matrix_white_np.ndarray, shape (n_components, n_components)

Mixing matrix A in whitened space: x_white = A @ sources + c.

unmixing_matrix_sensor_np.ndarray, shape (n_components, n_channels)

Full unmixing in sensor space: W @ sphere.

mixing_matrix_sensor_np.ndarray, shape (n_channels, n_components)

Full mixing in sensor space: desphere @ A.

whitener_np.ndarray, shape (n_components, n_channels)

Sphering/whitening matrix S.

dewhitener_np.ndarray, shape (n_channels, n_components)

Dewhitening matrix (pseudo-inverse of sphere).

mean_np.ndarray, shape (n_channels,)

Data mean removed during preprocessing.

alpha_np.ndarray, shape (n_mix, n_components) or (n_models, n_mix, n_components)

Mixture weights for each component.

mu_np.ndarray, shape (n_mix, n_components) or (n_models, n_mix, n_components)

Location parameters.

rho_np.ndarray, shape (n_mix, n_components) or (n_models, n_mix, n_components)

Shape parameters.

sbeta_np.ndarray, shape (n_mix, n_components) or (n_models, n_mix, n_components)

Scale parameters (inverse beta).

c_np.ndarray, shape (n_components,) or (n_models, n_components)

Model centers.

gm_np.ndarray, shape (n_models,)

Model weights (for multi-model).

log_likelihoodnp.ndarray, shape (n_iter,)

Log-likelihood per iteration.

iteration_timesnp.ndarray, shape (n_iter,)

Wall-clock time per iteration in seconds.

elapsed_timesnp.ndarray, shape (n_iter,)

Cumulative wall-clock time in seconds.

n_iterint

Number of iterations performed.

convergedbool

Whether the algorithm converged.

sample_mask_np.ndarray of bool or None, shape (n_samples,)

Likelihood-based sample-rejection mask over the fit-input samples (True = kept). None when do_reject was off or never fired. Single-model only; indexes the data passed to fit (post-decim / post-epoch-reject), not the original recording times.

n_rejected_int

Number of samples rejected ((~sample_mask_).sum()); 0 if no rejection.

Parameters:

Notes

Matrix naming convention

AMICA operates in whitened space. Matrices are stored in both spaces with explicit suffixes to avoid ambiguity:

  • *_white_ — whitened space (after sphering)

  • *_sensor_ — original sensor space

The relationship is:

sources = unmixing_matrix_white_ @ whitener_ @ (data - mean_)
data = mixing_matrix_sensor_ @ sources + mean_
__init__(unmixing_matrix_white_, mixing_matrix_white_, unmixing_matrix_sensor_, mixing_matrix_sensor_, whitener_, dewhitener_, mean_, alpha_, mu_, rho_, sbeta_, c_, gm_, log_likelihood, n_iter, iteration_times=<factory>, elapsed_times=<factory>, converged=False, data_scale=1.0, model_posteriors_=None, sample_mask_=None, n_rejected_=0)#
Parameters:
Return type:

None

Methods

__init__(unmixing_matrix_white_, ...[, ...])

to_mne(info)

Convert results to MNE ICA object.

Attributes

unmixing_matrix_white_: ndarray#
mixing_matrix_white_: ndarray#
unmixing_matrix_sensor_: ndarray#
mixing_matrix_sensor_: ndarray#
whitener_: ndarray#
dewhitener_: ndarray#
mean_: ndarray#
alpha_: ndarray#
mu_: ndarray#
rho_: ndarray#
sbeta_: ndarray#
c_: ndarray#
gm_: ndarray#
log_likelihood: ndarray#
n_iter: int#
iteration_times: ndarray#
elapsed_times: ndarray#
converged: bool = False#
data_scale: float = 1.0#
model_posteriors_: ndarray | None = None#
sample_mask_: ndarray | None = None#
n_rejected_: int = 0#
to_mne(info)[source]#

Convert results to MNE ICA object.

AMICA decomposes as: sources = W @ S @ (x - mean) where W is the unmixing matrix in whitened space and S is the sphering/whitening matrix.

MNE’s ICA reconstructs via: unmixing_full = unmixing_ @ pca_components_[:n_comp] mixing_full = pca_components_.T @ mixing_

To make these equivalent we use QR decomposition on the combined transform W @ S to extract an orthonormal pca_components_ (Q.T) and a square unmixing_matrix_ (R), satisfying MNE’s requirement that pca_components_ has orthonormal rows.

Parameters:
infomne.Info

Measurement info (from the Raw/Epochs used for fitting).

Returns:
icamne.preprocessing.ICA

Fitted MNE ICA object compatible with plot_components(), get_sources(), apply(), and ICLabel.