Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix bug with mne browser backend #12078

Merged
merged 10 commits into from
Oct 6, 2023
Merged

Conversation

ruuskas
Copy link
Contributor

@ruuskas ruuskas commented Oct 5, 2023

Changing the MNE browser backend with mne.set_config("MNE_BROWSER_BACKEND", "backend") would have no effect within a Python session. The following script will generate both plots with the backend that has been set in the config beforehand (or the default, if the backend has not been configured).

import mne
mne.set_config('MNE_BROWSER_BACKEND', 'qt')
raw_path = mne.datasets.sample.data_path() / "MEG" / "sample" / "sample_audvis_raw.fif"
raw = mne.io.read_raw_fif(raw_path)
raw.plot()
mne.set_config('MNE_BROWSER_BACKEND', 'matplotlib')
raw.plot()

This change leads to the expected behavior, i.e., mne.set_config('MNE_BROWSER_BACKEND', ...) changes the backend used by raw.plot().

This change fixes a bug where using mne.set_config() to change the
browser backend would have no effect within the same Python session.
@larsoner
Copy link
Member

larsoner commented Oct 5, 2023

The way we envisioned users interactively changing he backend in a session is by doing mne.viz.set_browser_backend. I think the solution here is to call this function inside set_config if the key is being set by the user, rather than by changing the existing logic. Does that make sense and solve your use case?

@drammock
Copy link
Member

drammock commented Oct 5, 2023

I think the solution here is to call this function inside set_config if the key is being set by the user, rather than by changing the existing logic.

Ah, that's a better approach than what I came up with. Sorry to have led you down the wrong path @ruuskas

This change fixes a bug where using mne.set_config() to change the
browser backend would have no effect within the same Python session.
@drammock drammock merged commit 92f5dd8 into mne-tools:main Oct 6, 2023
28 checks passed
larsoner added a commit to larsoner/mne-python that referenced this pull request Oct 10, 2023
* upstream/main: (37 commits)
  Use constrained layout in matplotlib visualization (mne-tools#12050)
  Add raw stc (mne-tools#12001)
  [MRG] update codeowners (mne-tools#12089)
  DOC: Morlet wavelet length in tfr_morlet (mne-tools#12073)
  BUG: Fix bug with mne browser backend (mne-tools#12078)
  Cache avatars (mne-tools#12077)
  BUG: Fix bug with ch_name resolution (mne-tools#12086)
  add unicode roundtrip for FIF (mne-tools#12080)
  add Ivan to names.inc (mne-tools#12081)
  MAINT: Work around PySide 6.5.3 event loop error (mne-tools#12076)
  mne-tools#11608, buggfix and docstring update (mne-tools#12066)
  MAINT: Fix broken examples (mne-tools#12074)
  Add UI Event linking to DraggableColorbar (mne-tools#12057)
  handle lazy loading through .pyi type stubs (mne-tools#12072)
  BUG: Fix bug with sensor_colors (mne-tools#12068)
  clean  up some deprecations (mne-tools#12067)
  Allow not dropping bads when creating or plotting Spectrum objs (mne-tools#12006)
  Collapsible html repr for raw/info (mne-tools#12064)
  BUG: Fix bug with pickling MNEBadsList (mne-tools#12063)
  add details for Denis (mne-tools#12065)
  ...
snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants