123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423 |
- % plot spontaneous rate in two different states: awake and anesthetized
- % plot firing rate in response to maskers in two different states: awake and anesthetized
- load('sp_context.mat')
- dur_echo=1.3311;
- dur_distress=1.9266;
- c_=sp_context(:,2)==0; % unit classification
- aw_=sp_context(:,3)==0; % awake data
- an_=sp_context(:,3)==1; % anesthetized data
- spont_=sp_context(:,7)==0; % spontaneous firing rate
- cont_=sp_context(:,7)==1; % context firing rate intact
- cont_chi=sp_context(:,7)==2; % context firing rate chimeras
- cont_pt=sp_context(:,7)==3; % context firing rate pure tones
- % submatrices
- aw_spont=sp_context(logical(c_.*aw_.*spont_),:);
- an_spont=sp_context(logical(c_.*an_.*spont_),:);
- aw_cont=sp_context(logical(c_.*aw_.*cont_),:);
- an_cont=sp_context(logical(c_.*an_.*cont_),:);
- an_chi=sp_context(logical(c_.*an_.*cont_chi),:);
- %% calculate spontaneous firing rate
- % awake data - spontaneous & context
- units=unique(aw_spont(:,1));
- aw_spontR=nan(numel(units),1);
- aw_contR=nan(numel(units),2);
- for u=1:numel(units)
- u_=aw_spont(:,1)==units(u);
- u_2=aw_cont(:,1)==units(u);
- rate=nanmean(aw_spont(u_,8));
- rate2=nanmean(aw_cont(u_2,5)); % nav
- rate3=nanmean(aw_cont(u_2,6)); % com
- aw_spontR(u,1)=rate;
- aw_contR(u,1)=rate2;
- aw_contR(u,2)=rate3;
- end
- aw_spontR=aw_spontR./((3.5-0.2));
- aw_contR(:,1)=aw_contR(:,1);
- aw_contR(:,2)=aw_contR(:,2);
- % anesthetized data - spontaneous
- units=unique(an_spont(:,1));
- an_spontR=nan(numel(units),1);
- for u=1:numel(units)
- u_=an_spont(:,1)==units(u);
- rate=nanmean(an_spont(u_,8));
- an_spontR(u,1)=rate;
- end
- an_spontR=an_spontR./((3.5-0.2));
- % anesthetized data - context
- units=unique(an_cont(:,1));
- an_contR=nan(numel(units),2);
- for u=1:numel(units)
- u_2=an_cont(:,1)==units(u);
- rate2=nanmean(an_cont(u_2,5)); % nav
- rate3=nanmean(an_cont(u_2,6)); % com
- an_contR(u,1)=rate2;
- an_contR(u,2)=rate3;
- end
- an_contR(:,1)=an_contR(:,1);
- an_contR(:,2)=an_contR(:,2);
- % anesthetized data - context CHIMERAS
- units=unique(an_chi(:,1));
- an_chiR=nan(numel(units),2);
- for u=1:numel(units)
- u_2=an_chi(:,1)==units(u);
- rate2=nanmean(an_chi(u_2,5)); % nav
- rate3=nanmean(an_chi(u_2,6)); % com
- an_chiR(u,1)=rate2;
- an_chiR(u,2)=rate3;
- end
- an_chiR(:,1)=an_chiR(:,1); % flipped
- an_chiR(:,2)=an_chiR(:,2);
- % firing rate in response to probes
- int=load('all_data.mat'); int=int.all_di;
- c_=int(:,2)==0;
- an_=int(:,3)==1;
- int=int(logical(c_.*an_),18:19);
- chi=load('chi_data.mat'); chi=chi.all_di;
- c_=chi(:,2)==0;
- an_=chi(:,3)==0;
- chi=chi(logical(c_.*an_),18:19);
- pt=load('pt_data.mat'); pt=pt.all_di;
- c_=pt(:,2)==0;
- an_=pt(:,3)==1;
- pt=pt(logical(c_.*an_),11:12);
- probe_an=[int; chi].*20 ; %; chi; pt].*20; % x20: spikecounts to firing rate
- aw=load('all_data.mat'); aw=aw.all_di;
- c_=aw(:,2)==0;
- aw_=aw(:,3)==0;
- probe_aw=aw(logical(c_.*aw_),18:19).*20; % x20: spikecounts to firing rate
- % compare non-paired samples
- pv1=ranksum(aw_spontR,an_spontR);
- pv2=ranksum(aw_contR(:,1),an_contR(:,1));
- pv3=ranksum(aw_contR(:,2),an_contR(:,2));
- pv4=signrank(aw_contR(:,1),aw_contR(:,2));
- pv5=signrank(an_contR(:,1),an_contR(:,2));
- pv6=ranksum(an_contR(:,1),an_chiR(:,1));
- pv7=ranksum(an_contR(:,2),an_chiR(:,2));
- pv8=ranksum(probe_aw(:,1),probe_an(:,1));
- pv9=ranksum(probe_aw(:,2),probe_an(:,2));
- pv10=signrank(probe_aw(:,1),probe_aw(:,2));
- pv11=signrank(probe_an(:,1),probe_an(:,2));
- %% plotting
- close all;
- red =[0.8500,0.3250, 0.0980];
- blue=[0,0.4470,0.7410];
- red_light=[1,0.5,0.5].*red;
- blue_light=[1,0.5,0.5].*blue;
- colors=[[0.3 0.3 0.3];[0.5 0.5 0.5];blue_light;red_light;blue;red];
- y1=nan(58,6);
- y1(1:numel(aw_spontR),1)=aw_spontR;
- y1(1:numel(an_spontR),2)=an_spontR;
- y1(1:numel(aw_contR(:,1)),3)=aw_contR(:,1);
- y1(1:numel(an_contR(:,1)),4)=an_contR(:,1);
- y1(1:numel(aw_contR(:,2)),5)=aw_contR(:,2);
- y1(1:numel(an_contR(:,2)),6)=an_contR(:,2);
- x = 1:6;
- figure(1); set(gcf,'Position',[400 200 250 170])
- ax = axes();
- hold(ax);
- for i=1:6
- h=boxchart(x(i)*ones(size(y1(:,i))), y1(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
- h.MarkerStyle='.';
- h.MarkerColor=colors(i,:);
- end
- hold on
- 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])
- plot(3,nanmedian(y1(:,3)),'o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
- plot(4,nanmedian(y1(:,4)),'o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
- plot(5,nanmedian(y1(:,5)),'o','LineWidth',1,'Color',blue,'MarkerSize',3,'MarkerFaceColor',blue)
- plot(6,nanmedian(y1(:,6)),'o','LineWidth',1,'Color',red,'MarkerSize',3,'MarkerFaceColor',red)
- hold off
- xlim([0.5 6.5])
- ylabel('# spikes')
- xticks(1:6)
- xticklabels({'awake','anesthetized','awake','anesthetized','awake','anesthetized'});
- set(gca, 'box', 'off')
- set(gca, 'Color','none')
- set(gca,'linewidth',1);set(gca,'fontsize',8);
- xt = get(gca, 'XTick');
- line1=165;
- line2=190;
- line3=215;
- sl=0.75;
- % plot lines for comparison
- hold on
- plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(1),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(2),[line1,line1-3],'-k', 'LineWidth',sl);
- plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(3),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(4),[line1,line1-3],'-k', 'LineWidth',sl);
- plot(xt(5:6), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(5),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(6),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([xt(3) xt(5)], [1 1]*line2, '-k','LineWidth',sl)
- plot([1;1]*xt(3),[line2,line2-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(5),[line2,line2-3],'-k', 'LineWidth',sl);
- plot([xt(4) xt(6)], [1 1]*line3, '-k','LineWidth',sl)
- plot([1;1]*xt(4),[line3,line3-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(6),[line3,line3-3],'-k', 'LineWidth',sl);
- ylim([-5 170])
- % plot level of significance
- if pv1 <= 0.05 && pv1 > 0.01
- text(mean(xt(1:2))-0.05, line1+5, '*','HorizontalAlignment','center')
- elseif pv1 <=0.01 && pv1 > 0.001
- text(mean(xt(1:2))-0.05, line1+5, '**','HorizontalAlignment','center')
- elseif pv1 <= 0.001
- text(mean(xt(1:2))-0.05, line1+5, '***','HorizontalAlignment','center')
- else
- text(mean(xt(1:2))-0.05, line1+12, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- if pv2 <= 0.05 && pv2 > 0.01
- text(mean(xt(3:4))-0.05, line1+5, '*','HorizontalAlignment','center')
- elseif pv2 <=0.01 && pv2 > 0.001
- text(mean(xt(3:4))-0.05, line1+5, '**','HorizontalAlignment','center')
- elseif pv2 <= 0.001
- text(mean(xt(3:4))-0.05, line1+5, '***','HorizontalAlignment','center')
- else
- text(mean(xt(3:4))-0.05, line1+12, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- if pv3 <= 0.05 && pv3 > 0.01
- text(mean(xt(5:6))-0.05, line1+5, '*','HorizontalAlignment','center')
- elseif pv3 <=0.01 && pv3 > 0.001
- text(mean(xt(5:6))-0.05, line1+5, '**','HorizontalAlignment','center')
- elseif pv3 <= 0.001
- text(mean(xt(5:6))-0.05, line1+5, '***','HorizontalAlignment','center')
- else
- text(mean(xt(5:6))-0.05, line1+15, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- % if pv4 <= 0.05 && pv4 > 0.01
- % text(mean(xt(3:5))-0.05, line2+5, '*','HorizontalAlignment','center')
- % elseif pv4 <=0.01 && pv4 > 0.001
- % text(mean(xt(3:5))-0.05, line2+5, '**','HorizontalAlignment','center')
- % elseif pv4 <= 0.001
- % text(mean(xt(3:5))-0.05, line2+5, '***','HorizontalAlignment','center')
- % else
- % text(mean(xt(3:5))-0.05, line2+12, 'ns','FontSize',8,'HorizontalAlignment','center')
- % end
- %
- % if pv5 <= 0.05 && pv5 > 0.01
- % text(mean(xt(4:6))-0.05, line3+5, '*','HorizontalAlignment','center')
- % elseif pv5 <=0.01 && pv5 > 0.001
- % text(mean(xt(4:6))-0.05, line3+5, '**','HorizontalAlignment','center')
- % elseif pv5 <= 0.001
- % text(mean(xt(4:6))-0.05, line3+5, '***','HorizontalAlignment','center')
- % else
- % text(mean(xt(4:6))-0.05, line3+12, 'ns','FontSize',8,'HorizontalAlignment','center')
- % end
- % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\preparation_rate_cont.pdf',...
- % 'Resolution',300','ContentType','vector','BackgroundColor','none')
- %% plotting probes
- colors=[blue_light;blue;red_light;red];
- y2=nan(58,4);
- y2(1:numel(probe_aw(:,1)),1)=probe_aw(:,1);
- y2(1:numel(probe_an(:,1)),2)=probe_an(:,1);
- y2(1:numel(probe_aw(:,2)),3)=probe_aw(:,2);
- y2(1:numel(probe_an(:,2)),4)=probe_an(:,2);
- x = 1:4;
- figure(2); set(gcf,'Position',[700 200 170 170])
- ax = axes();
- hold(ax);
- for i=1:4
- h=boxchart(x(i)*ones(size(y2(:,i))), y2(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
- h.MarkerStyle='.';
- h.MarkerColor=colors(i,:);
- end
- hold on
- plot(1:2,nanmedian(y2(:,1:2)),'-o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
- plot(3:4,nanmedian(y2(:,3:4)),'-o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
- hold off
- xlim([0.5 4.5])
- ylabel('firing rate ')
- xticks(1:4)
- xticklabels({'awake','anesthetized','awake','anesthetized'});
- set(gca, 'box', 'off')
- set(gca, 'Color','none')
- set(gca,'linewidth',1);set(gca,'fontsize',8);
- xt = get(gca, 'XTick');
- line1=290;
- line2=340;
- line3=390;
- sl=0.75;
- % plot lines for comparison
- hold on
- plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(1),[line1,line1-10],'-k', 'LineWidth',sl);
- plot([1;1]*xt(2),[line1,line1-10],'-k', 'LineWidth',sl);
- plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(3),[line1,line1-10],'-k', 'LineWidth',sl);
- plot([1;1]*xt(4),[line1,line1-10],'-k', 'LineWidth',sl);
- % plot([xt(1) xt(3)], [1 1]*line2, '-k','LineWidth',sl)
- % plot([1;1]*xt(1),[line2,line2-10],'-k', 'LineWidth',sl);
- % plot([1;1]*xt(3),[line2,line2-10],'-k', 'LineWidth',sl);
- %
- % plot([xt(2) xt(4)], [1 1]*line3, '-k','LineWidth',sl)
- % plot([1;1]*xt(2),[line3,line3-10],'-k', 'LineWidth',sl);
- % plot([1;1]*xt(4),[line3,line3-10],'-k', 'LineWidth',sl);
- ylim([-5 320])
- % plot level of significance
- if pv8 <= 0.05 && pv8 > 0.01
- text(mean(xt(1:2))-0.05, line1+20, '*','HorizontalAlignment','center')
- elseif pv8 <=0.01 && pv8 > 0.001
- text(mean(xt(1:2))-0.05, line1+20, '**','HorizontalAlignment','center')
- elseif pv8 <= 0.001
- text(mean(xt(1:2))-0.05, line1+20, '***','HorizontalAlignment','center')
- else
- text(mean(xt(1:2))-0.05, line1+28, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- if pv9 <= 0.05 && pv9 > 0.01
- text(mean(xt(3:4))-0.05, line1+20, '*','HorizontalAlignment','center')
- elseif pv9 <=0.01 && pv9 > 0.001
- text(mean(xt(3:4))-0.05, line1+20, '**','HorizontalAlignment','center')
- elseif pv9 <= 0.001
- text(mean(xt(3:4))-0.05, line1+20, '***','HorizontalAlignment','center')
- else
- text(mean(xt(3:4))-0.05, line1+28, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- % if pv10 <= 0.05 && pv10 > 0.01
- % text(mean(xt(1:3))-0.05, line2+20, '*','HorizontalAlignment','center')
- % elseif pv10 <=0.01 && pv10 > 0.001
- % text(mean(xt(1:3))-0.05, line2+20, '**','HorizontalAlignment','center')
- % elseif pv10 <= 0.001
- % text(mean(xt(1:3))-0.05, line2+20, '***','HorizontalAlignment','center')
- % else
- % text(mean(xt(1:3))-0.05, line2+28, 'ns','FontSize',8,'HorizontalAlignment','center')
- % end
- %
- % if pv11 <= 0.05 && pv11 > 0.01
- % text(mean(xt(2:4))-0.05, line3+20, '*','HorizontalAlignment','center')
- % elseif pv11 <=0.01 && pv11 > 0.001
- % text(mean(xt(2:4))-0.05, line3+20, '**','HorizontalAlignment','center')
- % elseif pv11 <= 0.001
- % text(mean(xt(2:4))-0.05, line3+20, '***','HorizontalAlignment','center')
- % else
- % text(mean(xt(2:4))-0.05, line3+28, 'ns','FontSize',8,'HorizontalAlignment','center')
- % end
- % exportgraphics(gcf,'E:\Users\User\Desktop\delay paper\anesthetized\figures_paper\preparation_rate_probe.pdf',...
- % 'Resolution',300','ContentType','vector','BackgroundColor','none')
- %% plotting chimeras
- green_light=[0.4863,0.3059,0.7098]; % green: [0.3922,0.8314,0.0745];
- green=[0.2980,0.1294,0.5098]; % gree: [0.4667,0.6745,0.1882];
- colors=[blue_light;green;red_light;green_light];
- y3=nan(46,4);
- y3(1:numel(an_contR(:,1)),1)=an_contR(:,1);
- y3(1:numel(an_chiR(:,1)),2)=an_chiR(:,1);
- y3(1:numel(an_contR(:,2)),3)=an_contR(:,2);
- y3(1:numel(an_chiR(:,2)),4)=an_chiR(:,2);
- x = 1:4;
- figure(3); set(gcf,'Position',[900 200 170 170])
- ax = axes();
- hold(ax);
- for i=1:4
- h=boxchart(x(i)*ones(size(y3(:,i))), y3(:,i), 'BoxFaceColor', colors(i,:),'Notch','on');
- h.MarkerStyle='.';
- h.MarkerColor=colors(i,:);
- end
- hold on
- plot(1:2,nanmedian(y3(:,1:2)),'-o','LineWidth',1,'Color',blue_light,'MarkerSize',3,'MarkerFaceColor',blue_light)
- plot(3:4,nanmedian(y3(:,3:4)),'-o','LineWidth',1,'Color',red_light,'MarkerSize',3,'MarkerFaceColor',red_light)
- hold off
- xlim([0.5 4.5])
- ylabel('firing rate ')
- xticks(1:4)
- xticklabels({'nav','fast nav','com','slow com'});
- set(gca, 'box', 'off')
- set(gca, 'Color','none')
- set(gca,'linewidth',1);set(gca,'fontsize',8);
- xt = get(gca, 'XTick');
- line1=170;
- sl=0.75;
- % plot lines for comparison
- hold on
- plot(xt(1:2), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(1),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(2),[line1,line1-3],'-k', 'LineWidth',sl);
- plot(xt(3:4), [1 1]*line1, '-k','LineWidth',sl)
- plot([1;1]*xt(3),[line1,line1-3],'-k', 'LineWidth',sl);
- plot([1;1]*xt(4),[line1,line1-3],'-k', 'LineWidth',sl);
- ylim([-5 185])
- % plot level of significance
- if pv6 <= 0.05 && pv6 > 0.01
- text(mean(xt(1:2))-0.05, line1+4, '*','HorizontalAlignment','center')
- elseif pv6 <=0.01 && pv6 > 0.001
- text(mean(xt(1:2))-0.05, line1+4, '**','HorizontalAlignment','center')
- elseif pv6 <= 0.001
- text(mean(xt(1:2))-0.05, line1+4, '***','HorizontalAlignment','center')
- else
- text(mean(xt(1:2))-0.05, line1+10, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
- if pv7 <= 0.05 && pv7 > 0.01
- text(mean(xt(3:4))-0.05, line1+4, '*','HorizontalAlignment','center')
- elseif pv7 <=0.01 && pv7 > 0.001
- text(mean(xt(3:4))-0.05, line1+4, '**','HorizontalAlignment','center')
- elseif pv7 <= 0.001
- text(mean(xt(3:4))-0.05, line1+4, '***','HorizontalAlignment','center')
- else
- text(mean(xt(3:4))-0.05, line1+10, 'ns','FontSize',8,'HorizontalAlignment','center')
- end
|