This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/projects/project_eyetracker/solution/get_fixation_offset.m

21 lines
1.1 KiB
Matlab

function [x_offset, y_offset] = get_fixation_offset(eye_x, eye_y, event_marker, fixation_event_marker, fixation_x, fixation_y)
% [x_offset, y_offset] = get_fixation_offset(eye_x_pos, eye_y_pos, event_marker, fixation_event_marker, fixation_x, fixation_y)
%
% Estimates the x, and y-offset between screen position and reported eye position while fixating
%
% Arguments:
% eye_x, eye_y: The eye positions reported by the tracker, vectors of coordinates
% event_marker: vector, the recorded event markers
% fixation_event_marker: scalar, the event marker that represents the fixation period
% fixation_x, fixation_y: scalar, the x and y position of the fixation cross on the screen
%
% Returns:
% x_offset, y_offset: scalar the deviation between reported x
% and y positions and the true positions.
eye_fixation_x_pos = median(eye_x(event_marker == fixation_event_marker));
eye_fixation_y_pos = median(eye_y(event_marker == fixation_event_marker));
x_offset = fixation_x - eye_fixation_x_pos;
y_offset = fixation_y - eye_fixation_y_pos;