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 tic % 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(length(vel), 1)]; eyeData(vel < velocityThreshold, 4) = 1; % collapse consecutive points into "event regions" (fixation/saccade) startFixIdx = find(diff(eyeData(:,4))==1)+1; endFixIdx = find(diff(eyeData(:,4))==-1); if(endFixIdx(1)