123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- %% for one way connections comment out if not used
- source_1=source;
- target_1=target;
- for i=1:length(source)
- temp=[source(i) target_1(i)];
- in1=find(target==temp(1,1));
- in2=find(source==temp(1,2));
- if isempty(intersect(in1,in2))~= 1
- source(i)=0;
- target(i)=0;
- weight(i)=0;
- end
- end
- source=(nonzeros(source))';
- target=(nonzeros(target))';
- weight=(nonzeros(weight))';
- %%
- clear channels
- clear ids
- j=1;
- channels(j)=source(1);
- for i=2:length(source) %finds all source channels and add them to channels
- if source(i)~=channels
- j=j+1;
- channels(j)=source(i);
- end
- end
- for i=1:length(target)
- if target(i)~=channels
- j=j+1;
- channels(j)=target(i); %finds also all target channels and add them
- end %to channels if they are not added as source before
- end
- N=length(channels);
- cm=zeros(N,N);
- weight_new=zeros(N,N);
- for i=1:length(channels)
- [row,col]=find(source==channels(i)) %make connections from source to target
- if size(row) ~= 0
- x=target(row,col);
- x=x(1,:);
- for j=1: length(row)
- [row1,col1]=find(channels==x(j))
- cm(i,col1)=1;
- weight_new (i,col1) = cross(channels(i),channels(col1));%%THIS PART IS ADDED AFTER REALIZING THE MISTAKE IN PUBLICATION...REORDERS THE WEIGHTS OF LINKS RIGHT WAY
- end
- end
-
- end
- for k=1:N
- ChannelName{k} = DataCell{channels(k),1}(end-3:end);
- ids{k}=['' ChannelName{k} ''''];
- end
- %%
- bg2=biograph(cm,ids,'NodeAutoSize','off','ShowArrows','off');
- get(bg2.nodes,'ID')
- set(bg2, 'EdgeType', 'curved')
- hbg= view(bg2);
- %% DO LAYOUT ACCORDING TO MEA SETUP
- page_Size = [400 400];
- XpageSize = page_Size(1);
- YpageSize = page_Size(2);
- for i = 1:length(ids)
- nodeID = str2num(ids{i}(end-2:end-1));
- tens = floor(nodeID / 10);
- ones = mod(nodeID , 10);
- xposition = floor(XpageSize / 8) * tens ;
- yposition = floor(YpageSize / 8) * (ones); %(9-ones) for MCS setup; (ones) for Axion setup
- set(hbg.Nodes(i),'Position', [xposition, yposition]);
- set(hbg.Nodes(i),'Color', [51/255 204/255 204/255]);%[20/255 108/255 217/255]);%[196/255 4/255 33/255]);%[51/255 204/255 204/255]);%[230/255 160/255 45/255]);%
- set(hbg.Nodes(i),'LineColor', [51/255 204/255 204/255]);%[196/255 4/255 33/255]);%[51/255 204/255 204/255]);%[230/255 160/255 45/255]);
- set(hbg.Nodes(i),'FontSize', 12);%12); in original 12
- set(hbg.Nodes(i),'Shape', 'circle');
- set(hbg.Nodes(i),'Size', [30 30]);% [30 30]); in original 30
- end
- %% SET PATH WIDTHS ACCORDING TO CORRELATION COEFFICIENTS i.e WEIGHTS
- % Set the weights in the right order reading as it is in cm
- weight_row=[];
- weight_col=[];
- for t = 1 : length(weight_new)
- [a, b]=find(weight_new(t,:)~=0);
- if size(b) ~= 0
- weight_row=[weight_row (a*t)];
- weight_col=[weight_col b];
- end
- end
- % added the correct till here
- for i = 1:length(weight_row)
- set(hbg.Edges(i),'LineWidth', (10*(abs(weight_new(weight_row(i),weight_col(i)))-treshold)+0.1)); % default (10*(abs(weight_new(weight_row(i),weight_col(i)))-treshold)+0.1 ))
- end
- %%
- set(hbg.Edges,'LineColor', [0/255 0/255 0/255]);
- dolayout(hbg, 'Pathsonly', true)
|