Skip to content

Commit 9ae1304

Browse files
authored
Merge pull request #94 from cpp-lln-lab/remi-update_from_retinotopy
add functions to change resolution and draw field of view
2 parents abc9014 + 9cd1deb commit 9ae1304

File tree

5 files changed

+54
-25
lines changed

5 files changed

+54
-25
lines changed

src/aperture/apertureTexture.m

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
case 'make'
1616

17-
transparent = [0, 0, 0, 0];
17+
TRANSPARENT = [0, 0, 0, 0];
1818

1919
xCenter = cfg.screen.center(1);
2020
yCenter = cfg.screen.center(2);
@@ -23,7 +23,7 @@
2323

2424
case 'none'
2525

26-
Screen('Fillrect', cfg.aperture.texture, transparent);
26+
Screen('Fillrect', cfg.aperture.texture, TRANSPARENT);
2727

2828
case 'circle'
2929

@@ -36,7 +36,7 @@
3636
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
3737
end
3838

39-
Screen('FillOval', cfg.aperture.texture, transparent, ...
39+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
4040
CenterRectOnPoint([0, 0, repmat(diameter, 1, 2)], ...
4141
xCenter, yCenter));
4242

@@ -47,7 +47,7 @@
4747

4848
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
4949

50-
Screen('FillOval', cfg.aperture.texture, transparent, ...
50+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
5151
CenterRectOnPoint( ...
5252
[0, 0, repmat(cfg.ring.outerRimPix, 1, 2)], ...
5353
xCenter, yCenter));
@@ -77,7 +77,7 @@
7777

7878
Screen('Fillrect', cfg.aperture.texture, cfg.color.background);
7979

80-
Screen('FillArc', cfg.aperture.texture, transparent, ...
80+
Screen('FillArc', cfg.aperture.texture, TRANSPARENT, ...
8181
CenterRect( ...
8282
[0, 0, repmat(cfg.stimRect(4), 1, 2)], ...
8383
cfg.screen.winRect), ...
@@ -90,10 +90,13 @@
9090
Screen('FillRect', cfg.aperture.texture, cfg.color.background);
9191

9292
% We let the stimulus through
93-
Screen('FillOval', cfg.aperture.texture, transparent, ...
93+
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
9494
CenterRect([0, 0, repmat(cfg.stimRect(3), 1, 2)], cfg.screen.winRect));
9595

9696
% Then we add the position of the bar aperture
97+
98+
% which one is the right and which one is the left??
99+
97100
Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
98101
[0, ...
99102
0, ...
@@ -120,7 +123,7 @@
120123
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture, ...
121124
cfg.screen.winRect, ...
122125
CenterRect( ...
123-
cfg.screen.winRect * cfg.magnify.scalingFactor, ...
126+
cfg.screen.winRect, ...
124127
cfg.screen.winRect), ...
125128
thisEvent.condition - 90);
126129
else
@@ -166,27 +169,14 @@
166169

167170
case 'bar'
168171

169-
extraPositons = 0;
170-
if cfg.magnify.do
171-
% we add some extra bar positions that we remove afterwards to
172-
% prevent having nothing on screen for a long time
173-
extraPositons = 12;
174-
end
175-
176172
% Set parameters drifting bars
177-
cfg.aperture.barWidthPix = cfg.stimRect(3) / (cfg.volsPerCycle + extraPositons);
173+
cfg.aperture.barWidthPix = cfg.stimRect(3) / cfg.volsPerCycle;
178174

179175
barPosPix = ...
180176
[0:cfg.aperture.barWidthPix:cfg.stimRect(3) - cfg.aperture.barWidthPix] + ...
181177
(cfg.screen.winRect(3) / 2 - cfg.stimRect(3) / 2) + ...
182178
cfg.aperture.barWidthPix / 2; %#ok<NBRAK>
183179

184-
% Those positions are removed because they are actually outside of
185-
% the screen when magnification (fit to windows width) is on
186-
if cfg.magnify.do
187-
barPosPix([1:6, end - 5:end]) = [];
188-
end
189-
190180
cfg.aperture.barPosPix = barPosPix;
191181

192182
% Width of bar in degrees of VA (needed for saving)

src/drawFieldOfVIew.m

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function drawFieldOfVIew(cfg)
2+
% drawFieldOfVIew(cfg)
3+
%
4+
% draws a red rectangle on the screen to materialize the field of view of
5+
% the participant. This can be used during debugging to help design the
6+
% stimuli if you know the FOV of the participant will be obstructed by
7+
% something
8+
9+
if isfield(cfg.screen, 'effectiveFieldOfView') && ...
10+
numel(cfg.screen.effectiveFieldOfView) == 2
11+
12+
RED = [255 0 0];
13+
penWidth = 2;
14+
15+
fov = cfg.screen.effectiveFieldOfView;
16+
17+
fov = CenterRect( ...
18+
[0, 0, fov(1), fov(2)], ...
19+
cfg.screen.winRect);
20+
21+
Screen('FrameRect', ...
22+
cfg.screen.win, ...
23+
RED, ...
24+
fov, ...
25+
penWidth);
26+
end
27+
28+
end

src/initPTB.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@
4646

4747
%% Visual
4848

49+
% Make sure we have black splash screen
50+
Screen('Preference', 'VisualDebugLevel', 1);
51+
4952
% Get the screen numbers and draw to the external screen if avaliable
5053
cfg.screen.idx = max(Screen('Screens'));
5154

55+
if isfield(cfg.screen, 'resolution')
56+
[newWidth, newHeight, newHz] = deal(cfg.screen.resolution{:});
57+
cfg.screen.oldResolution = Screen('Resolution', cfg.screen.idx, ...
58+
newWidth, newHeight, newHz);
59+
end
60+
5261
cfg = openWindow(cfg);
5362

5463
% window size info

src/setDefaultsPTB.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
fieldsToSet.screen.monitorWidth = 42;
3131
fieldsToSet.screen.monitorDistance = 134;
32+
fieldsToSet.screen.resolution = {[], [], []};
3233

3334
% fixation cross or dot
3435
fieldsToSet.fixation.type = 'cross';

tests/test_setDefaultsPTB.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ function test_setDefaultsPtbAudio()
6464
'debug', struct('do', true, 'transpWin', true, 'smallWin', true), ...
6565
'color', struct( ...
6666
'background', [0 0 0]), ...
67-
'text', struct('font', 'Courier New', 'size', 18, 'style', 1), ...
68-
'screen', struct( ...
69-
'monitorWidth', 42, ...
70-
'monitorDistance', 134));
67+
'text', struct('font', 'Courier New', 'size', 18, 'style', 1));
68+
69+
expectedCFG.screen.monitorWidth = 42;
70+
expectedCFG.screen.monitorDistance = 134;
71+
expectedCFG.screen.resolution = {[], [], []};
7172

7273
% fixation cross or dot
7374
expectedCFG.fixation.type = 'cross';

0 commit comments

Comments
 (0)