MakePSR05.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 ~isempty(find(tmp>Win(1) & tmp<Win(2)))
  17. if FLAG==0
  18. PSRout{i}=cat(1,PSRout{i},tmp(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax));
  19. else
  20. PSRout{i}=cat(1,PSRout{i},tmp(find(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax,1,PRMS{2})));
  21. end
  22. else PSRout{i}=NaN;
  23. end
  24. end
  25. end
  26. elseif Otype==2
  27. PSRout=cell(size(Nrast,1),size(Erast,1)); %PSRout is a cell(neurons,trials)
  28. for i=1:length(Nrast) %loops through the number of neurons
  29. for k=1:size(Erast,1) %loops through the trials
  30. tmp=Nrast{i}-Erast(k);
  31. if ~isempty(find(tmp>Win(1) & tmp<Win(2)))
  32. if FLAG==0
  33. PSRout{i,k}=tmp(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax);
  34. else
  35. PSRout{i,k}=tmp(find(tmp>Win(1)-Bmax & tmp<Win(2)+Bmax,1,PRMS{2}));
  36. end
  37. else
  38. PSRout{i,k}=NaN;
  39. end
  40. end
  41. end
  42. end
  43. Nout=size(Erast,1);