close all; clear; % plot sPSTH for paired data before and after injection load('inj_psth.mat') pair=psths(:,3)==1; class_=psths(:,5)==0; aw_=psths(:,2)==0; % an=psths(:,2)==1; aw=logical(pair.*aw_.*class_); units_aw=psths(aw,1); units_an=units_aw+1; an=ismember(psths(:,1),units_an); % protocols nav_iso=psths(:,4)==1; com_iso=psths(:,4)==2; exp_nav=psths(:,4)==3; unexp_nav=psths(:,4)==4; exp_com=psths(:,4)==5; unexp_com=psths(:,4)==6; % average PSTHs for all units equally and paired (n=6) av_psth1=mean(psths(logical(nav_iso.*aw),6:106)); av_psth2=mean(psths(logical(com_iso.*aw),6:106)); av_psth3=mean(psths(logical(exp_nav.*aw),6:106)); av_psth4=mean(psths(logical(unexp_nav.*aw),6:106)); av_psth5=mean(psths(logical(exp_com.*aw),6:106)); av_psth6=mean(psths(logical(unexp_com.*aw),6:106)); av_psth1AN=mean(psths(logical(nav_iso.*an),6:106)); av_psth2AN=mean(psths(logical(com_iso.*an),6:106)); av_psth3AN=mean(psths(logical(exp_nav.*an),6:106)); av_psth4AN=mean(psths(logical(unexp_nav.*an),6:106)); av_psth5AN=mean(psths(logical(exp_com.*an),6:106)); av_psth6AN=mean(psths(logical(unexp_com.*an),6:106)); edges=-0.1:0.002:0.1; % smooth PSTHs % y=0.005; % [av_psth1,~]=ksdensity(av_psth1,edges,'Width', y); % [av_psth2,~]=ksdensity(av_psth2,edges,'Width', y); % [av_psth3,~]=ksdensity(av_psth3,edges,'Width', y); % [av_psth4,~]=ksdensity(av_psth4,edges,'Width', y); % [av_psth5,~]=ksdensity(av_psth5,edges,'Width', y); % [av_psth6,~]=ksdensity(av_psth6,edges,'Width', y); % % [av_psth1AN,~]=ksdensity(av_psth1AN,edges,'Width', y); % [av_psth2AN,~]=ksdensity(av_psth2AN,edges,'Width', y); % [av_psth3AN,~]=ksdensity(av_psth3AN,edges,'Width', y); % [av_psth4AN,~]=ksdensity(av_psth4AN,edges,'Width', y); % [av_psth5AN,~]=ksdensity(av_psth5AN,edges,'Width', y); % [av_psth6AN,xi]=ksdensity(av_psth6AN,edges,'Width', y); % psth of an individual unit unit=12; u_=psths(:,1)==unit; ind_nav=psths(logical(u_.*nav_iso),6:106); ind_com=psths(logical(u_.*com_iso),6:106); % plot spectrogram of stimuli load('stims.mat') Fs=SoundStruct(1).Fs; nav_stim=SoundStruct(10).sound; stim_onset=672009; w=0.010*Fs; nav_stim=nav_stim(stim_onset-w:stim_onset+w); com_stim=SoundStruct(2).sound; stim_onset=672009; com_stim=com_stim(stim_onset-w:stim_onset+w); nwin=64; noverlap=48; nfft = 1024; %% plotting figure(1); set(gcf,'Position',[300 150 450 100]) subplot(1,3,1) plot(edges,av_psth1,'b'); hold on plot(edges,av_psth2,'r') subplot(1,3,2) plot(edges,av_psth3,'Color',[0.6 0.6 0.6]); hold on plot(edges,av_psth4,'k') subplot(1,3,3) plot(edges,av_psth5,'Color',[0.6 0.6 0.6]); hold on plot(edges,av_psth6,'k') linkaxes() % xlim([0 100]) % ylim([0 24]) figure(2); set(gcf,'Position',[300 150 450 100]) subplot(1,3,1) plot(edges,av_psth1AN,'b'); hold on plot(edges,av_psth2AN,'r') subplot(1,3,2) plot(edges,av_psth3AN,'Color',[0.6 0.6 0.6]); hold on plot(edges,av_psth4AN,'k') subplot(1,3,3) plot(edges,av_psth5AN,'Color',[0.6 0.6 0.6]); hold on plot(edges,av_psth6AN,'k') linkaxes() % xlim([0 100]) % ylim([0 24]) figure(3); set(gcf,'Position',[300 450 350 150]) subplot(221) spectrogram(nav_stim, nwin, noverlap, nfft,Fs,'yaxis'); colorbar off caxis([-100, -50]) xlabel([]) ylabel('freq. (kHz)','FontSize',8) yticks(0:40:80) xticks(0:5:20) xticklabels(-10:5:10) set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); subplot(222) spectrogram(com_stim, nwin, noverlap, nfft,Fs,'yaxis'); colorbar off caxis([-100, -50]) colormap(flipud(gray)); ylabel([]) xlabel([]) yticks(0:40:80) xticks(0:5:20) xticklabels(-10:5:10) set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); subplot(223) bar(edges*1000,ind_nav,'k'); xline(0,'Color','k','LineWidth',1,'LineStyle',':') ylabel({'# spikes';'in 2ms'}, 'FontSize', 8) set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); subplot(224) bar(edges*1000,ind_com,'k'); yticks([]) xline(0,'Color','k','LineWidth',1,'LineStyle',':') ylim([0 0.7]) set(gca, 'box', 'off') set(gca, 'Color','none') set(gca,'linewidth',1);set(gca,'fontsize',8); exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\ind_unit_iso.pdf',... 'Resolution',300','ContentType','vector','BackgroundColor','none')