Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

MakePTH07.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. function [PTHout,BWout,MSRout]=MakePTH06(PSRin,Numin,PRMS)
  2. %!!!!!!!!CAUTION !!!!!
  3. %this version was modified by Fred and Ali to use DP and NOT Optimal BW
  4. %
  5. %INPUTS:
  6. %PSRin can be collapsed or not. if not, the output is uncollapsed as well
  7. %Numin= number of trials
  8. %PRMS{1}==1 for making baseline-only PSTH and ==2 for normal, main PSTH %(i.e. -15 to 15s)
  9. %PRMS{2}==0 for fixed binwidth and ==1 for DP binwidth
  10. %PRMS{3}=binwidth used
  11. %OUTPUTS:
  12. %PTHout
  13. %BWout is a vector stores the DP BW
  14. %MSRout is MSR=f(BW)
  15. global Tm Tbase
  16. if PRMS{1}==1
  17. T0=Tbase;
  18. elseif PRMS{1}==2
  19. T0=Tm;
  20. end
  21. BWx=[0.01:0.005:1]; % Range of binsizes considered
  22. PTH=[];
  23. if size(PSRin,2)==1 %if TRUE, all trials are collapsed
  24. if PRMS{2}==0 %fixed/assigned binwidth for all
  25. if numel(PRMS{3})==1,
  26. BW=repmat(PRMS{3},length(PSRin),1);
  27. else
  28. BW=PRMS{3};
  29. end
  30. for k=1:length(PSRin)
  31. Tn=[-BW(k)/2:-BW(k):T0(1)-BW(k)]; Tp=[BW(k)/2:BW(k):T0(end)+BW(k)];
  32. T=[Tn(end:-1:1),Tp];%making PSTH centered on zero
  33. %T=[T0(1)-BW(k):BW(k):T0(end)+BW(k)];
  34. TMP=hist(PSRin{k},T)/(BW(k)*Numin(k)); % make PSTH and normalize by number of refs used (Hz)
  35. %deals with low firing in which there is too few DP bins to do
  36. %interppolation
  37. if length(T)>4
  38. PTH(k,:)=interp1(T(2:end-1),TMP(2:end-1),T0,'nearest','extrap');BWout(k,1)=BW(k);
  39. else
  40. PTH(k,:)=repmat(mean(TMP),1,length(T0));BWout(k,1)=T0(end)-T0(1);
  41. end
  42. end
  43. PTHout=PTH;MSRout=[];
  44. else %DP binwidth for all
  45. for k=1:length(PSRin)
  46. [~,~,MSR]=optimalBW05(PSRin(k),T0); % make PSTH and normalize by number of refs used (Hz)
  47. [~,I]=findDP(BWx,MSR,{2,.9});%{DP=1,DEG/TSH=2,TSHOLD}
  48. Tn=[-BWx(I)/2:-BWx(I):T0(1)-BWx(I)]; Tp=[BWx(I)/2:BWx(I):T0(end)+BWx(I)];T=[Tn(end:-1:1),Tp];%making PSTH centered on zero
  49. TMP=hist(PSRin{k},T)/(BWx(I)*Numin(k)); % make PSTH and normalize by number of refs used (Hz)
  50. %deals with low firing in which there is too few DP bins to do
  51. %interppolation
  52. if length(T)>4
  53. PTH(k,:)=interp1(T(2:end-1),TMP(2:end-1),T0,'nearest','extrap'); BWout(k,1)=BWx(I);
  54. else
  55. PTH(k,:)=repmat(mean(TMP),1,length(T0));BWout(k,1)=T0(end)-T0(1);
  56. end
  57. MSRout(k,:)=MSR;
  58. end
  59. PTHout=PTH;
  60. end
  61. else % trial-by-trial PTH
  62. if PRMS{2}==0 %fixed/assigned binwidth for all
  63. if numel(PRMS{3})==1,
  64. BW=repmat(PRMS{3},length(PSRin),1);
  65. else
  66. BW=PRMS{3};
  67. end
  68. for k=1:size(PSRin,1) %neuron
  69. Tn=[-BW(k)/2:-BW(k):T0(1)-BW(k)]; Tp=[BW(k)/2:BW(k):T0(end)+BW(k)];T=[Tn(end:-1:1),Tp];%making PSTH centered on zero
  70. % T=[T0(1)-BW(k):BW(k):T0(end)+BW(k)];
  71. for n=1:size(PSRin,2)%trial
  72. TMP=hist(PSRin{k,n},T)/BW(k); % make PSTH and normalize by number of refs used (Hz)
  73. %deals with low firing in which there is too few DP bins to do
  74. %interppolation
  75. if length(T)>4
  76. PTH(k,:,n)=interp1(T(2:end-1),TMP(2:end-1),T0,'nearest','extrap');BWout(k,1)=BW(k);
  77. else
  78. PTH(k,:,n)=repmat(mean(TMP),1,length(T0));BWout(k,1)=T0(end)-T0(1);
  79. end
  80. end
  81. end
  82. PTHout=PTH;MSRout=[];
  83. else %DP binwidth for all
  84. for k=1:size(PSRin,1)%neuron
  85. [~,~,MSR]=optimalBW05(PSRin(k,:),T0);
  86. [~,I]=findDP(BWx,MSR,{2,.9});%{DP=1,DEG/TSH=2,TSHOLD}
  87. Tn=[-BWx(I)/2:-BWx(I):T0(1)-BWx(I)]; Tp=[BWx(I)/2:BWx(I):T0(end)+BWx(I)];T=[Tn(end:-1:1),Tp];%making PSTH centered on zero
  88. for n=1:size(PSRin,2)%trial
  89. TMP=hist(PSRin{k,n},T)/BWx(I); % make PSTH and normalize by number of refs used (Hz)
  90. %deals with low firing in which there is too few DP bins to do
  91. %interppolation
  92. if length(T)>4
  93. PTH(k,:,n)=interp1(T(2:end-1),TMP(2:end-1),T0,'nearest','extrap');BWout(k,1)=BWx(I);
  94. else
  95. PTH(k,:,n)=repmat(mean(TMP),1,length(T0));BWout(k,1)=T0(end)-T0(1);
  96. end
  97. end
  98. MSRout(k,:)=MSR;
  99. end
  100. PTHout=PTH;
  101. end
  102. end