stc.plot with pos_lim parameter and a divergent colormap does not plot negative values

Hello!

Iā€™m having a problem with stc.plot function. I want to use a divergent colormap when plotting the source estimate which includes negative values as well as positive ones. Mne documentation suggests using pos_lim instead of lim for divergent colormaps. Therefore, I used pos_lim as following:
brain = stc.plot(**kwargs, colormap=ā€˜seismicā€™, clim=dict(kind=ā€˜valueā€™, pos_lims=[0, 300, 600]))

What I expected from this was to have a plot with negative and positive values with a scale of [-600, 600] however I ended up with having only positive values and scale of [0,600] in resulting plot.

So, Iā€™d like to ask if there is any other parameter that I need to set to make this work?

Thank you!

Hello @pgoktepe and welcome to the forum!

Which version of MNE-Python are you using?

I cannot reproduce your problem with the following code:

# %%
from pathlib import Path
import mne


mne.viz.set_3d_backend('pyvista')

sample_dir = Path(mne.datasets.sample.data_path())
stc_fname = sample_dir / 'MEG' / 'sample' / 'sample_audvis-meg'  # omit suffix
fs_subject = 'sample'
fs_subjects_dir = sample_dir / 'subjects'

stc = mne.read_source_estimate(fname=stc_fname, subject=fs_subject)

brain = stc.plot(
    subject=fs_subject,
    subjects_dir=fs_subjects_dir,
    initial_time=0.1,
    views=('lateral', 'medial'),
    hemi='split',
    surface='inflated',
    clim=dict(kind='value', pos_lims=[0, 300, 600])
)

Hello @richard! Thanks for your incredibly fast response!

The mne version Iā€™m using is 0.21.0. When I looked at the code snippet you sent, I saw that youā€™re using pyvista as the mne backend. Iā€™m using mayavi. So, do you think that could be the reason?

I tried changing that to pyvista but now Iā€™m getting an error saying BackgroundPlotter is no longer accessible by pyvista.BackgroundPlotter

Thanks for your help!

Hello, please update to MNE-Python 0.23.1, as it includes numerous fixes and improvements compared to 0.21. The PyVista backend provides a greatly improved plotting experience, so you donā€™t want to miss out on that anyway :sunglasses:

Updating mne to 0.23.1 solved the issue when running with mayavi however I got another error "type object ā€˜Languageā€™ has no attribute ā€˜Englishā€™ " when I tried using PyVista.

Thank you so much for your help! :slight_smile:

1 Like