mne-tools / mne-tools/mne-python
Function _plot_connectivity_circle connects nodes with score zero
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.5k
- Forks
- 1.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 100
Description
Description of the problem
The function _plot_connectivity_circle shows links between nodes when the score between nodes is zero. One can observe this behavior when facecolor is set to a color different than black.
Steps to reproduce
import numpy as np
from mne.viz.circle import _plot_connectivity_circle
import matplotlib.pyplot as plt
A = np.array([[0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0.7, 0.5, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0.5, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0.8, 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0.6, 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0.8, 0. , 0.6, 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0. , 0. , 0.8, 0. , 0. , 0. , 0. ],
[0. , 0. , 0. , 0.5, 0. , 0. , 0. , 0. , 0.6, 0. ]])
names = [f'X{i+1}' for i in range(A.shape[0])]
_plot_connectivity_circle(A, names, facecolor='white', textcolor='black',
node_edgecolor='white')
plt.show()
Expected results
I expect a figure that shows a link between a pair of nodes only when the score is large than zero. That's what one can observe when the function is used with the default values. The following is the figure I would expect:
Actual results
I get the following figure:
Additional information
It could be argued that this is not a bug. However, one can not observe links with zero scores when facecolor is set to black (default values).
Replacing
...
# Finally, we draw the connections
for pos, (i, j) in enumerate(zip(indices[0], indices[1])):
t0, r0 = node_angles[i], 10
by
# Finally, we draw the connections
for pos, (i, j) in enumerate(zip(indices[0], indices[1])):
if con_val_scaled[pos] == 0:
continue
# Start point
t0, r0 = node_angles[i], 10
seems to solve the problem. I'll happily make a pull request if the main developers think it is useful.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in mne.viz.circle at _plot_connectivity_circle and reproduce the issue with the provided matrix and facecolor='white'. Check how con_val_scaled and the connection loop handle zero values; done means the figure shows links only for positive scores while preserving the existing default behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100