fid = 'herbI5373_12DIV_pre-drug_03';
t_end = loadspk([fid '.spk'],'last');
spk = loadspk([fid '.spk'],[0 t_end],0);
ss = SqueakySpk(fid,spk.meta.fs_Hz,1,spk);
b = loadbang([fid '.bang']);

%length(ss.time(ss.unit>0))/max(ss.time)/max(ss.unit)

avgFR_1hr = length(ss.time(ss.time>max(ss.time)-1*3600))/(1*3600)
avgFR_3hr = length(ss.time(ss.time>max(ss.time)-3*3600))/(3*3600)
avgFR_6hr = length(ss.time(ss.time>max(ss.time)-6*3600))/(6*3600)
% avgFR_12hr = length(ss.time(ss.time>max(ss.time)-12*3600))/(12*3600)

%%
bin = max(ss.time(ss.unit>0))-12*3600:60:max(ss.time(ss.unit>0));
asdr = histc(ss.time,bin);
plot(bin,asdr/60,'k-'); hold on;
plot([max(ss.time)-1*3600,max(ss.time)],[avgFR_1hr,avgFR_1hr],'-m','LineWidth',2);
plot([max(ss.time)-3*3600,max(ss.time)],[avgFR_3hr,avgFR_3hr],'-g','LineWidth',2);
plot([max(ss.time)-6*3600,max(ss.time)],[avgFR_6hr,avgFR_6hr],'-b','LineWidth',2);
% plot([max(ss.time)-12*3600,max(ss.time)],[avgFR_12hr,avgFR_12hr],'-r','LineWidth',2);

%%
close all
ss.ASDR(0.01)
plot(ss.asdr.bin,ss.asdr.asdr,'r')
hold on
plot(b.time,b.meas)

sum(b.meas/100)
length(ss.time)

mean(b.meas)
mean(ss.asdr.asdr)