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) tuple[ndarray, int, ndarray][source]#
Compute the SNS spatial operator from a channel covariance matrix.
Each channel is regenerated by a least-squares projection onto its most correlated neighbour channels. The channel itself is always excluded, so the diagonal of the resulting operator is zero [1].
- Parameters:
cov (ndarray, shape (n_channels, n_channels)) – Finite, symmetric, positive-semidefinite channel covariance matrix.
n_neighbors (int, default=0) – Number of neighbours used to regenerate each channel. Zero uses all available channels after applying
skip.skip (int, default=0) – Number of the most-correlated neighbours to omit. This can be useful when adjacent sensors may share local noise.
rcond (float, default=1e-12) – Relative cutoff for the pseudoinverse of each neighbour covariance.
- Returns:
weights (ndarray, shape (n_channels, n_channels)) – Spatial operator to apply to centered channel-first data.
n_neighbors_used (int) – Effective number of neighbours after capping to those available.
neighbor_ranks (ndarray, shape (n_channels,)) – Numerical rank of each selected neighbour covariance.
- Raises:
TypeError – If an integer parameter or
rcondhas an invalid type.ValueError – If
covor an operating parameter is invalid.
Notes
For centered data
X, the regenerated signal isweights @ X.References
[1]de Cheveigné, A., & Simon, J. Z. (2008). Sensor noise suppression. Journal of Neuroscience Methods, 168(1), 195-202. https://doi.org/10.1016/j.jneumeth.2007.09.012