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.

1
0

Figure_4_panel_ab.m 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. clear all
  2. mainfolder='';
  3. addpath(genpath([mainfolder 'subfunctions/']))
  4. addpath(genpath('subfunctions/rm_anova2'))
  5. %% Panel 1
  6. clear all
  7. %data for polarplots
  8. [oriC, oriP, oriN]=orivectors(16,6.43);
  9. theta1=oriC
  10. theta=[0 0 pi/2 pi/2 pi/2 pi/2 pi pi pi pi pi*1.5 pi*1.5 pi*1.5 pi*1.5 0 0];
  11. uno=ones(1,16)
  12. thetaall{1}=[theta theta(1)];
  13. uno=[uno uno(1)];
  14. theta1=oriC
  15. theta2=[0 0 0 0 pi/2 pi/2 pi/2 pi/2 pi pi pi pi pi*1.5 pi*1.5 pi*1.5 pi*1.5]-pi/4
  16. theta3=[theta1;theta2]
  17. theta=mean(theta3)
  18. uno=ones(1,16)
  19. thetaall{2}=[theta theta(1)];
  20. uno=[uno uno(1)];
  21. theta=oriC
  22. uno=ones(1,16)
  23. thetaall{3}=[theta theta(1)];
  24. uno=[uno uno(1)];
  25. theta1=oriC
  26. theta2=[0 0 0 0 pi/2 pi/2 pi/2 pi/2 pi pi pi pi pi*1.5 pi*1.5 pi*1.5 pi*1.5]+pi/4
  27. theta3=[theta1;theta2]
  28. theta=mean(theta3)
  29. uno=ones(1,16)
  30. thetaall{4}=[theta theta(1)];
  31. theta=[0 0 0 0 pi/2 pi/2 pi/2 pi/2 pi pi pi pi pi*1.5 pi*1.5 pi*1.5 pi*1.5]+pi/4
  32. uno=ones(1,16)
  33. thetaall{5}=[theta theta(1)];
  34. uno=[uno uno(1)];
  35. A=0.2
  36. thetaall{4}=A.*thetaall{5}+(1-A)*thetaall{3};
  37. A=1
  38. thetaall{5}=A.*thetaall{5}+(1-A)*thetaall{3};
  39. a{1}=creatcatcardeucl;
  40. a{3}=creatcontmodel(1);
  41. a{5}=creatcatcardeucl45;
  42. A=0.5;
  43. a{2}=A*a{1}+(1-A)*a{3}
  44. a{4}=A*a{5}+(1-A)*a{3}
  45. % Plotting
  46. figure;
  47. subplot(2,5,1);
  48. polarmodelplot(thetaall{1},uno)
  49. subplot(2,5,2);
  50. polarmodelplot(thetaall{2},uno)
  51. subplot(2,5,3);
  52. polarmodelplot(thetaall{3},uno)
  53. subplot(2,5,4);
  54. polarmodelplot(thetaall{4},uno)
  55. subplot(2,5,5);
  56. polarmodelplot(thetaall{5},uno)
  57. subplot(2,5,6);
  58. moldelmatplot(a{5},theta1)
  59. subplot(2,5,7);
  60. moldelmatplot(a{4},theta1)
  61. subplot(2,5,8);
  62. moldelmatplot(a{3},theta1)
  63. subplot(2,5,9);
  64. moldelmatplot(a{2},theta1)
  65. subplot(2,5,10);
  66. moldelmatplot(a{1},theta1)
  67. %% Panel 2
  68. clear all
  69. %Loading data
  70. beh=load('data_for_plots/Figure_4/all_behaviour_n41_trialbytrial_C05.mat')
  71. load('data_for_plots/Figure_4/avg_polarbias_n41_C1.mat')
  72. %Loadin eyedata
  73. load('data_for_plots/Figure_4/test1_meanrecent_100pth_n41_lastsec.mat')
  74. eye.all{1}(:,1)=av_a1cued1(:)-av_a1cued2(:)
  75. eye.all{1}(:,2)=av_a2cued1(:)-av_a2cued2(:)
  76. load('data_for_plots/Figure_4/test2_meanrecent_100pth_n41_lastsec.mat')
  77. eye.all{1}(:,3)=av_a1cued1(:)-av_a1cued2(:)
  78. eye.all{1}(:,4)=av_a2cued1(:)-av_a2cued2(:)
  79. fp=(~isnan(eye.all{1}(:,1))+~isnan(eye.all{1}(:,2))...
  80. +~isnan(eye.all{1}(:,3))+~isnan(eye.all{1}(:,4)))==4; %checking we have data from all participants
  81. eye.all{1}=eye.all{1}(:,:)
  82. figure('Position' ,[100 600 950 600]);
  83. %behavioural plot
  84. subplot(1,3,1)
  85. colores=[0 0 0];
  86. % barplotbias(beh.all{1},[-0.51,0.51],'behaviour','A (bias index)',1)
  87. lineartrendana(beh.all,1,1,[-.4,0.7],'behaviour','B (bias index)',colores,-0.6)
  88. % polarplot of behav bias
  89. oi=avg_bCueor;
  90. oiac=avg_aCueor;
  91. yourBias=[];
  92. yourAccu=[];
  93. for ppp=1:size(oi,2)
  94. behB=oi(:,ppp)'; %BheaviouralBias
  95. s=avg_Paramsr(ppp,1); % noise (in memory/decision-making)
  96. A=avg_Paramsr(ppp,2); % Key Parameter (squircle) 0: all circle; 1: all square
  97. C=avg_Paramsr(ppp,3);
  98. makefig=0;
  99. [yourAccu(:,ppp) yourBias(:,ppp)]=squircleBehave2compB(s,A,C,behB,makefig);
  100. end
  101. counter=1;
  102. subplot(1,3,2)
  103. polarplot([0 pi],[1 1],'k-','LineWidth',1);hold on;
  104. polarplot([pi/2 pi*1.5],[1 1],'k-','LineWidth',1);hold on;
  105. Aave=round(mean(avg_Paramsr(:,2),1),3)
  106. Astd=std(avg_Paramsr(:,2),0,1);
  107. quickplotcompBerrors(bb',(yourBias),(oi),[''],1,Aave);
  108. counter=counter+1,
  109. set(gca,'GridAlpha',0.25);
  110. set(gca,'FontSize',20);
  111. %eye plot
  112. subplot(1,3,3)
  113. lineartrendana(eye.all,1,0,[-.1,.175],'gaze','\Delta (rho) repulsion - attraction',colores,-0.15)
  114. %% Analysis
  115. %T test againg 0
  116. mmm=mean(beh.all{1}(:,:),2);
  117. mean(beh.all{1}) %mean of B index in each condition
  118. h = lillietest(mmm);
  119. [h,p,ci,stats] = ttest(mmm,0)
  120. [h,p,ci,stats] = ttest(beh.all{1},0)
  121. [p,h,stats] = ranksum(mmm,0)
  122. % Anova
  123. al=[]
  124. al= cat(1,beh.all{1}(:,1),beh.all{1}(:,2),beh.all{1}(:,3),beh.all{1}(:,4))';
  125. p=size(beh.all{1},1);
  126. S=[1:p,1:p,1:p,1:p];
  127. F1=[ones(p,1);ones(p,1)*2;ones(p,1);ones(p,1)*2]'
  128. F2=[ones(p*2,1);ones(p*2,1)*2]'
  129. FACTNAMES={'item order', 'test order'}
  130. stats = rm_anova2(al,S,F1,F2,FACTNAMES)
  131. totalSS=sum([stats{2,2},stats{3,2},stats{4,2},stats{5,2},stats{6,2},stats{7,2}]);
  132. etaS=[stats{2,2}/totalSS,stats{3,2}/totalSS,stats{4,2}/totalSS]
  133. %% Linear trend analysis beh
  134. b_beh=lineartrendana(beh.all,0);
  135. %%
  136. %T test againg 0
  137. mmm=mean(eye.all{1}(:,:),2);
  138. h = lillietest(mmm);
  139. [h,p,ci,stats] = ttest(mmm,0)
  140. [h,p,ci,stats] = ttest(eye.all{1},0)
  141. [p,h,stats] = ranksum(mmm,0)
  142. 1
  143. % Anova
  144. al=[]
  145. al= cat(1,eye.all{1}(fp,1),eye.all{1}(fp,2),eye.all{1}(fp,3),eye.all{1}(fp,4))';
  146. p=size(eye.all{1}(fp,1),1);
  147. S=[1:p,1:p,1:p,1:p];
  148. F1=[ones(p,1);ones(p,1)*2;ones(p,1);ones(p,1)*2]'
  149. F2=[ones(p*2,1);ones(p*2,1)*2]'
  150. FACTNAMES={'item order', 'test order'}
  151. stats = rm_anova2(al,S,F1,F2,FACTNAMES)
  152. totalSS=sum([stats{2,2},stats{3,2},stats{4,2},stats{5,2},stats{6,2},stats{7,2}]);
  153. etaS=[stats{2,2}/totalSS,stats{3,2}/totalSS,stats{4,2}/totalSS]
  154. %% Linear trend analysis eye
  155. b_eye=lineartrendana(eye.all,0,0,[-.075,.2]);
  156. %% Correlation between slopes in beh and eyes
  157. [rho pval]=corr(b_beh',b_eye','Type','Pearson')
  158. %%
  159. figure; % barplotbias(beh.all{1},[-0.51,0.51],'behaviour','A (bias index)',1)
  160. lineartrendana(beh.all,1,1,[-.9,0.9],'behaviour','B (bias index)')
  161. %% Subfunctions
  162. function polarmodelplot(theta,uno)
  163. polarplot(theta,uno,'k-o','MarkerFaceColor', 'k', 'MarkerSize', 8);
  164. r=gca;
  165. r.FontSize=20;
  166. r.RTickLabel=[];
  167. r.RGrid='off';
  168. rlim([0 1.25])
  169. c=creat_u_d_model;
  170. d=creat_l_r_model;
  171. aa=c+d;
  172. cont=creatcontmodel(1);
  173. A=0.5;
  174. a=A*aa+(1-A)*cont
  175. end
  176. function moldelmatplot(a,theta1)
  177. imagesc(a);hold on;
  178. xlabel('orientation (°)')
  179. ylabel('orientation (°)')
  180. xticks = 1:16; %adjust as appropriate, positive integers only
  181. xlabels = round(rad2deg(theta1(1:4:16))); %time labels
  182. set(gca, 'XTick', 1:4:16, 'XTickLabel', xlabels, ...
  183. 'YTick', 1:4:16, 'YTickLabel', xlabels, 'YAxisLocation','left','FontSize',20);
  184. end
  185. function barplotbias(data,yl,tito,yla,labels,sublabels,colores,xpos)
  186. ax=notBoxPlot(data,'style','sdline')
  187. line([0,5], [0,0], 'Color', 'k','LineStyle',':','LineWidth',2);hold on;
  188. line([2.5,2.5], [-10,10], 'Color', 'k','LineStyle','--','LineWidth',2);hold on;
  189. for i=1:4
  190. ax(i).semPtch.FaceColor = [0.75 0.75 0.75];
  191. ax(i).semPtch.EdgeColor = [0.75 0.75 0.75];
  192. ax(i).semPtch.LineWidth = 3;
  193. ax(i).data.MarkerSize = 8;
  194. ax(i).mu.Color = [0 0 0];
  195. ax(i).sd.Color = [0 0 0];
  196. end
  197. xticks([1:4])
  198. xticklabels(labels)
  199. % xtickangle(45)
  200. ylim(yl)
  201. xlim([0.5 4.5])
  202. ylabel(yla)
  203. set(gca,'FontSize',20);
  204. title(tito)
  205. text(1.5,xpos,sublabels{1},'HorizontalAlignment','center','FontSize',20,'FontWeight','bold')
  206. text(3.5,xpos,sublabels{2},'HorizontalAlignment','center','FontSize',20,'FontWeight','bold')
  207. end
  208. function ball=lineartrendana(all,plotyes,beh,ylimits,btit,ylab,colores,xpos)
  209. distances(:,1)=all{1}(:,2) %stim 2 cued 1st
  210. distances(:,2)=all{1}(:,1) %stim 1 cued 1st
  211. distances(:,3)=all{1}(:,4)%stim 2 cued 2nd
  212. distances(:,4)=all{1}(:,3) %stim 1 cued 2nd
  213. %% Check linear trend
  214. % ball=[];
  215. % yfit = [];
  216. for ppp = 1:size(distances,1)
  217. tof=[];
  218. for c=1:size(distances,2);
  219. tof=[tof; distances(ppp,c)];
  220. end
  221. [b,dev,stats] = glmfit(1:size(distances,2),tof,'normal');
  222. yfit(ppp,:) = polyval([b(2,1),b(1,1)],[1,2,3,4]);
  223. ball(ppp) = b(2);
  224. end
  225. [h,p,ci,stats] = ttest(ball,0)
  226. if plotyes
  227. if beh
  228. labels={'Stim 2 ','Stim 1','Stim 2','Stim 1'};
  229. sublabel={'test 1', 'test 2'};
  230. else
  231. labels={'Stim 2 ','Stim 1','Stim 2','Stim 1'};
  232. % labels={'stim 2 - delay 1','stim 1 - delay 1','stim 2 - delay 2','stim 1 - delay 2'};
  233. sublabel={'delay 1', 'delay 2'};
  234. end
  235. plot(yfit','Color',[colores 0.25],'LineWidth',1);hold on;
  236. plot(mean(yfit,1)','Color',[0 0 0],'LineWidth',3);hold on;
  237. barplotbias(distances,ylimits,btit,ylab,labels,sublabel,colores,xpos)
  238. end
  239. end