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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
%_______________________________________________________________________
%
% dotInfo = randomDotTrial(dotInfo, trialData)
%_______________________________________________________________________
%
% Generates the configuration for next trial
%_______________________________________________________________________
%
% Input
%
% dotInfo | experiment configuration (struct)
% trialData | results of the session (struct)
%_______________________________________________________________________
%
% Output
%
% dotInfo | experiment configuration (struct)
%_______________________________________________________________________
%
function dotInfo = randomDotTrial(dotInfo, trialData)
% adjust coherence if accuracy is off target
if not(isnan(dotInfo.movAccuracy)) && not(dotInfo.movAccuracy == dotInfo.targetAcc) && dotInfo.subjResponded
dotInfo = updateCohMobs(dotInfo);
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
% update coherence using the MOBS heuristic
function dotInfo = updateCohMobs(dotInfo)
% short-term accuracy for increasing/decreasing coherence
if dotInfo.movAccuracy < dotInfo.targetAcc
dotInfo.resp = 'no';
else
dotInfo.resp = 'yes';
end
% stable mid-term accuracy for deciding about regressions
if not(isnan(dotInfo.longMovAccuracy))
if dotInfo.longMovAccuracy < dotInfo.targetAcc
dotInfo.longResp = 'no';
else
dotInfo.longResp = 'yes';
end
else
dotInfo.longResp = '';
end
% ignore long-term accuracy if it contradicts short-term accuracy
if not(strcmp(dotInfo.resp, dotInfo.longResp))
dotInfo.longResp = '';
end
dotInfo = mobs(dotInfo);
end