function [ fixations ] = labelFixationsViaIVT( EyeMove, mode, velocityThreshold ) %%% labels data by applying an IVT fixation algorithms %%% on the given EyeMove data %%% %%% EyeMove: eye movements of the participant [time|Lx|Ly|Rx|Ry|Hx|Hy] %%% mode: L, R %%% velocityThreshold: point-to-point velocity threshold between fixation %%% and saccade (pixel based) %%% %%% Output: %%% fixation Nx4 [posX | posY | startTimestamp | duration] %%% Created by: Jakob Karolus %%% Last updated: 2016-06-29 switch upper(mode) case 'L' eyeData = EyeMove(:,1:3); case 'R' eyeData = [EyeMove(:,1) EyeMove(:, 4:5)]; end % Implement your version of IVT here % calculate the velocities velX = diff(eyeData(:,2)); velY = diff(eyeData(:,3)); vel = sqrt(velX.^2+velY.^2); vel = [vel; 0]; % label fixation and saccade points eyeData = [eyeData zeros(size(eyeData,1),1)]; eyeData(:,4) = vel continue elseif eyeData(i,4) == 1 && startedFixation == true %(startedFixation) continue; % if we are not evaluating a fixation, and a new one doesn't start -> continue elseif eyeData(i,4) == 0 && startedFixation == false %(~startedFixation) continue; % if a fixation ends else startedFixation = false; % create X centroid meanX = mean(eyeData(fixationStartIndex:i-1,2)); % create Y centroid meanY = mean(eyeData(fixationStartIndex:i-1,3)); % starttime startTime = eyeData(fixationStartIndex,1); % duration duration = eyeData(i,1)-startTime; fixations = [fixations; [meanX meanY startTime duration]]; end end % delete fixations that are shorter than 50ms fixations = fixations(fixations(:,4)>=50,:); end