from
CoCoMac
by James Allen Download CoCoMac.org cortical connectivity data, model it as a network, and simulate epileptic sprea
clustering(net, netLabels)
function [netClustered,newNetLabels] = clustering(net, netLabels)
% Permutates node sequence to
% generate clusters in adjacency net
% yields:
% netClustered: clustered adjacency net
% newNetLabels: corresponding netLabels
% Author: Marcus Kaiser Date: 10 Oct 2003
% Modified by: James Allen Date: July 2006
n = length(net);
center = zeros(n,1);
% get center (average) of node
for newNetIndex=1:n
outarray = net(newNetIndex,:).*(1:n);
[dummy,dummy2,outindices]=find(outarray);
outcenter = median(outindices);
inarray = net(:,newNetIndex).*(1:n)';
[dummy,dummy2,inindices]=find(inarray);
incenter = median(inindices);
center(newNetIndex) = mean([outcenter,incenter]);
end
[dummy,newNetIndex] = sort(center);
netClustered = net(newNetIndex,newNetIndex);
%-----------------------
%ADDITION BY JAMES ALLEN
%Return a rearranged
%'netLabels' variable
%corresponding to new
%clustering
newNetLabels = cell(1,n);
for labelCounter = 1 : n
% Copy cells from supplied netLabels cell array into newNetLabels cell
% array, using the cell indexes listed in number array newNetIndex
newNetLabels{1, labelCounter} = netLabels{1, newNetIndex(labelCounter)};
end
%-------------------------
return;