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

MNE Python stc.plot(), draws the brain as translucent #9263

Closed
Mirrabella opened this issue Apr 7, 2021 · 8 comments
Closed

MNE Python stc.plot(), draws the brain as translucent #9263

Mirrabella opened this issue Apr 7, 2021 · 8 comments
Labels

Comments

@Mirrabella
Copy link

When I use stc.plot(), this function draws the brain as translucent, and it is seems very stange and the picture is poorly perceived.

Can you please tell me how to change the transparency parameter?

MNE version 23.0

I tried to used View — Toggle Eye Dome Lighting, but it did not help, picture still seems strange too. :(
Снимок экрана от 2021-04-07 17-33-42
Снимок экрана от 2021-04-07 17-45-51

@welcome
Copy link

welcome bot commented Apr 7, 2021

Hello! 👋 Thanks for opening your first issue here! ❤️ We will try to get back to you soon. 🚴🏽‍♂️

@GuillaumeFavelier
Copy link
Contributor

Hello @Mirrabella and thank you for reporting your issue. I would like to know more about your configuration, it will help me investigate the origin of this behaviour.

If you don't mind, could you share the output of:

$ python -c "import mne; mne.sys_info()"

and:

$ python -c "import pyvista; print(pyvista.Report())"

It would be helpful if you could also share a minimal code snippet giving this output so that I can try to reproduce on my end.

@GuillaumeFavelier
Copy link
Contributor

From what I can tell, you seem to use the pyvista 3d backend with the old version of the GUI of stc.plot() since those sliders have been migrated from vtk to PyQt5 in #8862.

@Mirrabella
Copy link
Author

Mirrabella commented Apr 8, 2021

Hello @Mirrabella and thank you for reporting your issue. I would like to know more about your configuration, it will help me investigate the origin of this behaviour.

If you don't mind, could you share the output of:

$ python -c "import mne; mne.sys_info()"

and:

$ python -c "import pyvista; print(pyvista.Report())"

It would be helpful if you could also share a minimal code snippet giving this output so that I can try to reproduce on my end.

Hello and thank you very much for your answer.

My configuration on printscreen.

pscr1
pscr2

Code is from example MNE Python:

import os.path as op
import os
import mne
from mne.datasets import sample

data_path = sample.data_path()
# the raw file containing the channel location + types
raw_fname = data_path + '/MEG/sample/sample_audvis_raw.fif'

# The paths to Freesurfer reconstructions
subjects_dir = data_path + '/subjects'
os.environ['SUBJECTS_DIR'] = subjects_dir
subject = 'sample'
raw = mne.io.read_raw_fif(raw_fname)
events = mne.find_events(raw = raw, stim_channel = 'STI 014')
event_id = dict(aud_r=2, vis_r=4)
epochs = mne.Epochs(raw=raw, events = events, event_id = event_id)
evoked = epochs.average()
conductivity = [0.3] # for single layer
model = mne.make_bem_model(subject=subject, ico=4, conductivity= conductivity, subjects_dir=subjects_dir, verbose=None)
bem = mne.make_bem_solution(model)
trans = data_path + '/MEG/sample/sample_audvis_raw-trans.fif'
src = mne.setup_source_space(subject, spacing='oct4', add_dist='patch', subjects_dir=subjects_dir)
fwd = mne.make_forward_solution(raw_fname, trans=trans, src=src, bem=bem, meg=True, eeg=False, mindist=5.0, n_jobs=1, verbose=True)
cov = mne.compute_covariance(epochs, method='auto')
inv = mne.minimum_norm.make_inverse_operator(raw.info, fwd, cov, loose=0.2)
stc = mne.minimum_norm.apply_inverse(evoked, inv, lambda2=1. / 9.)
stc.plot(hemi='both')

Thank you in advance:)

@GuillaumeFavelier
Copy link
Contributor

Unfortunately, I can't reproduce this transparency bug on my machine right now but I can still guess that it could come from vtk or mesa 🤔

I'm less familiar with mesa but I can try to help for vtk 9.0.1:

  1. You could use the latest version of MNE conda configuration file to create a new environment. It uses at least python 3.8 so I hope you don't have any issue with that (it's required since mne 0.21.0 anyway) but I expect it to fetch the latest vtk successfully. The installation procedure for each system is described on MNE's website:
environment.yml
name: mne
channels:
- conda-forge
dependencies:
- python>=3.8
- pip
- numpy
- scipy
- matplotlib
- numba
- pandas
- xlrd
- scikit-learn
- h5py
- pillow
- statsmodels
- jupyter
- joblib
- psutil
- numexpr
- traits
- pyface
- traitsui
- imageio
- tqdm
- spyder-kernels>=1.10.0
- imageio-ffmpeg>=0.4.1
- vtk>=9.0.1
- pyvista>=0.24
- pyvistaqt>=0.2.0
- mayavi
- PySurfer
- dipy
- nibabel
- nilearn
- python-picard
- pyqt
- mne
- mffpy>=0.5.7
  1. If you know how to manage an environment with both conda and pip or if 1) does not work, you could try:
conda uninstall vtk
pip install --upgrade vtk

This will effectively fetch the latest version of vtk available on PyPI but I have to warn you that it is not a stable solution (as package coherence is not fully managed by conda).

@Mirrabella
Copy link
Author

Unfortunately, I can't reproduce this transparency bug on my machine right now but I can still guess that it could come from vtk or mesa

I'm less familiar with mesa but I can try to help for vtk 9.0.1:

  1. You could use the latest version of MNE conda configuration file to create a new environment. It uses at least python 3.8 so I hope you don't have any issue with that (it's required since mne 0.21.0 anyway) but I expect it to fetch the latest vtk successfully. The installation procedure for each system is described on MNE's website:

environment.yml

  1. If you know how to manage an environment with both conda and pip or if 1) does not work, you could try:
conda uninstall vtk
pip install --upgrade vtk

This will effectively fetch the latest version of vtk available on PyPI but I have to warn you that it is not a stable solution (as package coherence is not fully managed by conda).

I tried to make the settings according to point 1. But now an error occurs. I would be very grateful if you could give me some more advice on how to fix it.

As I understand it, there are some problems with mesa (I'm not very strong in this :()

Снимок экрана от 2021-04-09 17-35-36

@GuillaumeFavelier
Copy link
Contributor

Hm... It seems that either mesa cannot be setup properly or no window can be opened, are you by any chance using a headless server? If that's the case you might be interested in:

https://mne.tools/stable/install/mne_python.html?highlight=server#installing-to-a-headless-server

@larsoner
Copy link
Member

This should be fixed on latest main by our use of depth peeling (by default anyway)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants