Fig7C.m 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. % plot spontaneous rate in two different states: awake and anesthetized
  2. % plot firing rate in response to maskers in two different states: awake and anesthetized
  3. load('sp_context.mat')
  4. dur_echo=1.3311;
  5. dur_distress=1.9266;
  6. c_=sp_context(:,2)==0; % unit classification
  7. aw_=sp_context(:,3)==0; % awake data
  8. an_=sp_context(:,3)==1; % anesthetized data
  9. spont_=sp_context(:,7)==0; % spontaneous firing rate
  10. cont_=sp_context(:,7)==1; % context firing rate intact
  11. cont_chi=sp_context(:,7)==2; % context firing rate chimeras
  12. cont_pt=sp_context(:,7)==3; % context firing rate pure tones
  13. % submatrices
  14. aw_spont=sp_context(logical(c_.*aw_.*spont_),:);
  15. an_spont=sp_context(logical(c_.*an_.*spont_),:);
  16. aw_cont=sp_context(logical(c_.*aw_.*cont_),:);
  17. an_cont=sp_context(logical(c_.*an_.*cont_),:);
  18. an_chi=sp_context(logical(c_.*an_.*cont_chi),:);
  19. %% calculate spontaneous firing rate
  20. % awake data - spontaneous & context
  21. units=unique(aw_spont(:,1));
  22. aw_spontR=nan(numel(units),1);
  23. aw_contR=nan(numel(units),2);
  24. for u=1:numel(units)
  25. u_=aw_spont(:,1)==units(u);
  26. u_2=aw_cont(:,1)==units(u);
  27. rate=nanmean(aw_spont(u_,8));
  28. rate2=nanmean(aw_cont(u_2,5)); % nav
  29. rate3=nanmean(aw_cont(u_2,6)); % com
  30. aw_spontR(u,1)=rate;
  31. aw_contR(u,1)=rate2;
  32. aw_contR(u,2)=rate3;
  33. end
  34. aw_spontR=aw_spontR./((3.5-0.2));
  35. aw_contR(:,1)=aw_contR(:,1);
  36. aw_contR(:,2)=aw_contR(:,2);
  37. % anesthetized data - spontaneous
  38. units=unique(an_spont(:,1));
  39. an_spontR=nan(numel(units),1);
  40. for u=1:numel(units)
  41. u_=an_spont(:,1)==units(u);
  42. rate=nanmean(an_spont(u_,8));
  43. an_spontR(u,1)=rate;
  44. end
  45. an_spontR=an_spontR./((3.5-0.2));
  46. % anesthetized data - context
  47. units=unique(an_cont(:,1));
  48. an_contR=nan(numel(units),2);
  49. for u=1:numel(units)
  50. u_2=an_cont(:,1)==units(u);
  51. rate2=nanmean(an_cont(u_2,5)); % nav
  52. rate3=nanmean(an_cont(u_2,6)); % com
  53. an_contR(u,1)=rate2;
  54. an_contR(u,2)=rate3;
  55. end
  56. an_contR(:,1)=an_contR(:,1);
  57. an_contR(:,2)=an_contR(:,2);
  58. % anesthetized data - context CHIMERAS
  59. units=unique(an_chi(:,1));
  60. an_chiR=nan(numel(units),2);
  61. for u=1:numel(units)
  62. u_2=an_chi(:,1)==units(u);
  63. rate2=nanmean(an_chi(u_2,5)); % nav
  64. rate3=nanmean(an_chi(u_2,6)); % com
  65. an_chiR(u,1)=rate2;
  66. an_chiR(u,2)=rate3;
  67. end
  68. an_chiR(:,1)=an_chiR(:,1); % flipped
  69. an_chiR(:,2)=an_chiR(:,2);
  70. % firing rate in response to probes
  71. int=load('all_data.mat'); int=int.all_di;
  72. c_=int(:,2)==0;
  73. an_=int(:,3)==1;
  74. int=int(logical(c_.*an_),18:19);
  75. chi=load('chi_data.mat'); chi=chi.all_di;
  76. c_=chi(:,2)==0;
  77. an_=chi(:,3)==0;
  78. chi=chi(logical(c_.*an_),18:19);
  79. pt=load('pt_data.mat'); pt=pt.all_di;
  80. c_=pt(:,2)==0;
  81. an_=pt(:,3)==1;
  82. pt=pt(logical(c_.*an_),11:12);
  83. probe_an=[int; chi].*20 ; %; chi; pt].*20; % x20: spikecounts to firing rate
  84. aw=load('all_data.mat'); aw=aw.all_di;
  85. c_=aw(:,2)==0;
  86. aw_=aw(:,3)==0;
  87. probe_aw=aw(logical(c_.*aw_),18:19).*20; % x20: spikecounts to firing rate
  88. % compare non-paired samples
  89. pv1=ranksum(aw_spontR,an_spontR);
  90. pv2=ranksum(aw_contR(:,1),an_contR(:,1));
  91. pv3=ranksum(aw_contR(:,2),an_contR(:,2));
  92. pv4=signrank(aw_contR(:,1),aw_contR(:,2));
  93. pv5=signrank(an_contR(:,1),an_contR(:,2));
  94. pv6=ranksum(an_contR(:,1),an_chiR(:,1));
  95. pv7=ranksum(an_contR(:,2),an_chiR(:,2));
  96. pv8=ranksum(probe_aw(:,1),probe_an(:,1));
  97. pv9=ranksum(probe_aw(:,2),probe_an(:,2));
  98. pv10=signrank(probe_aw(:,1),probe_aw(:,2));
  99. pv11=signrank(probe_an(:,1),probe_an(:,2));
  100. %% plotting
  101. close all;
  102. red =[0.8500,0.3250, 0.0980];
  103. blue=[0,0.4470,0.7410];
  104. red_light=[1,0.5,0.5].*red;
  105. blue_light=[1,0.5,0.5].*blue;
  106. colors=[[0.3 0.3 0.3];[0.5 0.5 0.5];blue_light;red_light;blue;red];
  107. y1=nan(58,6);
  108. y1(1:numel(aw_spontR),1)=aw_spontR;
  109. y1(1:numel(an_spontR),2)=an_spontR;
  110. y1(1:numel(aw_contR(:,1)),3)=aw_contR(:,1);
  111. y1(1:numel(an_contR(:,1)),4)=an_contR(:,1);
  112. y1(1:numel(aw_contR(:,2)),5)=aw_contR(:,2);
  113. y1(1:numel(an_contR(:,2)),6)=an_contR(:,2);
  114. x = 1:6;
  115. figure(1); set(gcf,'Position',[400 200 250 170])
  116. ax = axes();
  117. hold(ax);
  118. for i=1:6
  119. h=boxchart(x(i)*ones(size(y1(:,i))), y1(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  120. h.MarkerStyle='.';
  121. h.MarkerColor=colors(i,:);
  122. end
  123. hold on
  124. plot(1:2,nanmedian(y1(:,1:2)),'o','LineWidth',1,'Color',[0.3 0.3 0.3],'MarkerSize',3,'MarkerFaceColor',[0.3 0.3 0.3])
  125. plot(3,nanmedian(y1(:,3)),'o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
  126. plot(4,nanmedian(y1(:,4)),'o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
  127. plot(5,nanmedian(y1(:,5)),'o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue)
  128. plot(6,nanmedian(y1(:,6)),'o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red)
  129. hold off
  130. xlim([0.5 6.5])
  131. ylabel('# spikes')
  132. xticks(1:6)
  133. xticklabels({'awake','anesthetized','awake','anesthetized','awake','anesthetized'});
  134. set(gca, 'box', 'off')
  135. set(gca, 'Color','none')
  136. set(gca,'linewidth',1);set(gca,'fontsize',8);
  137. xt = get(gca, 'XTick');
  138. line1=165;
  139. line2=190;
  140. line3=215;
  141. sl=0.75;
  142. % plot lines for comparison
  143. hold on
  144. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  145. plot([1;1]*xt(1),[line1,line1-3],'-k', 'LineWidth',sl);
  146. plot([1;1]*xt(2),[line1,line1-3],'-k', 'LineWidth',sl);
  147. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  148. plot([1;1]*xt(3),[line1,line1-3],'-k', 'LineWidth',sl);
  149. plot([1;1]*xt(4),[line1,line1-3],'-k', 'LineWidth',sl);
  150. plot(xt(5:6), [1 1]*line1, '-k','LineWidth',sl)
  151. plot([1;1]*xt(5),[line1,line1-3],'-k', 'LineWidth',sl);
  152. plot([1;1]*xt(6),[line1,line1-3],'-k', 'LineWidth',sl);
  153. plot([xt(3) xt(5)], [1 1]*line2, '-k','LineWidth',sl)
  154. plot([1;1]*xt(3),[line2,line2-3],'-k', 'LineWidth',sl);
  155. plot([1;1]*xt(5),[line2,line2-3],'-k', 'LineWidth',sl);
  156. plot([xt(4) xt(6)], [1 1]*line3, '-k','LineWidth',sl)
  157. plot([1;1]*xt(4),[line3,line3-3],'-k', 'LineWidth',sl);
  158. plot([1;1]*xt(6),[line3,line3-3],'-k', 'LineWidth',sl);
  159. ylim([-5 170])
  160. % plot level of significance
  161. if pv1 <= 0.05 && pv1 > 0.01
  162. text(mean(xt(1:2))-0.05, line1+5, '*','HorizontalAlignment','center')
  163. elseif pv1 <=0.01 && pv1 > 0.001
  164. text(mean(xt(1:2))-0.05, line1+5, '**','HorizontalAlignment','center')
  165. elseif pv1 <= 0.001
  166. text(mean(xt(1:2))-0.05, line1+5, '***','HorizontalAlignment','center')
  167. else
  168. text(mean(xt(1:2))-0.05, line1+12, 'ns','FontSize',8,'HorizontalAlignment','center')
  169. end
  170. if pv2 <= 0.05 && pv2 > 0.01
  171. text(mean(xt(3:4))-0.05, line1+5, '*','HorizontalAlignment','center')
  172. elseif pv2 <=0.01 && pv2 > 0.001
  173. text(mean(xt(3:4))-0.05, line1+5, '**','HorizontalAlignment','center')
  174. elseif pv2 <= 0.001
  175. text(mean(xt(3:4))-0.05, line1+5, '***','HorizontalAlignment','center')
  176. else
  177. text(mean(xt(3:4))-0.05, line1+12, 'ns','FontSize',8,'HorizontalAlignment','center')
  178. end
  179. if pv3 <= 0.05 && pv3 > 0.01
  180. text(mean(xt(5:6))-0.05, line1+5, '*','HorizontalAlignment','center')
  181. elseif pv3 <=0.01 && pv3 > 0.001
  182. text(mean(xt(5:6))-0.05, line1+5, '**','HorizontalAlignment','center')
  183. elseif pv3 <= 0.001
  184. text(mean(xt(5:6))-0.05, line1+5, '***','HorizontalAlignment','center')
  185. else
  186. text(mean(xt(5:6))-0.05, line1+15, 'ns','FontSize',8,'HorizontalAlignment','center')
  187. end
  188. % if pv4 <= 0.05 && pv4 > 0.01
  189. % text(mean(xt(3:5))-0.05, line2+5, '*','HorizontalAlignment','center')
  190. % elseif pv4 <=0.01 && pv4 > 0.001
  191. % text(mean(xt(3:5))-0.05, line2+5, '**','HorizontalAlignment','center')
  192. % elseif pv4 <= 0.001
  193. % text(mean(xt(3:5))-0.05, line2+5, '***','HorizontalAlignment','center')
  194. % else
  195. % text(mean(xt(3:5))-0.05, line2+12, 'ns','FontSize',8,'HorizontalAlignment','center')
  196. % end
  197. %
  198. % if pv5 <= 0.05 && pv5 > 0.01
  199. % text(mean(xt(4:6))-0.05, line3+5, '*','HorizontalAlignment','center')
  200. % elseif pv5 <=0.01 && pv5 > 0.001
  201. % text(mean(xt(4:6))-0.05, line3+5, '**','HorizontalAlignment','center')
  202. % elseif pv5 <= 0.001
  203. % text(mean(xt(4:6))-0.05, line3+5, '***','HorizontalAlignment','center')
  204. % else
  205. % text(mean(xt(4:6))-0.05, line3+12, 'ns','FontSize',8,'HorizontalAlignment','center')
  206. % end
  207. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\preparation_rate_cont.pdf',...
  208. % 'Resolution',300','ContentType','vector','BackgroundColor','none')
  209. %% plotting probes
  210. colors=[blue_light;blue;red_light;red];
  211. y2=nan(58,4);
  212. y2(1:numel(probe_aw(:,1)),1)=probe_aw(:,1);
  213. y2(1:numel(probe_an(:,1)),2)=probe_an(:,1);
  214. y2(1:numel(probe_aw(:,2)),3)=probe_aw(:,2);
  215. y2(1:numel(probe_an(:,2)),4)=probe_an(:,2);
  216. x = 1:4;
  217. figure(2); set(gcf,'Position',[700 200 170 170])
  218. ax = axes();
  219. hold(ax);
  220. for i=1:4
  221. h=boxchart(x(i)*ones(size(y2(:,i))), y2(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  222. h.MarkerStyle='.';
  223. h.MarkerColor=colors(i,:);
  224. end
  225. hold on
  226. plot(1:2,nanmedian(y2(:,1:2)),'-o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
  227. plot(3:4,nanmedian(y2(:,3:4)),'-o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
  228. hold off
  229. xlim([0.5 4.5])
  230. ylabel('firing rate ')
  231. xticks(1:4)
  232. xticklabels({'awake','anesthetized','awake','anesthetized'});
  233. set(gca, 'box', 'off')
  234. set(gca, 'Color','none')
  235. set(gca,'linewidth',1);set(gca,'fontsize',8);
  236. xt = get(gca, 'XTick');
  237. line1=290;
  238. line2=340;
  239. line3=390;
  240. sl=0.75;
  241. % plot lines for comparison
  242. hold on
  243. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  244. plot([1;1]*xt(1),[line1,line1-10],'-k', 'LineWidth',sl);
  245. plot([1;1]*xt(2),[line1,line1-10],'-k', 'LineWidth',sl);
  246. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  247. plot([1;1]*xt(3),[line1,line1-10],'-k', 'LineWidth',sl);
  248. plot([1;1]*xt(4),[line1,line1-10],'-k', 'LineWidth',sl);
  249. % plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl)
  250. % plot([1;1]*xt(1),[line2,line2-10],'-k', 'LineWidth',sl);
  251. % plot([1;1]*xt(3),[line2,line2-10],'-k', 'LineWidth',sl);
  252. %
  253. % plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl)
  254. % plot([1;1]*xt(2),[line3,line3-10],'-k', 'LineWidth',sl);
  255. % plot([1;1]*xt(4),[line3,line3-10],'-k', 'LineWidth',sl);
  256. ylim([-5 320])
  257. % plot level of significance
  258. if pv8 <= 0.05 && pv8 > 0.01
  259. text(mean(xt(1:2))-0.05, line1+20, '*','HorizontalAlignment','center')
  260. elseif pv8 <=0.01 && pv8 > 0.001
  261. text(mean(xt(1:2))-0.05, line1+20, '**','HorizontalAlignment','center')
  262. elseif pv8 <= 0.001
  263. text(mean(xt(1:2))-0.05, line1+20, '***','HorizontalAlignment','center')
  264. else
  265. text(mean(xt(1:2))-0.05, line1+28, 'ns','FontSize',8,'HorizontalAlignment','center')
  266. end
  267. if pv9 <= 0.05 && pv9 > 0.01
  268. text(mean(xt(3:4))-0.05, line1+20, '*','HorizontalAlignment','center')
  269. elseif pv9 <=0.01 && pv9 > 0.001
  270. text(mean(xt(3:4))-0.05, line1+20, '**','HorizontalAlignment','center')
  271. elseif pv9 <= 0.001
  272. text(mean(xt(3:4))-0.05, line1+20, '***','HorizontalAlignment','center')
  273. else
  274. text(mean(xt(3:4))-0.05, line1+28, 'ns','FontSize',8,'HorizontalAlignment','center')
  275. end
  276. % if pv10 <= 0.05 && pv10 > 0.01
  277. % text(mean(xt(1:3))-0.05, line2+20, '*','HorizontalAlignment','center')
  278. % elseif pv10 <=0.01 && pv10 > 0.001
  279. % text(mean(xt(1:3))-0.05, line2+20, '**','HorizontalAlignment','center')
  280. % elseif pv10 <= 0.001
  281. % text(mean(xt(1:3))-0.05, line2+20, '***','HorizontalAlignment','center')
  282. % else
  283. % text(mean(xt(1:3))-0.05, line2+28, 'ns','FontSize',8,'HorizontalAlignment','center')
  284. % end
  285. %
  286. % if pv11 <= 0.05 && pv11 > 0.01
  287. % text(mean(xt(2:4))-0.05, line3+20, '*','HorizontalAlignment','center')
  288. % elseif pv11 <=0.01 && pv11 > 0.001
  289. % text(mean(xt(2:4))-0.05, line3+20, '**','HorizontalAlignment','center')
  290. % elseif pv11 <= 0.001
  291. % text(mean(xt(2:4))-0.05, line3+20, '***','HorizontalAlignment','center')
  292. % else
  293. % text(mean(xt(2:4))-0.05, line3+28, 'ns','FontSize',8,'HorizontalAlignment','center')
  294. % end
  295. % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\preparation_rate_probe.pdf',...
  296. % 'Resolution',300','ContentType','vector','BackgroundColor','none')
  297. %% plotting chimeras
  298. green_light=[0.4863,0.3059,0.7098]; % green: [0.3922,0.8314,0.0745];
  299. green=[0.2980,0.1294,0.5098]; % gree: [0.4667,0.6745,0.1882];
  300. colors=[blue_light;green;red_light;green_light];
  301. y3=nan(46,4);
  302. y3(1:numel(an_contR(:,1)),1)=an_contR(:,1);
  303. y3(1:numel(an_chiR(:,1)),2)=an_chiR(:,1);
  304. y3(1:numel(an_contR(:,2)),3)=an_contR(:,2);
  305. y3(1:numel(an_chiR(:,2)),4)=an_chiR(:,2);
  306. x = 1:4;
  307. figure(3); set(gcf,'Position',[900 200 170 170])
  308. ax = axes();
  309. hold(ax);
  310. for i=1:4
  311. h=boxchart(x(i)*ones(size(y3(:,i))), y3(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
  312. h.MarkerStyle='.';
  313. h.MarkerColor=colors(i,:);
  314. end
  315. hold on
  316. plot(1:2,nanmedian(y3(:,1:2)),'-o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
  317. plot(3:4,nanmedian(y3(:,3:4)),'-o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
  318. hold off
  319. xlim([0.5 4.5])
  320. ylabel('firing rate ')
  321. xticks(1:4)
  322. xticklabels({'nav','fast nav','com','slow com'});
  323. set(gca, 'box', 'off')
  324. set(gca, 'Color','none')
  325. set(gca,'linewidth',1);set(gca,'fontsize',8);
  326. xt = get(gca, 'XTick');
  327. line1=170;
  328. sl=0.75;
  329. % plot lines for comparison
  330. hold on
  331. plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
  332. plot([1;1]*xt(1),[line1,line1-3],'-k', 'LineWidth',sl);
  333. plot([1;1]*xt(2),[line1,line1-3],'-k', 'LineWidth',sl);
  334. plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
  335. plot([1;1]*xt(3),[line1,line1-3],'-k', 'LineWidth',sl);
  336. plot([1;1]*xt(4),[line1,line1-3],'-k', 'LineWidth',sl);
  337. ylim([-5 185])
  338. % plot level of significance
  339. if pv6 <= 0.05 && pv6 > 0.01
  340. text(mean(xt(1:2))-0.05, line1+4, '*','HorizontalAlignment','center')
  341. elseif pv6 <=0.01 && pv6 > 0.001
  342. text(mean(xt(1:2))-0.05, line1+4, '**','HorizontalAlignment','center')
  343. elseif pv6 <= 0.001
  344. text(mean(xt(1:2))-0.05, line1+4, '***','HorizontalAlignment','center')
  345. else
  346. text(mean(xt(1:2))-0.05, line1+10, 'ns','FontSize',8,'HorizontalAlignment','center')
  347. end
  348. if pv7 <= 0.05 && pv7 > 0.01
  349. text(mean(xt(3:4))-0.05, line1+4, '*','HorizontalAlignment','center')
  350. elseif pv7 <=0.01 && pv7 > 0.001
  351. text(mean(xt(3:4))-0.05, line1+4, '**','HorizontalAlignment','center')
  352. elseif pv7 <= 0.001
  353. text(mean(xt(3:4))-0.05, line1+4, '***','HorizontalAlignment','center')
  354. else
  355. text(mean(xt(3:4))-0.05, line1+10, 'ns','FontSize',8,'HorizontalAlignment','center')
  356. end