brainconn icon indicating copy to clipboard operation
brainconn copied to clipboard

Positive and negative scales for edges

Open hgrotzin opened this issue 2 years ago • 2 comments

Hey Sid!

I wanted to see if it would be possible to add in a second scale for positive and negative edges. I'm trying to replicate the scales in the figure attached.

Thanks! Hannah

brain

hgrotzin avatar May 17 '22 18:05 hgrotzin

Hey Hannah, I haven't added functionality for two separate colour bars, but you could achieve the same effect using a diverging colour scale with a mid point. e.g: brainconn(atlas = custom_atlas, conmat = c_serum, node.size = 1.5, view = "ortho", edge.width = 0.8, edge.color.weighted = T, edge.color = scale_edge_color_gradient2( low = "red", mid = "white", high ="blue", midpoint = 0, space = "Lab", na.value = "grey50", guide = "edge_colourbar" )) image

If you want to threshold to make the midpoint -/+ 3.5 like the figure you attached, you will have to threshold the matrix before the brainconn function, as the inbuilt thresholding options in brainconn (thr/uthr) only allow an upper or lower threshold, not both. E.g:

c_serum[c_serum < 3.5 & c_serum > -3.5 ] <- 0 brainconn(atlas = custom_atlas, conmat = c_serum, node.size = 1.5, view = "ortho", edge.width = 0.8, edge.color.weighted = T, edge.color = scale_edge_color_gradient2( low = "red", mid = "white", high ="blue", midpoint = 0, space = "Lab", guide = "edge_colourbar"))

brainconn(atlas = custom_atlas, conmat = c_serum, node.size = 1.5, view = "ortho", edge.width = 0.8, edge.color.weighted = T, edge.color = scale_edge_color_distiller( type = "div", palette = 1, direction = -1, values = NULL, space = "Lab", guide = "edge_colourbar" ))

image image

I am not sure if its possible to grey out the values not plotted (e.g. -3.5 to 3.5), as brainconn doesn't like NA valued in the matrices. Check out the other continuous/gradient scale_edge_color* functions from ggraph, there might be something in there which can do it without NA values.

If you definitely need separate colour scales, some other tools which might be able to do it are: surfice (python), visbrain (python), BrainNet Viewer (MATLAB - probably your best bet), graphpype (python), or nilearn (python).

Best, Sid

sidchop avatar May 17 '22 20:05 sidchop

great thanks so much! I'll keep playing around with the color options.

hgrotzin avatar May 17 '22 23:05 hgrotzin