%% APV: Collards 22566, 2013-04-02 (33DIV)

figure(20); hold off;
figure(21); hold off;
figure(22); hold off;
figure(23); hold off;

tcent_pre = 2.7825e4;
tcent_drug = 4.575*3600;
t_window = 2*3600;

load('C:\Users\USER\Documents\mingfaifong\opticalstim ctrl cnqx apv\burst analysis\2013_04_02_Collards-22566_no-drug_01_nowaveform_burst.mat')
dt = 1; bin = 0:dt:max(time); asdr = histc(time,bin);
figure(25); stairs(bin,asdr,'-k');
avgburst_pre = nanmean(dat.burst.snippet.FR(dat.burst.time>tcent_pre-t_window/2 & dat.burst.time<tcent_pre+t_window/2,:),1);
stdburst_pre = nanstd(dat.burst.snippet.FR(dat.burst.time>tcent_pre-t_window/2 & dat.burst.time<tcent_pre+t_window/2,:),1);
axis([tcent_pre-2.5*60 tcent_pre+2.5*60 0 300]);

load('C:\Users\USER\Documents\mingfaifong\opticalstim ctrl cnqx apv\burst analysis\2013_04_02_Collards-22566_50um-ap5_01_nowaveform_burst.mat')
dt = 1; bin = 0:dt:max(time); asdr = histc(time,bin);
figure(23); stairs(bin,asdr,'-k');
avgburst_drug = nanmean(dat.burst.snippet.FR(dat.burst.time>tcent_drug-t_window/2 & dat.burst.time<tcent_drug+t_window/2,:),1);
stdburst_drug = nanstd(dat.burst.snippet.FR(dat.burst.time>tcent_drug-t_window/2 & dat.burst.time<tcent_drug+t_window/2,:),1);
axis([tcent_drug-2.5*60 tcent_drug+2.5*60 0 300]);

figure(20);
plot(snippetWidth,avgburst_pre,'-','Color',[0 0 0],'LineWidth',2);
hold on;
% plot(snippetWidth-0.07,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
% plot(snippetWidth,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
plot(snippetWidth-0.01,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
% xlim([-1 4]);
xlim([-0.2 0.8]);

figure(21);
hold off;
shadedErrorBar(snippetWidth,avgburst_pre,stdburst_pre,'k');
hold on;
% shadedErrorBar(snippetWidth-0.07,avgburst_drug,stdburst_drug,'b');
shadedErrorBar(snippetWidth-0.01,avgburst_drug,stdburst_drug,'b');
% shadedErrorBar(snippetWidth,avgburst_drug,stdburst_drug,'b');
xlim([-0.2 0.8]);
% xlim([-1 4]);


%% CNQX: Yam 22565, 2013-02-26 (26DIV)


figure(20); hold off;
figure(24); hold off;
figure(22); hold off;
figure(23); hold off;

tcent_pre = 15.74*3600;
tcent_drug = 4.575*3600;
t_window = 1*3600;

load('C:\Users\USER\Documents\mingfaifong\opticalstim ctrl cnqx apv\burst analysis\2013_02_26_Yam-22565_no-drug_01_nowaveform_burst.mat')
dt = 1; bin = 0:dt:max(time); asdr = histc(time,bin);
figure(22); stairs(bin,asdr,'-k');
avgburst_pre = nanmean(dat.burst.snippet.FR(dat.burst.time>tcent_pre-t_window/2 & dat.burst.time<tcent_pre+t_window/2,:),1);
stdburst_pre = nanstd(dat.burst.snippet.FR(dat.burst.time>tcent_pre-t_window/2 & dat.burst.time<tcent_pre+t_window/2,:),1);
axis([tcent_pre-2.5*60 tcent_pre+2.5*60 0 1500]);

load('C:\Users\USER\Documents\mingfaifong\opticalstim ctrl cnqx apv\burst analysis\2013_02_26_Yam-22565_40-um-cnqx_01_nowaveform_burst.mat')
dt = 1; bin = 0:dt:max(time); asdr = histc(time,bin);
figure(23); stairs(bin,asdr,'-k');
avgburst_drug = nanmean(dat.burst.snippet.FR(dat.burst.time>tcent_drug-t_window/2 & dat.burst.time<tcent_drug+t_window/2,:),1);
stdburst_drug = nanstd(dat.burst.snippet.FR(dat.burst.time>tcent_drug-t_window/2 & dat.burst.time<tcent_drug+t_window/2,:),1);
axis([tcent_drug-2.5*60 tcent_drug+2.5*60 0 1500]);

figure(20);
plot(snippetWidth,avgburst_pre,'-','Color',[0 0 0],'LineWidth',2);
hold on;
% plot(snippetWidth-0.07,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
% plot(snippetWidth,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
plot(snippetWidth-0.04,avgburst_drug,'-','Color',[0.2 0.4 0.85],'LineWidth',2);
% xlim([-1 4]);
xlim([-0.2 0.8]);

figure(24);
hold off;
shadedErrorBar(snippetWidth,avgburst_pre,stdburst_pre,'k');
hold on;
% shadedErrorBar(snippetWidth-0.07,avgburst_drug,stdburst_drug,'b');
shadedErrorBar(snippetWidth-0.04,avgburst_drug,stdburst_drug,'b');
% shadedErrorBar(snippetWidth,avgburst_drug,stdburst_drug,'b');
xlim([-0.2 0.8]);
% xlim([-1 4]);