fid = 'atlas22471_10DIV_nodrug_01';
t_end = loadspk([fid '.spk'],'last');
spk = loadspk([fid '.spk'],[0 t_end],0);
ss = SqueakySpk(fid,spk.meta.fs_Hz,1,spk);
% ss.RemoveChannel([1 8 33 57 64 55])
sc = ss.ReturnClean();
% b = loadbang([fid '.bang']);

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

%%
close all
figure
dt_asdr = 60; % sec
bin = max(sc.time)-12*3600:dt_asdr:max(sc.time);
asdr = histc(sc.time,bin);
plot(bin,asdr/dt_asdr,'k-'); hold on;
plot([max(sc.time)-1*3600, max(sc.time)],[avgFR_1hr,avgFR_1hr],'-m','LineWidth',2);
plot([max(sc.time)-3*3600, max(sc.time)],[avgFR_3hr,avgFR_3hr],'-g','LineWidth',2);
plot([max(sc.time)-6*3600, max(sc.time)],[avgFR_6hr,avgFR_6hr],'-b','LineWidth',2);
plot([max(sc.time)-12*3600,max(sc.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)