load('stim_info.mat')
timediff = 5;
tim = stim.ts{2}(119,1);
d = LoadBinary('camkii10_180102.dat','nchannels',32,'frequency',30000,'start',tim-timediff,'duration',2*timediff,'channels',[28 17 1 9]);
d= double(d');
   d = 0.195 * (d - 32768);
spikes = bz_GetSpikes('basepath',pwd);
ra = cellfun(@(a) a(a>7761.4-timediff &  a<tim+timediff) -tim,spikes.times,'UniformOutput',false)';
ts = (1:size(d,2))/30000 - timediff;
%%
close all

 figure
col1 = [[1 0 0];[0 1 0 ];[1 0 1];[0 0 1]];
for i = 1:4
    d1 = BandpassFilter(d(i,:),30000,[7 14000]);
    plot(ts(1:10:end),d1(1:10:end)-i*1000,'color',col1(i,:))
    hold on
   xlim([-1 2])
end

col = zeros(size(ra,1),3);
col(spikes.shankID==1,:) = repmat(col1(1,:),sum(spikes.shankID==1),1);
col(spikes.shankID==2,:) = repmat(col1(2,:),sum(spikes.shankID==2),1);
col(spikes.shankID==3,:) = repmat(col1(3,:),sum(spikes.shankID==3),1);
col(spikes.shankID==4,:) = repmat(col1(4,:),sum(spikes.shankID==4),1);

figure
 PipeRaster(ra,'color',col)
 set(gca,'ydir','reverse')
 xlim([-1 2])