Test plotting of components as instances of raw and epochs.
(browser_backend)
| 514 | |
| 515 | |
| 516 | def 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 |
nothing calls this directly
no test coverage detected