brainconn.utils.visualization.grid_communities

grid_communities(c)[source]

(X,Y,INDSORT) = GRID_COMMUNITIES(C) takes a vector of community assignments C and returns three output arguments for visualizing the communities. The third is INDSORT, which is an ordering of the vertices so that nodes with the same community assignment are next to one another. The first two arguments are vectors that, when overlaid on the adjacency matrix using the PLOT function, highlight the communities.

Parameters:c (Nx1 numpy.ndarray) – community assignments
Returns:
  • bounds (list) – list containing the communities
  • indsort (numpy.ndarray) – indices

Notes

Note: This function returns considerably different values than in matlab due to differences between matplotlib and matlab. This function has been designed to work with matplotlib, as in the following example:

ci,_=modularity_und(adj) bounds,ixes=grid_communities(ci) pylab.imshow(adj[np.ix_(ixes,ixes)],interpolation=’none’,cmap=’BuGn’) for b in bounds:

pylab.axvline(x=b,color=’red’) pylab.axhline(y=b,color=’red’)

Note that I adapted the idea from the matlab function of the same name, and have not tested the functionality extensively.