WhitakerLab / scona

Code to analyse structural covariance brain networks using python.
https://whitakerlab.github.io/scona/
MIT License
68 stars 33 forks source link

Nodal measures for plotting with nilearn #142

Closed wingedRuslan closed 5 years ago

wingedRuslan commented 5 years ago

Hi @Islast,

while working on the plotting brain images with nilearn, I've noticed your idea to create array of nodes sizes, where size is the value of nodal attribute node_size_att. The same idea is about node_colour_att. source code

    if node_colour_att is not None:
        node_colour_att = [G._node[node][node_colour_att] for node in node_order]

    if node_size_att is not None:
        node_size_att = [G._node[node][node_size_att] for node in node_order]

So you assume that each node in Graph could have the property - node_size_att and node_colour_att. And you create an array of sizes, colors respectively and then use this array to determine the size/color of a node while plotting.

Do you wish to have this feature?

I think if a node has additional properties like size and color, it will make properties look "messy", especially with calculated nodal measures. image

Also, it is kinda redundant, cause created functions have parameters to handle plotting in different colors and sizes.

Islast commented 5 years ago

This is just a method of incorporating the nodal measures that we calculate earlier on. The code should not involve adding new attributes to the nodal measures to inform a plotting function. What's going on here is that rather than adding node_size_att and node_colour_att to the graph as nodal attributes, you pass the function an existing nodal attribute to use. So for example if I wanted my nodes to be scaled by degree, I would pass node_size_att="degree"to the plotting function. As for the redundancy of having these parameters, the idea was to allow the user to scale nodes by degree without having to do the wrangling themselves, but I am happy to ditch it if you think it's unnecessary

wingedRuslan commented 5 years ago

@Islast okay, that's interesting, I have not thought about it in that way. Thanks for clarifying!

Just to make sure that I understood you correctly. Assume we pass node_size_att="degree" to the plotting function. So the size of each node is determined based on its value of degree measure, right.

If yes, do we need to normalize values to fit into the interval (let's say [2, 8])? Because the degree values could be in the interval [0, len(G.nodes)]. For example, ff degree equals 12, that's a pretty big value for size property while plotting.

And what's going on with choosing a color for each node?

if node_colour_att is not None:
       node_colour_att = [G._node[node][node_colour_att] for node in node_order]

For me, it is not clear because we can't just use the value of degree measure for picking up color. There should be some sort of setup_color_list function where we can select a color from colormap for continuous data.

Well, I would prefer to create plotting functions and after that add these additional features if needed.

Islast commented 5 years ago

We would need to do a bunch of normalisation and write a method to choose a colour (I think I used to pass a lambda function to do that? Definitely not a great way to proceed though!) if you wanted to pursue this. I think the last time we spoke we said that you should have my old work as a reference point but definitely feel free to deviate and reinvent wherever you like. I'm very comfortable with you abandoning all of this. As you say it can always be added in later if we decide we want it

Islast commented 5 years ago

@wingedRuslan is it okay to close this?

wingedRuslan commented 5 years ago

@Islast, yep, totally!