fid = '2013_03_11_Yam-22564_24-hr-ap5-clamp_no-drug_01';
spk = loadspk([fid '.spk'],[],0);
ss = SqueakySpk(fid,spk.meta.fs_Hz,1,spk);
% ss.RemoveChannel()
ss.RemoveUnit(0);
% ss.RemoveUnit(unique(ss.unit(ismember(ss.channel,[22,43,55])))')
sc = ss.ReturnClean();
% b = loadbang([fid '.bang']);

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

%%

figure
dt_asdr = 60; % sec
bin = max(sc.time)-12*3600:dt_asdr:max(sc.time);
asdr = histc(sc.time,bin)/max(ss.unit);
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)