mne_rt.tools.ORICA#

class mne_rt.tools.ORICA(n_channels: int, learning_rate: float = 0.1, block_size: int = 256, online_whitening: bool = True, calibrate_pca: bool = False, forgetfac: float = 1.0, nonlinearity: str = 'tanh', random_state: int | None = None)[source]#

Bases: object

Online Recursive ICA (ORICA) for EEG data.

Parameters:
n_channelsint

Number of input EEG channels.

learning_ratefloat

Learning rate for ICA updates.

block_sizeint

Size of blocks for online updates.

online_whiteningbool

If True, perform online whitening. If False, assumes input is already whitened.

calibrate_pcabool

If True, estimate whitening matrix from the first block and fix it. If False, update recursively.

forgetfacfloat

Forgetting factor for online covariance (0 < forgetfac <= 1). Values < 1 allow adaptation to nonstationary signals.

nonlinearitystr

Nonlinearity: "tanh", "pow3", or "gauss".

random_stateint | None

Seed for reproducibility.

__init__(n_channels: int, learning_rate: float = 0.1, block_size: int = 256, online_whitening: bool = True, calibrate_pca: bool = False, forgetfac: float = 1.0, nonlinearity: str = 'tanh', random_state: int | None = None) None[source]#

Methods

__init__(n_channels[, learning_rate, ...])

denoise(X, artifact_idx)

Remove specific ICs and reconstruct sensor data.

find_blink_ic(template_map[, threshold])

Identify ICs corresponding to blinks by template correlation.

fit_transform(X)

Fit on X and return estimated sources.

inverse_transform(S)

Reconstruct sensor-space data from source signals.

partial_fit(X)

Update the unmixing matrix with a new block of EEG data.

transform(X)

Project data to source space without updating W.

update_and_denoise(X, template_map[, threshold])

Fit one block, detect blinks by template, and return cleaned data.

partial_fit(X: ndarray) ORICA[source]#

Update the unmixing matrix with a new block of EEG data.

Parameters:
Xndarray, shape (n_channels, n_samples)

EEG data block.

Returns:
self
transform(X: ndarray) ndarray[source]#

Project data to source space without updating W.

Parameters:
Xndarray, shape (n_channels, n_samples)
Returns:
Sndarray, shape (n_channels, n_samples)
fit_transform(X: ndarray) ndarray[source]#

Fit on X and return estimated sources.

Equivalent to partial_fit(X) followed by transform(X).

inverse_transform(S: ndarray) ndarray[source]#

Reconstruct sensor-space data from source signals.

Applies the full inverse pipeline: X_rec = whitening_inv_ @ pinv(W) @ S + mean_

Parameters:
Sndarray, shape (n_channels, n_samples)

Source signals to reconstruct.

Returns:
X_recndarray, shape (n_channels, n_samples)

Identify ICs corresponding to blinks by template correlation.

Parameters:
template_mapndarray, shape (n_channels,)

Spatial topography of a typical blink.

thresholdfloat

Absolute-correlation threshold.

Returns:
blink_idxlist of int
corrsndarray, shape (n_channels,)
denoise(X: ndarray, artifact_idx: list[int]) ndarray[source]#

Remove specific ICs and reconstruct sensor data.

Parameters:
Xndarray, shape (n_channels, n_samples)

Raw EEG data.

artifact_idxlist of int

Component indices to suppress.

Returns:
X_cleanndarray, shape (n_channels, n_samples)
update_and_denoise(X: ndarray, template_map: ndarray, threshold: float = 0.7) ndarray[source]#

Fit one block, detect blinks by template, and return cleaned data.

Parameters:
Xndarray, shape (n_channels, n_samples)
template_mapndarray, shape (n_channels,)
thresholdfloat
Returns:
X_cleanndarray, shape (n_channels, n_samples)