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

MAINT: Offload GUI abstraction #11990

Open
larsoner opened this issue Sep 12, 2023 · 7 comments
Open

MAINT: Offload GUI abstraction #11990

larsoner opened this issue Sep 12, 2023 · 7 comments
Assignees

Comments

@larsoner
Copy link
Member

larsoner commented Sep 12, 2023

@alexrockhill and now @wmvanvliet have raised issues about the complexity of our GUI backend abstraction. TL;DR is that it works most of the time for what we already have (brain and coreg I think), but can be very difficult to add new stuff.

I went looking for an abstraction layer for Qt/ipywidgets and it looks like there is one:

https://github.com/pyapp-kit/magicgui

It's MIT licensed, actively developed, and available on PyPI and conda-forge. One disadvantage is that it looks like it has a truck factor of one. But with our expertise maybe we can become active contributors there instead of just in our own code!

I'm tempted to take a look at look in the coming weeks at how it works and see if I can fairly easily get a pyvistaqt.BackgroundPlotter in when it's Qt and a trame-backend pyvista.Plotter when it's in notebook with some interaction.

EDIT: Might also take care of #11027

@larsoner larsoner self-assigned this Sep 12, 2023
@larsoner
Copy link
Member Author

While we're at it, I've also used vedo a bit instead of PyVista and some of the interfaces were quite nice. We could try it as well. It has nice stuff like working SSAO and classes for hover legends. One time I had to compute the intersection of two meshes and it was super easy (I just + / __add__ed them!).

In principle we could see how difficult it would be to add it as a new 3D backend. Right now PyVistaQt isn't maintained super well, and the interactions between PyVistaQt and PyVista cause problems fairly regularly. In vedo I think Plotter has first-class support for Qt given this example passes qt_widget=... in the Plotter class initialization. We already have a 3D abstraction layer for our transition from Mayavi a couple of years ago, so trying out vedo as a "new" backend might not be too difficult actually. (Maybe just a few hours of work to get surface plotting working?)

@wmvanvliet
Copy link
Contributor

vedo looks cool. But does it support the contour lines we would need for plot_evoked_field?

@larsoner
Copy link
Member Author

I think something like https://vedo.embl.es/docs/vedo/mesh.html#Mesh.isolines is probably what we'd want

@wmvanvliet
Copy link
Contributor

oh yeah! neat.

@agramfort
Copy link
Member

No strong feeling here. Whatever works !

@larsoner
Copy link
Member Author

larsoner commented Oct 5, 2023

In ~150 lines we can get widgets + PyVista + matplotlib in a reasonable layout (no events hooked up yet, incomplete widgets, too), with MNE's Brain in the leftmost image for comparison:

MNE magic-Qt magic-notebook

Cross-ref pyapp-kit/magicgui#593 (comment)

@agramfort
Copy link
Member

agramfort commented Oct 5, 2023 via email

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

No branches or pull requests

3 participants