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

Draft plotting function for network API #181

Merged
merged 6 commits into from
Dec 6, 2023
Merged

Draft plotting function for network API #181

merged 6 commits into from
Dec 6, 2023

Conversation

michaeldeistler
Copy link
Contributor

@michaeldeistler michaeldeistler commented Dec 6, 2023

closes #179

@kyralianaka @jnsbck plotting is on the way.

net = jx.Network(cells, conns)
net.vis()

For feedforward NNs:

net = jx.Network(cells, conns)
net.vis(layers=[5, 10, 1])  # 5 input neurons, 10 hidden, 1 output.

@jnsbck jnsbck mentioned this pull request Dec 6, 2023
@jnsbck
Copy link
Contributor

jnsbck commented Dec 6, 2023

Cool! Should this be recursive? I.e. vis/plot/render also being callable on a cell / branch level and being called by Network.vis?

@jnsbck
Copy link
Contributor

jnsbck commented Dec 6, 2023

Some misc. ideas / considerations from my side:

  • If I am not mistaken, connections are only tracked via the parents attr. I am guessing morphologies / graphs are reconstructed from this, which means 3D structure is lost, that we get from .swc files. It would be nice to somehow store the x,y,z,d (d=diameter) coords in a position attr or sth of each compartment. Then we could plot the 3D morphology or projections thereof. Then we could add a kwarg project="xy" or dims="xy" or sth. similar to choose on which plane to project the neuron and even render it in 3d? (maybe longterm), which could be added as option to `dims="xyz".
  • should we build from scratch or parse graph and use some existing graph plotting lib?
  • I really like the detail kwarg. Could be useful on a cell level as well. I.e. plot thickness of compartments or just the raw graph.
  • Maybe MorphoPy's draw_2D and draw_3D could be a starting point / provide some inspiration.

Will also continue to think some more about this.

@michaeldeistler
Copy link
Contributor Author

Great suggestsions, I agree with almost all points. Especially with keeping (x,y,z). I would prefer using graph libraries only for plotting. Otherwise I am worried we will run into autograd issues in the long run.

@michaeldeistler
Copy link
Contributor Author

Merging now to unblock Kyra, but I think this can definitely be improved.

@michaeldeistler michaeldeistler merged commit bb8f9e0 into main Dec 6, 2023
1 check passed
@michaeldeistler michaeldeistler deleted the nx branch December 6, 2023 15:04
@jnsbck
Copy link
Contributor

jnsbck commented Dec 7, 2023

Cool! One addition I would make is, nx.draw takes ax as a kwarg. I think it would be convenient for plotting if vis would take an ax kwarg as well.
Furthermore, draw takes a lot of kwargs (see networkx.draw_networkx()). It would be nice to link it in the docs.
We could also provide some nice defaults, i.e. edge-thickness / edge-color $\propto$ Weights or arrows in direction of synapse.

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

Successfully merging this pull request may close these issues.

Network visualization
2 participants