PlotRaster.m 698 B

123456789101112131415161718192021
  1. function PlotRaster(Timestamps,Reference,Window)
  2. %timestamps are the times of the events (spikes usually)
  3. %reference is the event times that the raster is aligned
  4. %window is the range in which events are plotted relative to reference
  5. hold on;
  6. trials=length(Reference);
  7. for trial=1:trials
  8. times=Timestamps-Reference(trial);
  9. times=times(times>Window(1) & times<Window(2));
  10. for stamp=1:length(times)
  11. plot([times(stamp) times(stamp)],[7+10*(trial-1) 13+10*(trial-1)],'color','k');
  12. end
  13. end
  14. yticks([100:100:10*trials]);
  15. yticklabels([10:10:trials]);
  16. ylabel('Reference No.');
  17. ylim([0 10*trials+10]);
  18. xlabel('Seconds from reference');
  19. set(gca,'ydir','reverse');