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

Function test_sorting

mne/decoding/tests/test_ssd.py:364–429  ·  view source on GitHub ↗

Test sorting learning during training.

()

Source from the content-addressed store, hash-verified

362
363
364def test_sorting():
365 """Test sorting learning during training."""
366 X, _, _ = simulate_data(n_trials=100, n_channels=20, n_samples=500)
367 # Epoch length is 1 second
368 X = np.reshape(X, (100, 20, 500))
369 # split data
370 Xtr, Xte = X[:80], X[80:]
371 sf = 250
372 n_channels = Xtr.shape[1]
373 info = create_info(ch_names=n_channels, sfreq=sf, ch_types="eeg")
374
375 filt_params_signal = dict(
376 l_freq=freqs_sig[0],
377 h_freq=freqs_sig[1],
378 l_trans_bandwidth=4,
379 h_trans_bandwidth=4,
380 )
381 filt_params_noise = dict(
382 l_freq=freqs_noise[0],
383 h_freq=freqs_noise[1],
384 l_trans_bandwidth=4,
385 h_trans_bandwidth=4,
386 )
387
388 # check sort_by_spectral_ratio set to False
389 ssd = SSD(
390 info,
391 filt_params_signal,
392 filt_params_noise,
393 n_components=None,
394 sort_by_spectral_ratio=False,
395 )
396 ssd.fit(Xtr)
397 _, sorter_tr = _get_spectral_ratio(
398 ssd.transform(Xtr), ssd.sfreq_, ssd.n_fft_, ssd.freqs_signal_, ssd.freqs_noise_
399 )
400 _, sorter_te = _get_spectral_ratio(
401 ssd.transform(Xte), ssd.sfreq_, ssd.n_fft_, ssd.freqs_signal_, ssd.freqs_noise_
402 )
403 assert any(sorter_tr != sorter_te)
404
405 # check sort_by_spectral_ratio set to True
406 ssd = SSD(
407 info,
408 filt_params_signal,
409 filt_params_noise,
410 n_components=None,
411 sort_by_spectral_ratio=True,
412 )
413 ssd.fit(Xtr)
414
415 # check sorters
416 sorter_in = ssd.sorter_
417 ssd = SSD(
418 info,
419 filt_params_signal,
420 filt_params_noise,
421 n_components=None,

Callers

nothing calls this directly

Calls 6

fitMethod · 0.95
transformMethod · 0.95
create_infoFunction · 0.90
SSDClass · 0.90
_get_spectral_ratioFunction · 0.90
simulate_dataFunction · 0.70

Tested by

no test coverage detected