mne_rt.tools.GEDAIDenoiser#
- class mne_rt.tools.GEDAIDenoiser(n_channels: int, shrinkage: float = 0.01)[source]#
Bases:
objectArtifact removal via Generalised Eigendecomposition-based Artifact Identification (GEDAI).
Solves the generalised eigenvalue problem (GEP):
\[\mathbf{C}\,\mathbf{w} = \lambda\,\mathbf{R}\,\mathbf{w}\]where \(\mathbf{C}\) is the signal covariance and \(\mathbf{R}\) is a reference covariance. Two modes are supported:
Leadfield mode (recommended, true GEDAI): \(\mathbf{R} = \mathbf{L}\mathbf{L}^\top\), where \(\mathbf{L}\) is the EEG forward/leadfield gain matrix. Components with large \(\lambda\) are well-explained by the brain’s theoretical source model and are kept; components with small \(\lambda\) are not leadfield-aligned and are treated as artifacts. Use
fit_from_leadfield()to fit in this mode.Band-filter mode (Cohen-style GED): \(\mathbf{C} = \mathbf{R}_{\mathrm{band}}\) and \(\mathbf{R} = \mathbf{R}_{\mathrm{broad}}\) (broadband EEG covariance, Tikhonov-regularised). Components with large \(\lambda\) maximise the target-band-to-broadband ratio. Use
fit()orfit_from_raw()for this mode.
In both modes the unmixing matrix \(\mathbf{W}\) (spatial filters) and activation patterns \(\mathbf{A} = (\mathbf{W}^\top)^+\) are stored after fitting. Denoising zeroes the selected artifact columns of \(\mathbf{A}\) and reconstructs clean sensor data as \(\hat{\mathbf{x}} = \mathbf{A}_{\mathrm{clean}}\,\mathbf{W}^\top\mathbf{x}\).
- Parameters:
References
Ros, T., Férat, V., Huang, Y., et al. (2025). Return of the GEDAI: Unsupervised EEG Denoising based on Leadfield Filtering. bioRxiv. https://doi.org/10.1101/2025.10.04.680449
Cohen, M. X. (2022). A tutorial on generalized eigendecomposition for denoising, contrast enhancement, and dimension reduction in multichannel electrophysiology. NeuroImage, 247, 118809.
Methods
__init__(n_channels[, shrinkage])denoise(data, artifact_idx)Suppress artifact components and reconstruct sensor data.
find_artifact_components(template_map[, ...])Identify artifact components by correlation with a spatial template.
find_noise_components([n_noise])Return indices of the
n_noisecomponents with smallest eigenvalues.fit(data_broadband, data_band)Estimate spatial filters from baseline data.
fit_from_leadfield(data, leadfield)Fit using the forward/leadfield matrix as the reference covariance.
fit_from_raw(data, sfreq, band)Convenience wrapper: bandpass-filter
datainternally then callfit.inverse_transform(components)Reconstruct sensor-space data from components.
transform(data)Project data into component space.
update_and_denoise(data, template_map[, ...])Identify blink/artifact components then denoise in one call.
Attributes
Activation patterns A = pinv(W.T), shape (n_channels, n_channels).
Sorted eigenvalues (descending) from the GED.
Spatial filters W, shape (n_channels, n_channels).
- fit(data_broadband: ndarray, data_band: ndarray) GEDAIDenoiser[source]#
Estimate spatial filters from baseline data.
- fit_from_leadfield(data: ndarray, leadfield: ndarray) GEDAIDenoiser[source]#
Fit using the forward/leadfield matrix as the reference covariance.
This is the true GEDAI mode described in Ros et al. (2025). The reference covariance is constructed as \(\mathbf{R} = \mathbf{L}\mathbf{L}^\top\) where \(\mathbf{L}\) is the leadfield gain matrix. Components whose eigenvalues are large are well-aligned with the theoretical brain source model and are treated as signal; components with small eigenvalues are artifact candidates.
- fit_from_raw(data: ndarray, sfreq: float, band: tuple[float, float]) GEDAIDenoiser[source]#
Convenience wrapper: bandpass-filter
datainternally then callfit.
- inverse_transform(components: ndarray) ndarray[source]#
Reconstruct sensor-space data from components.
- find_artifact_components(template_map: ndarray, threshold: float = 0.7) tuple[list[int], ndarray][source]#
Identify artifact components by correlation with a spatial template.
- find_noise_components(n_noise: int = 1) list[int][source]#
Return indices of the
n_noisecomponents with smallest eigenvalues.These components capture the least band-specific activity and are candidates for broadband noise.
- denoise(data: ndarray, artifact_idx: list[int]) ndarray[source]#
Suppress artifact components and reconstruct sensor data.