-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetEyeDirMtx.m
More file actions
33 lines (27 loc) · 844 Bytes
/
getEyeDirMtx.m
File metadata and controls
33 lines (27 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function dirMtx = getEyeDirMtx(dd, t_r, eyeData_rmblk_cat, cardinalDir)
% dirMtx = getTgtDirMtx(dd, t_r, tOnset_cat, cardinalDir)
%
% INPUT:
% dd
% t_r: time axis of concatenated events
% cardinalDir: list of directions of targets in deg
%
% OUTPUT:
% dirMtx: matrix [cardinalDir x t_r]
%TODO
% use cOnset as a proxy of saccade onsets?
if nargin < 4
cardinalDir = unique(dd.targetloc);
end
x_r = interp1(eyeData_rmblk_cat.t, eyeData_rmblk_cat.x, t_r);
y_r = interp1(eyeData_rmblk_cat.t, eyeData_rmblk_cat.y, t_r);
eyeRad = atan2(y_r, x_r); %[-pi pi]
dist = sqrt(y_r.^2+x_r.^2);
minDirIdx = zeros(length(t_r),1);
for tt = 1:length(t_r)
[~,minDirIdx(tt)] = min(abs(circ_dist(eyeRad(tt), pi/180*cardinalDir)));
end
dirMtx = zeros(length(cardinalDir), length(t_r));
for tt = 1:length(t_r)
dirMtx(minDirIdx(tt),tt) = dist(tt);
end