|
24 | 24 | cfg = struct; |
25 | 25 |
|
26 | 26 | %% Visual |
27 | | - |
| 27 | + |
28 | 28 | % set to false if no visual stimulation |
29 | | - cfg.screen.do = true; |
30 | | - |
| 29 | + cfg.screen.do = true; |
| 30 | + |
31 | 31 | % Set the PTB window background manually |
32 | 32 | cfg.color.background = [127 127 27]; |
33 | | - |
| 33 | + |
34 | 34 | % Set monitor parameters if you care about visual angle |
35 | 35 | cfg.visualAngle.do = true; |
36 | 36 | cfg.screen.monitorWidth = 21.5; % cm |
37 | 37 | cfg.screen.monitorDistance = 30; % cm |
38 | 38 |
|
39 | 39 | % Init PTB, see the Sub-Functions below |
40 | 40 | cfg = devSandbox_initPTB(cfg); |
41 | | - |
| 41 | + |
42 | 42 | % OUTPUT: |
43 | | - % |
| 43 | + % |
44 | 44 | % cfg.screen.idx % Screen number where to draw, external screen if avaliable |
45 | 45 | % cfg.screen.win % The onscreen window whose content should be shown at flip time |
46 | 46 | % cfg.screen.winRect % The onscreen window size in pixels coordinates |
47 | | - % cfg.screen.winWidth |
| 47 | + % cfg.screen.winWidth |
48 | 48 | % cfg.screen.winHeight |
49 | | - % cfg.screen.center % Center of the screen window |
50 | | - % cfg.screen.ifi % Frame duration |
51 | | - % cfg.screen.monitorRefresh % Monitor refresh rate |
52 | | - |
| 49 | + % cfg.screen.center % Center of the screen window |
| 50 | + % cfg.screen.ifi % Frame duration |
| 51 | + % cfg.screen.monitorRefresh % Monitor refresh rate |
| 52 | + |
53 | 53 | % Compute pixels per degrees |
54 | 54 | cfg = devSandbox_computePpd(cfg); |
55 | | - |
| 55 | + |
56 | 56 | % OUTPUT: |
57 | 57 | % |
58 | 58 | % cfg.screen.ppd % The number of pixels per degree given the distance to screen |
59 | | - |
| 59 | + |
60 | 60 | %% Auditory |
61 | 61 | % Set AUDIO |
62 | | - |
| 62 | + |
63 | 63 | % set to false if no auditory stimulation |
64 | 64 | cfg.audio.do = false; |
65 | | - |
66 | | - % Set audio freq. and nb. of channels of your audio file input |
| 65 | + |
| 66 | + % Set audio freq. and nb. of channels of your audio file input |
67 | 67 | cfg.audio.fs = 44100; |
68 | 68 | cfg.audio.channels = 2; |
69 | | - |
| 69 | + |
70 | 70 | % Init Audio, see the Sub-Functions below |
71 | 71 | cfg = devSandbox_initAudio(cfg); |
72 | 72 |
|
73 | 73 | % OUTPUT: |
74 | | - % |
75 | | - % cfg.audio.pahandle |
76 | | - |
| 74 | + % |
| 75 | + % cfg.audio.pahandle |
| 76 | + |
77 | 77 | %% |
78 | 78 | % ------------------------------------------------------------------------- |
79 | 79 | % -------------------------- SET YOUR VARS HERE --------------------------- |
|
106 | 106 | % ------------------------------------------------------------------------- |
107 | 107 | % ------------------------------ PLAYGROUND ------------------------------- |
108 | 108 | % ------------------------------------------------------------------------- |
109 | | - |
| 109 | + |
110 | 110 | % Define black and white |
111 | 111 | white = WhiteIndex(cfg.screen.idx); |
112 | 112 | grey = white / 2; |
113 | 113 | inc = white - grey; |
114 | | - |
| 114 | + |
115 | 115 | % Define Half-Size of the grating image. |
116 | 116 | textureSize = gratingSizePix / 2; |
117 | 117 |
|
|
212 | 212 | function cfg = devSandbox_initPTB(cfg) |
213 | 213 |
|
214 | 214 | % Shorter version of `initPTB.m` |
215 | | - |
| 215 | + |
216 | 216 | if cfg.screen.do |
217 | 217 |
|
218 | | - % Skip the PTB sync test |
219 | | - Screen('Preference', 'SkipSyncTests', 2); |
| 218 | + % Skip the PTB sync test |
| 219 | + Screen('Preference', 'SkipSyncTests', 2); |
| 220 | + |
| 221 | + % Open a transparent window |
| 222 | + PsychDebugWindowConfiguration; |
| 223 | + |
| 224 | + % Here we call some default settings for setting up Psychtoolbox |
| 225 | + PsychDefaultSetup(2); |
220 | 226 |
|
221 | | - % Open a transparent window |
222 | | - PsychDebugWindowConfiguration; |
| 227 | + % Get the screen numbers and draw to the external screen if avaliable |
| 228 | + cfg.screen.idx = max(Screen('Screens')); |
223 | 229 |
|
224 | | - % Here we call some default settings for setting up Psychtoolbox |
225 | | - PsychDefaultSetup(2); |
| 230 | + % Open an on screen window |
| 231 | + [cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background); |
226 | 232 |
|
227 | | - % Get the screen numbers and draw to the external screen if avaliable |
228 | | - cfg.screen.idx = max(Screen('Screens')); |
| 233 | + % Get the size of the on screen window |
| 234 | + [cfg.screen.winWidth, cfg.screen.winHeight] = WindowSize(cfg.screen.win); |
229 | 235 |
|
230 | | - % Open an on screen window |
231 | | - [cfg.screen.win, cfg.screen.winRect] = Screen('OpenWindow', cfg.screen.idx, cfg.color.background); |
| 236 | + % Get the Center of the Screen |
| 237 | + cfg.screen.center = [cfg.screen.winRect(3), cfg.screen.winRect(4)] / 2; |
232 | 238 |
|
233 | | - % Get the size of the on screen window |
234 | | - [cfg.screen.winWidth, cfg.screen.winHeight] = WindowSize(cfg.screen.win); |
235 | | - |
236 | | - % Get the Center of the Screen |
237 | | - cfg.screen.center = [cfg.screen.winRect(3), cfg.screen.winRect(4)] / 2; |
| 239 | + % Query the frame duration |
| 240 | + cfg.screen.ifi = Screen('GetFlipInterval', cfg.screen.win); |
238 | 241 |
|
239 | | - % Query the frame duration |
240 | | - cfg.screen.ifi = Screen('GetFlipInterval', cfg.screen.win); |
241 | | - |
242 | | - % Get monitor refresh rate |
243 | | - cfg.screen.monitorRefresh = 1 / cfg.screen.ifi; |
| 242 | + % Get monitor refresh rate |
| 243 | + cfg.screen.monitorRefresh = 1 / cfg.screen.ifi; |
| 244 | + |
| 245 | + % Set up alpha-blending for smooth (anti-aliased) lines |
| 246 | + Screen('BlendFunction', cfg.screen.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
244 | 247 |
|
245 | | - % Set up alpha-blending for smooth (anti-aliased) lines |
246 | | - Screen('BlendFunction', cfg.screen.win, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA'); |
247 | | - |
248 | 248 | end |
249 | 249 |
|
250 | 250 | end |
|
261 | 261 | [], ... |
262 | 262 | cfg.audio.fs, ... |
263 | 263 | cfg.audio.channels); |
264 | | - |
| 264 | + |
265 | 265 | end |
266 | 266 | end |
267 | 267 |
|
268 | 268 | function cfg = devSandbox_computePpd (cfg) |
269 | 269 |
|
270 | 270 | % Computes the number of pixels per degree given the distance to screen and |
271 | 271 | % monitor width. This assumes that the window fills the whole screen |
272 | | - |
| 272 | + |
273 | 273 | cfg.screen.FOV = 180 / pi * 2 * atan(cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance)); |
274 | 274 | cfg.screen.ppd = cfg.screen.winWidth / cfg.screen.FOV; |
275 | | - |
276 | | -end |
277 | 275 |
|
| 276 | +end |
278 | 277 |
|
279 | 278 | function devSandbox_cleanUp |
280 | 279 |
|
|
0 commit comments