GetSpatialInfo_pvalue_ALT.m 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. function Spainfo_pvalue = GetSpatialInfo_pvalue_ALT(thisCLST, Pos, SpaInfo)
  2. randN = 100;%
  3. infoArray = nan(randN, 1);
  4. randArray = nan(randN, 1);
  5. SpaInfo_Random_Array=0;
  6. XsizeOfVideo = 720;
  7. YsizeOfVideo = 480;
  8. samplingRate = 30;
  9. scaleForRateMap = 10;
  10. binXForRateMap = XsizeOfVideo / scaleForRateMap;
  11. binYForRateMap = YsizeOfVideo / scaleForRateMap;
  12. % parfor randI = 1:randN
  13. spkN = size(thisCLST.PositionLocked(thisCLST.Flag_Position_pvalue), 1);
  14. if spkN ~= 0
  15. for randI = 1:randN
  16. %input x, y, t: position data. it must include only behavior session data.
  17. %t_spk: spk data time stamps. it must include only behavior session data.
  18. %SpaInfo : Real spatial information score
  19. x_spkR = nan(spkN, 1);
  20. y_spkR = nan(spkN, 1);
  21. t_spkR = nan(spkN, 1);
  22. occN = size(Pos.t(Pos.Flag_Position_pvalue),1);
  23. T=Pos.t(Pos.Flag_Position_pvalue);
  24. startTime =T(1);
  25. endTime = T(end);
  26. Endtime=T(end);
  27. if occN < 1500 %minimum value
  28. error('occ data must be greater than or equare to 1500');
  29. end
  30. for i=1:spkN
  31. while true
  32. cRand = rand();
  33. shift = occN * cRand; %shift amount (unit: occ)
  34. if shift > 300 && (occN-shift) > 300 % sufficiantly far from original position
  35. Shift(i)=shift; % randomize the every spike's positions.
  36. break;
  37. end
  38. end
  39. end
  40. t_spk=thisCLST.PositionLocked(thisCLST.Flag_Position_pvalue);
  41. x_spk = thisCLST.x(thisCLST.Flag_Position_pvalue);
  42. y_spk = thisCLST.y(thisCLST.Flag_Position_pvalue);
  43. t_pos=Pos.t(Pos.Flag_Position_pvalue);
  44. x_pos=Pos.x(Pos.Flag_Position_pvalue);
  45. y_pos=Pos.y(Pos.Flag_Position_pvalue);
  46. spk_index=zeros(1,length(t_spk));
  47. for i=1:length(t_pos)
  48. for j=1:length(t_spk)
  49. if(t_spk(j)==t_pos(i))
  50. spk_index(j)=i;
  51. end
  52. end
  53. end
  54. spkR_index=spk_index+floor(Shift);
  55. outRange = spkR_index > occN;
  56. spkR_index(outRange) = spkR_index(outRange) - occN;
  57. for i=1:length(x_spk)
  58. x_spkR(i) = x_pos(spkR_index(i));
  59. y_spkR(i) = y_pos(spkR_index(i));
  60. t_spkR(i) = t_pos(spkR_index(i));
  61. end
  62. %%
  63. [occMatR, spkMatR, rawMatR, skaggsrateMatR] = abmFiringRateMap( ...
  64. [t_spkR, x_spkR, y_spkR], ...
  65. [Pos.t(Pos.Flag_Position_pvalue), Pos.x(Pos.Flag_Position_pvalue), Pos.y(Pos.Flag_Position_pvalue)], ...
  66. binYForRateMap, binXForRateMap, scaleForRateMap, samplingRate);
  67. SpaInfo_Random= GetSpaInfo(occMatR, skaggsrateMatR);
  68. SpaInfo_Random_Array(randI) = SpaInfo_Random;
  69. rand_Array(randI) = cRand;
  70. end
  71. Spainfo_pvalue = sum(SpaInfo_Random_Array > SpaInfo) / randN;
  72. else
  73. Spainfo_pvalue = NaN;
  74. end