Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function _plot_connectivity_circle connects nodes with score zero #11712

Open
aweinstein opened this issue May 29, 2023 · 3 comments · May be fixed by #12210
Open

Function _plot_connectivity_circle connects nodes with score zero #11712

aweinstein opened this issue May 29, 2023 · 3 comments · May be fixed by #12210
Labels

Comments

@aweinstein
Copy link
Contributor

aweinstein commented May 29, 2023

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:

image

Actual results

I get the following figure:

image

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.

@aweinstein aweinstein added the BUG label May 29, 2023
@drammock
Copy link
Member

sorry for the slow reply! Your proposed fix looks reasonable. Still willing to open a PR?

@aweinstein
Copy link
Contributor Author

Sure! I'll do it next week.

@aweinstein
Copy link
Contributor Author

Sorry for the delay. I just submitted pull request #12210.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants