Skip to content

Commit 23199f8

Browse files
committed
create a post-initialization function
- this is where we set all the parameters that can not be set up till we PTB returns some info about the system
1 parent acda14a commit 23199f8

File tree

2 files changed

+28
-15
lines changed

2 files changed

+28
-15
lines changed

subfun/postInitializationSetup.m

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function varargout = postInitializationSetup(varargin)
2+
% varargout = postInitializatinSetup(varargin)
3+
4+
% generic function to finalize some set up after psychtoolbox has been
5+
% initialized
6+
7+
cfg = deal(varargin{:});
8+
9+
cfg.dot.matrixWidth = cfg.screen.winWidth;
10+
11+
% Convert some values from degrees to pixels
12+
cfg.dot = degToPix('size', cfg.dot, cfg);
13+
cfg.dot = degToPix('speed', cfg.dot, cfg);
14+
15+
% Get dot speeds in pixels per frame
16+
cfg.dot.speedPixPerFrame = cfg.dot.speedPix / cfg.screen.monitorRefresh;
17+
18+
cfg.aperture = degToPix('xPos', cfg.aperture, cfg);
19+
20+
% dots are displayed on a square with a length in visual angle equal to the
21+
% field of view
22+
cfg.dot.number = round(cfg.dot.density * ...
23+
(cfg.dot.matrixWidth / cfg.screen.ppd)^2);
24+
25+
varargout = cfg;
26+
27+
end

visualLocTranslational.m

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,7 @@
3333
%% Init the experiment
3434
[cfg] = initPTB(cfg);
3535

36-
cfg.dot.matrixWidth = cfg.screen.winWidth;
37-
38-
% Convert some values from degrees to pixels
39-
cfg.dot = degToPix('size', cfg.dot, cfg);
40-
cfg.dot = degToPix('speed', cfg.dot, cfg);
41-
42-
% Get dot speeds in pixels per frame
43-
cfg.dot.speedPixPerFrame = cfg.dot.speedPix / cfg.screen.monitorRefresh;
44-
45-
cfg.aperture = degToPix('xPos', cfg.aperture, cfg);
46-
47-
% dots are displayed on a square with a length in visual angle equal to the
48-
% field of view
49-
cfg.dot.number = round(cfg.dot.density * ...
50-
(cfg.dot.matrixWidth / cfg.screen.ppd)^2);
36+
cfg = postInitializationSetup(cfg);
5137

5238
[el] = eyeTracker('Calibration', cfg);
5339

0 commit comments

Comments
 (0)