MakePSR04.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function [PSRout Nout]=MakePSR04(Nrast,Erast,Win,PRMS)
  2. %Win is the time window around the event
  3. %PRMS=2 give a PSR cell {neurons,trials} and PRMS=1 collapses all the trials >
  4. %cell{neurons,1}
  5. %N is the number of trials
  6. Otype=PRMS{1};
  7. FLAG=0;Bmax=0;
  8. if length(PRMS)>1
  9. FLAG=1;
  10. end
  11. if Otype==1
  12. PSRout=cell(size(Nrast,1),1);
  13. for i=1:length(Nrast)
  14. for k=1:size(Erast,1)
  15. tmp=Nrast{i}-Erast(k);
  16. if FLAG==0
  17. PSRout{i}=cat(1,PSRout{i},tmp(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax));
  18. else
  19. PSRout{i}=cat(1,PSRout{i},tmp(find(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax,1,PRMS{2})));
  20. end
  21. end
  22. end
  23. elseif Otype==2
  24. PSRout=cell(size(Nrast,1),size(Erast,1)); %PSRout is a cell(neurons,trials)
  25. for i=1:length(Nrast) %loops through the number of neurons
  26. for k=1:size(Erast,1) %loops through the trials
  27. tmp=Nrast{i}-Erast(k);
  28. if ~isempty(find(tmp>Win(1) & tmp<Win(2), 1))
  29. if FLAG==0
  30. PSRout{i,k}=tmp(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax);
  31. else
  32. PSRout{i,k}=tmp(find(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax,1,PRMS{2}));
  33. end
  34. else
  35. PSRout{i,k}=NaN;
  36. end
  37. end
  38. end
  39. end
  40. Nout=size(Erast,1);