Missing Data in 3D Connectivity Visualization

  • MNE version: 1.4.2
  • MNE - Connectivity version: 0.5.0
  • operating system: Windows 10
  • Python version: 3.10.9

Hello, I’m using the mne_connectivity method plot_sensors_connectivity and I’m getting the output shown below. However, I’ve noticed that not all the connections are represented and the colorbar has a value range defined.
Is there a way to tell the mne method that I would like to visualize all the connections and therefore, change the range of values of the color bar?
Second but not least, can I change the colors of the colorbar?
My code was based on the example given by MNE itself
https://mne.tools/mne-connectivity/dev/auto_examples/sensor_connectivity.html#sphx-glr-auto-examples-sensor-connectivity-py

My procedure:

  • Data acquired with 9 electrodes.
  • After I calculate the coherence and I got the (81,2) array I’m asigning a variable to the alpha band and another one to the beta band.
  • The new alpha and beta arrays (9,9) have values ranged from 0.0 to 1.0
epoc_1s = mne.Epochs(canales, event_1s[0], tmin=0, tmax=1, baseline=None)
conectividad_1s_coh = spectral_connectivity_epochs(epoc_1s, method='coh', sfreq=Fs, mode='fourier', fmin=f_min, fmax=f_max, faverage=True)
matriz_conectividad_coh = conectividad_1s_coh.get_data()
mc_alfa_coh = matriz_conectividad_coh[:, 0].reshape(9, 9)
  • Plotting the connectivity with alpha band information and ONLY values from 0.650 (not the min value) to 0.856 (which is the max value) are shown.
easycap_montage = mne.channels.make_standard_montage('easycap-M1')
epoc_1s.set_montage(easycap_montage)
plot_sensors_connectivity(epoc_1s.info, mc_alfa_coh)

In version 0.5 the function is hard-coded to only show the 20 strongest connections. The current development version added a new parameter n_con to the plotting function so users can control how many connections are shown. Here is the PR that added the new functionality: [ENH] Added n_con arg to function call by Avoide · Pull Request #133 · mne-tools/mne-connectivity · GitHub

You can either upgrade to the current development version (instructions here: Installation — MNE-Connectivity 0.5.0 documentation) or wait for version 0.6 to be released. I don’t know what the release plan is, @adam2392 do you know?

1 Like

Hoping to release v0.6 sometime before the end of summer.

1 Like

Thank you very much!
Regarding the question of the colorbar when plotting, can I change the colors?

not easily. If you do:

scene = plot_sensors_connectivity(epoc_1s.info, mc_alfa_coh)
scene.plotter.scalar_bar.GetLookupTable().apply_cmap("viridis")

then you can change the colormap of the bar, but this won’t affect the color of the lines connecting the sensors. I doubt changing both tubes and colorbar after rendering will be easy (or even possible?) so we would need to expose a new option plot_sensors_connectivity(..., cmap="RdBu") for it to work. If you want to try to hack it locally, you would need to add the new cmap param to the function signature, and then pass it through to renderer.tube() here:

cc @larsoner who might know the trick to changing it after rendering.

1 Like

It looks like under the hood we use pyvista.Line and add a mesh:

So you could look into the relevant PyVista objects and see how they can be modified…

1 Like

feature added in this PR: