Interest in mne docker

I have need for a containerized mne install complete with 3d graphics support (for full Qa reporting etc) and optionally with freesurfer (for bem creation etc).

Is there interest in something like this? Has anyone already done it?

I have played alittle bit with it, with middling success. Mostly due to the opengl stuff I think. If there is interest I can push it to github repo and iterate more publicly on it.

1 Like

Hello, I’m working on something similar, maybe we can join forces if you’re interested. So yes, feel free to push to GH if you want!

I think i settled on a base structure at least to start. You can find it here.

GitHub - bloyl/mne_docker.

I think that computation and 2D plotting work, but 3d plotting is broken. I have in mind to rebuild mesa with the opengl drivers, but I’d like to rule out other issues first. such as the vtk issue discussed at PyVista within a Docker Container — PyVista 0.29.0 documentation. Though I hoped that the vtk in the mne server_environment.yml sorted that issue.

Anyway, anyone interested in helping, ( @larsoner, @GuillaumeFavelier @sappelhoff @richard ) or pointing me in the right direction would be welcome.

Thanks for starting this @bloyl, I think it’s an interesting project :slight_smile:

The version of VTK used in server_environment.yml should rely on osmesa for rendering if mesalib is available in the environment. It was designed to be used with the “off_screen”, PyVista-based notebook 3d backend.

From what I see in your README.md, you try to use PyVista with PyQt5:

$ docker run -it mne_docker python work/plot_eeg_on_scalp.py
Opening raw data file /home/jovyan/mne_data/MNE-sample-data/MEG/sample/sample_audvis_raw.fif...
    Read a total of 3 projection items:
        PCA-v1 (1 x 102)  idle
        PCA-v2 (1 x 102)  idle
        PCA-v3 (1 x 102)  idle
    Range : 25800 ... 192599 =     42.956 ...   320.670 secs
Ready.
Using outer_skin.surf for head surface.
Using pyvista 3d backend.
...

Is that your intention?

The rest of the log seems related to an issue with Qt itself:

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

And I remember seeing this on CircleCI for example. IIRC, it’s because it needs a (virtual) screen to open windows, e.g. xvfb but I am not 100% sure.

Yes, this is correct.

From what I see in your README.md , you try to use PyVista with PyQt5:
Is that your intention?

I have 2 use cases

  1. To be able to use jupyter with 3d and 2d plotting interactively
  2. To be able to use non interactive scripts to do analysis, which includes off screen 2d/3d plotting to files and to mne.Report objects. I think this is identical to a true headless HPC type of install.

I think I’m going to focus on getting jupyter up and running.

@GuillaumeFavelier what would you suggest is the best setup for jupyter, mne and pyvista all happily getting along?

FYI the current docker file uses:

  1. stock Xvfb
  2. MNE 0.22 installed via the server_environmnet.yml file
  3. ENV PYVISTA_USE_IPYVTK=true
    ENV PYVISTA_OFF_SCREEN=true

Using %matplotlib inline gives a kernel fault. and if I then set the backend to notebook I get: a Error displaying widget: model not found

I can easily switch to mne 0.23-dev. but beyond that I’m not sure what might need tweaking?

To be able to use non interactive scripts to do analysis, which includes off screen 2d/3d plotting

As of now, I don’t think PyVistaQt supports this. It would require some work to switch our backend to PyVista instead. Technically, the code to achieve this is already there in the notebook backend… :thinking:

To be able to use jupyter with 3d and 2d plotting interactively

I would start by using ipyvtk Dockerfile as a minimal working example then try to integrate mne-python in a second step:

But I perhaps you got that covered already.

Error displaying widget: model not found

This one seems to be reported in Example notebooks does not show widgets · Issue #27 · Kitware/ipyvtklink · GitHub and after quick scrolling, the PR Fix Dockerfile issues with nodejs by banesullivan · Pull Request #28 · Kitware/ipyvtklink · GitHub is still work in progress. Maybe, you’ll have an insight there?