sp = zeros(length(spikes),10,80001);

for i = 1:10
   for j=1:length(spikes)
      f = find(spikes{j} > r(i)./1000-40);
      ff = find(spikes{j} < r(i)./1000+40);
      fff = intersect(f,ff);
      sp(j,i,round(spikes{j}(fff)*1000)-r(i)+40001) = 1;
   end    
end