% Jon Newman
% Look at control performance

k = 1;
st = {};
sp = {};

% Pre-drug
fid = '2013_03_22_Yam-22565_no-drug_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;
ko = k;

fid = '2013_03_22_Yam-22565_no-drug_02';
[sp{k} st{k}] = smoosh(fid);
k = k+1;
ko = k;

% 50 uM AP5 clamp
fid = '2013_03_22_Yam-22565_50um-ap5_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;

% 50 uM AP5 clamp
fid = '2013_03_22_Yam-22565_50um-ap5_02';
[sp{k} st{k}] = smoosh(fid);
k = k+1;

% Wash 1
fid = '2013_03_22_Yam-22565_wash1-2_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;

% Wash 2
fid = '2013_03_22_Yam-22565_wash3-4_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;

% Wash 3
fid = '2013_03_22_Yam-22565_wash5-6_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;

% Wash 4
fid = '2013_03_22_Yam-22565_wash7_01';
[sp{k} st{k}] = smoosh(fid);
k = k+1;


%%
close all
figure
hold on
dt_asdr = 300; % sec

for i = 1:length(st)
    
    
    bin = 0:dt_asdr:max(sp{i}.time);
    asdr = hist(sp{i}.time,bin)/max(sp{i}.unit);
    bin = bin + 24*3600*(st{i} - st{ko});
    if i == 3
        da = bin(1);
    end
    stairs(bin/3600,asdr/dt_asdr,'k-');
    
    
end

plot([3 27],[0.4458 0.4458],'r-')
% ylim([0 1])
xlim([-3 34])
xlabel('Time (hrs)')
ylabel('FR (Hz/unit)')
grid on

%%
export_fig('2013_03_22_Yam-22565_fr-summary_dt-300sec_01','-pdf','-transparent',gcf)





