Skip to content

ENH: Notebook 3d backend improvements (ipyvtklink) #8704

Closed

Description

@GuillaumeFavelier

I open this issue following #8503 (comment) to keep track of the missing features or anything that could be improved.

Feature status

Design/UX


Known issues

Resolved

JupyterLab

  • matplotlib is not interactive Javascript Error: IPython is not defined
  • The mesh is translucent
  • A VTK window opens on local instance

Google Colab


A testing notebook is available on gist.github.com.

Activity

  1. changed the title [-]Notebook improvements[/-] [+]Notebook 3d backend improvements (ipyvtk)[/+] on Jan 7, 2021
  2. GuillaumeFavelier commented on Jan 7, 2021

    @GuillaumeFavelier
    ContributorAuthor

    About Google Colab, I made some research @agramfort.

    Considering that ipyvtk_simple's main viewer class, ViewInteractiveWidget, is based on ipycanvas's Canvas widget, I found that it is a known issue. The short answer is (and I quote Martin Renou):

    Custom widgets libraries are not supported by Google colab yet

    We could track the progress on this matter on https://github.com/martinRenou/ipycanvas/issues/170 or more directly in googlecolab/colabtools#498.

    Anyway, I think those need to be resolved before more can be expected from ipyvtk_simple and finally mne-python.

  3. larsoner commented on Jan 7, 2021

    @larsoner
    Member

    For movie and autoplay I think you basically need a timer, e.g. https://stackoverflow.com/questions/57255394/jupyter-and-timer-functions

    For a screenshot it seems like it should be fairly easy since the ipyvtk_simple is sending bitmaps, and/or we should be able to get the Renderer directly and get the image from it

    For label time course do you need more than https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20List.html#Dropdown ?

    For sizing I think it's https://ipywidgets.readthedocs.io/en/latest/examples/Widget%20Styling.html

  4. GuillaumeFavelier commented on Jan 7, 2021

    @GuillaumeFavelier
    ContributorAuthor

    Exactly what I was looking for, thank you @larsoner 👍

  5. changed the title [-]Notebook 3d backend improvements (ipyvtk)[/-] [+]ENH: Notebook 3d backend improvements (ipyvtk)[/+] on Feb 3, 2021
  6. GuillaumeFavelier commented on Apr 14, 2021

    @GuillaumeFavelier
    ContributorAuthor

    The mouse events on Firefox might be fixed by Kitware/ipyvtklink#25. I'll open a PR and give it a try.

  7. GuillaumeFavelier commented on Apr 14, 2021

    @GuillaumeFavelier
    ContributorAuthor

    It might not be necessary, I don't have those issues anymore on Firefox 87.0

  8. GuillaumeFavelier commented on Apr 29, 2021

    @GuillaumeFavelier
    ContributorAuthor

    For Jupyter Lab integration it might worth trying again once pyvista/pyvista#1116 is fixed.

  9. GuillaumeFavelier commented on Mar 9, 2022

    @GuillaumeFavelier
    ContributorAuthor

    Quick update: ipycanvas now works on Google Colab. It's a big milestone for the notebook 3d backend.

    https://github.com/martinRenou/ipycanvas/issues/170#issuecomment-1062071346

    I'll check ipyvtklink and report back in here.

  10. agramfort commented on Mar 9, 2022

    @agramfort
    SponsorMember
  11. changed the title [-]ENH: Notebook 3d backend improvements (ipyvtk)[/-] [+]ENH: Notebook 3d backend improvements (ipyvtklink)[/+] on Mar 9, 2022
  12. GuillaumeFavelier commented on Mar 9, 2022

    @GuillaumeFavelier
    ContributorAuthor

    Although now ipycanvas is supported on Google Colab, vtk, even on notebook, still requires a running X server.

    My testing workflow is: ipycanvas ✔️ -> ipyvtklink ✔️ -> pyvista (ipyvtklink) ✔️ -> mne-python (notebook)

    It's a work in progress but I managed to get it working at low resolution, which is already amazing IMO.
    Here is a modified version of ipyvtklink's default example:

    output.mp4

    The important points:

    1. setting the custom widget manager
    from google.colab import output
    output.enable_custom_widget_manager()
    
    1. setting up xvfb
    !sudo apt update
    !sudo apt-get install libgl1-mesa-dev xvfb
    !sudo apt install -yqq libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 libopengl0
    
    1. start xvfb with the correct DISPLAY variable at the beginning of the cell
    !/sbin/start-stop-daemon --start --quiet --background --exec /usr/bin/Xvfb -- :99 -screen 0 800x600x24 -ac +extension GLX +render -noreset
    
    import os
    os.environ['DISPLAY'] = ':99'
    

    Note:
    I tested on Mozilla Firefox 97.0.2.

    Known issues:
    I encountered a bug where I have to change the size of the viewer explicitly to re-render.

  13. larsoner commented on Oct 1, 2023

    @larsoner
    Member

    I think we can close this now that the notebook seems to be working correctly (even nowadays with trame)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions