mne-tools / mne-connectivity

Connectivity algorithms that leverage the MNE-Python API.
https://mne.tools/mne-connectivity/dev/index.html
BSD 3-Clause "New" or "Revised" License
68 stars 34 forks source link

Allow to plot asymmetric connectivity matrix with mne-connectivity.viz.plot_connectivity_circle #246

Open JohannesWiesner opened 1 month ago

JohannesWiesner commented 1 month ago

If your issue is a usage question, please consider asking on the MNE Forum instead of opening an issue.

Describe the problem

This function currently only supports plotting symmetric connectivity matrices (only the lower half of the matrix is used). However, in my case I would be interested in plotting asymmetric (directed) matrices.

See for example: https://nilearn.github.io/dev/modules/generated/nilearn.plotting.plot_connectome.html

This function checks first if the user provided a symmetric or asymmetric matrix. If the matrix is asymmetric this of course has to be visualized. Can be done for example by using arrows instead of lines, different colors or different line shapes (dotted vs fixed lines).

Describe your solution

A clear and concise description of what you want to happen.

Describe possible alternatives

A clear and concise description of any alternative solutions or features you have considered.

Additional context

Add any other context or screenshots about the feature request here.

tsbinns commented 1 month ago

Hi Johannes,

I can definitely see the value in this for looking at directed connectivity scores. I suppose the challenge is finding a solution that is still somewhat legible with the additional information that would be present.

I think changing the colour of the lines is tricky since we are encoding the connectivity strength here. For interhemispheric connectivity you could have one colourbar for L -> R connectivity and one for R -> L, but what if you're also interested in intrahemispheric connectivity, or connectivity between different channels for a single region? Then defining line colours for different directions becomes tricky.

I see a similar problem with using solid vs. dotted lines: how do you define what directions these correspond to?

I think the most effective solution would be your suggestion of simply using arrows for asymmetric matrices instead of lines.

It would be good to hear from someone more senior if they would be happy with such a change. If so, @JohannesWiesner would you be willing to implement these changes? The code for handling this is actually in the main MNE package though, so it would require a PR there.

Cheers, Thomas

drammock commented 1 month ago

Two colormaps that each went from a single hue to transparent might also work. But it would only make sense to do it that way if there were a meaningful notion of "forward" and "backward" connections. Otherwise there is the same problem as with line style --- no way to guess which end is source and which is sink. So yeah, I can't think of anything better than using arrows.

JohannesWiesner commented 1 month ago

Completely agree that arrows are the most intuitive approach! I guess that's why the nilearn folks also stick to that.

Two colormaps that each went from a single hue to transparent might also work. But it would only make sense to do it that way if there were a meaningful notion of "forward" and "backward" connections. Otherwise there is the same problem as with line style --- no way to guess which end is source and which is sink. So yeah, I can't think of anything better than using arrows.

That's exactly how I wanted to answer, any other formatting style would require a legend again that maps the formatting style to the direction so the viewer can interpret it.

JohannesWiesner commented 3 weeks ago

If so, @JohannesWiesner would you be willing to implement these changes?

Perhaps over the christmas holidays but I can't promise :(

tsbinns commented 2 weeks ago

Perhaps over the christmas holidays but I can't promise :(

There's no rush from our end. Unfortunately I would also not have time to work on this before January, but if there's still work to be done then I am happy to try lend a hand!