mne.decoding.SSD#
- class mne.decoding.SSD(info, filt_params_signal, filt_params_noise, reg=None, n_components=None, picks=None, sort_by_spectral_ratio=True, return_filtered=False, n_fft=None, cov_method_params=None, rank=None)[source]#
Signal decomposition using the Spatio-Spectral Decomposition (SSD).
SSD seeks to maximize the power at a frequency band of interest while simultaneously minimizing it at the flanking (surrounding) frequency bins (considered noise). It extremizes the covariance matrices associated with signal and noise [1].
SSD can either be used as a dimensionality reduction method or a ‘denoised’ low rank factorization method [2].
- Parameters:
- info
mne.Info
The
mne.Info
object with information about the sensors and methods of measurement. Must match the input data.- filt_params_signal
dict
Filtering for the frequencies of interest.
- filt_params_noise
dict
Filtering for the frequencies of non-interest.
- reg
float
|str
|None
(default) Which covariance estimator to use. If not None (same as ‘empirical’), allow regularization for covariance estimation. If float, shrinkage is used (0 <= shrinkage <= 1). For str options, reg will be passed to method
mne.compute_covariance()
.- n_components
int
|None
(defaultNone
) The number of components to extract from the signal. If None, the number of components equal to the rank of the data are returned (see
rank
).- picks
array
ofint
|None
(defaultNone
) The indices of good channels.
- sort_by_spectral_ratiobool (default
True
) If set to True, the components are sorted according to the spectral ratio. See Eq. (24) in [1].
- return_filteredbool (default
False
) If return_filtered is True, data is bandpassed and projected onto the SSD components.
- n_fft
int
(defaultNone
) If sort_by_spectral_ratio is set to True, then the SSD sources will be sorted according to their spectral ratio which is calculated based on
mne.time_frequency.psd_array_welch()
. The n_fft parameter sets the length of FFT used. Seemne.time_frequency.psd_array_welch()
for more information.- cov_method_params
dict
|None
(defaultNone
) As in
mne.decoding.SPoC
The default is None.- rank
None
|dict
| ‘info’ | ‘full’ As in
mne.decoding.SPoC
This controls the rank computation that can be read from the measurement info or estimated from the data, which determines the maximum possible number of components. See Notes ofmne.compute_rank()
for details. We recommend to use ‘full’ when working with epoched data.
- info
- Attributes:
Methods
apply
(X)Remove selected components from the signal.
fit
(X[, y])Estimate the SSD decomposition on raw or epoched data.
fit_transform
(X[, y])Fit SSD to data, then transform it.
Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
get_spectral_ratio
(ssd_sources)Get the spectal signal-to-noise ratio for each spatial filter.
Not implemented yet.
set_output
(*[, transform])Set output container.
set_params
(**params)Set the parameters of this estimator.
transform
(X)Estimate epochs sources given the SSD filters.
References
- apply(X)[source]#
Remove selected components from the signal.
This procedure will reconstruct M/EEG signals from which the dynamics described by the excluded components is subtracted (denoised by low-rank factorization). See [2] for more information.
Note
Unlike in other classes with an apply method, only NumPy arrays are supported (not instances of MNE objects).
- Parameters:
- Xarray, shape ([n_epochs, ]n_channels, n_times)
The input data from which to estimate the SSD. Either 2D array obtained from continuous data or 3D array obtained from epoched data.
- Returns:
- Xarray, shape ([n_epochs, ]n_channels, n_times)
The processed data.
- fit(X, y=None)[source]#
Estimate the SSD decomposition on raw or epoched data.
- Parameters:
- Xarray, shape ([n_epochs, ]n_channels, n_times)
The input data from which to estimate the SSD. Either 2D array obtained from continuous data or 3D array obtained from epoched data.
- y
None
Ignored; exists for compatibility with scikit-learn pipelines.
- Returns:
- selfinstance of
SSD
Returns the modified instance.
- selfinstance of
Examples using
fit
:Compute spatial filters with Spatio-Spectral Decomposition (SSD)
Compute spatial filters with Spatio-Spectral Decomposition (SSD)
- fit_transform(X, y=None, **fit_params)[source]#
Fit SSD to data, then transform it.
Fits transformer to
X
andy
with optional parametersfit_params
, and returns a transformed version ofX
.- Parameters:
- Xarray, shape ([n_epochs, ]n_channels, n_times)
The input data from which to estimate the SSD. Either 2D array obtained from continuous data or 3D array obtained from epoched data.
- y
None
Ignored; exists for compatibility with scikit-learn pipelines.
- **fit_params
dict
Additional fitting parameters passed to the
mne.decoding.SSD.fit()
method. Not used for this class.
- Returns:
- X_ssdarray, shape ([n_epochs, ]n_components, n_times)
The processed data.
- get_metadata_routing()[source]#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routing
MetadataRequest
A
MetadataRequest
encapsulating routing information.
- routing
- get_spectral_ratio(ssd_sources)[source]#
Get the spectal signal-to-noise ratio for each spatial filter.
Spectral ratio measure for best n_components selection See [1], Eq. (24).
- Parameters:
- ssd_sources
array
Data projected to SSD space.
- ssd_sources
- Returns:
References
Examples using
get_spectral_ratio
:Compute spatial filters with Spatio-Spectral Decomposition (SSD)
Compute spatial filters with Spatio-Spectral Decomposition (SSD)
- set_output(*, transform=None)[source]#
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
- transform{“default”, “pandas”, “polars”}, default=None
Configure output of
transform
andfit_transform
.“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
New in v1.4: “polars” option was added.
- Returns:
- self
estimator
instance Estimator instance.
- self
- set_params(**params)[source]#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline
). The latter have parameters of the form<component>__<parameter>
so that it’s possible to update each component of a nested object.
- transform(X)[source]#
Estimate epochs sources given the SSD filters.
- Parameters:
- Xarray, shape ([n_epochs, ]n_channels, n_times)
The input data from which to estimate the SSD. Either 2D array obtained from continuous data or 3D array obtained from epoched data.
- Returns:
- X_ssdarray, shape ([n_epochs, ]n_components, n_times)
The processed data.
Examples using
transform
:Compute spatial filters with Spatio-Spectral Decomposition (SSD)
Compute spatial filters with Spatio-Spectral Decomposition (SSD)
Examples using mne.decoding.SSD
#
Compute spatial filters with Spatio-Spectral Decomposition (SSD)