mne_denoise.sns.SNS#

class mne_denoise.sns.SNS(n_neighbors: int = 0, skip: int = 0, rcond: float = 1e-12, preserve_mean: bool = False, verbose: bool | str | int | None = None, n_iter: int = 1, outlier_threshold: float | None = None, chunk_size: int | None = None)[source]#

Sensor Noise Suppression estimator.

The estimator learns a channel mean and spatial operator from training data and reuses both during transform.

Parameters:
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.

preserve_meanbool, default=False

Add the fitted channel mean after regeneration.

verbosebool, str, int, or None, default=None

Logging level.

n_iterint, default=1

Number of SNS projections to compose.

outlier_thresholdfloat or None, default=None

Robust channel-wise z-score threshold for fitting.

chunk_sizeint or None, default=None

Samples per covariance/application chunk.

Attributes:
training_mean_ndarray

Weighted channel mean.

denoising_matrix_ndarray

Composite spatial operator.

denoising_matrices_tuple of ndarray

One operator per iteration.

neighbor_ranks_per_iteration_tuple of ndarray

Local covariance ranks by iteration.

See also

compute_sns

One-shot SNS operation for channel-first arrays.

compute_sns_weights

Construct the local sensor reconstruction operator.

mne_denoise.sound.SOUND

Forward-model-based sensor-noise suppression.

Notes

Channel-first NumPy arrays and MNE Raw, Epochs, and Evoked inputs are supported; transform returns the corresponding type without mutating the input. SNS reconstructs each channel from spatially redundant signals in other channels; it is intended for noise specific to individual sensors, not for a source or artifact shared across the array [1].

References

Examples

>>> import numpy as np
>>> from mne_denoise.sns import SNS
>>> rng = np.random.default_rng(0)
>>> data = rng.standard_normal((8, 1000))
>>> model = SNS(n_neighbors=4)
>>> clean = model.fit_transform(data)
fit(X: Any, y=None, sample_weight: ndarray | None = None, *, callback=None, verbose: bool | str | int | None = None) SNS[source]#

Fit the SNS mean and spatial operator.

Parameters:
Xarray-like or MNE Raw, Epochs, or Evoked

Data used to learn the operator.

yNone, default=None

Ignored for scikit-learn compatibility.

sample_weightndarray or None, default=None

Non-negative fitting weights.

callbackcallable or None, default=None

Synchronous channel-solve callback.

verbosebool, str, int, or None, default=None

Logging level.

Returns:
SNS

The fitted estimator.

fit_transform(X: Any, y=None, *, sample_weight: ndarray | None = None, callback=None, verbose: bool | str | int | None = None, **fit_params) Any[source]#

Fit SNS and apply the fitted operator.

Parameters:
Xarray-like or MNE Raw, Epochs, or Evoked

Data to fit and transform.

yNone, default=None

Ignored for scikit-learn compatibility.

sample_weightndarray or None, default=None

Non-negative fitting weights.

callbackcallable or None, default=None

Synchronous channel-solve callback.

verbosebool, str, int, or None, default=None

Logging level.

**fit_paramsdict

Unexpected fit parameters raise TypeError.

Returns:
same type as X

Sensor-noise-suppressed data.

transform(X: Any, y=None, *, verbose: bool | str | int | None = None) Any[source]#

Apply the fitted SNS operator.

Parameters:
Xarray-like or MNE Raw, Epochs, or Evoked

Data with the fitted channel layout.

yNone, default=None

Ignored for scikit-learn compatibility.

verbosebool, str, int, or None, default=None

Logging level.

Returns:
same type as X

A cleaned copy.