1414 % - sound
1515 %
1616 % OUTPUT:
17- % cfg.keyboard = [];
18- % cfg.responseBox = [];
1917 %
20- % cfg.debug = true;
21- % cfg.testingTranspScreen = true;
22- % cfg.testingSmallScreen = true;
2318 %
24- % cfg.screen : screen numbers where drawing the stimulation (external screen if available)
25- % cfg.win : window opened by PTB
26- % cfg.winRect : window rectangule positiona and dimensions in pixel coordinates
27- % cfg.winWidth : window width in pixels
28- % cfg.winHeight : window height in pixels
29- % cfg.center : coordinate of the window center
30- % cfg.ppd : pixels per degree assuming the window fills the whole screen
31- % cfg.ifi : estimate of the monitor flip interval
32- % cfg.monRefresh : monitor refresh rate
33- % cfg.vbl : (I don't think this output is useful)
34- % cfg.textFont = 'Courier New';
35- % cfg.textSize = 18;
36- % cfg.textStyle = 1;
37- % cfg.backgroundColor = [0 0 0];
38- % cfg.monitorWidth = 42;
39- % cfg.screenDistance = 134;
40-
41- % TO DO
42- % - We might want to add a couple of IF in case the experiment does not use audio for example.
4319
4420 checkPtbVersion();
21+
22+ pth = fileparts(mfilename(' fullpath' ));
23+ addpath(fullfile(pth , ' subfun' ));
4524
4625 % For octave: to avoid displaying messenging one screen at a time
4726 more off ;
6342 %% Visual
6443
6544 % Get the screen numbers and draw to the external screen if avaliable
66- cfg.screen = max(Screen(' Screens' ));
45+ cfg.screen.idx = max(Screen(' Screens' ));
6746
6847 cfg = openWindow(cfg );
6948
7049 % window size info
71- [cfg .winWidth , cfg .winHeight ] = WindowSize(cfg .win );
72-
73- % if strcmpi(cfg.stimPosition, 'mri')
74- % cfg.winRect(1, 4) = cfg.winRect(1, 4) * 2 / 3;
75- % end
50+ [cfg .screen .winWidth , cfg .screen .winHeight ] = WindowSize(cfg .screen .win );
7651
7752 % Get the Center of the Screen
78- cfg.center = [cfg .winRect(3 ), cfg .winRect(4 )] / 2 ;
53+ cfg.screen. center = [cfg .screen . winRect(3 ), cfg . screen .winRect(4 )] / 2 ;
7954
8055 % Computes the number of pixels per degree given the distance to screen and
8156 % monitor width
8257 % This assumes that the window fills the whole screen
83- cfg.FOV = computeFOV(cfg );
84- cfg.ppd = cfg .winRect(3 ) / cfg .FOV ;
58+ cfg.screen. FOV = computeFOV(cfg );
59+ cfg.screen. ppd = cfg .winRect(3 ) / cfg .FOV ;
8560
8661 %% Select specific text font, style and size
8762 initText(cfg );
8863
8964 %% Timing
9065 % Query frame duration
91- cfg.ifi = Screen(' GetFlipInterval' , cfg .win );
92- cfg.monRefresh = 1 / cfg .ifi ;
66+ cfg.screen. ifi = Screen(' GetFlipInterval' , cfg .win );
67+ cfg.screen. monRefresh = 1 / cfg .ifi ;
9368
9469 % Set priority for script execution to realtime priority:
95- Priority(MaxPriority(cfg .win ));
70+ Priority(MaxPriority(cfg .screen . win ));
9671
9772 %% Warm up some functions
9873 % Do dummy calls to GetSecs, WaitSecs, KbCheck to make sure
10277 WaitSecs(0.1 );
10378 GetSecs ;
10479
105- %% Initial flip to get a first time stamp
106- % Initially sync us to VBL at start of animation loop.
107- cfg.vbl = Screen(' Flip' , cfg .win );
10880
10981end
11082
11183function initDebug(cfg )
11284
11385 % init PTB with different options in concordance to the debug Parameters
11486 Screen(' Preference' , ' SkipSyncTests' , 0 );
115- if cfg .debug
87+ if cfg .debug . do
11688
11789 Screen(' Preference' , ' SkipSyncTests' , 2 );
11890 Screen(' Preference' , ' Verbosity' , 0 );
@@ -128,7 +100,7 @@ function initDebug(cfg)
128100
129101 end
130102
131- if cfg .testingTranspScreen
103+ if cfg .debug . transpWin
132104 PsychDebugWindowConfiguration ;
133105 end
134106
@@ -147,7 +119,7 @@ function initDebug(cfg)
147119
148120function cfg = initAudio(cfg )
149121
150- if cfg .initAudio
122+ if cfg .audio . do
151123
152124 InitializePsychSound(1 );
153125
@@ -194,23 +166,16 @@ function initDebug(cfg)
194166
195167function cfg = openWindow(cfg )
196168
197- if cfg .testingSmallScreen
198- [cfg .win , cfg .winRect ] = Screen(' OpenWindow' , cfg .screen , cfg .backgroundColor , ...
169+ if cfg .debug . smallWin
170+ [cfg .screen . win , cfg .screen . winRect ] = Screen(' OpenWindow' , cfg .screen . idx , cfg .color . background , ...
199171 [0 , 0 , 480 , 270 ]);
200172 else
201- [cfg .win , cfg .winRect ] = Screen(' OpenWindow' , cfg .screen , cfg .backgroundColor );
173+ [cfg .screen . win , cfg .screen . winRect ] = Screen(' OpenWindow' , cfg .screen . idx , cfg .color . background );
202174 end
203175
204176 % Enable alpha-blending, set it to a blend equation useable for linear
205177 % superposition with alpha-weighted source.
206- Screen(' BlendFunction' , cfg .win , GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );
207-
208- end
209-
210- function FOV = computeFOV(cfg )
211-
212- % computes the number of degrees of visual angle in the whole field of view
213- FOV = 2 * (180 * (atan(cfg .monitorWidth / (2 * cfg .screenDistance )) / pi ));
178+ Screen(' BlendFunction' , cfg .screen .win , GL_SRC_ALPHA , GL_ONE_MINUS_SRC_ALPHA );
214179
215180end
216181
0 commit comments