mne_denoise.sns.compute_sns_weights#

mne_denoise.sns.compute_sns_weights(cov: ndarray, n_neighbors: int = 0, skip: int = 0, *, rcond: float = 1e-12, callback=None) tuple[ndarray, int, ndarray][source]#

Compute SNS weights from a channel covariance matrix.

Parameters:
covndarray, shape (n_channels, n_channels)

Finite symmetric positive-semidefinite covariance matrix.

n_neighborsint, default=0

Number of neighbors per channel; zero uses all available neighbors.

skipint, default=0

Number of most-correlated neighbors to omit.

rcondfloat, default=1e-12

Relative pseudoinverse cutoff.

callbackcallable or None, default=None

Synchronous callback after each channel solve.

Returns:
weightsndarray, shape (n_channels, n_channels)

Operator for centered channel-first data.

n_neighbors_usedint

Effective neighbor count.

neighbor_ranksndarray, shape (n_channels,)

Numerical rank of each selected neighbor covariance.

See also

SNS

Estimator that fits and reuses the SNS operator.

compute_sns

One-shot SNS operation for channel-first data.

Examples

>>> import numpy as np
>>> from mne_denoise.sns import compute_sns_weights
>>> rng = np.random.default_rng(0)
>>> data = rng.standard_normal((8, 1000))
>>> weights, n_neighbors, ranks = compute_sns_weights(np.cov(data), n_neighbors=4)