| function [eeg, seq_bad, origNrChannels] = SyncET2EEG(eeg, etFile, currentPath,trigger,plot) |
| origNrChannels = eeg.nbchan; |
| if plot |
| eeg = pop_importeyetracker(eeg,etFile, [trigger(1,1),trigger(1,2)] ,[1,2,3,4] ,{'TIME','L_GAZE_X','L_GAZE_Y','L_AREA'},0,1,0,1); |
| |
| else |
| eeg = pop_importeyetracker(eeg,etFile, [trigger(1,1),trigger(1,2)] ,[1,2,3,4] ,{'TIME','L_GAZE_X','L_GAZE_Y','L_AREA'},0,1,0,0); |
| end |
| |
| |
| |
| |
| xgazeChan = find(strcmp({eeg.chanlocs.labels}','L_GAZE_X')); |
| ygazeChan = find(strcmp({eeg.chanlocs.labels}','L_GAZE_Y')); |
| [eeg,~,seq_bad] = RejectEyecontin(eeg,[xgazeChan:ygazeChan] ,[1 1] ,[800 600] ,5); |
| |
| new_event = []; |
| eeg.event(1).duration=[]; |
| for ii = 1:size(seq_bad,1) |
| new_event(1,ii).type = 'bad eye'; |
| |
| new_event(1,ii).latency = seq_bad(ii,1); |
| new_event(1,ii).duration = seq_bad(ii,3); |
| new_event(1,ii).urevent = size(eeg.event,2)+ii; |
| end |
|
|
| eeg.event = [eeg.event, new_event]; |
| i = 1; |
| for ii = size(eeg.event,2)-size(new_event,2)+1:size(eeg.event,2) |
| eeg.event(1,ii).duration = seq_bad(i,3); |
| i = i+1; |
| end |
| for i = 1:size(eeg.event,2) |
| ind_sort(i,1) = eeg.event(1,i).latency; |
| end |
| [i,or] = sort(ind_sort); |
| for i = 1:size(eeg.event,2) |
| new_order(i,1) = eeg.event(1,or(i,1)); |
| end |
| eeg.event = new_order'; |
| end |