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

BUG: Bugs with VTK 9 #7599

Closed
larsoner opened this issue Apr 11, 2020 · 28 comments · Fixed by #8576
Closed

BUG: Bugs with VTK 9 #7599

larsoner opened this issue Apr 11, 2020 · 28 comments · Fixed by #8576
Labels
Milestone

Comments

@larsoner
Copy link
Member

larsoner commented Apr 11, 2020

@GuillaumeFavelier you can now pretty easily build and install VTK 9 (which is good because they are on RC3, and it should fix some bugs and bring 3.8 support):

git clone --recursive https://gitlab.kitware.com/vtk/vtk.git
mkdir vtk-build
cd vtk-build
cmake -GNinja -DVTK_BUILD_TESTING=OFF -DVTK_WHEEL_BUILD=ON -DVTK_PYTHON_VERSION=3 -DVTK_WRAP_PYTHON=ON ../vtk
ninja -j 4
python setup.py bdist_wheel
pip install dist/vtk-*.whl

However, there is at least one rendering bug (depth peeling again maybe?) where the surface overlay gets cut off at some distance based on rotation (note the rightward "v" cut of the overlay):

Screenshot from 2020-04-11 09-36-36

We might need to figure out how to properly resolve the coincident topology here -- relying on VTK to do it automagically might not work anymore. Or maybe it's something else...?

@larsoner
Copy link
Member Author

FWIW, PyVista worked "out of the box" this way, while Mayavi fails to compile (which I'll look into) :)

@larsoner
Copy link
Member Author

Can someone else on macOS see if you can replicate https://gitlab.kitware.com/vtk/vtk/-/issues/17846 ?

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 13, 2020

Thanks for starting this @larsoner. I'll follow the procedure you explained to be better prepared for VTK 9.

Also relevant for pyvista/pyvista#562

@banesullivan
Copy link

Can you share that data or how to launch that scene? I'll try to look into this and see what's happening to the overlain mesh.

@larsoner
Copy link
Member Author

WARNING: Will download 1.5 GB of data to ~/mne_data (unless you give it a different path to use)

import faulthandler
import os.path as op
import mne

faulthandler.enable()
data_path = mne.datasets.sample.data_path()
sample_dir = op.join(data_path, 'MEG', 'sample')
subjects_dir = op.join(data_path, 'subjects')
inv = mne.minimum_norm.read_inverse_operator(op.join(
    sample_dir, 'sample_audvis-meg-eeg-oct-6-meg-eeg-inv.fif'))
evoked = mne.read_evokeds(op.join(sample_dir, 'sample_audvis-ave.fif'))[0]
evoked.apply_baseline((None, 0))
stc = mne.minimum_norm.apply_inverse(
    evoked, inv, method='dSPM', verbose='debug', pick_ori=None)  # 'vector')
initial_time = 0.1

with mne.viz.use_3d_backend('pyvista'):
    brain = stc.plot(subjects_dir=subjects_dir, initial_time=initial_time,
                     clim='auto', views='lat', hemi='lh',
                     smoothing_steps='nearest', verbose=True)

You will probably need to pip install nibabel https://github.com/mne-tools/mne-python/zipball/master first.

This is the code I was using (last I recall!), but for some reason now it hangs when I try it.

@larsoner
Copy link
Member Author

(FYI I forgot a ninja -j 4 in the command list above, I've updated it now)

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 15, 2020

Sorry I am late, I had to build everything from scratch and follow your instructions.

This is the result of: python -c "import pyvista; print(pyvista.Report())"

--------------------------------------------------------------------------------
  Date: Wed Apr 15 15:02:56 2020 CEST

                OS : Linux
            CPU(s) : 4
           Machine : x86_64
      Architecture : 64bit
       Environment : Python
        GPU Vendor : NVIDIA Corporation
      GPU Renderer : GeForce GTX 960M/PCIe/SSE2
       GPU Version : 4.5.0 NVIDIA 430.64

  Python 3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 23:51:54)  [GCC 7.3.0]

           pyvista : 0.24.1
               vtk : 9.0.0
             numpy : 1.18.2
           imageio : 2.8.0
           appdirs : 1.4.3
            scooby : 0.5.2
            meshio : 4.0.10
             PyQt5 : 5.14.1
           IPython : 7.13.0
--------------------------------------------------------------------------------

EDIT I created vtk-build into vtk source folder. My mistake.

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 15, 2020

rendering bug (depth peeling again maybe?) where the surface overlay gets cut off at some distance based on rotation

I can also reproduce the bug with the camera angle 👍

output

I also notice an issue with point picking but maybe this one is related to _TimeViewer

@larsoner
Copy link
Member Author

git clone --recursive https://gitlab.kitware.com/vtk/vtk.git
mkdir vtk-build
cd vtk-build

after these three steps you should be in vtk-build, not vtk/vtk-build. Perhaps you had an extra cd vtk after the git clone line?

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 15, 2020

Yes but the sources are in vtk and not vtk-build right? It's just an empty folder.

Perhaps you had an extra cd vtk after the git clone line?

Exactly.

@GuillaumeFavelier
Copy link
Contributor

I disabled depth peeling explictly without success:

ren_win = self.plotter.ren_win
ren_win.SetAlphaBitPlanes(0)
renderer = self.plotter.renderer
print(renderer.GetLastRenderingUsedDepthPeeling())  # prints 0
renderer.SetUseDepthPeeling(0)

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 15, 2020

Using offset like we did with Vispy does work for me, I'll open a PR:

mapper.SetResolveCoincidentTopologyToPolygonOffset()
mapper.SetRelativeCoincidentTopologyPolygonOffsetParameters(-4., -4.)

@larsoner
Copy link
Member Author

vtk-build starts out empty, but the cmake line populates it. I wonder if your problems were due somehow to building in a subdirectory of the source directory, rather than a totally separate one

@larsoner
Copy link
Member Author

What's interesting about the topology problem is that I don't see it on mayavi. But whatever makes it work I guess!

@GuillaumeFavelier
Copy link
Contributor

I don't see it on mayavi.

Any idea how they deal with it?

@larsoner
Copy link
Member Author

No idea

@larsoner
Copy link
Member Author

VTK9 rc3 wheels are up so you can try @GuillaumeFavelier :

https://vtk.org/download/

For me the stc.py example we always runs just freezes, I think due in part to this:

pyvista/pyvista#686

It occurred to me that we actually need to fix this soon because once VTK9 wheels land on PyPi and are incorporated by Anaconda, anyone who installs or upgrades MNE will be stuck with unusable plotting :(

Can you look into it?

@GuillaumeFavelier
Copy link
Contributor

I'm on it

@GuillaumeFavelier
Copy link
Contributor

@larsoner I installed it and I have an issue with picking:

Traceback (most recent call last):
  File "/home/guillaume/source/mne-python/mne/viz/_brain/_timeviewer.py", line 939, in on_pick
    cell = mesh.faces[cell_id][1:]
IndexError: invalid index to scalar variable.

But except from that, the app is completely interactive. All the sliders and tool bar buttons work and are linked correctly.

@larsoner
Copy link
Member Author

Hmm, must be some issue with my system. What's your mne sys_info? I'll try your version of Qt.

@GuillaumeFavelier
Copy link
Contributor

Platform:      Linux-4.19.114-1-MANJARO-x86_64-with-arch-Manjaro-Linux
Python:        3.6.10 |Anaconda, Inc.| (default, Mar 25 2020, 23:51:54)  [GCC 7.3.0]
Executable:    /home/guillaume/source/anaconda3/envs/pyvista-dev/bin/python
CPU:           : 4 cores
Memory:        Unavailable (requires "psutil" package)
mne:           0.21.dev0
numpy:         1.18.3 {blas=openblas, lapack=openblas}
scipy:         1.4.1
matplotlib:    3.2.1 {backend=Qt5Agg}

sklearn:       Not found
numba:         Not found
nibabel:       Not found
cupy:          Not found
pandas:        Not found
dipy:          Not found
mayavi:        Not found
pyvista:       0.24.1
vtk:           9.0.0

@GuillaumeFavelier
Copy link
Contributor

And I use PyQt5 5.14.1

@larsoner
Copy link
Member Author

Ahh right without mayavi it will not tell you, let me update sys_info...

@larsoner
Copy link
Member Author

Hooray! With pip install --upgrade --user pyqt5 which gives 5.14.2 everything works fine

@GuillaumeFavelier
Copy link
Contributor

GuillaumeFavelier commented Apr 23, 2020

Feel free to try #7665 then. It worked for me.

@larsoner
Copy link
Member Author

@larsoner larsoner reopened this Sep 15, 2020
@larsoner larsoner added this to the 0.22 milestone Sep 15, 2020
@larsoner
Copy link
Member Author

larsoner commented Nov 9, 2020

@GuillaumeFavelier might be good to fix this before looking into coreg

@GuillaumeFavelier
Copy link
Contributor

For future reference, the visual issues mentioned in #7599 (comment):

image

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 a pull request may close this issue.

3 participants