API Reference#
This page documents the stable public API of jamica.
Most users will interact with one of these interfaces:
jamica.Amicafor fitting AMICA directly on NumPy arrays.jamica.fit_ica()for single-model MNE-Python workflows.jamica.AmicaICAfor multi-model fits, which exposes onemne.preprocessing.ICAper model.jamica.amica()as the stable single-model solver boundary for frameworks such as MNE that already whiten and PCA-reduce their data. See MNE single-model solver contract for its matrix and validation contract.
Core API#
Classes#
Native JAX implementation of AMICA algorithm. |
|
Configuration for AMICA algorithm. |
|
Container for AMICA results. |
|
Multi-model AMICA fit exposing one |
Functions#
- jamica.amica(X, n_components=None, whiten=False, return_n_iter=False, random_state=None, max_iter=2000, num_mix=3, *, num_models=1, min_dll=1e-09, do_newton=True, newt_start=50, chunk_size='auto')[source]#
Fit a single AMICA model through a Picard-compatible interface.
Returns the
(K, W, Y)tuple MNE-Python’s ICA dispatch expects (the calling convention shared by its FastICA/Infomax/Picard methods).With
whiten=False, this function is a strict preprocessed-data boundary: JAMICA performs no centering, sphering, or PCA, and always fits exactly one model. In that mode the returned unmixing matrix operates directly onX, including when the solver applies its emergency scalar rescaling for numerical stability.- Parameters:
- X
ndarray,shape(n_features,n_samples) Pre-whitened data, features x samples. This matches MNE’s ICA-method convention; MNE passes
data[:, sel].Twhich gives (n_components, n_samples).- n_components
int|None Number of components. With
whiten=False, this must beNoneor equal toX.shape[0]because the input has already been reduced by the caller. Withwhiten=True, it controls JAMICA’s internal PCA.- whitenbool
If True, whiten the data internally. MNE always passes False (data is pre-whitened by MNE’s PCA step).
- return_n_iterbool
If True, return n_iter as a fourth element:
K, W, Y, n_iter.- random_state
int|numpy.random.RandomState|numpy.random.Generator|None Random state controlling initialization. Integer seeds are repeatable across calls; NumPy RNG objects are consumed in place.
- max_iter
int Maximum number of EM iterations.
- num_mix
int Number of generalized Gaussian mixture components per source.
- num_models
int Number of AMICA models. Only
1is supported by this functional interface. Usejamica.AmicaICAfor multiple models.- min_dll
float Minimum log-likelihood improvement used for convergence.
- do_newtonbool
Whether to use Newton updates after the natural-gradient warm-up.
- newt_start
int Iteration at which Newton updates may begin.
- chunk_size
int| ‘auto’ |None Number of samples per E-step block.
'auto'selects a block size from the active backend and available memory.
- X
- Returns:
- K
ndarray,shape(n_components,n_features),orNone Pre-whitening matrix. Always None when
whiten=False, which is the case for MNE (it pre-whitens itself and discards this value). Whenwhiten=Truethis is the sphering matrix, including any scalar input rescaling applied by the solver.- W
ndarray,shape(n_components,n_components) Unmixing matrix. With
whiten=False, it operates directly onX. Withwhiten=True, it operates on the centered data transformed byK.- Y
ndarray,shape(n_components,n_samples) Source matrix. This is exactly
W @ Xwhenwhiten=False; otherwise JAMICA’s centering and the returnedKare also applied.- n_iter
int Number of iterations. Only returned when
return_n_iter=True, as the fourth element.
- K
Fit ICA using AMICA on MNE Raw or Epochs data. |
|
Return an |
|
Read an |
Warnings#
Warning raised when JAMICA stops before convergence. |