MakePSR0int.m 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function [PSRout, Nout]=MakePSR0int(Nrast,EintS,EintE,PRMS,Int)
  2. %Eint is the interval start and end
  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 interval
  6. %Int: 1=iti. 2=trial
  7. inttype=Int{1};
  8. if inttype==1
  9. Timeshift=10;
  10. elseif inttype==2
  11. Timeshift=0;
  12. end
  13. Otype=PRMS{1};
  14. FLAG=0;
  15. if length(PRMS)>1
  16. FLAG=1;
  17. end
  18. if Otype==1
  19. PSRout=cell(size(Nrast,1),1);
  20. for i=1:length(Nrast)
  21. for k=1:size(EintS,1)
  22. if FLAG==0
  23. tmp=Nrast{i};
  24. PSRout{i}=cat(1,PSRout{i},tmp(tmp>EintS(k,1)+Timeshift & tmp<EintE(k,1)-Timeshift));
  25. else
  26. PSRout{i}=cat(1,PSRout{i},tmp(find(tmp>EintS(k,1)+Timeshift & tmp<EintE(k,1)-Timeshift),1,PRMS{2}));
  27. end
  28. end
  29. end
  30. elseif Otype==2
  31. PSRout=cell(size(Nrast,1),size(EintS,1)); %PSRout is a cell(neurons,intervals)
  32. for i=1:length(Nrast) %loops through the number of neurons
  33. for k=1:size(EintS,1) %loops through interval, exclude the 1st interval
  34. tmp=Nrast{i};
  35. if ~isempty(find(tmp>EintS(k,1) & tmp<EintE(k,1), 1))
  36. if FLAG==0
  37. PSRout{i,k}=tmp(tmp>EintS(k,1)+Timeshift & tmp<EintE(k,1)-Timeshift);
  38. else
  39. PSRout{i,k}=tmp(find(tmp(tmp>EintS(k,1)+Timeshift & tmp<EintE(k,1)-Timeshift),1,PRMS{2}));
  40. end
  41. else
  42. PSRout{i,k}=NaN;
  43. end
  44. end
  45. end
  46. end
  47. Nout=size(EintS,1)-1;