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.

figure_SRT.m 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. function figure_SRT(fld)
  2. load(fullfile(fld.basedir, 'results','figure_behavior','RTcoll.mat'),'RTcoll');
  3. %% RT distribution
  4. green = [23, 105, 13]./255;
  5. red = [201, 0, 34]./255;
  6. cols = [green; 0.3 0.3 0.3; red];
  7. minRT = 75;
  8. minX2 = 120;
  9. zoomY=[0.35 0.40];
  10. maxRT = 750;
  11. fastRT = 250;
  12. frt = figure;
  13. set(frt,'Position',[0,0,1900,800]);
  14. frt2=figure;
  15. set(frt2,'Position',[0,0,1800,700]);
  16. for mi=1:2
  17. fastRT = ceil(prctile([RTcoll{mi,1};RTcoll{mi,3}],25));
  18. fastRT = 10*ceil(fastRT/10);
  19. p25 = prctile([RTcoll{mi,1};RTcoll{mi,3}],25);
  20. p50 = median([RTcoll{mi,1};RTcoll{mi,3}]);
  21. p75 = prctile([RTcoll{mi,1};RTcoll{mi,3}],75);
  22. figure(frt);
  23. subplot(2,4,[(mi-1)*2+1 (mi-1)*2+2]); hold on;
  24. for c = [3 1]
  25. rts = RTcoll{mi,c};
  26. rts(rts>maxRT) = [];
  27. be=minRT:10:maxRT;
  28. [y,x]=histcounts(rts,be,'Normalization','cdf');
  29. x = x(1:end-1)+10/2;
  30. plot(x,y,'LineWidth',2,'Color',cols(c,:))
  31. end
  32. set(gca,'xlim',[minRT maxRT],'Box','off');
  33. ylimits=get(gca,'ylim');
  34. plot([p25 p25],[0 1.1],'k--');
  35. plot([p50 p50],[0 1.1],'k-');
  36. plot([p75 p75],[0 1.1],'k--');
  37. set(gca,'ylim',[0 1.1]);
  38. xlabel('RT (ms)');ylabel('CDF');
  39. title(['M' num2str(mi) ': all sacc > 75 ms'])
  40. %STATS
  41. % choices
  42. fprintf('\n==============================\n')
  43. fprintf(['Stats (RT all) for M' num2str(mi) '\n']);
  44. fprintf('==============================\n')
  45. rt1 = RTcoll{mi,1}; rt2=RTcoll{mi,3};
  46. [p,h,s]=ranksum(rt1,rt2);
  47. fprintf(['\nM' num2str(mi) ': Wilcoxon for all saccades -----\n'])
  48. fprintf(['z = ' num2str(s.zval) ', p = ' num2str(p) '\n']);
  49. fprintf(['TARGET median = ' num2str(median(rt1)) ', IQR = '...
  50. num2str(iqr(rt1)) '\n']);
  51. fprintf(['SALIENT DISTRACTOR median = ' num2str(median(rt2)) ', IQR = '...
  52. num2str(iqr(rt2)) '\n']);
  53. figure(frt);
  54. subplot(2,4,(mi-1)*2+5); hold off
  55. for c = [3 1]
  56. rts = RTcoll{mi,c};
  57. rts(rts>fastRT) = [];
  58. be=minRT:5:fastRT;
  59. histogram(rts,be,'FaceColor',cols(c,:),'Normalization',...
  60. 'probability'); hold all
  61. end
  62. set(gca,'xlim',[minX2 fastRT],'ylim',[0 0.29],'Box','off');
  63. xlabel('RT (ms)');ylabel('Probability');
  64. title(['M' num2str(mi) ': fast sacc ' num2str(minRT) '-' num2str(fastRT) ' ms'])
  65. figure(frt2)
  66. subplot(2,4,4+mi);
  67. hold on;
  68. for c = [3 1]
  69. rts = RTcoll{mi,c};
  70. rts(rts>fastRT) = [];
  71. be=minRT:5:fastRT;
  72. histogram(rts,be,'FaceColor',cols(c,:),'Normalization',...
  73. 'probability'); hold all
  74. end
  75. set(gca,'xlim',[130 fastRT],'ylim',[0 0.29],'Box','off');
  76. xlabel('RT (ms)');ylabel('Probability');
  77. title(['M' num2str(mi) ': fast sacc ' num2str(minRT) '-' num2str(fastRT) ' ms'])
  78. subplot(2,4,mi);
  79. hold on;
  80. nSRT = numel(RTcoll{mi,1})+numel(RTcoll{mi,2})+numel(RTcoll{mi,3});
  81. for c = [3 1]
  82. rts = RTcoll{mi,c};
  83. be=minRT:10:710;
  84. histogram(rts,be,'FaceColor',cols(c,:),'Normalization',...
  85. 'probability'); hold all
  86. end
  87. %set(gca,'xlim',[130 715],'ylim',[0 0.29],'Box','off');
  88. xlabel('RT (ms)');ylabel('Probability');
  89. title(['M' num2str(mi) ': all sacc (norm by choice)'])
  90. subplot(2,4,2+mi);
  91. hold on;
  92. nSRT = numel(RTcoll{mi,1})+numel(RTcoll{mi,2})+numel(RTcoll{mi,3});
  93. for c = [3 1]
  94. rts = RTcoll{mi,c};
  95. be=minRT:10:710;
  96. H = histogram(rts,be,'FaceColor',cols(c,:),'Normalization',...
  97. 'count'); hold all
  98. set(H,"BinCounts",H.BinCounts./nSRT);
  99. end
  100. %set(gca,'xlim',[130 715],'ylim',[0 0.29],'Box','off');
  101. xlabel('RT (ms)');ylabel('Probability');
  102. title(['M' num2str(mi) ': all sacc (norm by all)'])
  103. subplot(2,4,6+mi);
  104. hold on;
  105. for c = [3 1]
  106. rts = RTcoll{mi,c};
  107. rts(rts>fastRT) = [];
  108. be=minRT:5:fastRT;
  109. H2 = histogram(rts,be,'FaceColor',cols(c,:),'Normalization',...
  110. 'count'); hold all
  111. set(H2,"BinCounts",H2.BinCounts./nSRT);
  112. end
  113. set(gca,'xlim',[130 fastRT],'ylim',[0 0.13],'Box','off');
  114. xlabel('RT (ms)');ylabel('Probability');
  115. title(['M' num2str(mi) ': fast sacc ' num2str(minRT) '-' num2str(fastRT) ' ms'])
  116. %STATS
  117. % choices
  118. fprintf('\n==============================\n')
  119. fprintf(['Stats (25prc fastest RTs) for M' num2str(mi) '\n']);
  120. fprintf('==============================\n')
  121. rt1 = RTcoll{mi,1}; rt1=rt1(rt1<fastRT & rt1>minRT);
  122. rt2 = RTcoll{mi,2}; rt2=rt2(rt2<fastRT & rt2>minRT);
  123. rt = [RTcoll{mi,1};RTcoll{mi,3}];
  124. sel = rt<fastRT & rt>minRT ; rt=rt(sel);
  125. s = categorical([ones(size(RTcoll{mi,1}));...
  126. 2*ones(size(RTcoll{mi,3}))]); s=s(sel);
  127. [p,h,s]=ranksum(rt1,rt2);
  128. fprintf(['\nM' num2str(mi) ': Wilcoxon for fast saccades -----\n'])
  129. fprintf(['z = ' num2str(s.zval) ', p = ' num2str(p) '\n']);
  130. fprintf(['TARGET median = ' num2str(median(rt1)) ', IQR = '...
  131. num2str(iqr(rt1)) '\n']);
  132. fprintf(['SALIENT DISTRACTOR median = ' num2str(median(rt2)) ', IQR = '...
  133. num2str(iqr(rt2)) '\n']);
  134. fprintf(['Effect size: ' num2str(s.zval./sqrt(length(rt))) '\n']);
  135. figure(frt);
  136. subplot(2,4,(mi-1)*2+6);
  137. hold on;
  138. plot([p25 p25],[0 1],'k--');
  139. plot([p50 p50],[0 1],'k-');
  140. plot([p75 p75],[0 1],'k--');
  141. for c = [3 1]
  142. rts = RTcoll{mi,c};
  143. be=minRT:5:maxRT;
  144. hold all
  145. [y,x]=histcounts(rts,be,'Normalization','cdf');
  146. x = x(1:end-1)+5/2;
  147. plot(x,y,'LineWidth',2,'Color',cols(c,:))
  148. end
  149. set(gca,'xlim',[minX2 p25],'ylim',[0 zoomY(mi)],'Box','off');
  150. xlabel('RT (ms)');ylabel('CDF');
  151. title(['M' num2str(mi) ': fast sacc ' num2str(minRT) '-' num2str(fastRT) ' ms'])
  152. end
  153. %% RT_SlidingWindow ====
  154. aRT = [...
  155. RTcoll{1,1} ones(size(RTcoll{1,1})) ones(size(RTcoll{1,1}));...
  156. RTcoll{2,1} 2.*ones(size(RTcoll{2,1})) ones(size(RTcoll{2,1}));...
  157. RTcoll{1,2} ones(size(RTcoll{1,2})) 2.*ones(size(RTcoll{1,2}));...
  158. RTcoll{2,2} 2.*ones(size(RTcoll{2,2})) 2.*ones(size(RTcoll{2,2}));...
  159. RTcoll{1,3} ones(size(RTcoll{1,3})) 3.*ones(size(RTcoll{1,3}));...
  160. RTcoll{2,3} 2.*ones(size(RTcoll{2,3})) 3.*ones(size(RTcoll{2,3}))];
  161. DoPooled = false;
  162. fsw=figure;
  163. set(fsw,'Position',[0,0,900,350]);
  164. if DoPooled
  165. set(fsw,'Position',[0,0,1350,350]);
  166. end
  167. ws = 20; st = 10;
  168. minw = 0; maxw = 500;
  169. xmin=125; %minw+st/2;
  170. xmax=305; %455;
  171. cw = [minw minw+ws];
  172. dotsz = 90;
  173. cRT_T = aRT(aRT(:,3)==1,1);
  174. cRT_SD = aRT(aRT(:,3)==3,1);
  175. cRT_ND = aRT(aRT(:,3)==2,1);
  176. medRT = median(aRT(:,1));
  177. p25 = prctile(aRT(:,1),25);
  178. p75 = prctile(aRT(:,1),75);
  179. mRT = mean(aRT(:,1));
  180. smoothwin = 3;
  181. pSD = []; pND = []; pSDR = [];
  182. while cw(2) < maxw
  183. TSDratio = ...
  184. sum(cRT_SD>cw(1) & cRT_SD<=cw(2))./...
  185. (sum(cRT_T>cw(1) & cRT_T<=cw(2)) + sum(cRT_SD>cw(1) & cRT_SD<=cw(2)));
  186. TNDratio = ...
  187. sum(cRT_ND>cw(1) & cRT_ND<=cw(2))./...
  188. (sum(cRT_T>cw(1) & cRT_T<=cw(2)) + sum(cRT_ND>cw(1) & cRT_ND<=cw(2)));
  189. SDR = sum(cRT_SD>cw(1) & cRT_SD<=cw(2))./size(aRT,1);
  190. if ~isnan(TSDratio)
  191. pSD=[pSD; mean(cw) TSDratio];
  192. end
  193. if ~isnan(TNDratio)
  194. pND=[pND; mean(cw) TNDratio];
  195. end
  196. if ~isnan(SDR)
  197. pSDR=[pSDR; mean(cw) SDR];
  198. end
  199. cw=cw+st;
  200. end
  201. if DoPooled
  202. subplot(1,3,1);hold on;
  203. plot([0 500],[0 0],'k-');
  204. plot([p25 p25],[-0.1 1.1],'k--');
  205. plot([medRT medRT],[-0.1 1.1],'k-');
  206. plot([p75 p75],[-0.1 1.1],'k--');
  207. scatter(pSDR(:,1),pSDR(:,2),'ko',...
  208. 'MarkerFaceColor','k','MarkerFaceAlpha',0.9,'SizeData',dotsz);
  209. set(gca,'xlim',[xmin xmax],'ylim',[-0.02 1.02],'Box','off')
  210. title('Pooled');
  211. xlabel('RT (ms)'); ylabel('SD choice-ratio')
  212. end
  213. for mi=1:2
  214. cw = [minw minw+ws];
  215. cRT_T = aRT(aRT(:,2)==mi & aRT(:,3)==1,1);
  216. cRT_SD = aRT(aRT(:,2)==mi & aRT(:,3)==3,1);
  217. cRT_ND = aRT(aRT(:,2)==mi & aRT(:,3)==2,1);
  218. cRT_A = aRT(aRT(:,2)==mi ,1);
  219. medRT = median(aRT(aRT(:,2)==mi,1));
  220. p25 = prctile(aRT(aRT(:,2)==mi,1),25);
  221. p75 = prctile(aRT(aRT(:,2)==mi,1),75);
  222. mRT = mean(aRT(aRT(:,2)==mi,1));
  223. pSDT = [];pSDND = []; pSDR = [];
  224. while cw(2) < maxw
  225. SDTratio = ...
  226. sum(cRT_SD>cw(1) & cRT_SD<=cw(2))./...
  227. (sum(cRT_T>cw(1) & cRT_T<=cw(2)) + sum(cRT_SD>cw(1) & cRT_SD<=cw(2)));
  228. SDNDratio = ...
  229. sum(cRT_SD>cw(1) & cRT_SD<=cw(2))./...
  230. (sum(cRT_SD>cw(1) & cRT_SD<=cw(2)) + sum(cRT_ND>cw(1) & cRT_ND<=cw(2))/4);
  231. SDR = sum(cRT_SD>cw(1) & cRT_SD<=cw(2))./(sum(cRT_A>cw(1) & cRT_A<=cw(2)));
  232. if ~isnan(SDTratio)
  233. pSDT=[pSDT; mean(cw) SDTratio];
  234. end
  235. if ~isnan(SDNDratio)
  236. pSDND=[pSDND; mean(cw) SDNDratio];
  237. end
  238. if ~isnan(SDR)
  239. pSDR=[pSDR; mean(cw) SDR];
  240. end
  241. cw=cw+st;
  242. end
  243. if DoPooled
  244. subplot(1,3,1+mi);
  245. else
  246. subplot(1,2,mi);
  247. end
  248. plot([0 500],[0 0],'k-'); hold on;
  249. plot([p25 p25],[-0.1 1.1],'k--');
  250. plot([medRT medRT],[-0.1 1.1],'k-');
  251. plot([p75 p75],[-0.1 1.1],'k--');
  252. scatter(pSDR(:,1),pSDR(:,2),'ko',...
  253. 'MarkerFaceColor','k','MarkerFaceAlpha',0.8,'SizeData',dotsz);
  254. set(gca,'xlim',[xmin xmax],'ylim',[-0.02 1.02],'Box','off')
  255. title(['M' num2str(mi)])
  256. xlabel('RT (ms)'); ylabel('SD choice-ratio')
  257. legend({'','p25','median','p75','SD/ALL'});
  258. end
  259. %% stats on SD ratio
  260. % proportions SD choices per octile
  261. nbins=8;
  262. for m=1:2
  263. mo(m).cnt=[];
  264. for i=1:nbins
  265. STDR(m,i).m = m;
  266. STDR(m,i).prct = i;
  267. STDR(m,i).prctval = prctile(aRT(aRT(:,2)==m,1),i*100/nbins);
  268. if i == 1
  269. STDR(m,i).SRT_SD = aRT( aRT(:,3)==3 & aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval,1);
  270. STDR(m,i).SRT_A = aRT( aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval,1);
  271. STDR(m,i).SRT_SDT = aRT( aRT(:,3)~=2 & aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval,1);
  272. else
  273. STDR(m,i).SRT_SD = aRT(aRT(:,3)==3 & aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval & aRT(:,1)> STDR(m,i-1).prctval,1);
  274. STDR(m,i).SRT_A = aRT(aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval & aRT(:,1)> STDR(m,i-1).prctval,1);
  275. STDR(m,i).SRT_SDT = aRT(aRT(:,3)~=2 & aRT(:,2)==m & aRT(:,1)< STDR(m,i).prctval & aRT(:,1)> STDR(m,i-1).prctval,1);
  276. end
  277. STDR(m,i).cnt = [length(STDR(m,i).SRT_SD) length(STDR(m,i).SRT_A) length(STDR(m,i).SRT_SDT)];
  278. mo(m).cnt=[mo(m).cnt; STDR(m,i).cnt];
  279. end
  280. % Observed data
  281. n1 = sum(mo(m).cnt(1,1)); % fastest 12.5%
  282. N1 = sum(mo(m).cnt(1,2));
  283. n2 = sum(mo(m).cnt(2:4,1)); % 12.5 - 25%
  284. N2 = sum(mo(m).cnt(2:4,2));
  285. % Pooled estimate of proportion
  286. p0 = (n1+n2) / (N1+N2);
  287. % Expected counts under H0 (null hypothesis)
  288. n10 = N1 * p0; n20 = N2 * p0;
  289. % Chi-square test, by hand
  290. observed = [n1 N1-n1 n2 N2-n2];
  291. expected = [n10 N1-n10 n20 N2-n20];
  292. chi2stat = sum((observed-expected).^2 ./ expected);
  293. p = 1 - chi2cdf(chi2stat,1);
  294. fprintf(['== Monkey ' num2str(m) ' pSD ===\n'])
  295. fprintf(['FASTEST 1/8 vs 1/8 to median\n'])
  296. fprintf(['CHISQ (1,' num2str(mo(m).cnt(1,2)) ') = ' ...
  297. num2str(chi2stat) ', p = ' num2str(p) '\n'])
  298. end