% Jon Newman
% 2013 01 26
% Look at reactivity of each the three wells

fids = {
    '2013-01-26_pulse_chr2_vivy_21367_wellA';
    '2013-01-26_pulse_chr2_vivy_21367_wellC'
    '2013-01-26_pulse_chr2_vivy_21367_wellE'
    };

w = zeros(6,9);
w(1,:) = [3 4 5 12 13 20 21 28 29];
w(2,:) = [7 14 15 16 22 23 24 30 31];
w(3,:) = [38 39 40 46 47 48 55 56 63];
w(4,:) = [36 37 44 45 52 53 60 61 62];
w(5,:) = [34 35 41 42 43 49 50 51 58];
w(6,:) = [2 9 10 17 18 19 25 26 27];



figure

% Spontd FR

% Evoked FR
ws = [1 3 5];
wn = {'A';'C';'E'};
for f = 1:length(fids)
   fid = fids{f};
   
   s = loadspk([fid '.spk']);
   ss = SqueakySpk(fid,s.meta.fs_Hz,1,s);
   ss.RemoveChannel(setdiff(1:64,w(ws(f),:)));

   subplot(3,3,f)
   ss.ASDR(10,[0 120])
   xlim([0 120])
   ylim([0 10])
   text(20,8,[wn{f} ' pre spont.'])
   set(gca,'XTick',[0 120 ])
   
   subplot(3,3,f+3)
   ss.ASDR(10,[120 240])
   xlim([120 240])
   ylim([0 10])
   text(140,8,[wn{f} ' evoke.'])
   set(gca,'XTick',[120 240])
   
   subplot(3,3,f+6)
   ss.ASDR(10,[240 360])
   xlim([240 360])
   ylim([0 10])
   text(260,8,[wn{f} ' post spont.'])
   set(gca,'XTick',[240 360])
    
    
end

export_fig('-pdf','-transparent',fid(1:end-6))
