Skip to content

Commit 7662e8c

Browse files
committed
mh fix
1 parent 9cab2ea commit 7662e8c

File tree

1 file changed

+49
-50
lines changed

1 file changed

+49
-50
lines changed

dev/devSandbox.m

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,56 @@
2424
cfg = struct;
2525

2626
%% Visual
27-
27+
2828
% set to false if no visual stimulation
29-
cfg.screen.do = true;
30-
29+
cfg.screen.do = true;
30+
3131
% Set the PTB window background manually
3232
cfg.color.background = [127 127 27];
33-
33+
3434
% Set monitor parameters if you care about visual angle
3535
cfg.visualAngle.do = true;
3636
cfg.screen.monitorWidth = 21.5; % cm
3737
cfg.screen.monitorDistance = 30; % cm
3838

3939
% Init PTB, see the Sub-Functions below
4040
cfg = devSandbox_initPTB(cfg);
41-
41+
4242
% OUTPUT:
43-
%
43+
%
4444
% cfg.screen.idx % Screen number where to draw, external screen if avaliable
4545
% cfg.screen.win % The onscreen window whose content should be shown at flip time
4646
% cfg.screen.winRect % The onscreen window size in pixels coordinates
47-
% cfg.screen.winWidth
47+
% cfg.screen.winWidth
4848
% 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+
5353
% Compute pixels per degrees
5454
cfg = devSandbox_computePpd(cfg);
55-
55+
5656
% OUTPUT:
5757
%
5858
% cfg.screen.ppd % The number of pixels per degree given the distance to screen
59-
59+
6060
%% Auditory
6161
% Set AUDIO
62-
62+
6363
% set to false if no auditory stimulation
6464
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
6767
cfg.audio.fs = 44100;
6868
cfg.audio.channels = 2;
69-
69+
7070
% Init Audio, see the Sub-Functions below
7171
cfg = devSandbox_initAudio(cfg);
7272

7373
% OUTPUT:
74-
%
75-
% cfg.audio.pahandle
76-
74+
%
75+
% cfg.audio.pahandle
76+
7777
%%
7878
% -------------------------------------------------------------------------
7979
% -------------------------- SET YOUR VARS HERE ---------------------------
@@ -106,12 +106,12 @@
106106
% -------------------------------------------------------------------------
107107
% ------------------------------ PLAYGROUND -------------------------------
108108
% -------------------------------------------------------------------------
109-
109+
110110
% Define black and white
111111
white = WhiteIndex(cfg.screen.idx);
112112
grey = white / 2;
113113
inc = white - grey;
114-
114+
115115
% Define Half-Size of the grating image.
116116
textureSize = gratingSizePix / 2;
117117

@@ -212,39 +212,39 @@
212212
function cfg = devSandbox_initPTB(cfg)
213213

214214
% Shorter version of `initPTB.m`
215-
215+
216216
if cfg.screen.do
217217

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);
220226

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'));
223229

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);
226232

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);
229235

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;
232238

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);
238241

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');
244247

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-
248248
end
249249

250250
end
@@ -261,20 +261,19 @@
261261
[], ...
262262
cfg.audio.fs, ...
263263
cfg.audio.channels);
264-
264+
265265
end
266266
end
267267

268268
function cfg = devSandbox_computePpd (cfg)
269269

270270
% Computes the number of pixels per degree given the distance to screen and
271271
% monitor width. This assumes that the window fills the whole screen
272-
272+
273273
cfg.screen.FOV = 180 / pi * 2 * atan(cfg.screen.monitorWidth / (2 * cfg.screen.monitorDistance));
274274
cfg.screen.ppd = cfg.screen.winWidth / cfg.screen.FOV;
275-
276-
end
277275

276+
end
278277

279278
function devSandbox_cleanUp
280279

0 commit comments

Comments
 (0)