Fig9B-C.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. close all;
  2. clear;
  3. % boxplots for context effect index
  4. load('all_ce.mat')
  5. aw_=all_ce(:,1)==1; n_aw=sum(aw_);
  6. an_=all_ce(:,1)==2; n_an=sum(an_);
  7. chi_=all_ce(:,1)==3; n_chi=sum(chi_);
  8. nav=all_ce(:,2:3);
  9. com=all_ce(:,4:5);
  10. % comparisons
  11. y1=nan(117,2);
  12. y2=nan(117,2);
  13. y1(1:n_chi,1:2)=nav(chi_,:);
  14. y2(1:n_chi,1:2)=com(chi_,:);
  15. y3=[(y1(:,2)-y1(:,1))./2,(y2(:,2)-y2(:,1))./2] ;
  16. % to obtain classification per quadrant
  17. chi_nav=y3(~isnan(y3(:,1)),1);
  18. chi_com=y3(~isnan(y3(:,2)),2);
  19. class_chi=nan(n_chi,1);
  20. % for n=12 uncomment the line below
  21. % n_chi=12;
  22. for u=1:n_chi
  23. if chi_nav(u)>0 && chi_com(u)>0 % first quadrant
  24. class_chi(u,1)=1;
  25. elseif chi_nav(u)>0 && chi_com(u)<=0 % second quadrant
  26. class_chi(u,1)=2;
  27. elseif chi_nav(u)<=0 && chi_com(u)>0 % forth quadrant
  28. class_chi(u,1)=4;
  29. elseif chi_nav(u)<=0 && chi_com(u)<=0 % third quadrant
  30. class_chi(u,1)=3;
  31. end
  32. end
  33. prop_chi=histcounts(class_chi)*100/n_chi;
  34. % save units # and their respective quadrant classification
  35. chi=load('chi_data.mat'); chi=chi.all_di;
  36. pt=load('pt_data.mat'); pt=pt.all_di;
  37. chi_1=chi(:,3)==0;
  38. eq_1=chi(:,2)==0;
  39. chi_2=pt(:,3)==2;
  40. eq_2=pt(:,2)==0;
  41. chi_eq=[chi(logical(chi_1.*eq_1),1); pt(logical(chi_2.*eq_2),1)];
  42. cell_chi=[chi_eq, class_chi];
  43. save('cell_chi.mat', 'cell_chi')
  44. % stats
  45. %for n=12, for n=26 just remove this 3 lines below
  46. % y1=y1(1:12,:);
  47. % y2=y2(1:12,:);
  48. % y3=y3(1:12,:);
  49. pv1=signrank(y1(:,1),y1(:,2));
  50. pv2=signrank(y2(:,1),y2(:,2));
  51. pv3=signrank(y3(:,1),y3(:,2));
  52. pv4=signrank(y3(:,1));
  53. pv5=signrank(y3(:,2));
  54. %% plotting
  55. red =[0.8500,0.3250, 0.0980];
  56. blue=[0,0.4470,0.7410];
  57. red_light=[1,0.5,0.5].*red;
  58. blue_light=[1,0.5,0.5].*blue;
  59. green_light=[0.4863,0.3059,0.7098]; % green: [0.3922,0.8314,0.0745];
  60. green=[0.2980,0.1294,0.5098]; % [0.4667,0.6745,0.1882];
  61. colors=[green;green_light];
  62. wid=100;
  63. hei=150;
  64. x = 1:2;
  65. figure(1); set(gcf,'Position',[400 200 wid hei])
  66. ax = axes();
  67. hold(ax);
  68. for i=1:2
  69. h=boxchart(x(i)*ones(size(y1(:,i))), y1(:,i), 'BoxFaceColor', colors(i,:),'Notch','off');
  70. h.MarkerStyle='.';
  71. h.MarkerColor=colors(i,:);
  72. end
  73. hold on
  74. plot(1:2,nanmedian(y1(:,1:2)),'-o','LineWidth',1,'Color',green,'MarkerSize',3,'MarkerFaceColor',green)
  75. hold off
  76. xlim([0.5 2.5])
  77. ylabel('fast echo effect')
  78. xticklabels({'match','mismatch'});
  79. set(gca, 'box', 'off')
  80. set(gca, 'Color','none')
  81. set(gca,'linewidth',1);set(gca,'fontsize',8);
  82. % plot lines for comparison
  83. line1=0.45;
  84. sl=0.75;
  85. hold on
  86. plot([1 2], [1 1]*line1, '-k','LineWidth',sl)
  87. plot([1;1]*1,[line1,line1-0.05],'-k', 'LineWidth',sl);
  88. plot([1;1]*2,[line1,line1-0.05],'-k', 'LineWidth',sl);
  89. ylim([-1.1 0.75])
  90. % plot level of significance
  91. if pv1 <= 0.05 && pv1 > 0.01
  92. text(mean(1:2)-0.025, line1+0.05, '*')
  93. elseif pv1 <=0.01 && pv1 > 0.001
  94. text(mean(1:2)-0.05, line1+0.05, '**')
  95. elseif pv1 <= 0.001
  96. text(mean(1:2)-0.15, line1+0.05, '***')
  97. else
  98. text(mean(1:2)-0.05, line1+0.1, 'ns','FontSize',8)
  99. end
  100. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\chi_nav.pdf',...
  101. % 'Resolution',300','ContentType','vector','BackgroundColor','none')
  102. figure(2); set(gcf,'Position',[500 200 wid hei])
  103. ax = axes();
  104. hold(ax);
  105. for i=1:2
  106. h=boxchart(x(i)*ones(size(y2(:,i))), y2(:,i), 'BoxFaceColor', colors(i,:),'Notch','off');
  107. h.MarkerStyle='.';
  108. h.MarkerColor=colors(i,:);
  109. end
  110. hold on
  111. plot(1:2,nanmedian(y2(:,1:2)),'-o','LineWidth',1,'Color',green,'MarkerSize',3,'MarkerFaceColor',green)
  112. hold off
  113. xlim([0.5 2.5])
  114. ylabel('slow com effect')
  115. xticklabels({'match','mismatch'});
  116. set(gca, 'box', 'off')
  117. set(gca, 'Color','none')
  118. set(gca,'linewidth',1);set(gca,'fontsize',8);
  119. % plot lines for comparison
  120. line1=0.45; % 0.0 for n=12 %0.45 for n=26
  121. sl=0.75;
  122. hold on
  123. plot([1 2], [1 1]*line1, '-k','LineWidth',sl)
  124. plot([1;1]*1,[line1,line1-0.05],'-k', 'LineWidth',sl);
  125. plot([1;1]*2,[line1,line1-0.05],'-k', 'LineWidth',sl);
  126. ylim([-1.1 0.75]) % for n=26
  127. % ylim([-1.1 0.2]) % for n=12
  128. % plot level of significance
  129. if pv2 <= 0.05 && pv2 > 0.01
  130. text(mean(1:2)-0.025, line1+0.05, '*')
  131. elseif pv2 <=0.01 && pv2 > 0.001
  132. text(mean(1:2)-0.05, line1+0.05, '**')
  133. elseif pv2 <= 0.001
  134. text(mean(1:2)-0.15, line1+0.05, '***')
  135. else
  136. text(mean(1:2)-0.05, line1+0.1, 'ns','FontSize',8)
  137. end
  138. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\chi_com.pdf',...
  139. % 'Resolution',300','ContentType','vector','BackgroundColor','none')
  140. figure(3); set(gcf,'Position',[600 200 wid hei])
  141. ax = axes();
  142. hold(ax);
  143. for i=1:2
  144. h=boxchart(x(i)*ones(size(y3(:,i))), y3(:,i), 'BoxFaceColor', colors(i,:),'Notch','off');
  145. h.MarkerStyle='.';
  146. h.MarkerColor=colors(i,:);
  147. end
  148. hold on
  149. plot(1:2,nanmedian(y3(:,1:2)),'-o','LineWidth',1,'Color',green,'MarkerSize',3,'MarkerFaceColor',green)
  150. hold off
  151. xlim([0.5 2.5])
  152. ylabel('s.s.s.')
  153. xticklabels({'fast echo','slow com'});
  154. set(gca, 'box', 'off')
  155. set(gca, 'Color','none')
  156. set(gca,'linewidth',1);set(gca,'fontsize',8);
  157. % plot lines for comparison
  158. xt = get(gca, 'XTick');
  159. line1=0.35;
  160. hold on
  161. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  162. plot([1;1]*xt(1),[line1,line1-0.03],'-k', 'LineWidth',sl);
  163. plot([1;1]*xt(2),[line1,line1-0.03],'-k', 'LineWidth',sl);
  164. ylim([-0.35 0.4])
  165. % plot level of significance
  166. if pv3 <= 0.05 && pv3 > 0.01
  167. text(mean(xt(1:2))-0.025, line1+0.02, '*','HorizontalAlignment','center')
  168. elseif pv3 <=0.01 && pv3 > 0.001
  169. text(mean(xt(1:2))-0.05, line1+0.02, '**','HorizontalAlignment','center')
  170. elseif pv3 <= 0.001
  171. text(mean(xt(1:2))-0.15, line1+0.02, '***','HorizontalAlignment','center')
  172. else
  173. text(mean(xt(1:2))-0.05, line1+0.1, 'ns','FontSize',7,'HorizontalAlignment','center')
  174. end
  175. % add stats against null distribution
  176. line0=-0.3;
  177. if pv4 <= 0.05 && pv4 > 0.01
  178. text(xt(1), line0, '*','HorizontalAlignment','center')
  179. elseif pv4 <=0.01 && pv4 > 0.001
  180. text(xt(1), line0, '**','HorizontalAlignment','center')
  181. elseif pv4 <= 0.001
  182. text(xt(1), line0, '***','HorizontalAlignment','center')
  183. else
  184. text(xt(1), line0+0.01, 'ns','FontSize',7,'HorizontalAlignment','center')
  185. end
  186. if pv5 <= 0.05 && pv5 > 0.01
  187. text(xt(2), line0, '*','HorizontalAlignment','center')
  188. elseif pv5 <=0.01 && pv5 > 0.001
  189. text(xt(2), line0, '**','HorizontalAlignment','center')
  190. elseif pv5 <= 0.001
  191. text(xt(2), line0, '***','HorizontalAlignment','center')
  192. else
  193. text(xt(2), line0+0.01, 'ns','FontSize',8,'HorizontalAlignment','center')
  194. end
  195. % l=yline(0,'Color',[0.6 0.6 0.6], 'LineWidth',2);
  196. % uistack(l,'bottom')
  197. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\dd_chi.pdf',...
  198. % 'Resolution',300','ContentType','vector','BackgroundColor','none')
  199. figure(4); set(gcf,'Position',[200 200 100 100])
  200. b=bar(prop_chi);
  201. b.EdgeColor=green_light;
  202. b.FaceColor=green_light;
  203. b.LineWidth =1.0;
  204. b.FaceAlpha = 0.2;
  205. b.BarWidth=0.75;
  206. xlim([0.25 4.75])
  207. ylabel('% units')
  208. xticklabels({'I','II','III','IV'});
  209. set(gca, 'box', 'off')
  210. set(gca, 'Color','none')
  211. set(gca,'linewidth',1);set(gca,'fontsize',8);
  212. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\class_quad_chi.pdf',...
  213. % 'Resolution',300','ContentType','vector','BackgroundColor','none')