Comments (5)
Thanks @wingedRuslan - can you add an example of the additional functions that seaborn heatmap gives us? I personally prefer the current version because I like the black line around the outside of the plot, and I can't think of options that heatmap will give us that are useful in this case. Happy to be wrong though!
from scona.
@KirstieJane, if the black line around the outside of the plot is the only reason, I could add this feature to the new function as well :)
you did this with the following line of code
# Put a box around your data
ax.add_patch(
mpatches.Rectangle(
(ax.get_xlim()[0], ax.get_ylim()[1]),
ax.get_xlim()[1],
ax.get_ylim()[0],
fill=False, # remove background
color='k',
linewidth=1) )
from scona.
@KirstieJane, the only difference (that we care about) could be concerning the improved colorbar:
- in the existed version, the colorbar range is hardcoded to be [-1,0,1]. That's why only the diverging colormap can be used to plot corr_mat; You can see the output above if we use, for instance, sequential colormap.
- in the seaborn version, we can adjust colormap with the vmin, vmax parameters
vmin, vmax - Values to anchor the colormap, otherwise they are inferred from the data and other keyword arguments.
cbar - Whether to draw a colorbar (although, not a problem to add this param to the existed version)
cbar_kws - Keyword arguments for fig.colorbar
Adjust colorbar properties
This param I used to set custom labels to the colorbar (-1,0,1) to create the same plot as the existed version.
from scona.
Link to the existed function - view_corr_mat
- here
from scona.
Thanks for the link @wingedRuslan! I like that function actually 😄
This is the code I was thinking of that's at the top of the tutorials:
# Read in sample data from the NSPN WhitakerVertes PNAS 2016 paper.
df, names, covars, centroids = datasets.NSPN_WhitakerVertes_PNAS2016.import_data()
# calculate residuals of the matrix df for the columns of names
df_res = scn.create_residuals_df(df, names, covars)
# create a correlation matrix over the columns of df_res
M = scn.create_corrmat(df_res, method='pearson')
# Initialise a weighted graph G from the correlation matrix M
G = scn.BrainNetwork(network=M, parcellation=names, centroids=centroids)
# Threshold G at cost 10 to create a binary graph with 10% as many edges as the complete graph G.
G10 = G.threshold(10)
M
is the correlation matrix.
The correct way to threshold the graph is using the G.threshold()
command because it makes a minimum spanning tree to make sure that every node is connected for any threshold (cost). BUT for visualization purposes that isn't super important, so we can just threshold using the np.percentile
function as in the current code.
To be clear - we do not need to pass a graph G
to the function. We can stick with giving it M
or a dataframe etc.
The bin
option is so that you can visualize the thresholded network as a (usually) black and white correlation matrix. It just sets all the values below the threshold to 0 and all those above to 1. This is what we do when we calculate the global measures.
So the current code looks great. Lets add vmin
and vmax
in whatever way you think is best (seaborn or adding those options to the current code), and maybe add a symmetric
option (or whatever you used for the other colormaps to force vmin
to be -vmax
or vmax
to be -vmin
depending on which gives the largest range 😄
Thanks for checking!
from scona.
Related Issues (20)
- Add padding to the colorbar at the bottom HOT 3
- calculate_nodal_measures doesn't work on graph bundles HOT 1
- Pad random graphs with 0s so they are in the right order HOT 4
- Set seed for Erdos Renyi graph in plot degree distribution HOT 4
- Include small world in plot_network_measures HOT 3
- Which version of nilearn do we need? HOT 1
- Cut covars columns from residuals matrix HOT 1
- feature request: tell brainbundle the total number of brains you want
- Catch error if name of graph doesn't exist in brain bundle for plot_rich_club HOT 4
- Adjust legend of plot_rich_club HOT 3
- small_world calculations HOT 1
- Nodal measures for plotting with nilearn HOT 5
- Plots of brains in plotting anatomical network HOT 2
- View Connectome with nilearn HOT 5
- Error with nilearn.plot_connectome HOT 1
- Test for visualisations HOT 1
- Removing old viz modules
- Make new get_anatomical_layouts() function HOT 1
- Two similar tutorials HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scona.