Skip to content

Commit ed51eef

Browse files
committed
severeral updates on some base functions
1 parent ac6fc16 commit ed51eef

File tree

7 files changed

+53
-25
lines changed

7 files changed

+53
-25
lines changed

apertureTexture.m

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,20 @@
2727
case 'circle'
2828

2929
diameter = cfg.aperture.widthPix;
30+
31+
xPos = cfg.screen.center(1);
32+
yPos = cfg.screen.center(2);
33+
if isfield(cfg.aperture, 'xPosPix')
34+
xPos = cfg.screen.center(1) + cfg.aperture.xPosPix;
35+
end
36+
if isfield(cfg.aperture, 'yPosPix')
37+
yPos = cfg.screen.center(2) + cfg.aperture.yPosPix;
38+
end
3039

3140
Screen('FillOval', cfg.aperture.texture, transparent, ...
3241
CenterRectOnPoint([0 0 repmat(diameter, 1, 2)], ...
33-
cfg.screen.winRect(3) / 2, cfg.screen.winRect(4) / 2));
34-
42+
xPos, yPos));
43+
3544
end
3645

3746
case 'draw'

computeFOV.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
%
44
% computes the number of degrees of visual angle in the whole field of view
55
%
6+
% δ = 2 arctan ( d / 2D )
7+
%
8+
% δ is the angular diameter, and d is the actual diameter of the object,
9+
% and D is the distance to the object.
10+
% The result obtained is in radians.
11+
%
612

7-
FOV = 2 * ...
8-
(180 * (atan(cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance)) / pi));
13+
FOV = ...
14+
180 / pi * ...
15+
2 * atan( cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance) );
916

1017
end

decompMotion.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function [horVector, vertVector] = decompMotion(angleMotion)
2+
% decompose angle of start motion into horizontal and vertical vector
3+
horVector = cos(pi * angleMotion / 180);
4+
vertVector = -sin(pi * angleMotion / 180);
5+
end

dotTexture.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
cfg.color.background(1) * ones(cfg.screen.winRect([4 3])));
88

99
case 'make'
10+
11+
dotType = 2;
1012

1113
Screen('FillRect', cfg.dot.texture, cfg.color.background);
1214
Screen('DrawDots', cfg.dot.texture, ...
1315
thisEvent.dot.positions, ...
1416
cfg.dot.sizePix, ...
1517
cfg.dot.color, ...
1618
cfg.screen.center, ...
17-
1);
19+
dotType);
1820

1921
case 'draw'
2022

drawFixation.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@ function drawFixation(cfg)
22
% Define the parameters of the fixation cross in `cfg` and `expParameters`
33

44
if strcmp(cfg.fixation.type, 'cross')
5+
6+
smooth = 1;
7+
58
Screen('DrawLines', ...
69
cfg.screen.win, ...
710
cfg.fixation.allCoords, ...
811
cfg.fixation.lineWidthPix, ...
912
cfg.fixation.color, ...
10-
[cfg.screen.center(1) cfg.screen.center(2)], 1);
13+
[cfg.screen.center(1) cfg.screen.center(2)], smooth);
1114
end
1215

1316
end

initFixation.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function cfg = initFixation(cfg)
2+
3+
if strcmp(cfg.fixation.type, 'cross')
4+
5+
% Convert some values from degrees to pixels
6+
cfg.fixation = degToPix('width', cfg.fixation, cfg);
7+
cfg.fixation = degToPix('xDisplacement', cfg.fixation, cfg);
8+
cfg.fixation = degToPix('yDisplacement', cfg.fixation, cfg);
9+
10+
% Prepare fixation cross
11+
cfg.fixation.xCoords = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] + ...
12+
cfg.fixation.xDisplacementPix;
13+
cfg.fixation.yCoords = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] + ...
14+
cfg.fixation.yDisplacementPix;
15+
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
16+
17+
end
18+
19+
end

initPTB.m

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
% monitor width
6060
% This assumes that the window fills the whole screen
6161
cfg.screen.FOV = computeFOV(cfg);
62-
cfg.screen.ppd = cfg.screen.winRect(3) / cfg.screen.FOV;
62+
cfg.screen.ppd = cfg.screen.winWidth / cfg.screen.FOV;
6363

6464
% Initialize visual parmaters for fixation cross or dot
6565
cfg = initFixation(cfg);
@@ -182,28 +182,11 @@ function initDebug(cfg)
182182

183183
% Enable alpha-blending, set it to a blend equation useable for linear
184184
% superposition with alpha-weighted source.
185+
% Required for drwing smooth lines and screen('DrawDots')
185186
Screen('BlendFunction', cfg.screen.win, GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
186187

187188
end
188189

189-
function cfg = initFixation(cfg)
190-
191-
if strcmp(cfg.fixation.type, 'cross')
192-
193-
% Convert some values from degrees to pixels
194-
cfg.fixation = degToPix('width', cfg.fixation, cfg);
195-
196-
% Prepare fixation cross
197-
cfg.fixation.xCoords = [-cfg.fixation.widthPix cfg.fixation.widthPix 0 0] + ...
198-
cfg.fixation.xDisplacement;
199-
cfg.fixation.yCoords = [0 0 -cfg.fixation.widthPix cfg.fixation.widthPix] + ...
200-
cfg.fixation.yDisplacement;
201-
cfg.fixation.allCoords = [cfg.fixation.xCoords; cfg.fixation.yCoords];
202-
203-
end
204-
205-
end
206-
207190
function initText(cfg)
208191

209192
Screen('TextFont', cfg.screen.win, cfg.text.font);

0 commit comments

Comments
 (0)