%pool spike triggered averages of all units from one cell together
close all
% clear all
% load('20160825_Stage8_V6_output.mat')
w1=-4;% w1 second delay before each spike and w2 s delay after
w2=4;
res2=0.04;
interval=w1:res2:w2;
figure(1)
title('spike triggered EODr')
hold on
figure(2)
title('spike triggered speed')
hold on
figure(3)
title('spike triggered sampling density')
hold on

for i=1:length(spktrig_EODr)
    figure(1)
    plot(interval,nanmean(spktrig_EODr{i}),'Color',[0.9100    0.6100    0.1700])
    plot(interval,nanmean(spktrig_EODr_shuff{i}),'Color',[0.8,0.8,0.8])
    figure(2)
    plot(interval,nanmean(spktrig_speed{i}),'Color',[0.9100    0.6100    0.1700])
    plot(interval,nanmean(spktrig_speed_shuff{i}),'Color',[0.8,0.8,0.8])
    figure(3)
    plot(interval,nanmean(spktrig_sampdens{i}),'Color',[0.9100    0.6100    0.1700])
    plot(interval,nanmean(spktrig_sampdens_shuff{i}),'Color',[0.8,0.8,0.8])

end
figure(1)
plot(interval,nanmean(cell2mat(spktrig_EODr')),'LineWidth',2,'Color','r')
plot(interval,nanmean(cell2mat(spktrig_EODr_shuff')),'LineWidth',2,'Color','k')

saveas(gcf,strcat('20160822_spktrigEODrMeanAllunits.pdf'))
figure(2)
plot(interval,nanmean(cell2mat(spktrig_speed')),'LineWidth',2,'Color','r')
plot(interval,nanmean(cell2mat(spktrig_speed_shuff')),'LineWidth',2,'Color','k')

saveas(gcf,strcat('20160822_spktrigspeedMeanAllunits.pdf'))
figure(3)
plot(interval,nanmean(cell2mat(spktrig_sampdens')),'LineWidth',2,'Color','r')
plot(interval,nanmean(cell2mat(spktrig_sampdens_shuff')),'LineWidth',2,'Color','k')

saveas(gcf,strcat('20160822_spktrigsampdensMeanAllunits.pdf'))

