mne_denoise.sns.compute_sns#
- mne_denoise.sns.compute_sns(X: ndarray, n_neighbors: int = 0, skip: int = 0, *, rcond: float = 1e-12, preserve_mean: bool = False, n_iter: int = 1, outlier_threshold: float | None = None, chunk_size: int | None = None, sample_weight: ndarray | None = None) tuple[ndarray, dict[str, Any]][source]#
Learn and apply Sensor Noise Suppression to a channel-first array.
This convenience function applies the algorithm described in [1] to the same data used to estimate its spatial operator. Use
SNSwhen fitting and transforming separate data.- Parameters:
X (ndarray, shape (n_channels, n_times) | (n_epochs, n_channels, n_times)) – Multichannel continuous or epoched data.
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.
rcond (float, default=1e-12) – Relative cutoff for local covariance pseudoinverses.
preserve_mean (bool, default=False) – If True, add the fitted channel means back after regeneration.
n_iter (int, default=1) – Number of successive SNS projections to learn and compose.
outlier_threshold (float | None, default=None) – Maximum robust channel-wise z-score allowed when learning the operator. Rejected samples are still transformed. None disables rejection.
chunk_size (int | None, default=None) – Number of samples processed at once during covariance accumulation and operator application. None processes all samples together.
sample_weight (ndarray, shape (n_times,) | (n_epochs, n_times) | None) – Non-negative fitting weight for each sample. Zero excludes a sample when learning the mean and operator, but not when applying the operator.
- Returns:
X_clean (ndarray) – Sensor-noise-suppressed data with the same shape as
X.info (dict) – Fitted operator and numerical diagnostics.
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