YangLab-um / BiologicalOscillations.jl

A package for researchers working with biological oscillations
https://yanglab-um.github.io/BiologicalOscillations.jl/
MIT License
1 stars 2 forks source link

Visualization of connectivity matrix #26

Closed biphy closed 9 months ago

biphy commented 9 months ago

A new function draw_connectivity visualizes connectivity matrices as shown in the attatched figure.

draw_connectivity([0 0 1; 1 0 0; 0 -1 0], output="01.png")
draw_connectivity([1 0 1; 1 0 0; 0 -1 0], output="02.png")
draw_connectivity([1 -1 1; 1 0 0; 0 -1 0], output="03.png")
draw_connectivity([0 0 0 0 1; -1 0 0 0 0; 0 -1 -1 0 0 ; -1 0 1 0 0; 0 0 0 -1 0], output="04.png")
draw_connectivity([0 0 0 0 1; -1 0 0 0 0; 0 -1 -1 0 0 ; -1 0 1 0 0; 0 0 0 -1 0], coherent_nodes=[3], incoherent_nodes=[4], positive_cycles=[[1, 4, 5]], negative_cycles=[[3]], output="05.png")
draw_connectivity([1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1; 1 1 1 1 1 1 1], output="06.png")

samples

It connects nodes by arrows representing either positive (--->) or negative (---|) interactions between them. Optional information on the node types (whether they get coherent or incoherent inputs) and the cycle types (positive or negative) is annotated as well if provided, as shown in the 5th example.

ftavella commented 9 months ago

It's looking great! I think for the test you could simply have a file that shows how would you call the function draw_connectivity and let it generate a couple of networks inside /test/draw_connectivity/. You can place the test file inside that folder too.

biphy commented 9 months ago

I added tests to compare raster images produced by draw_connectivity with pre-made references. They are very strict tests that compare matrices of pixels to see if two images are identical and thus might be buggy in some cases. The reference images must be replaced whenever the visualization module (including default visualization parameters) is updated.