MCPcopy
hub / github.com/mne-tools/mne-python / _get_spectral_ratio

Function _get_spectral_ratio

mne/decoding/_mod_ged.py:54–83  ·  view source on GitHub ↗

Get the spectal signal-to-noise ratio for each spatial filter. Spectral ratio measure for best n_components selection See :footcite:`NikulinEtAl2011`, Eq. (24). Returns ------- spec_ratio : array, shape (n_channels) Array with the sprectal ratio value for each component

(ssd_sources, sfreq, n_fft, freqs_signal, freqs_noise)

Source from the content-addressed store, hash-verified

52
53
54def _get_spectral_ratio(ssd_sources, sfreq, n_fft, freqs_signal, freqs_noise):
55 """Get the spectal signal-to-noise ratio for each spatial filter.
56
57 Spectral ratio measure for best n_components selection
58 See :footcite:`NikulinEtAl2011`, Eq. (24).
59
60 Returns
61 -------
62 spec_ratio : array, shape (n_channels)
63 Array with the sprectal ratio value for each component.
64 sorter_spec : array, shape (n_channels)
65 Array of indices for sorting spec_ratio.
66
67 References
68 ----------
69 .. footbibliography::
70 """
71 psd, freqs = psd_array_welch(ssd_sources, sfreq=sfreq, n_fft=n_fft)
72 sig_idx = _time_mask(freqs, *freqs_signal)
73 noise_idx = _time_mask(freqs, *freqs_noise)
74 if psd.ndim == 3:
75 mean_sig = psd[:, :, sig_idx].mean(axis=2).mean(axis=0)
76 mean_noise = psd[:, :, noise_idx].mean(axis=2).mean(axis=0)
77 spec_ratio = mean_sig / mean_noise
78 else:
79 mean_sig = psd[:, sig_idx].mean(axis=1)
80 mean_noise = psd[:, noise_idx].mean(axis=1)
81 spec_ratio = mean_sig / mean_noise
82 sorter_spec = spec_ratio.argsort()[::-1]
83 return spec_ratio, sorter_spec
84
85
86def _ssd_mod(

Callers 6

test_ssdFunction · 0.90
test_ssd_epoched_dataFunction · 0.90
test_sortingFunction · 0.90
test_get_spectral_ratioFunction · 0.90
_ssd_modFunction · 0.85
get_spectral_ratioMethod · 0.85

Calls 3

psd_array_welchFunction · 0.85
_time_maskFunction · 0.85
meanMethod · 0.45

Tested by 4

test_ssdFunction · 0.72
test_ssd_epoched_dataFunction · 0.72
test_sortingFunction · 0.72
test_get_spectral_ratioFunction · 0.72