fid_predrug = 'C:\Users\USER\Documents\mingfaifong\2013-01-21_trouble22467_12-14DIV_MEA_CNQX\trouble22467_12DIV_nodrug_01.spk';
fid_CNQX = 'C:\Users\USER\Documents\mingfaifong\2013-01-21_trouble22467_12-14DIV_MEA_CNQX\trouble22467_13DIV_40uM-CNQX_01.spk';
excludechannels = [1 8 33 57 64];

% 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];

% fid_predrug = 'C:\Users\USER\Documents\mingfaifong\2013-02-03_wingnut22468_10-12DIV_MEA_CNQX\wingnut22468_10DIV_nodrug_01.spk';
% fid_CNQX = 'C:\Users\USER\Documents\mingfaifong\2013-02-03_wingnut22468_10-12DIV_MEA_CNQX\wingnut22468_11DIV_40uM-CNQX_01.spk';
% excludechannels = [1 8 33 57 64];

% fid_predrug = 'C:\Users\USER\Documents\mingfaifong\2013-02-08_xinhai22493_11-13DIV_MEA_CNQX\xinhai22493_11DIV_nodrug_01.spk';
% fid_CNQX = 'C:\Users\USER\Documents\mingfaifong\2013-02-08_xinhai22493_11-13DIV_MEA_CNQX\xinhai22493_12DIV_40uM-CNQX_01.spk';
% excludechannels = [1 8 33 57 64];

% fid_predrug = 'C:\Users\USER\Documents\mingfaifong\2013-03-01_atlas22493_10-12DIV_MEA_CNQX\atlas22493_10DIV_nodrug_01.spk';
% fid_CNQX = 'C:\Users\USER\Documents\mingfaifong\2013-03-01_atlas22493_10-12DIV_MEA_CNQX\atlas22493_11DIV_40uM-CNQX_01.spk';
% excludechannels = [1 8 33 57 64];

clear dat FR

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

FR.predrug3hr = length(dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-3*3600)))/(3*3600);

FR.CNQX24hr = length(dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600)))/(24*3600);

FR.deltaFR = FR.CNQX24hr/FR.predrug3hr;
%%
dt = 3600;
time = [dat.predrug.time(ismember(dat.predrug.channel,excludechannels)==0 ...
    & dat.predrug.time>=(max(dat.predrug.time)-3*3600))-max(dat.predrug.time); ...
    dat.CNQX.time(ismember(dat.CNQX.channel,excludechannels)==0 ...
    & dat.CNQX.time<=(24*3600))];
bin = [-3*3600:dt:24*3600];
ASDR = histc(time,bin)/dt;
stairs(bin/3600,ASDR,'-k','LineWidth',2);
xlim([-3 24]);
set(gca,'FontSize',12,'XTick',[-3:3:24]);
xlabel('Time (hours)','FontSize',16);
ylabel('Array-Wide Firing Rate (Hz)','FontSize',16);
text(0.5,max(ASDR),[num2str((1-FR.deltaFR)*100) '% reduction'],'VerticalAlignment','top','HorizontalAlignment','left','Color',[1 0 0],'FontSize',10)
title('trouble22467');