getevents.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. function [mdat nevt tim evt] = getevents(actname)
  2. %tmp=load([actname '.mat']);
  3. %mdat=tmp.mdat;
  4. load([actname '.mat']);
  5. tmp=mdat.evt;
  6. evt=zeros(length(tmp),1);
  7. for i=1:length(tmp)
  8. if isempty(str2num(tmp{i}))
  9. evt(i)=NaN;
  10. else
  11. evt(i)=str2num(tmp{i});
  12. end
  13. end
  14. tim=mdat.evT;
  15. nevt=zeros(length(tmp),3);
  16. ori1=NaN; ori2=NaN; cori=NaN; cued=NaN; ncued=NaN; task=NaN; pos1=NaN; pos2=NaN; cpos=NaN; ncpos=NaN;
  17. stim1=NaN; stim2=NaN; cstim=NaN; ncstim=NaN; pos3=NaN; ori3=NaN;
  18. pingcount=0; tricount=0; fix=1;
  19. for i=1:length(evt)
  20. if ismember(evt(i),[20:76]) % first stim
  21. tricount=tricount+1;
  22. ori1=rem(evt(i),20); % first stim ori
  23. if ismember(evt(i),[21:36])
  24. stim1=1;
  25. elseif ismember(evt(i),[41:56])
  26. stim1=2;
  27. elseif ismember(evt(i),[61:76])
  28. stim1=3;
  29. end
  30. if i<length(evt) & ismember(evt(i+1),91:106)
  31. pos1=rem(evt(i+1)-10,20);
  32. end
  33. end
  34. if ismember(evt(i),[120:176]) % second stim
  35. ori2=rem(evt(i),20); % second stim ori
  36. if ismember(evt(i),[121:136])
  37. stim2=1;
  38. elseif ismember(evt(i),[141:156])
  39. stim2=2;
  40. elseif ismember(evt(i),[161:176])
  41. stim2=3;
  42. end
  43. if i<length(evt) & ismember(evt(i+1),91:106)
  44. pos2=rem(evt(i+1)-10,20);
  45. end
  46. end
  47. if evt(i)==1
  48. cued=1;
  49. cori=ori1;
  50. ncori=ori2;
  51. cstim=stim1;
  52. ncstim=stim2;
  53. cpos=pos1;
  54. ncpos=pos2;
  55. elseif evt(i)==2
  56. cued=2;
  57. cori=ori2;
  58. ncori=ori1;
  59. cstim=stim2;
  60. ncstim=stim1;
  61. cpos=pos2;
  62. ncpos=pos1;
  63. end
  64. if evt(i)==3;
  65. task=1;
  66. elseif evt(i)==4;
  67. task=2;
  68. end
  69. if ismember(evt(i),[232]) % off-fixation [100 200 232]
  70. fix=1;
  71. end
  72. if ismember(evt(i),[230 231])
  73. pingcount=pingcount+1;
  74. end
  75. if ismember(evt(i),[201:216])
  76. ori3=rem(evt(i),20);
  77. if ismember(evt(i-1),91:106)
  78. pos3=rem(evt(i-1)-10,20);
  79. end
  80. end
  81. if fix==1 & ~isnan(ori1) & ~isnan(ori2) % & ~isnan(ori3) %& ~isnan(stim1) & ~isnan(stim2)% & cued==2
  82. % if ismember(evt(i),[230 231]) % & pingcount<3 % & ismember(evt(i-4),[3 4]);
  83. % % if ismember(evt(i),[201:221]);
  84. % nevt(i,1)=1000+cpos;
  85. %
  86. % % nevt(i,1)=1000+cori;
  87. % % nevt(i,2)=1000+ncori;
  88. % % nevt(i,3)=1000+ncori;
  89. %
  90. % end
  91. %use this also for simple within/between
  92. if ismember(evt(i),[1]) % & cued==1
  93. nevt(i,ncstim)=1000+ncori;
  94. end
  95. % if ismember(evt(i),[1 2])% & cued==2% for X2
  96. % nevt(i,stim1)=1000+ori1;
  97. % nevt(i,stim2)=2000+ori2;
  98. % end
  99. % if ismember(evt(i),[1 2]) % & task==2% for X2
  100. % nevt(i,cstim)=1000+cori;
  101. % nevt(i,ncstim)=2000+ncori;
  102. % end
  103. % if ismember(evt(i),[20:76])%
  104. % %if ismember(evt(i),[201:221]);
  105. % nevt(i,stim1)=1000+ori1;
  106. % end
  107. % if ismember(evt(i),[120:176])%
  108. % %if ismember(evt(i),[201:221]);
  109. % nevt(i,stim2)=1000+ori2;
  110. % end
  111. % if ismember(evt(i),[1 2]) % & cued==2
  112. % %if ismember(evt(i),[201:221]);
  113. % % nevt(i,1)=1000+pos1;
  114. % % nevt(i,2)=1000+pos2;
  115. % % nevt(i,3)=1000+pos2;
  116. % nevt(i,1)=1000+ori1;
  117. % nevt(i,2)=1000+ori2;
  118. % nevt(i,3)=1000+ori2;
  119. % end
  120. %
  121. % if ismember(evt(i),[1 2]) %& task==1%
  122. % % nevt(i,cstim)=1000+cori;
  123. % nevt(i,1)=1000+cori;
  124. % nevt(i,2)=1000+ncori;
  125. % nevt(i,3)=1000+ncori;
  126. % end
  127. % if ismember(evt(i),[120:176]) % for 16 x16
  128. % nevt(i,1)=1000+ceil([ori2]./2);
  129. % nevt(i,2)=1000+ceil([ori1]./2);
  130. % nevt(i,3)=1000+ceil([ori1]./2);
  131. % end
  132. if ismember(evt(i),[201:221])
  133. % nevt(i,cstim)=1000+cori;
  134. fix=1;
  135. pingcount=0;
  136. ori1=NaN; ori2=NaN; cori=NaN; cued=NaN; ncued=NaN; task=NaN; pos1=NaN; pos2=NaN; cpos=NaN; ncpos=NaN;
  137. stim1=NaN; stim2=NaN; cstim=NaN; ncstim=NaN; pos3=NaN; ori3=NaN;
  138. end
  139. % if tricount==576
  140. % break
  141. % end
  142. end
  143. end
  144. end