% Jon Newman
% 2012 03 15

fid = '2012_03_15_Ollie363_10sec-1to5hz-multi-block_00';

s = loadspk([fid '.spk']);
sim = loadsimoc([fid '.simoc']);
ss = SqueakySpk(fid,s.meta.fs_Hz,1,s);

%% Plot parameters
tpre = 20;
tpost = 20;
len = 10*10;

start = find(sim.target > 0, 1);
stop = find(sim.target > 0, 1,'last');
b = sim.time >= (sim.time(start) - tpre) & sim.time <= (sim.time(stop) + tpost);
start_t = sim.time(start);

%%
close all
figure

subplot(311)
hold on
plot(sim.time(b)-start_t,sim.target(b),'r')
plot(sim.time(b)-start_t,smooth(smooth(sim.filt(b),10),10),'k')
set(gca,'TickDir','out','TickLength',[0.01 0.01],'XTick',[],'Box','off')
axis tight
ylim([0 6])

subplot(312)
hold on
plot(sim.time(b)-start_t,sim.output(1,b),'k')
set(gca,'TickDir','out','TickLength',[0.01 0.01],'XTick',[],'Box','off')
axis tight

subplot(313)
hold on
plot(sim.time(b)-start_t,sim.output(2,b),'b-')
plot(sim.time(b)-start_t,sim.output(3,b),'r-')
set(gca,'TickDir','out','TickLength',[0.01 0.01],'Box','off')
axis tight
% plot(sim.time(b),sim.output(4,b),'g-')

%%
% export_fig(fid,'-pdf','-transparent')
% export_fig(fid,'-r400','-transparent')