periEventPlot.m 1010 B

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