From 088fa8a6028e7ebbdf71dba92e6da4c35da50e4c Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 7 Nov 2023 18:04:47 +0000 Subject: [PATCH] wip: chord diagram --- pyneuroml/plot/Connectivity.py | 15 ++++++++++++++- tests/plot/test_plot.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pyneuroml/plot/Connectivity.py b/pyneuroml/plot/Connectivity.py index a70cad9a..4be44abc 100644 --- a/pyneuroml/plot/Connectivity.py +++ b/pyneuroml/plot/Connectivity.py @@ -8,6 +8,7 @@ """ import logging +import numpy as np logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) @@ -41,4 +42,16 @@ def plot_chord_diagram(filename): :param filename: name of NeuroML file :type filename: str """ - pass + from pyneuroml.pynml import read_neuroml2_file + from mne_connectivity.viz import plot_connectivity_circle + + doc = read_neuroml2_file(filename) + + nodes = [p.id for p in doc.networks[0].populations] + print(f"Nodes for chord diagram are: {nodes}") + + con = [] + # TODO: logic to get connectivity information + print(f"Connecitivity is {con}") + + fix, axes = plot_connectivity_circle(con, nodes) diff --git a/tests/plot/test_plot.py b/tests/plot/test_plot.py index b14a8181..02fda544 100644 --- a/tests/plot/test_plot.py +++ b/tests/plot/test_plot.py @@ -12,6 +12,7 @@ import pathlib as pl from pyneuroml.plot import generate_plot, generate_interactive_plot +from pyneuroml.plot.Connectivity import plot_chord_diagram from .. import BaseTestCase logger = logging.getLogger(__name__) @@ -86,6 +87,17 @@ def test_generate_interactive_plot(self): self.assertIsFile(filename) pl.Path(filename).unlink() + def test_chord_diagram(self): + """Test the chord diagram plotter""" + filename = "tests/plot/test_chord_diagram.png" + + # remove the file first + try: + pl.Path(filename).unlink() + except FileNotFoundError: + pass + plot_chord_diagram("./Izh2007Cells.net.nml") + if __name__ == "__main__": unittest.main()