123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- clear all;
- mainfolder=''
- load([mainfolder 'good_partis.mat']) %list of participant with a good performance
- partis=good_partis';
- partis_sub=good_partis';
- yp=(-200:1:200); % screen area of interest (pixel)
- xp=(-200:1:200);
- 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.
- hhmap_notrot=nan(length(partis),9,16,length(yp),length(xp));
- realig=1; %realigning
- config{1}.fname= 'stim1'; %first object
- config{2}.fname= 'stim2'; %second object
- config{3}.fname= 'delay1_stim1'; %first delay
- config{4}.fname= 'delay1_stim2'; %first delay
- config{5}.fname= 'delay2_stim1'; %second delay
- config{6}.fname= 'delay2_stim2'; %second delay
- config{1}.timofi= [100 500]; %first object
- config{2}.timofi= [1100 1500]; %second object
- config{3}.timofi= [2350 5850]; %first delay
- config{4}.timofi= [2350 5850]; %first delay
- config{5}.timofi= [350 2850]; %second delay
- config{6}.timofi= [350 2850]; %second delay
- config{1}.object=1;
- config{2}.object=2;
- config{3}.object=1;
- config{4}.object=2;
- config{5}.object=1;
- config{6}.object=2;
- config{1}.retrocue=0;
- config{2}.retrocue=0;
- config{3}.retrocue=1;
- config{4}.retrocue=2;
- config{5}.retrocue=2;
- config{6}.retrocue=1;
- % Data to load
- config{1}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
- config{2}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
- config{3}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
- config{4}.toloadfolder='/eyelink_preprocessed/object_1_onset_11_seconds/';
- config{5}.toloadfolder='/eyelink_preprocessed/2nd_cue_onset_17_5__seconds/';
- config{6}.toloadfolder='/eyelink_preprocessed/2nd_cue_onset_17_5__seconds/';
- config{1}.title='stim 1';
- config{2}.title='stim 2';
- config{3}.title='delay 1- stim 1';
- config{4}.title='delay 1- stim 2';
- config{5}.title='delay 2- stim 1';
- config{6}.title='delay 2- stim 2';
- plot_avg_point=0; % plotting a avg point
- %%
-
- for conf= 1:6 % for each possible configuration pattern
-
- for ppp=1:length(partis)
-
- %% Loading dataset
- toload =[mainfolder config{conf}.toloadfolder partis{ppp,:} '.mat'];
- load(toload)
-
- %Loading logfiles
-
- subtable=[];
-
- if strcmp( partis_sub{ppp,:},'p11')
- load([mainfolder '/logfiles/resultfile_p11_table_repaired.mat']);
- subtable=sub;
- else
-
- sub = tdfread([mainfolder '/logfiles/resultfile_' partis_sub{ppp,:} '.txt'],'tab'); %Logfile for this participant
- subtable=struct2table(sub);
- end
-
- %% Adding info about the general object id
-
- allobject={'01_lamp','02_gaze','01_nigh',...
- '02_tabl','01_ligh','02_radi',...
- '02_crow','01_outd','01_cand'};
-
- subtable.object_1_name=char(subtable.object_1_name);
- subtable.object_2_name=char(subtable.object_2_name);
-
- %adding info about item ID
-
- for ttt=1:size(subtable,1)
-
- gid1=find(strcmp(subtable.object_1_name(ttt,1:7) ,allobject));
- gid2=find(strcmp(subtable.object_2_name(ttt,1:7) ,allobject));
- subtable.object_1_gen_id(ttt)=gid1;
- subtable.object_2_gen_id(ttt)=gid2;
-
- data_epoch_recenter.trialinfo.object_1_gen_id(ttt)=gid1;
- data_epoch_recenter.trialinfo.object_2_gen_id(ttt)=gid2;
-
- end
- %% If the position is out of the threshold, it will be a NaN
- %
- data_art_reject=data_epoch_recenter;
- thr=100; %threshold in pixels
-
- for tr = 1:size(data_epoch_recenter.eyedat,1) %trial
- for tt=1:size(data_epoch_recenter.eyedat,3) %time
-
- if abs(data_epoch_recenter.eyedat(tr,1,tt))>thr|abs(data_epoch_recenter.eyedat(tr,2,tt))>thr
- data_art_reject.eyedat(tr,:,tt)=NaN;
- end
-
- end
- end
-
- %%
- %checking the where is time window of interest
-
- tf1=find(data_art_reject.time==config{conf}.timofi(1));
- tf2=find(data_art_reject.time==config{conf}.timofi(2));
-
- time=(tf1:tf2);
-
- objlistid=unique(data_art_reject.trialinfo.object_1_gen_id);
- rotlist=unique(data_art_reject.trialinfo.object_1_rot);
-
- for k =1:length(rotlist) % loop - rotations
-
- for i=1:9%length(objlistid) % loop - object id (1 to 9)
-
- %keep in mind that each participant only use 3 object id
-
- %trials of interest
-
- if config{conf}.object==1
-
- if config{conf}.retrocue==0;
- triales = find(data_epoch_recenter.trialinfo.object_1_rot==rotlist(k)...
- &data_epoch_recenter.trialinfo.object_1_gen_id==i);%objlistid(i));
- else
- triales = find(data_epoch_recenter.trialinfo.object_1_rot==rotlist(k)...
- &data_epoch_recenter.trialinfo.object_1_gen_id==i&data_epoch_recenter.trialinfo.retrocue==config{conf}.retrocue);%objlistid(i));
- end
-
- elseif config{conf}.object==2
-
- if config{conf}.retrocue==0;
- triales = find(data_epoch_recenter.trialinfo.object_2_rot==rotlist(k)...
- &data_epoch_recenter.trialinfo.object_2_gen_id==i);%objlistid(i));
- else
- triales = find(data_epoch_recenter.trialinfo.object_2_rot==rotlist(k)...
- &data_epoch_recenter.trialinfo.object_2_gen_id==i&data_epoch_recenter.trialinfo.retrocue==config{conf}.retrocue);%objlistid(i));
- end
-
- end
-
- combimap=nan(length(yp),length(xp));
- avg_c=nan(1,2);
-
- if ~isempty(triales)
-
- eyedat = data_art_reject.eyedat(triales,1:2,time);
-
- %averaging data on time
-
- eyedat=nanmean(eyedat,3);
- mateye=zeros(length(yp),length(xp));
-
- avg_c(1)=nanmean(eyedat(:,2));
- avg_c(2)=nanmean(eyedat(:,1));
-
- counter=0;
- for ttt = 1:size(eyedat,1)
-
- if ~isempty(eyedat(ttt,1))&~isempty(eyedat(ttt,2))
-
- counter=counter+1;
-
- %finding the eye position in an area
- yn=find(round(eyedat(ttt,2))==yp);
- xn=find(round(eyedat(ttt,1))==xp);
-
- mateye(yn,xn)= mateye(yn,xn)+1;
-
- end
- end
-
- combimap(:,:)=mateye./counter;
-
- end
- if realig==1;
- bbb=imrotate(combimap,rotlist(k),'nearest','crop');
- else
- bbb=combimap;
- end
- hhmap(ppp,i,k,:,:)=bbb;
- hhmap_notrot(ppp,i,k,:,:)=combimap;
-
- avg_coord(ppp,i,k,:)=avg_c;
-
- canvas=zeros(size(combimap));
- rotcanvas=zeros(size(combimap));
-
- d1=nan;
- d2=nan;
-
- if ~isnan(sum(avg_c))
- popo=avg_c+round(size(combimap,1)/2);
- canvas(round(popo(1)),round(popo(2)))=1;
- rotcanvas=imrotate(canvas,rotlist(k),'nearest','crop');
-
- dd1=find(sum(rotcanvas,1)>0);
- dd2=find(sum(rotcanvas,2)>0);
-
- if sum(dd1)~=0|sum(dd2)~=0
- d1=dd1(1);
- d2=dd2(1);
- end
- end
- avg_coord_rot(ppp,i,k,:)=[d1 d2];
-
-
- end
- end
- ppp
- end
-
- fold_tosave =[mainfolder '/gaze_heatmaps/' config{conf}.fname];
- save (fold_tosave,'hhmap','avg_coord_rot','-v7.3')
-
- end
|