Newer
Older
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
%_______________________________________________________________________
%
% dotInfo = randomIntroTrial(dotInfo, trialData, count)
%_______________________________________________________________________
%
% Generates the configuration for next introduction trial
%_______________________________________________________________________
%
% Input
%
% dotInfo | experiment configuration (struct)
% trialData | results of the session (struct)
% count | current trial number (numeric)
%_______________________________________________________________________
%
% Output
%
% dotInfo | experiment configuration (struct)
%_______________________________________________________________________
%
function dotInfo = randomIntroTrial(dotInfo, trialData, count)
if count > 1
rxtime = [trialData.rxtime];
subjResponded = not(isnan(rxtime(end))); % response in last trial
fprintf(' [coh: %.5f]', dotInfo.coh)
if subjResponded
coh = dotInfo.coh;
dotInfo.coh = dotInfo.coh * 0.85;
end
end
% choose random direction
dotInfo.dir = dotInfo.dirSet(ceil(rand*length(dotInfo.dirSet)));
% limit number of consecutive trials with dots in same direction to three
% caveat: current implementation only works for two directions
if numel(trialData) > 2
dir1 = trialData(end).dotDir;
dir2 = trialData(end-1).dotDir;
dir3 = trialData(end-2).dotDir;
threeSameDir = all(dotInfo.dir == [dir1 dir2 dir3]);
if threeSameDir
otherDir = not(dotInfo.dirSet == dotInfo.dir);
dotInfo.dir = dotInfo.dirSet(otherDir);
end
end
% generate random fixation duration
fixMin = dotInfo.fixMinTime; % minimum fixation
fixMax = dotInfo.fixMaxTime; % maximum fixation
dotInfo.fixTime = (fixMax - fixMin) * rand + fixMin;
end