mne-tools / mne-bids-pipeline

Automatically process entire electrophysiological datasets using MNE-Python.
https://mne.tools/mne-bids-pipeline/
BSD 3-Clause "New" or "Revised" License
138 stars 65 forks source link

the make_forward step fails when saving trans to report #989

Open drammock opened 2 weeks ago

drammock commented 2 weeks ago

I'm running the pipeline on a remote server, in tmux. My config file has the default interactive=False and yet I get the error Cannot connect to a valid display. Is that expected? I'd assumed it would use xvfb automatically in such cases. The error arises in report.add_trans, called from _04_make_forward.py. Here's an approximation of a traceback (just pushing u in pdb until I hit MBP code):

│15:36:27│ 🐛 sub-116 ses-a A critical error occurred. The error message was: Cannot connect to a valid display

Starting post-mortem debugger.
<traceback object at 0x7f8d5cd0de00>
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/_utils.py(159)_init_mne_qtapp()
-> raise RuntimeError("Cannot connect to a valid display")
(Pdb)
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/_pyvista.py(142)_build()
-> out = _init_mne_qtapp(enable_icon=True, splash=self.splash)
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/_pyvista.py(255)__init__()
-> self.plotter = self.figure._build()
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/_qt.py(1776)__init__()
-> super().__init__(*args, **kwargs)
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/_utils.py(391)func()
-> meth(self, *args, **kwargs)
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/renderer.py(53)_get_renderer()
-> return backend._Renderer(*args, **kwargs)
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/viz/backends/renderer.py(339)create_3d_figure()
-> renderer = _get_renderer(
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/report/report.py(493)_iterate_trans_views()
-> fig = create_3d_figure(size, bgcolor=(0.5, 0.5, 0.5))
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/report/report.py(4056)_add_trans()
-> img, caption = _iterate_trans_views(
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne/report/report.py(1515)add_trans()
-> self._add_trans(
(Pdb) u
> /opt/conda/miniforge3/envs/badbaby/lib/python3.12/site-packages/mne_bids_pipeline/steps/source/_04_make_forward.py(209)run_forward()
-> report.add_trans(
larsoner commented 1 week ago

I think we should document somewhere that working 3D graphics are needed, and if people are in headless mode they can set up and use xvfb-run.

drammock commented 1 week ago

I think we should document somewhere that working 3D graphics are needed, and if people are in headless mode they can set up and use xvfb-run.

SGTM. WDYT about also adding a --no3d flag or similar, to skip steps that require 3d plotting (and/or fall back to MPL brain plots)? I don't have a strong desire for this, just wondering about systems where getting xvfb might be difficult or time consuming

hoechenberger commented 1 week ago

I'm surprised we depend on 3D rendering, we used to have support for MPL-based Brain plotting at one time

Either we removed this, support was dropped from MNE, or we simply only have this in a few steps? 🤔

larsoner commented 1 week ago

I think we should try to keep 3d. The mpl brain viewer is not very good compared to the 3d version. And we need 3d for source alignment plots anyway (there is no 2d alternative).

Maybe instead of a command line option we can make it easier/clearer how to use xvfb or alternatively vtk osmesa build?

drammock commented 1 week ago

I'm fine with a documentation-based solution to this