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/main.m

35 lines
1.4 KiB
Matlab

% Project Eyetracking
% Name: John Doe
% Matrikelnummer: 123456789
clear
close all
%% Definition of constants
framerate = 60; % Hz
screen_width = 0.376; % m
screen_height = 0.301; % m
screen_resolution_x = 1280; % pixel
screen_resolution_y = 1024; % pixel
fixation_x = screen_resolution_x/2; % position of fixation cross on screen
fixation_y = screen_resolution_y/2; % position of fixation cross on screen
fixation_marker = 1; % event marker for fixtion period
movement_marker = 2; % event marker for free movement period
data_files = [fullfile("..", "data", "1_1.mat"), fullfile("..", "data", "1_5.mat")];
scenes = [fullfile("..", "data", "Genesis_VIII.png"), fullfile("..", "data", "Genesis_XXXIX.png")];
%% Process files
for i = 1:length(data_files)
file = data_files(i);
scene = scenes(i);
fprintf("processing: %s\n", file)
[frame_indices, x, y, event_marker, eye_found] = load_eye_tracking_data(file);
[x_offset, y_offset] = get_fixation_offset(x, y, event_marker, fixation_marker, fixation_x, fixation_y);
[true_x, true_y] = correct_eye_positions(x, y, x_offset, y_offset);
[true_x, true_y] = fix_eye_lost(true_x, true_y, frame_indices, eye_found);
time = convert_indices_to_time(frame_indices, framerate);
fig = plot_image_position_overlay(true_x, true_y, time, scene);
saveas(fig, sprintf("test_%i", i), "pdf")
end