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.

creating_gaze_heatmap_v5m.m 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. clear all;
  2. mainfolder=''
  3. load([mainfolder 'good_partis.mat']) %list of participant with a good performance
  4. partis=good_partis';
  5. partis_sub=good_partis';
  6. yp=(-200:1:200); % screen area of interest (pixel)
  7. xp=(-200:1:200);
  8. hhmap=nan(length(partis),9,16,length(yp),length(xp)); %results are return in these format. Dimension being (i) participants (ii) item ID (among 9 items) (iii) orientation (iv) and (v) screen area in y and x axis respec.
  9. hhmap_notrot=nan(length(partis),9,16,length(yp),length(xp));
  10. realig=1; %realigning
  11. config{1}.fname= 'stim1'; %first object
  12. config{2}.fname= 'stim2'; %second object
  13. config{3}.fname= 'delay1_stim1'; %first delay
  14. config{4}.fname= 'delay1_stim2'; %first delay
  15. config{5}.fname= 'delay2_stim1'; %second delay
  16. config{6}.fname= 'delay2_stim2'; %second delay
  17. config{1}.timofi= [100 500]; %first object
  18. config{2}.timofi= [1100 1500]; %second object
  19. config{3}.timofi= [2350 5850]; %first delay
  20. config{4}.timofi= [2350 5850]; %first delay
  21. config{5}.timofi= [350 2850]; %second delay
  22. config{6}.timofi= [350 2850]; %second delay
  23. config{1}.object=1;
  24. config{2}.object=2;
  25. config{3}.object=1;
  26. config{4}.object=2;
  27. config{5}.object=1;
  28. config{6}.object=2;
  29. config{1}.retrocue=0;
  30. config{2}.retrocue=0;
  31. config{3}.retrocue=1;
  32. config{4}.retrocue=2;
  33. config{5}.retrocue=2;
  34. config{6}.retrocue=1;
  35. % Data to load
  36. config{1}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
  37. config{2}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
  38. config{3}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
  39. config{4}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
  40. config{5}.toloadfolder='/eyelink_preprocessed/2nd_cue_onset_17_5__seconds/';
  41. config{6}.toloadfolder='/eyelink_preprocessed/2nd_cue_onset_17_5__seconds/';
  42. config{1}.title='stim 1';
  43. config{2}.title='stim 2';
  44. config{3}.title='delay 1- stim 1';
  45. config{4}.title='delay 1- stim 2';
  46. config{5}.title='delay 2- stim 1';
  47. config{6}.title='delay 2- stim 2';
  48. plot_avg_point=0; % plotting a avg point
  49. %%
  50. for conf= 1:6 % for each possible configuration pattern
  51. for ppp=1:length(partis)
  52. %% Loading dataset
  53. toload =[mainfolder config{conf}.toloadfolder partis{ppp,:} '.mat'];
  54. load(toload)
  55. %Loading logfiles
  56. subtable=[];
  57. if strcmp( partis_sub{ppp,:},'p11')
  58. load([mainfolder '/logfiles/resultfile_p11_table_repaired.mat']);
  59. subtable=sub;
  60. else
  61. sub = tdfread([mainfolder '/logfiles/resultfile_' partis_sub{ppp,:} '.txt'],'tab'); %Logfile for this participant
  62. subtable=struct2table(sub);
  63. end
  64. %% Adding info about the general object id
  65. allobject={'01_lamp','02_gaze','01_nigh',...
  66. '02_tabl','01_ligh','02_radi',...
  67. '02_crow','01_outd','01_cand'};
  68. subtable.object_1_name=char(subtable.object_1_name);
  69. subtable.object_2_name=char(subtable.object_2_name);
  70. %adding info about item ID
  71. for ttt=1:size(subtable,1)
  72. gid1=find(strcmp(subtable.object_1_name(ttt,1:7) ,allobject));
  73. gid2=find(strcmp(subtable.object_2_name(ttt,1:7) ,allobject));
  74. subtable.object_1_gen_id(ttt)=gid1;
  75. subtable.object_2_gen_id(ttt)=gid2;
  76. data_epoch_recenter.trialinfo.object_1_gen_id(ttt)=gid1;
  77. data_epoch_recenter.trialinfo.object_2_gen_id(ttt)=gid2;
  78. end
  79. %% If the position is out of the threshold, it will be a NaN
  80. %
  81. data_art_reject=data_epoch_recenter;
  82. thr=100; %threshold in pixels
  83. for tr = 1:size(data_epoch_recenter.eyedat,1) %trial
  84. for tt=1:size(data_epoch_recenter.eyedat,3) %time
  85. if abs(data_epoch_recenter.eyedat(tr,1,tt))>thr|abs(data_epoch_recenter.eyedat(tr,2,tt))>thr
  86. data_art_reject.eyedat(tr,:,tt)=NaN;
  87. end
  88. end
  89. end
  90. %%
  91. %checking the where is time window of interest
  92. tf1=find(data_art_reject.time==config{conf}.timofi(1));
  93. tf2=find(data_art_reject.time==config{conf}.timofi(2));
  94. time=(tf1:tf2);
  95. objlistid=unique(data_art_reject.trialinfo.object_1_gen_id);
  96. rotlist=unique(data_art_reject.trialinfo.object_1_rot);
  97. for k =1:length(rotlist) % loop - rotations
  98. for i=1:9%length(objlistid) % loop - object id (1 to 9)
  99. %keep in mind that each participant only use 3 object id
  100. %trials of interest
  101. if config{conf}.object==1
  102. if config{conf}.retrocue==0;
  103. triales = find(data_epoch_recenter.trialinfo.object_1_rot==rotlist(k)...
  104. &data_epoch_recenter.trialinfo.object_1_gen_id==i);%objlistid(i));
  105. else
  106. triales = find(data_epoch_recenter.trialinfo.object_1_rot==rotlist(k)...
  107. &data_epoch_recenter.trialinfo.object_1_gen_id==i&data_epoch_recenter.trialinfo.retrocue==config{conf}.retrocue);%objlistid(i));
  108. end
  109. elseif config{conf}.object==2
  110. if config{conf}.retrocue==0;
  111. triales = find(data_epoch_recenter.trialinfo.object_2_rot==rotlist(k)...
  112. &data_epoch_recenter.trialinfo.object_2_gen_id==i);%objlistid(i));
  113. else
  114. triales = find(data_epoch_recenter.trialinfo.object_2_rot==rotlist(k)...
  115. &data_epoch_recenter.trialinfo.object_2_gen_id==i&data_epoch_recenter.trialinfo.retrocue==config{conf}.retrocue);%objlistid(i));
  116. end
  117. end
  118. combimap=nan(length(yp),length(xp));
  119. avg_c=nan(1,2);
  120. if ~isempty(triales)
  121. eyedat = data_art_reject.eyedat(triales,1:2,time);
  122. %averaging data on time
  123. eyedat=nanmean(eyedat,3);
  124. mateye=zeros(length(yp),length(xp));
  125. avg_c(1)=nanmean(eyedat(:,2));
  126. avg_c(2)=nanmean(eyedat(:,1));
  127. counter=0;
  128. for ttt = 1:size(eyedat,1)
  129. if ~isempty(eyedat(ttt,1))&~isempty(eyedat(ttt,2))
  130. counter=counter+1;
  131. %finding the eye position in an area
  132. yn=find(round(eyedat(ttt,2))==yp);
  133. xn=find(round(eyedat(ttt,1))==xp);
  134. mateye(yn,xn)= mateye(yn,xn)+1;
  135. end
  136. end
  137. combimap(:,:)=mateye./counter;
  138. end
  139. if realig==1;
  140. bbb=imrotate(combimap,rotlist(k),'nearest','crop');
  141. else
  142. bbb=combimap;
  143. end
  144. hhmap(ppp,i,k,:,:)=bbb;
  145. hhmap_notrot(ppp,i,k,:,:)=combimap;
  146. avg_coord(ppp,i,k,:)=avg_c;
  147. canvas=zeros(size(combimap));
  148. rotcanvas=zeros(size(combimap));
  149. d1=nan;
  150. d2=nan;
  151. if ~isnan(sum(avg_c))
  152. popo=avg_c+round(size(combimap,1)/2);
  153. canvas(round(popo(1)),round(popo(2)))=1;
  154. rotcanvas=imrotate(canvas,rotlist(k),'nearest','crop');
  155. dd1=find(sum(rotcanvas,1)>0);
  156. dd2=find(sum(rotcanvas,2)>0);
  157. if sum(dd1)~=0|sum(dd2)~=0
  158. d1=dd1(1);
  159. d2=dd2(1);
  160. end
  161. end
  162. avg_coord_rot(ppp,i,k,:)=[d1 d2];
  163. end
  164. end
  165. ppp
  166. end
  167. fold_tosave =[mainfolder '/gaze_heatmaps/' config{conf}.fname];
  168. save (fold_tosave,'hhmap','avg_coord_rot','-v7.3')
  169. end