Figure_4_timeline.m 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. mainfolder='';
  2. addpath(genpath([mainfolder 'subfunctions/']))
  3. addpath(genpath(['subfunctions/rm_anova2']))
  4. %%
  5. % GENERAL DIFFERENCE BETWEEN MODELS DURING DELAY (CUED UNCUED) (cat cardinal model vs
  6. % anti cardinal model)
  7. clear all
  8. mainfolder='';
  9. %% Uncomment to load the data
  10. %
  11. % %1 cued
  12. % folder{1}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_1_cued_cat_udlr_Pearson/']
  13. % folder{2}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_1_cued_cat_udlr45_Pearson/']
  14. %
  15. % %1 uncued
  16. % folder{3}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_1_uncued_cat_udlr_Pearson/']
  17. % folder{4}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_1_uncued_cat_udlr45_Pearson/']
  18. %
  19. % %2 cued
  20. % folder{5}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_2_cued_cat_udlr_Pearson/']
  21. % folder{6}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_2_cued_cat_udlr45_Pearson/']
  22. %
  23. % %2 uncued
  24. % folder{7}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_2_uncued_cat_udlr_Pearson/']
  25. % folder{8}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_2_uncued_cat_udlr45_Pearson/']
  26. %
  27. % % 1 and 2 cued - circle
  28. % folder{9}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_1_cued_Pearson/']
  29. % folder{10}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/single_trial_RSA_first_check_object_2_cued_Pearson/']
  30. %
  31. %
  32. % load([mainfolder, 'good_partis.mat']) %list of participant with a good performance
  33. % partis=good_partis';
  34. %
  35. %
  36. % [RHO_id_group,time]=loadingrsa(folder,partis)
  37. %
  38. %
  39. %
  40. % %% Loading 2 delay
  41. %
  42. % %1 cued
  43. % folder{1}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_1_cued_cat_udlr_Pearson/']
  44. % folder{2}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_1_cued_cat_udlr45_Pearson/']
  45. %
  46. % %1 uncued
  47. % folder{3}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_1_uncued_cat_udlr_Pearson/']
  48. % folder{4}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_1_uncued_cat_udlr45_Pearson/']
  49. %
  50. % %2 cued
  51. % folder{5}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_2_cued_cat_udlr_Pearson/']
  52. % folder{6}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_2_cued_cat_udlr45_Pearson/']
  53. %
  54. % %2 uncued
  55. % folder{7}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_2_uncued_cat_udlr_Pearson/']
  56. % folder{8}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_2_uncued_cat_udlr45_Pearson/']
  57. %
  58. % % 1 2 cued circle
  59. % folder{9}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_1_uncued_Pearson/']
  60. % folder{10}=[mainfolder 'results/mean_recentered_th100/euclideanmodels/2nd_cue/single_trial_RSA_first_check_object_2_uncued_Pearson/']
  61. %
  62. % load([mainfolder, 'good_partis.mat']) %list of participant with a good performance
  63. % partis=good_partis';
  64. %
  65. % [RHO_id_group2,time2]=loadingrsa(folder,partis)
  66. %% Optional -> Loading the data ready to be plotted
  67. load('data_for_plots/Figure_3/data_n41_2022.mat');
  68. %% delay 1
  69. %ori1 cued
  70. a1cued{1}=RHO_id_group{1}; % model model 1
  71. a1cued{2}=RHO_id_group{2}; % model model 2 (anticardinal)
  72. %ori1 uncued
  73. a1uncued{1}=RHO_id_group{3}; % model model 1
  74. a1uncued{2}=RHO_id_group{4}; % model model 2 (anticardinal)
  75. %ori2 cued
  76. a2cued{1}=RHO_id_group{5}; % model model 1
  77. a2cued{2}=RHO_id_group{6}; % model model 2 (anticardinal)
  78. %ori2 uncued
  79. a2uncued{1}=RHO_id_group{7}; % model model 1
  80. a2uncued{2}=RHO_id_group{8}; % model model 2 (anticardinal)
  81. a1circle=RHO_id_group{9}; % model circle 1
  82. a2circle=RHO_id_group{10}; % model cicle 2
  83. %% delay 2
  84. %ori1 cued
  85. a1cued2{1}=RHO_id_group2{1}; % model model 1
  86. a1cued2{2}=RHO_id_group2{2}; % model model 2 (anticardinal)
  87. %ori1 uncued
  88. a1uncued2{1}=RHO_id_group2{3}; % model model 1
  89. a1uncued2{2}=RHO_id_group2{4}; % model model 2 (anticardinal)
  90. %ori2 cued
  91. a2cued2{1}=RHO_id_group2{5}; % model model 1
  92. a2cued2{2}=RHO_id_group2{6}; % model model 2 (anticardinal)
  93. %ori2 uncued
  94. a2uncued2{1}=RHO_id_group2{7}; % model model 1
  95. a2uncued2{2}=RHO_id_group2{8}; % model model 2 (anticardinal)
  96. a1circle2=RHO_id_group2{9}; % model circle 1
  97. a2circle2=RHO_id_group2{10}; % model cicle 2
  98. %% Uncomment to run the cluster perm tests
  99. % %% Cluster analysis of the difference (delay 1)
  100. %
  101. % %Setting times (from -100 stim onset until the end of the delay period)
  102. % t1=find(time==-100)
  103. % t2=find(time==5850)
  104. % t1_2=find(time==900)
  105. % [timesignclust cluspval] = cluster_dif(a1cued,a2cued,time,t1,t2,t1_2)
  106. %
  107. % % mean([timesignclust(1,1) timesignclust(2,1)]) %average of "starting" point;
  108. %
  109. % %% Cluster analysis of the difference within-between (delay 2)
  110. %
  111. % %Setting times (from -100 stim onset until the end of the delay period)
  112. % t1=find(time2==-100)
  113. % t2=find(time2==2850)
  114. % t1_2=find(time2==-100)
  115. % [timesignclust2 cluspval2] = cluster_dif(a1uncued2,a2uncued2,time2,t1,t2,t1_2)
  116. %
  117. % % mean([timesignclust(1,1) timesignclust(2,1)]) %average of "starting" point;
  118. %% Delay 1 fig
  119. %% mode 3
  120. coloresb=(colormap((parula(5))));
  121. coloresb(6,:)=[0 0 0];
  122. coloresb(1,:)=[1 0 0];
  123. coloresb(3,:)=[1 0 0];
  124. figure('Position',([200 800 750 700]))
  125. subplot(2,1,1)
  126. colores=coloresb([1 2 3 6 6],:)
  127. leng1='repulsion (B=1)'
  128. leng2='attraction (B=-1)'
  129. titu=''
  130. xl=[-500 5850];
  131. yl=[-0.02 0.15];
  132. pval=0.05
  133. spa=0.1
  134. toi=[2300 5000]
  135. plot3lines_models(time,a1cued,colores,xl,yl,leng1,leng2,titu,0,'time (ms)',1,timesignclust(1,:),colores(1,:),nanmean(a1circle,2),colores(4,:),'unbiased (B=0)',1)
  136. set(gca,'FontSize',20);
  137. subplot(2,1,2)
  138. titu=''
  139. plot3lines_models(time,a2cued,colores,xl,yl,leng1,leng2,titu,0,'time (ms)',1,timesignclust(2,:),colores(1,:),nanmean(a2circle,2),colores(4,:),'unbiased (B=0)',0)
  140. set(gca,'FontSize',20);
  141. %% Delay 2 fig
  142. figure('Position',([200 800 420 700]))
  143. subplot(2,1,1)
  144. leng1='repulsion (B=1)'
  145. leng2='attraction (B=-1)'
  146. titu=''
  147. xl=[-300 2850];
  148. yl=[-0.02 0.15];
  149. pval=0.05
  150. spa=0.1
  151. toi=[2500 5000]
  152. plot3lines_models2nd2(time2,a1uncued2,colores,xl,yl,leng1,leng2,titu,0,'time (ms) from Cue 2',1,timesignclust2(1,:),colores(1,:),nanmean(a1circle2,2),colores(4,:),'unbiased (B=0)',0)
  153. set(gca,'FontSize',20);
  154. subplot(2,1,2)
  155. titu=''
  156. plot3lines_models2nd2(time2,a2uncued2,colores,xl,yl,leng1,leng2,titu,0,'time (ms) from Cue 2',1,timesignclust2(2,:),colores(1,:),nanmean(a2circle2,2),colores(4,:),'unbiased (B=0)',0)
  157. set(gca,'FontSize',20);
  158. %% subfuction
  159. function [RHO_id_group,time]=loadingrsa(folder,partis)
  160. counter=1;
  161. for ppp=1:length(partis)
  162. counterf=1;
  163. for fff=1:size(folder,2)
  164. toload=[folder{fff}, partis{ppp,:},'.mat']
  165. load(toload)
  166. RHO_id_group{counterf}(:,counter)=squeeze(nanmean(RSA_obj_rot.rho(:,:,:),1));
  167. counterf=counterf+1;
  168. end
  169. counter=counter+1;
  170. end
  171. time=RSA_obj_rot.time;
  172. end
  173. function [timesignclust cluspv] = cluster_dif(a1_1,a2_1,time_1,t1,t2,t1_2)
  174. %ori1 cued
  175. wi1 =a1_1{1}(t1:t2,:); % with 1
  176. bet1 =a1_1{2}(t1:t2,:); % bet 1
  177. %ori2 cued
  178. wi2 =a2_1{1}(t1_2:t2,:); % w 2
  179. bet2 =a2_1{2}(t1_2:t2,:); % betwen 2
  180. RHOD_wi{1}=wi1();
  181. RHOD_wi{2}=wi2();
  182. RHOD_be{1}=bet1();
  183. RHOD_be{2}=bet2();
  184. pv_cluster=0.05; % p-vals for clust perm test
  185. % az=zeros(size(RHOD_diff{1})); % matrix to be compare (in this case against 0);
  186. timesall{1}=time_1(t1:t2);
  187. timesall{2}=time_1(t1_2:t2);
  188. [timesignclust cluspv]=allclustperm2(RHOD_wi,timesall,RHOD_be,pv_cluster) % output variable (rows -> lines; columns -> start and end (ms))
  189. end
  190. function [timesignclust cluspv]=allclustperm2(RHO_all,time,az,pv_cluster)
  191. timesignclust=nan(size(RHO_all,2),2); % output variable (rows -> lines; columns -> start and end (ms))
  192. for r=1:size(RHO_all,2);
  193. [clusters, p_values, t_sums, permutation_distribution] =permutest(RHO_all{r},az{r},1,0.05,20000)
  194. if p_values(1)<pv_cluster
  195. timesignclust(r,1)=time{r}(clusters{1}(1))
  196. timesignclust(r,2)=time{r}(clusters{1}(end))
  197. end
  198. cluspv(r)=p_values(1);
  199. end
  200. end