mne_denoise.dss.DSS#

class mne_denoise.dss.DSS(bias: LinearDenoiser | Callable, n_components: int | None = None, rank: int | dict | None = None, reg: float = 1e-09, normalize_input: bool = True, cov_method: str = 'empirical', cov_kws: dict | None = None, return_type: str = 'sources')[source]#

Denoising Source Separation (DSS) Transformer.

Implements DSS as a scikit-learn compatible transformer that fits natively on MNE-Python objects (Raw, Epochs, Evoked) or numpy arrays.

Parameters:
  • n_components (int, optional) – Number of DSS components to keep. If None, keep all.

  • bias (LinearDenoiser) – Bias function to define the signal of interest. Must be an instance of mne_denoise.dss.LinearDenoiser (e.g. BandpassBias, TrialAverageBias) or a callable that takes data and returns biased data.

  • rank (int or dict, optional) – Rank of the data for whitening. If None, rank is estimated automatically.

  • reg (float) – Regularization for covariance estimation. Default 1e-9.

  • normalize_input (bool) – If True, normalize input data channel-wise (L2 norm) before fitting/transforming. Useful when mixing sensors with different scales (e.g. MAG and GRAD). Default True.

  • cov_method (str) – Method for covariance estimation. For MNE objects, passed as method to mne.compute_covariance. For NumPy arrays, passed as method to mne_denoise.utils.compute_covariance. Default ‘empirical’.

  • cov_kws (dict, optional) – Additional keywords options for covariance estimation. For MNE objects, passed to mne.compute_covariance (e.g. {‘tstep’: 0.1, ‘rank’: ‘info’}). For NumPy arrays, passed to mne_denoise.utils.compute_covariance (e.g. {‘shrinkage’: 0.1}).

  • return_type ({'sources', 'epochs', 'raw'}) – Type of object to return from transform. ‘sources’ returns a numpy array of DSS components. ‘epochs’/’raw’ returns the denoised input object.

filters_#

The spatial filters (un-mixing matrix).

Type:

array, shape (n_components, n_channels)

patterns_#

The spatial patterns (mixing matrix).

Type:

array, shape (n_channels, n_components)

eigenvalues_#

The power of each component in the biased data (bias score).

Type:

array, shape (n_components,)

Examples

>>> from mne_denoise.dss import DSS, BandpassBias
>>> from mne_denoise.dss.denoisers import TrialAverageBias
>>> # Create a bias (e.g. emphasize 10Hz oscillations)
>>> bias = BandpassBias(sfreq=250, freq=10, bandwidth=2)
>>> # Initialize DSS
>>> dss = DSS(bias=bias, n_components=3)
>>> # Fit on data (MNE Raw/Epochs or NumPy)
>>> dss.fit(raw_data)
>>> # Extract sources
>>> sources = dss.transform(raw_data)
>>> # Or return denoised data
>>> dss.return_type = "raw"
>>> denoised_raw = dss.transform(raw_data)

See also

compute_dss

Functional interface for computing DSS solutions.

__init__(bias: LinearDenoiser | Callable, n_components: int | None = None, rank: int | dict | None = None, reg: float = 1e-09, normalize_input: bool = True, cov_method: str = 'empirical', cov_kws: dict | None = None, return_type: str = 'sources') None[source]#

Methods

__init__(bias[, n_components, rank, reg, ...])

fit(X[, y, weights])

Compute DSS spatial filters.

fit_transform(X[, y])

Fit to data, then transform it.

get_metadata_routing()

Get metadata routing of this object.

get_normalized_patterns()

Get L2-normalized spatial patterns for visualization.

get_params([deep])

Get parameters for this estimator.

inverse_transform(sources[, component_indices])

Transform sources back to sensor space.

set_fit_request(*[, weights])

Configure whether metadata should be requested to be passed to the fit method.

set_inverse_transform_request(*[, ...])

Configure whether metadata should be requested to be passed to the inverse_transform method.

set_output(*[, transform])

Set output container.

set_params(**params)

Set the parameters of this estimator.

transform(X)

Apply DSS spatial filters.