question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] `mne.viz.Brain` volume rendering doesn't show up

See original GitHub issue

If you don’t set alpha=0, you get an opaque inflated brain along with your volume source estimate. I think the default arguments could handle this better.

image

To replicate:

import mne
from mne.datasets import sample
from mne import read_evokeds
from mne.minimum_norm import apply_inverse, read_inverse_operator

data_path = sample.data_path()
meg_path = data_path / 'MEG' / 'sample'
fname_inv = meg_path / 'sample_audvis-meg-vol-7-meg-inv.fif'
fname_evoked = meg_path / 'sample_audvis-ave.fif'

snr = 3.0
lambda2 = 1.0 / snr ** 2
method = "dSPM"  # use dSPM method (could also be MNE or sLORETA)

# Load data
evoked = read_evokeds(fname_evoked, condition=0, baseline=(None, 0))
inverse_operator = read_inverse_operator(fname_inv)
src = inverse_operator['src']

# Compute inverse solution
stc = apply_inverse(evoked, inverse_operator, lambda2, method)
stc.crop(0.0, 0.2)

brain = mne.viz.plot_source_estimates(stc, subject='sample', subjects_dir=data_path / 'subjects', src=src)

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
larsonercommented, Jun 1, 2022

I thought about it a bit more and maybe a major refactoring isn’t the best use of time either,

Agreed, seems like something we can do later

My suggestion would be to make plot_source_estimates and internal function since it’s not maintained to give the right output for every class given the input

plot_source_estimates has been around since at least MNE-Python 0.5, i.e., 10 years:

https://github.com/mne-tools/mne-python/blob/2de217d600e5b198820adb992d5f1b8bda2b006e/mne/viz.py#L875

And while a lot of these will be false positives, the “2k” count here gives me pause as well:

https://github.com/search?q=plot_source_estimates&type=code

So I’d rather fix than deprecate. Or the easiest route is to just .. note:: after the one-line description of the function that it isn’t guaranteed yet to give the correct output for each input, and that stc.plot for surface and stc.plot_3d for vol source estimates should be preferred for optimal behavior

1reaction
larsonercommented, May 31, 2022

Argh yes we should fix that bug first. Maybe doing a plot that currently on broken main produces an all black screenshot would be a good way to test, because it’s easy to check in CIs (e.g., that the .mean() of the screenshot is greater than 0.005 for example)

Read more comments on GitHub >

github_iconTop Results From Across the Web

mne.viz.Brain — MNE 1.2.2 documentation
Specifies how the cortical surface is rendered. Options: The name of one of the preset cortex styles: 'classic' (default), ...
Read more >
Support for 3D brain visualization in headless mode?
MNE version: 0.24.0 operating system: Linux on Docker I'm trying to run the MRI reconstruction example without success on a headless installation on...
Read more >
Wavelet-based Volume Rendering
The analytic representation of the used B-spline wavelets provides realistic shading effects and analytic error bounds. Finally, by further assuming an ...
Read more >
An Overview of Common Data Visualization Mistakes - Toptal
Linking correlation to causation is a data visualization mistake. Data may show correlation, but it doesn't equal causation. 8. Zooming in on Favorable...
Read more >
Article - HPC-Forge - Cineca
In-situ visualization allows to couple a simulation with visualization in order to ... volume rendering didn't show any significant scaling after 2 cores....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found