fid_predrug = 'C:\Users\USER\Documents\mingfaifong\2013-01-24_usain22493_12-14DIV_MEA_CNQX\usain22493_12DIV_nodrug_02.spk';
fid_CNQX = 'C:\Users\USER\Documents\mingfaifong\2013-01-24_usain22493_12-14DIV_MEA_CNQX\usain22493_13DIV_40uM-CNQX_01.spk';
excludechannels = [1 8 33 57 64];

dat.predrug = loadspk(fid_predrug);
dat.CNQX = loadspk(fid_CNQX);

figure;

subplot(5,1,1);
dt = 1;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-12*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-12*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-12 24]);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)

subplot(5,1,2);
dt = 60;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-12*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-12*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-12 24]);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)

subplot(5,1,3);
dt = 300;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-12*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-12*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-12 24]);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)

subplot(5,1,4);
dt = 600;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-12*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-12*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-12 24]);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)

subplot(5,1,5);
dt = 3600;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-12*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-12*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-12 24]);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)


% set(gca,'FontSize',12,'XTick',[-3:3:24]);
% xlabel('Time (hours)','FontSize',16);
% ylabel('Array-Wide Firing Rate (Hz)','FontSize',16);
% title('trouble22467');