Skip to content

Commit 71f5f77

Browse files
committed
implement best fixation option
1 parent 867aba4 commit 71f5f77

File tree

2 files changed

+66
-11
lines changed

2 files changed

+66
-11
lines changed

drawFixation.m

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,41 @@ function drawFixation(cfg)
3030
CenterRect( ...
3131
[0 0 repmat(cfg.fixation.widthPix, 1, 2)], ...
3232
cfg.screen.winRect));
33+
34+
35+
case 'bestFixation'
36+
37+
% Code adapted from:
38+
% What is the best fixation target?
39+
% DOI 10.1016/j.visres.2012.10.012
40+
41+
% Draw gap around fixation of 20% the size
42+
Screen('FillOval', ...
43+
cfg.screen.win, ...
44+
cfg.color.background, ...
45+
CenterRect( ...
46+
[0 0 repmat(1.5 * cfg.fixation.widthPix, 1, 2)], ...
47+
cfg.screen.winRect));
48+
49+
Screen('FillOval', ...
50+
cfg.screen.win, ...
51+
cfg.color.black, ...
52+
cfg.fixation.outerOval, ...
53+
cfg.fixation.widthPix);
54+
55+
Screen('DrawLines', ...
56+
cfg.screen.win, ...
57+
cfg.fixation.allCoords, ...
58+
cfg.fixation.widthPix / 3, ...
59+
cfg.color.white, ...
60+
[cfg.screen.center(1) cfg.screen.center(2)]);
61+
62+
Screen('FillOval', ...
63+
cfg.screen.win, ...
64+
cfg.color.black, ...
65+
cfg.fixation.innerOval, ...
66+
cfg.fixation.widthPix / 3);
67+
3368
end
3469

3570
end

initFixation.m

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,36 @@
44
cfg.fixation = degToPix('width', cfg.fixation, cfg);
55
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
66
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);
7-
8-
if strcmp(cfg.fixation.type, 'cross')
9-
10-
% Prepare fixation cross
11-
cfg.fixation.xCoords = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2 + ...
12-
cfg.fixation.xDisplacementPix;
13-
cfg.fixation.yCoords = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2 + ...
14-
cfg.fixation.yDisplacementPix;
15-
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
16-
7+
8+
% Prepare fixation cross
9+
xLine = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] / 2;
10+
yLine = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] / 2;
11+
12+
cfg.fixation.xCoords = xLine + cfg.fixation.xDisplacementPix;
13+
cfg.fixation.yCoords = yLine + cfg.fixation.yDisplacementPix;
14+
15+
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
16+
17+
switch cfg.fixation.type
18+
19+
case 'bestFixation'
20+
21+
% Code adapted from:
22+
% What is the best fixation target?
23+
% DOI 10.1016/j.visres.2012.10.012
24+
25+
cfg.fixation.outerOval = [...
26+
cfg.screen.center(1)-cfg.fixation.widthPix/2, ...
27+
cfg.screen.center(2)-cfg.fixation.widthPix/2, ...
28+
cfg.screen.center(1)+cfg.fixation.widthPix/2, ...
29+
cfg.screen.center(2)+cfg.fixation.widthPix/2];
30+
31+
cfg.fixation.innerOval = [...
32+
cfg.screen.center(1)-cfg.fixation.widthPix/6, ...
33+
cfg.screen.center(2)-cfg.fixation.widthPix/6, ...
34+
cfg.screen.center(1)+cfg.fixation.widthPix/6, ...
35+
cfg.screen.center(2)+cfg.fixation.widthPix/6];
36+
1737
end
18-
38+
1939
end

0 commit comments

Comments
 (0)