SFig5C.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. close all;
  2. clear;
  3. % plot sPSTH for paired data before and after injection
  4. load('inj_psth.mat')
  5. pair=psths(:,3)==1;
  6. class_=psths(:,5)==0;
  7. aw_=psths(:,2)==0;
  8. % an=psths(:,2)==1;
  9. aw=logical(pair.*aw_.*class_);
  10. units_aw=psths(aw,1);
  11. units_an=units_aw+1;
  12. an=ismember(psths(:,1),units_an);
  13. % protocols
  14. nav_iso=psths(:,4)==1;
  15. com_iso=psths(:,4)==2;
  16. exp_nav=psths(:,4)==3;
  17. unexp_nav=psths(:,4)==4;
  18. exp_com=psths(:,4)==5;
  19. unexp_com=psths(:,4)==6;
  20. % average PSTHs for all units equally and paired (n=6)
  21. av_psth1=mean(psths(logical(nav_iso.*aw),6:106));
  22. av_psth2=mean(psths(logical(com_iso.*aw),6:106));
  23. av_psth3=mean(psths(logical(exp_nav.*aw),6:106));
  24. av_psth4=mean(psths(logical(unexp_nav.*aw),6:106));
  25. av_psth5=mean(psths(logical(exp_com.*aw),6:106));
  26. av_psth6=mean(psths(logical(unexp_com.*aw),6:106));
  27. av_psth1AN=mean(psths(logical(nav_iso.*an),6:106));
  28. av_psth2AN=mean(psths(logical(com_iso.*an),6:106));
  29. av_psth3AN=mean(psths(logical(exp_nav.*an),6:106));
  30. av_psth4AN=mean(psths(logical(unexp_nav.*an),6:106));
  31. av_psth5AN=mean(psths(logical(exp_com.*an),6:106));
  32. av_psth6AN=mean(psths(logical(unexp_com.*an),6:106));
  33. edges=-0.1:0.002:0.1;
  34. % smooth PSTHs
  35. % y=0.005;
  36. % [av_psth1,~]=ksdensity(av_psth1,edges,'Width', y);
  37. % [av_psth2,~]=ksdensity(av_psth2,edges,'Width', y);
  38. % [av_psth3,~]=ksdensity(av_psth3,edges,'Width', y);
  39. % [av_psth4,~]=ksdensity(av_psth4,edges,'Width', y);
  40. % [av_psth5,~]=ksdensity(av_psth5,edges,'Width', y);
  41. % [av_psth6,~]=ksdensity(av_psth6,edges,'Width', y);
  42. %
  43. % [av_psth1AN,~]=ksdensity(av_psth1AN,edges,'Width', y);
  44. % [av_psth2AN,~]=ksdensity(av_psth2AN,edges,'Width', y);
  45. % [av_psth3AN,~]=ksdensity(av_psth3AN,edges,'Width', y);
  46. % [av_psth4AN,~]=ksdensity(av_psth4AN,edges,'Width', y);
  47. % [av_psth5AN,~]=ksdensity(av_psth5AN,edges,'Width', y);
  48. % [av_psth6AN,xi]=ksdensity(av_psth6AN,edges,'Width', y);
  49. % psth of an individual unit
  50. unit=12;
  51. u_=psths(:,1)==unit;
  52. ind_nav=psths(logical(u_.*nav_iso),6:106);
  53. ind_com=psths(logical(u_.*com_iso),6:106);
  54. % plot spectrogram of stimuli
  55. load('stims.mat')
  56. Fs=SoundStruct(1).Fs;
  57. nav_stim=SoundStruct(10).sound;
  58. stim_onset=672009;
  59. w=0.010*Fs;
  60. nav_stim=nav_stim(stim_onset-w:stim_onset+w);
  61. com_stim=SoundStruct(2).sound;
  62. stim_onset=672009;
  63. com_stim=com_stim(stim_onset-w:stim_onset+w);
  64. nwin=64;
  65. noverlap=48;
  66. nfft = 1024;
  67. %% plotting
  68. figure(1); set(gcf,'Position',[300 150 450 100])
  69. subplot(1,3,1)
  70. plot(edges,av_psth1,'b'); hold on
  71. plot(edges,av_psth2,'r')
  72. subplot(1,3,2)
  73. plot(edges,av_psth3,'Color',[0.6 0.6 0.6]); hold on
  74. plot(edges,av_psth4,'k')
  75. subplot(1,3,3)
  76. plot(edges,av_psth5,'Color',[0.6 0.6 0.6]); hold on
  77. plot(edges,av_psth6,'k')
  78. linkaxes()
  79. % xlim([0 100])
  80. % ylim([0 24])
  81. figure(2); set(gcf,'Position',[300 150 450 100])
  82. subplot(1,3,1)
  83. plot(edges,av_psth1AN,'b'); hold on
  84. plot(edges,av_psth2AN,'r')
  85. subplot(1,3,2)
  86. plot(edges,av_psth3AN,'Color',[0.6 0.6 0.6]); hold on
  87. plot(edges,av_psth4AN,'k')
  88. subplot(1,3,3)
  89. plot(edges,av_psth5AN,'Color',[0.6 0.6 0.6]); hold on
  90. plot(edges,av_psth6AN,'k')
  91. linkaxes()
  92. % xlim([0 100])
  93. % ylim([0 24])
  94. figure(3); set(gcf,'Position',[300 450 350 150])
  95. subplot(221)
  96. spectrogram(nav_stim, nwin, noverlap, nfft,Fs,'yaxis');
  97. colorbar off
  98. caxis([-100, -50])
  99. xlabel([])
  100. ylabel('freq. (kHz)','FontSize',8)
  101. yticks(0:40:80)
  102. xticks(0:5:20)
  103. xticklabels(-10:5:10)
  104. set(gca, 'box', 'off')
  105. set(gca, 'Color','none')
  106. set(gca,'linewidth',1);set(gca,'fontsize',8);
  107. subplot(222)
  108. spectrogram(com_stim, nwin, noverlap, nfft,Fs,'yaxis');
  109. colorbar off
  110. caxis([-100, -50])
  111. colormap(flipud(gray));
  112. ylabel([])
  113. xlabel([])
  114. yticks(0:40:80)
  115. xticks(0:5:20)
  116. xticklabels(-10:5:10)
  117. set(gca, 'box', 'off')
  118. set(gca, 'Color','none')
  119. set(gca,'linewidth',1);set(gca,'fontsize',8);
  120. subplot(223)
  121. bar(edges*1000,ind_nav,'k');
  122. xline(0,'Color','k','LineWidth',1,'LineStyle',':')
  123. ylabel({'# spikes';'in 2ms'}, 'FontSize', 8)
  124. set(gca, 'box', 'off')
  125. set(gca, 'Color','none')
  126. set(gca,'linewidth',1);set(gca,'fontsize',8);
  127. subplot(224)
  128. bar(edges*1000,ind_com,'k');
  129. yticks([])
  130. xline(0,'Color','k','LineWidth',1,'LineStyle',':')
  131. ylim([0 0.7])
  132. set(gca, 'box', 'off')
  133. set(gca, 'Color','none')
  134. set(gca,'linewidth',1);set(gca,'fontsize',8);
  135. exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\ind_unit_iso.pdf',...
  136. 'Resolution',300','ContentType','vector','BackgroundColor','none')