map.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. %% for one way connections comment out if not used
  2. source_1=source;
  3. target_1=target;
  4. for i=1:length(source)
  5. temp=[source(i) target_1(i)];
  6. in1=find(target==temp(1,1));
  7. in2=find(source==temp(1,2));
  8. if isempty(intersect(in1,in2))~= 1
  9. source(i)=0;
  10. target(i)=0;
  11. weight(i)=0;
  12. end
  13. end
  14. source=(nonzeros(source))';
  15. target=(nonzeros(target))';
  16. weight=(nonzeros(weight))';
  17. %%
  18. clear channels
  19. clear ids
  20. j=1;
  21. channels(j)=source(1);
  22. for i=2:length(source) %finds all source channels and add them to channels
  23. if source(i)~=channels
  24. j=j+1;
  25. channels(j)=source(i);
  26. end
  27. end
  28. for i=1:length(target)
  29. if target(i)~=channels
  30. j=j+1;
  31. channels(j)=target(i); %finds also all target channels and add them
  32. end %to channels if they are not added as source before
  33. end
  34. N=length(channels);
  35. cm=zeros(N,N);
  36. weight_new=zeros(N,N);
  37. for i=1:length(channels)
  38. [row,col]=find(source==channels(i)) %make connections from source to target
  39. if size(row) ~= 0
  40. x=target(row,col);
  41. x=x(1,:);
  42. for j=1: length(row)
  43. [row1,col1]=find(channels==x(j))
  44. cm(i,col1)=1;
  45. 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
  46. end
  47. end
  48. end
  49. for k=1:N
  50. ChannelName{k} = DataCell{channels(k),1}(end-3:end);
  51. ids{k}=['' ChannelName{k} ''''];
  52. end
  53. %%
  54. bg2=biograph(cm,ids,'NodeAutoSize','off','ShowArrows','off');
  55. get(bg2.nodes,'ID')
  56. set(bg2, 'EdgeType', 'curved')
  57. hbg= view(bg2);
  58. %% DO LAYOUT ACCORDING TO MEA SETUP
  59. page_Size = [400 400];
  60. XpageSize = page_Size(1);
  61. YpageSize = page_Size(2);
  62. for i = 1:length(ids)
  63. nodeID = str2num(ids{i}(end-2:end-1));
  64. tens = floor(nodeID / 10);
  65. ones = mod(nodeID , 10);
  66. xposition = floor(XpageSize / 8) * tens ;
  67. yposition = floor(YpageSize / 8) * (ones); %(9-ones) for MCS setup; (ones) for Axion setup
  68. set(hbg.Nodes(i),'Position', [xposition, yposition]);
  69. 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]);%
  70. 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]);
  71. set(hbg.Nodes(i),'FontSize', 12);%12); in original 12
  72. set(hbg.Nodes(i),'Shape', 'circle');
  73. set(hbg.Nodes(i),'Size', [30 30]);% [30 30]); in original 30
  74. end
  75. %% SET PATH WIDTHS ACCORDING TO CORRELATION COEFFICIENTS i.e WEIGHTS
  76. % Set the weights in the right order reading as it is in cm
  77. weight_row=[];
  78. weight_col=[];
  79. for t = 1 : length(weight_new)
  80. [a, b]=find(weight_new(t,:)~=0);
  81. if size(b) ~= 0
  82. weight_row=[weight_row (a*t)];
  83. weight_col=[weight_col b];
  84. end
  85. end
  86. % added the correct till here
  87. for i = 1:length(weight_row)
  88. 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 ))
  89. end
  90. %%
  91. set(hbg.Edges,'LineColor', [0/255 0/255 0/255]);
  92. dolayout(hbg, 'Pathsonly', true)