SFig5B.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. close all;
  2. clear;
  3. path='\';
  4. delay=9261/192000-0.005;
  5. preT=0.150;
  6. % onset=delay+preT;
  7. onset=0.2;
  8. freqs=17;
  9. d=1; y_av=0;
  10. for u = 12 %[10:15,18]
  11. unit=[num2str(u) 'p1.mat'];
  12. disp([path unit])
  13. figure(u); set(gcf, 'Position', [200, 250, 160, 160])
  14. % load data
  15. load(strcat(path,unit));
  16. trials=numel(unique(spikes_prot(:,3)));
  17. tones=numel(unique(spikes_prot(:,2)));
  18. levels=tones/freqs;
  19. spikes=spikes_prot(:,4);
  20. fr=[1,10:17,2:9];
  21. sounds=[repelem(fr,levels)' repmat(20:10:80, 1, 17)'] ;
  22. for s=1:tones
  23. stim_i=spikes_prot(:,2)==s;
  24. for t=1:trials
  25. trial_i=spikes_prot(:,3)==t;
  26. stim_and_trial=stim_i.*trial_i;
  27. spikes_i=spikes(stim_and_trial==1);
  28. num=sum(spikes_i>onset & spikes_i<onset+0.020);
  29. sounds(s,t+2)=num;
  30. % if ~isempty(spikes_i) && sounds(s,2)==80
  31. % subplot(121)
  32. % plot(spikes_i,trials*(s-1)+t,'k.','MarkerSize',2); hold on
  33. % end
  34. end
  35. % yline(trials*(s-1),'r');
  36. end
  37. % xlim([0 0.45])
  38. % xline(onset);
  39. counts_spikes = mean(sounds(:,3:10),2);
  40. ft=(counts_spikes-min(counts_spikes))/(max(counts_spikes)-min(counts_spikes));
  41. counts_spikes(counts_spikes<0.2*max(counts_spikes))=0;
  42. y=reshape(counts_spikes*50,levels,freqs);
  43. y=y(:,fr);
  44. ax1=subplot(3,1,[1,2]);
  45. k=2; % refinement factor
  46. x_2d=10:5:90;
  47. nx=2^k * (size(x_2d,2)-1)+1;
  48. y_2d=20:10:80;
  49. ny=2^k * (size(y_2d,2)-1)+1;
  50. Nx_2d=linspace(min(x_2d),max(x_2d),nx);
  51. Ny_2d=linspace(min(y_2d),max(y_2d),ny);
  52. Vq = interp2(y,k);
  53. [X,Y] = meshgrid(Nx_2d,Ny_2d);
  54. contourf(X,Y,Vq,20,'edgecolor','none')
  55. colormap(jet)
  56. c = colorbar;
  57. ylabel(c, 'rate (Hz)');
  58. set(gca,'YDir','normal')
  59. xticks([])
  60. ylabel('dB SPL')
  61. hold on
  62. contour(X,Y,Vq,1,'k')
  63. set(ax1, 'box', 'off')
  64. set(ax1, 'Color','none')
  65. set(ax1,'linewidth',1); set(gca,'fontsize',8);
  66. d=d+1;
  67. y_av = [y_av + y];
  68. % plot isolevel
  69. ax2=subplot(3,1,3);
  70. ax2.Position(3) = ax1.Position(3);
  71. iso_=sounds(:,2)==70;
  72. y2=ft(iso_,:)*50;
  73. y2=y2(fr);
  74. plot(10:5:90,y2,'k')
  75. xlim([10 90])
  76. xlabel('freq. (kHz)')
  77. ylabel('rate')
  78. set(ax2, 'box', 'off')
  79. set(ax2, 'Color','none')
  80. set(ax2,'linewidth',1); set(gca,'fontsize',8);
  81. end
  82. % % plot mean of all previous plots
  83. % figure(); set(gcf, 'Position', [200, 200, 160, 160])
  84. % y_av=y_av/(d-1);
  85. % Vq = interp2(y_av,k);
  86. % [X,Y] = meshgrid(Nx_2d,Ny_2d);
  87. % contourf(X,Y,Vq,20,'edgecolor','none')
  88. % colormap(jet)
  89. % set(gca,'YDir','normal')
  90. % xlabel('freq. (kHz)')
  91. % ylabel('dB SPL')
  92. % hold on
  93. % contour(X,Y,Vq,1,'k')
  94. % set(gca, 'box', 'off')
  95. % set(gca, 'Color','none')
  96. % set(gca,'linewidth',1);set(gca,'fontsize',8);