|
16 | 16 | logger, |
17 | 17 | ) |
18 | 18 | from ._covs_ged import _ssd_estimate |
19 | | -from ._mod_ged import _ssd_mod |
| 19 | +from ._mod_ged import _get_spectral_ratio, _ssd_mod |
20 | 20 | from .base import _GEDTransformer |
21 | 21 |
|
22 | 22 |
|
@@ -289,6 +289,37 @@ def fit_transform(self, X, y=None, **fit_params): |
289 | 289 | # use parent TransformerMixin method but with custom docstring |
290 | 290 | return super().fit_transform(X, y=y, **fit_params) |
291 | 291 |
|
| 292 | + def get_spectral_ratio(self, ssd_sources): |
| 293 | + """Get the spectal signal-to-noise ratio for each spatial filter. |
| 294 | +
|
| 295 | + Spectral ratio measure for best n_components selection |
| 296 | + See :footcite:`NikulinEtAl2011`, Eq. (24). |
| 297 | +
|
| 298 | + Parameters |
| 299 | + ---------- |
| 300 | + ssd_sources : array |
| 301 | + Data projected to SSD space. |
| 302 | +
|
| 303 | + Returns |
| 304 | + ------- |
| 305 | + spec_ratio : array, shape (n_channels) |
| 306 | + Array with the sprectal ratio value for each component. |
| 307 | + sorter_spec : array, shape (n_channels) |
| 308 | + Array of indices for sorting spec_ratio. |
| 309 | +
|
| 310 | + References |
| 311 | + ---------- |
| 312 | + .. footbibliography:: |
| 313 | + """ |
| 314 | + spec_ratio, sorter_spec = _get_spectral_ratio( |
| 315 | + ssd_sources=ssd_sources, |
| 316 | + sfreq=self.sfreq_, |
| 317 | + n_fft=self.n_fft_, |
| 318 | + freqs_signal=self.freqs_signal_, |
| 319 | + freqs_noise=self.freqs_noise_, |
| 320 | + ) |
| 321 | + return spec_ratio, sorter_spec |
| 322 | + |
292 | 323 | def inverse_transform(self): |
293 | 324 | """Not implemented yet.""" |
294 | 325 | raise NotImplementedError("inverse_transform is not yet available.") |
|
0 commit comments