periEventPlot.asv 842 B

12345678910111213141516171819202122232425262728293031323334
  1. clear all
  2. close all
  3. cbmex('open');
  4. cbmex('trialconfig',1,'absolute')
  5. samplingFreq = 30000;
  6. eventChannel = 1;
  7. contChannel = 1;
  8. EventLFPs = [];
  9. EventLFPTotal = [];
  10. while size(EventLFPTotal,1) < 100
  11. [spikeData, procTime, contData] = cbmex('trialdata',1);
  12. %Example channel to choose for perievent marks
  13. ContinuousData = contData{contChannel,3};
  14. spikeTimes = spikeData{eventChannel,2}- procTime * samplingFreq;
  15. if ~isempty(spikeTimes)
  16. EventLFPs = bsxfun(@plus, -50:50, double(spikeTimes));
  17. EventLFPTotal = [EventLFPTotal; EventLFPs];
  18. end
  19. % for i = 1:length(SpikeTimes)
  20. % try
  21. % EventLFPs(size(EventLFPs,1)+1,:) = ContinuousData(SpikeTimes(i):SpikeTimes(i)+100);
  22. % catch
  23. % end
  24. % end
  25. pause(0.5);
  26. end
  27. cbmex('close');
  28. plot(mean(EventLFPTotal,1));