clear all;
% fid_label = 'trouble22467';
% load('C:\Users\USER\Documents\mingfaifong\2013-01-21_trouble22467_12-14DIV_MEA_CNQX\trouble22467_12-14DIV.mat');
% fid_label = 'usain22493';
% load('C:\Users\USER\Documents\mingfaifong\2013-01-24_usain22493_12-14DIV_MEA_CNQX\usain22493_12-14DIV.mat');
% fid_label = 'wingnut22468';
% load('C:\Users\USER\Documents\mingfaifong\2013-02-03_wingnut22468_10-12DIV_MEA_CNQX\wingnut22468_10-12DIV.mat');
% fid_label = 'xinhai22493';
% load('C:\Users\USER\Documents\mingfaifong\2013-02-08_xinhai22493_11-13DIV_MEA_CNQX\xinhai22493_11-13DIV.mat');
% fid_label = 'atlas22493';
load('C:\Users\USER\Documents\mingfaifong\2013-03-01_atlas22493_10-12DIV_MEA_CNQX\atlas22493_10-12DIV.mat');
% fid_label = 'dojo22493';
% load('C:\Users\USER\Documents\mingfaifong\2013-03-19_dojo22493_11-13DIV_MEA_CNQX\dojo22493_11-13DIV.mat');


%% 1/medianISI
time = sort(time);
max(time)/3600

predrug3hr.ISI = diff(time(time<0 & time>=-3*3600));
predrug3hr.medFR = 1/median(predrug3hr.ISI);

drughr1.ISI = diff(time(time<1*3600 & time>=0));
drughr1.medFR = 1/median(drughr1.ISI);

drughr24.ISI = diff(time(time<24*3600 & time>=23*3600));
drughr24.medFR = 1/median(drughr24.ISI);

drugall24.ISI = diff(time(time<24*3600 & time>=0));
drugall24.medFR = 1/median(drugall24.ISI);

medFR = [drughr1.medFR drughr24.medFR drugall24.medFR]/predrug3hr.medFR-1

%% median of smoothed ASDR
% dt = 30;
% f_smooth = 1;
% bin = [-3*3600:dt:24*3600];
% asdr = histc(time,bin)/dt;
% predrug3hr.medASDR = median(smooth(asdr(bin<0 & bin>-3*3600),f_smooth));
% drughr1.medASDR = median(smooth(asdr(bin<1*3600 & bin>0),f_smooth));
% drughr24.medASDR = median(smooth(asdr(bin<24*3600 & bin>23*3600),f_smooth));
% drugall24.medASDR = median(smooth(asdr(bin<24*3600 & bin>0),f_smooth));
% 
% hold off;
% stairs(bin,smooth(asdr,f_smooth),'-r');
% hold on;
% stairs(bin,asdr,'-k');
% 
% medASDR = [drughr1.medASDR drughr24.medASDR drugall24.medASDR]/predrug3hr.medASDR-1
% 

%% ChR2 stimulated cultures
% fid_label = 'trouble22468';
% load('C:\Users\USER\Documents\mingfaifong\2013-01-21_trouble22468_12-14DIV_MEA_CNQX-ChR2-stim-CL\trouble22468_12-14DIV.mat');
% fid_label = 'usain22471';
% load('C:\Users\USER\Documents\mingfaifong\2013-01-24_usain22471_12-14DIV_MEA_CNQX-ChR2-stim-CL\usain22471_12-14DIV.mat');
% fid_label = 'wingnut21332';
% load('C:\Users\USER\Documents\mingfaifong\2013-02-03_wingnut21332_10-13DIV_MEA_CNQX-ChR2-stim-CL\wingnut21332_10-12DIV.mat');
% fid_label = 'xinhai22471';
% load('C:\Users\USER\Documents\mingfaifong\2013-02-08_xinhai22471_11-13DIV_MEA_CNQX-ChR2-stim-CL\xinhai22471_11-13DIV.mat');
% fid_label = 'zarathustra21332';
% load('C:\Users\USER\Documents\mingfaifong\2013-02-19_zarathustra21332_12-14DIV_MEA_CNQX-ChR2-stim-CL\zarathustra21332_12-14DIV.mat');
% fid_label = 'barbie22468';
% load('C:\Users\USER\Documents\mingfaifong\2013-03-08_barbie22468_11-13DIV_MEA_CNQX-ChR2-stim-2x-CL\barbie22468_11-13DIV.mat');
% fid_label = 'dojo22471';
% load('C:\Users\USER\Documents\mingfaifong\2013-03-19_dojo22471_11-13DIV_MEA_CNQX-ChR2-stim-2x-CL\dojo22471_11-13DIV.mat');
% fid_label = 'jujuI5388';
% load('C:\Users\USER\Documents\mingfaifong\2012-10-28_jujuI5388_11-13DIV_MEA_CNQX-ChR2-stim-CL\jujuI5388_11-13DIV.mat');
