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

Function test_plot_instance_components

mne/viz/tests/test_ica.py:516–564  ·  view source on GitHub ↗

Test plotting of components as instances of raw and epochs.

(browser_backend)

Source from the content-addressed store, hash-verified

514
515
516def test_plot_instance_components(browser_backend):
517 """Test plotting of components as instances of raw and epochs."""
518 raw = _get_raw()
519 picks = _get_picks(raw)
520 ica = ICA(noise_cov=read_cov(cov_fname), n_components=2)
521 with pytest.warns(RuntimeWarning, match="projection"):
522 ica.fit(raw, picks=picks)
523 ica.exclude = [0]
524 fig = ica.plot_sources(raw, title="Components")
525 keys = (
526 "home",
527 "home",
528 "end",
529 "down",
530 "up",
531 "right",
532 "left",
533 "-",
534 "+",
535 "=",
536 "d",
537 "d",
538 "pageup",
539 "pagedown",
540 "z",
541 "z",
542 "s",
543 "s",
544 "b",
545 )
546 for key in keys:
547 fig._fake_keypress(key)
548 x = fig.mne.traces[0].get_xdata()[0]
549 y = fig.mne.traces[0].get_ydata()[0]
550 fig._fake_click((x, y), xform="data")
551 fig._click_ch_name(ch_index=0, button=1)
552 fig._fake_keypress("escape")
553 browser_backend._close_all()
554
555 epochs = _get_epochs()
556 fig = ica.plot_sources(epochs, title="Components")
557 for key in keys:
558 fig._fake_keypress(key)
559 # Test a click
560 x = fig.mne.traces[0].get_xdata()[0]
561 y = fig.mne.traces[0].get_ydata()[0]
562 fig._fake_click((x, y), xform="data")
563 fig._click_ch_name(ch_index=0, button=1)
564 fig._fake_keypress("escape")
565
566
567@pytest.mark.slowtest

Callers

nothing calls this directly

Calls 10

fitMethod · 0.95
plot_sourcesMethod · 0.95
ICAClass · 0.90
read_covFunction · 0.90
_get_rawFunction · 0.70
_get_picksFunction · 0.70
_get_epochsFunction · 0.70
_fake_keypressMethod · 0.45
_fake_clickMethod · 0.45
_click_ch_nameMethod · 0.45

Tested by

no test coverage detected