Skip to content

Interactive version of plot_evoked_fieldmap#11942

Merged
larsoner merged 158 commits intomne-tools:mainfrom
wmvanvliet:fieldlines2
Sep 19, 2023
Merged

Interactive version of plot_evoked_fieldmap#11942
larsoner merged 158 commits intomne-tools:mainfrom
wmvanvliet:fieldlines2

Conversation

@wmvanvliet
Copy link
Copy Markdown
Contributor

@wmvanvliet wmvanvliet commented Aug 31, 2023

Continuation of #11676 but now on top of the new UI events system. This PR is built on top of #11891

All the functionality is there I think. Now it just needs to be made a bit more pretty.

Todo:

  • Implement the core functionality
  • Make HTML notebook version pretty
  • Move time interaction to renderer so it can be shared between Brain and EvokedField
  • Add unit tests
  • Add documentation
  • Update What's new

@wmvanvliet
Copy link
Copy Markdown
Contributor Author

While digging in the whole playback business I stumbled across the _PlayMenu class that is there but doesn't seem to be used at all. Looks like stuff we wanted to implement at some point but abandoned.

@larsoner
Copy link
Copy Markdown
Member

Feel free to delete it if it's not used, it's in git history if we need it later. And we might want to implement it differently/better in the end anyway

@wmvanvliet wmvanvliet marked this pull request as ready for review September 12, 2023 15:35
@wmvanvliet
Copy link
Copy Markdown
Contributor Author

Ready from my end!

@larsoner
Copy link
Copy Markdown
Member

CircleCI failed, feel free to look or I can look later

@larsoner
Copy link
Copy Markdown
Member

CIs should be fixed, will test and look at code hopefully tomorrow!

Copy link
Copy Markdown
Member

@larsoner larsoner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run the example and slide the Brain time slider I get updates to the clim sliders that are incorrect (they change which they shouldn't, and they don't update the clim values actually), can you replicate?

Screenshot 2023-09-12 at 5 09 07 PM

But other than that it's remarkably smooth!

mne/viz/_3d.py Outdated
.. versionadded:: 1.1
time_viewer : bool | str
Display time viewer GUI. Can also be ``"auto"``, which will mean
``True`` for the PyVista backend and ``False`` otherwise.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyVista is currently the only 3d backend, I thought at first you meant PyVistaQt vs notebook. But looking at the code I think you mean

Suggested change
``True`` for the PyVista backend and ``False`` otherwise.
``True`` if there is more than one time point and ``False`` otherwise.

.. versionadded:: 1.1
time_viewer : bool | str
Display time viewer GUI. Can also be ``"auto"``, which will mean
``True`` for the PyVista backend and ``False`` otherwise.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also fix here

if not self._in_brain_figure:
self._renderer.set_camera(azimuth=10, elevation=60)

self._renderer.show()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably also should be indented / only done if not in a brain?

else:
raise ValueError(f"No {type.upper()} field map currently shown.")

def rescale(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be private I think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I guess so.


# Test plotting inside an existing Brain figure. This should not work in a notebook.
brain = Brain("fsaverage", "lh", "inflated", subjects_dir=subjects_dir)
if get_3d_backend() == "notebook":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that renderer ran both notebook and non-notebook variants, but it doesn't look that way :(

Looks like we'd have to create a test_notebook.py like this to test this stuff properly on notebook, basically each "test" contains Python code that must be self-contained (with all imports and variables etc.) necessary to run it in nbexec:

https://github.com/mne-tools/mne-python/blob/main/mne/viz/_brain/tests/test_notebook.py

One fairly low-effort solution is to write some minimal code to take care of covering the time_viewer=True and time_viewer=False cases plus the Brain-embedding case (which would cover this NotImplementedError. If you're sick of this notebook business I could push it quickly I think.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm giving it a try.

@wmvanvliet
Copy link
Copy Markdown
Contributor Author

When I run the example and slide the Brain time slider I get updates to the clim sliders that are incorrect (they change which they shouldn't, and they don't update the clim values actually), can you replicate?

Unfortunately, this doesn't replicate on my Window nor my Linux machine. Is this on OSX?

@larsoner
Copy link
Copy Markdown
Member

Unfortunately, this doesn't replicate on my Window nor my Linux machine. Is this on OSX?

I was, but after updating I no longer see this behavior. Not sure if you fixed something or I had some broken code, but I think we're okay now!

CircleCI and pip-pre are being fixed in #11926 which I'll merge into this branch once it's in. I'll also look at the code again and mark for green when merge assuming I don't find anything else, thanks in advance!

@larsoner larsoner enabled auto-merge (squash) September 19, 2023 20:39
@larsoner larsoner merged commit d2883d5 into mne-tools:main Sep 19, 2023
larsoner added a commit to larsoner/mne-python that referenced this pull request Sep 20, 2023
* upstream/main:
  Interactive version of plot_evoked_fieldmap (mne-tools#11942)
  ENH: Add support for Artinis SNIRF data (mne-tools#11926)
@larsoner
Copy link
Copy Markdown
Member

@wmvanvliet can you quickly fix the failures here?

https://app.circleci.com/pipelines/github/mne-tools/mne-python/20847/workflows/308d8d33-9678-42e4-9dcb-51f2b2ec3d08/jobs/59285

If not I can do it. I think we maybe just need time_viewer=False or so

@wmvanvliet
Copy link
Copy Markdown
Contributor Author

#12005

snwnde pushed a commit to snwnde/mne-python that referenced this pull request Mar 20, 2024
@wmvanvliet wmvanvliet deleted the fieldlines2 branch July 18, 2024 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants