123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- close all;
- clear;
- path='\';
- delay=9261/192000-0.005;
- preT=0.150;
- % onset=delay+preT;
- onset=0.2;
- freqs=17;
- d=1; y_av=0;
- for u = 12 %[10:15,18]
-
- unit=[num2str(u) 'p1.mat'];
- disp([path unit])
- figure(u); set(gcf, 'Position', [200, 250, 160, 160])
- % load data
- load(strcat(path,unit));
- trials=numel(unique(spikes_prot(:,3)));
- tones=numel(unique(spikes_prot(:,2)));
- levels=tones/freqs;
- spikes=spikes_prot(:,4);
-
- fr=[1,10:17,2:9];
- sounds=[repelem(fr,levels)' repmat(20:10:80, 1, 17)'] ;
-
- for s=1:tones
-
- stim_i=spikes_prot(:,2)==s;
-
- for t=1:trials
- trial_i=spikes_prot(:,3)==t;
- stim_and_trial=stim_i.*trial_i;
- spikes_i=spikes(stim_and_trial==1);
- num=sum(spikes_i>onset & spikes_i<onset+0.020);
- sounds(s,t+2)=num;
- % if ~isempty(spikes_i) && sounds(s,2)==80
- % subplot(121)
- % plot(spikes_i,trials*(s-1)+t,'k.','MarkerSize',2); hold on
- % end
- end
- % yline(trials*(s-1),'r');
- end
- % xlim([0 0.45])
- % xline(onset);
-
- counts_spikes = mean(sounds(:,3:10),2);
- ft=(counts_spikes-min(counts_spikes))/(max(counts_spikes)-min(counts_spikes));
- counts_spikes(counts_spikes<0.2*max(counts_spikes))=0;
-
- y=reshape(counts_spikes*50,levels,freqs);
- y=y(:,fr);
-
- ax1=subplot(3,1,[1,2]);
- k=2; % refinement factor
- x_2d=10:5:90;
- nx=2^k * (size(x_2d,2)-1)+1;
- y_2d=20:10:80;
- ny=2^k * (size(y_2d,2)-1)+1;
-
- Nx_2d=linspace(min(x_2d),max(x_2d),nx);
- Ny_2d=linspace(min(y_2d),max(y_2d),ny);
-
- Vq = interp2(y,k);
- [X,Y] = meshgrid(Nx_2d,Ny_2d);
-
- contourf(X,Y,Vq,20,'edgecolor','none')
- colormap(jet)
- c = colorbar;
- ylabel(c, 'rate (Hz)');
- set(gca,'YDir','normal')
- xticks([])
- ylabel('dB SPL')
- hold on
- contour(X,Y,Vq,1,'k')
-
- set(ax1, 'box', 'off')
- set(ax1, 'Color','none')
- set(ax1,'linewidth',1); set(gca,'fontsize',8);
-
- d=d+1;
- y_av = [y_av + y];
-
- % plot isolevel
- ax2=subplot(3,1,3);
- ax2.Position(3) = ax1.Position(3);
- iso_=sounds(:,2)==70;
- y2=ft(iso_,:)*50;
- y2=y2(fr);
- plot(10:5:90,y2,'k')
- xlim([10 90])
- xlabel('freq. (kHz)')
- ylabel('rate')
-
- set(ax2, 'box', 'off')
- set(ax2, 'Color','none')
- set(ax2,'linewidth',1); set(gca,'fontsize',8);
-
-
- end
- % % plot mean of all previous plots
- % figure(); set(gcf, 'Position', [200, 200, 160, 160])
- % y_av=y_av/(d-1);
- % Vq = interp2(y_av,k);
- % [X,Y] = meshgrid(Nx_2d,Ny_2d);
- % contourf(X,Y,Vq,20,'edgecolor','none')
- % colormap(jet)
- % set(gca,'YDir','normal')
- % xlabel('freq. (kHz)')
- % ylabel('dB SPL')
- % hold on
- % contour(X,Y,Vq,1,'k')
- % set(gca, 'box', 'off')
- % set(gca, 'Color','none')
- % set(gca,'linewidth',1);set(gca,'fontsize',8);
|