mne_denoise.ssa.LocalSingularSpectrumAnalysis#
- class mne_denoise.ssa.LocalSingularSpectrumAnalysis(window_length: int | None = None, *, window_seconds: float | None = None, sfreq: float | None = None, n_clusters: int | str = 'auto', max_clusters: int = 10, max_window: int = 100, random_state: int | None = 0, verbose: bool | str | int | None = None)[source]#
Local-SSA high-amplitude artifact transformer.
The estimator applies the clustered local-subspace reconstruction of Teixeira et al. independently to each selected channel and exposes the fitted clustering diagnostics after transformation.
- Parameters:
window_length (int | None, default=None) – Delay-vector dimension in samples. It is mutually exclusive with
window_seconds. None selects an automatic value.window_seconds (float | None, default=None) – Delay-vector duration in seconds. It requires a sampling frequency and is mutually exclusive with
window_length.sfreq (float | None, default=None) – Sampling frequency in Hz. MNE input supplies it from metadata and must agree with an explicit value.
n_clusters (int | "auto", default="auto") – Number of delay-vector clusters, or automatic reliable selection.
max_clusters (int, default=10) – Upper bound for automatic cluster-count selection.
max_window (int, default=100) – Maximum delay-vector dimension used by automatic window selection.
random_state (int | None, default=0) – Random seed passed to k-means.
verbose (bool | str | int | None, default=None) – MNE-style logging level.
- sfreq_#
Validated sampling frequency, or None when sample-based parameters and NumPy input do not require one.
- Type:
float | None
- ch_names_in_#
Fitted MNE channel names and order, or None for NumPy input.
- diagnostics_#
Diagnostics from the most recent transformation. Epoched input stores one dictionary per epoch.
- n_clusters_#
Effective cluster count per channel, or per epoch and channel.
- Type:
ndarray
See also
compute_local_ssaFunctional interface for channel-first arrays.
local_ssa_clean_channelCanonical single-channel implementation.
mne_denoise.ssa.SingularSpectrumAnalysisBasic SSA with frequency grouping.
Notes
The estimator is transductive.
fitvalidates the operating point and records the channel layout; everytransformclusters and decomposes the records supplied to that call. Record and epoch boundaries can therefore change the delay vectors, clusters, covariance spectra, and reconstruction.Local SSA assumes that coherent, high-energy structure is artifact. Genuine neural activity that satisfies the same local-subspace model can be removed [1].
References
[1]Teixeira, A. R., Tome, A. M., Lang, E. W., Gruber, P., & Martins da Silva, A. (2006). Automatic removal of high-amplitude artefacts from single-channel electroencephalograms. Computer Methods and Programs in Biomedicine, 83, 125-138. https://doi.org/10.1016/j.cmpb.2006.06.003
Examples
>>> import numpy as np >>> from mne_denoise.ssa import LocalSingularSpectrumAnalysis >>> sfreq = 100.0 >>> time = np.arange(500) / sfreq >>> data = np.vstack( ... [np.sin(2 * np.pi * 0.5 * time), np.sin(2 * np.pi * 10.0 * time)] ... ) >>> model = LocalSingularSpectrumAnalysis( ... window_length=20, n_clusters=2, random_state=0 ... ) >>> cleaned = model.fit_transform(data) >>> cleaned.shape (2, 500)
- __init__(window_length: int | None = None, *, window_seconds: float | None = None, sfreq: float | None = None, n_clusters: int | str = 'auto', max_clusters: int = 10, max_window: int = 100, random_state: int | None = 0, verbose: bool | str | int | None = None) None[source]#
Methods
__init__([window_length, window_seconds, ...])fit(X[, y])Validate the operating point and record the fitted channel layout.
fit_transform(X[, y])Fit to data, then transform it.
get_metadata_routing()Get metadata routing of this object.
get_params([deep])Get parameters for this estimator.
set_output(*[, transform])Set output container.
set_params(**params)Set the parameters of this estimator.
transform(X[, y])Apply the transductive SSA decomposition to the supplied records.