Created
May 10, 2011 16:14
-
-
Save iscadar/964782 to your computer and use it in GitHub Desktop.
Visualising the structural and functional connectivity of a neural network.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##Visualising the structural and functional connectivity | |
##of a neural network. | |
##by Alexandros Kourkoulas-Chondrorizos | |
##v0.1 | |
##This is a simple function that calculates the covariance | |
##matrix of a neural network based on its activity. It then | |
##reorders the covariance matrix to obtain a depiction of | |
##functional connectivity and based on that reordering also | |
##rearranges the connectivity matrix in order to obtain a | |
##clearer picture of its structural connectivity. Put simply, | |
##it brings closer neurons that are structurally and | |
##functionally connected. All it needs is the network's | |
##connectivity matrix and a sample of its activity in order to | |
##calculate the covariance matrix. S should be a N-by-N matrix | |
##where N is the number of neurons in the neural network and | |
##Nact should be a N-by-T matrix where N is the same as above | |
##and T is the length of the simulation. | |
def mat_reorder(S,Nact): | |
#compute covariance matrix | |
Cm=cov(Nact) | |
#compute dendrogram | |
Y=sch.linkage(D,method='centroid') | |
Z=sch.dendrogram(Y,orientation='right') | |
index=Z['leaves'] | |
#reorder matrices | |
Cm=Cm[index,:] | |
Cm=Cm[:,index] | |
S=S[index,:] | |
S=S[:,index] | |
#save reordered covariance and connectivity matrices | |
figure(1),matshow(S,origin='lower'),xticks([]),yticks([]), | |
title('Reordered Connectivity Matrix'),savefig('structural_connectivity.png') | |
figure(2),matshow(Cm,origin='lower'),xticks([]),yticks([]), | |
title('Reordered Covariance Matrix'),savefig('functional_connectivity.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment