# Missing Data in 3D Connectivity Visualization

**URL:** <https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184>\
**Category:** Support & Discussions\
**Tags:** eeg, visualization\
**Created:** [July 5, 2023, 4:39pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184 "2023-07-05T16:39:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![LEPacheco](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/lepacheco/32/2833_2.png) [@LEPacheco](https://mne.discourse.group/u/LEPacheco)\
**Post date:** [July 5, 2023, 4:39pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/1 "2023-07-05T16:39:09Z")

</div>

- 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](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

```python
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.

```python
easycap_montage = mne.channels.make_standard_montage('easycap-M1')
epoc_1s.set_montage(easycap_montage)
plot_sensors_connectivity(epoc_1s.info, mc_alfa_coh)

```

 ![imagen](https://global.discourse-cdn.com/free1/uploads/mne/original/2X/e/e77ac18f7f8d162f0bce647b52ef5ab9e81d12e3.png)

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [July 11, 2023, 3:04pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/2 "2023-07-11T15:04:38Z")

</div>

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](https://github.com/mne-tools/mne-connectivity/pull/133)

You can either upgrade to the current development version (instructions here: [Installation — MNE-Connectivity 0.5.0 documentation](https://mne.tools/mne-connectivity/stable/install.html#installation-via-pip)) or wait for version 0.6 to be released. I don’t know what the release plan is, @adam2392 do you know?

---

<div class="post-metadata">

**Author:** ![adam2392](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/adam2392/32/35_2.png) [@adam2392](https://mne.discourse.group/u/adam2392)\
**Post date:** [July 11, 2023, 3:28pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/3 "2023-07-11T15:28:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LEPacheco](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/lepacheco/32/2833_2.png) [@LEPacheco](https://mne.discourse.group/u/LEPacheco)\
**Post date:** [July 11, 2023, 3:35pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/4 "2023-07-11T15:35:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [July 11, 2023, 5:03pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/5 "2023-07-11T17:03:41Z")

</div>

not easily. If you do:

```python
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:

> <https://github.com/mne-tools/mne-connectivity/blob/e953bfc9039f07fda2e0c0ba9f3fb3b7c649826c/mne_connectivity/viz/_3d.py#L91-L95>

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

---

<div class="post-metadata">

**Author:** ![larsoner](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/larsoner/32/3_2.png) [@larsoner](https://mne.discourse.group/u/larsoner)\
**Post date:** [July 13, 2023, 3:11pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/6 "2023-07-13T15:11:59Z")

</div>

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

> <https://github.com/mne-tools/mne-python/blob/926bec285c34c0fbdcad7b09ac4f550af8288e8a/mne/viz/backends/_pyvista.py#L607-L625>

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

---

<div class="post-metadata">

**Author:** ![drammock](https://yyz2.discourse-cdn.com/free1/user_avatar/mne.discourse.group/drammock/32/4_2.png) [@drammock](https://mne.discourse.group/u/drammock)\
**Post date:** [July 14, 2023, 9:32pm UTC](https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualization/7184/7 "2023-07-14T21:32:36Z")

</div>

feature added in this PR:

> <https://github.com/mne-tools/mne-connectivity/pull/141>
>
> Addresses https://mne.discourse.group/t/missing-data-in-3d-connectivity-visualiz…ation/7184/4
> 
> PR Description
> \--------------
> 
> Exposes new \`cmap\` argument in \`plot\_sensors\_connectivity\`
> 
> Merge checklist
> \---------------
> 
> Maintainer, please confirm the following before merging:
> 
> \- \[\] All comments resolved
> \- \[\] This is not your own PR
> \- \[\] All CIs are happy
> \- \[\] PR title starts with \[MRG\]
> \- \[\] \[whats\_new.rst\](https://github.com/mne-tools/mne-connectivity/blob/main/doc/whats\_new.rst) is updated
> \- \[\] PR description includes phrase "closes \<#issue-number\>"
