-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetCueDirMtx.m
More file actions
34 lines (30 loc) · 953 Bytes
/
getCueDirMtx.m
File metadata and controls
34 lines (30 loc) · 953 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
34
function dirMtx = getCueDirMtx(dd, t_r, onsets_cat, cardinalDir)
% dirMtx = getCueDirMtx(dd, t_r, tOnset_cat, cardinalDir)
%
% INPUT:
% dd
% t_r: time axis of concatenated events
% onsets_cat: time of target and cue onsets
% cardinalDir: list of directions of targets in deg
%
% OUTPUT:
% dirMtx: matrix [cardinalDir x t_r]
if nargin < 4
cardinalDir = unique(dd.targetloc);
end
minDirIdx = zeros(dd.numTrials);
for itr = 1:dd.numTrials
[~, minDirIdx(itr)] = min(abs(circ_dist(pi/180*dd.targetloc(itr), pi/180*cardinalDir)));
end
dirMtx = zeros(length(cardinalDir), length(t_r));
for itr = 1:dd.numTrials
%only register trials with cue and task completion
cueOnset = onsets_cat.cueOnset(itr);
cOnset = onsets_cat.cOnset(itr);
if isinf(cueOnset) || isnan(cOnset)
continue;
end
[~, onIdx] = min(abs(t_r - cueOnset));
[~, offIdx] = min(abs(t_r - cOnset));
dirMtx(minDirIdx(itr), onIdx:offIdx) = 1;
end