Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 11 additions & 21 deletions src/aperture/apertureTexture.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

case 'make'

transparent = [0, 0, 0, 0];
TRANSPARENT = [0, 0, 0, 0];

xCenter = cfg.screen.center(1);
yCenter = cfg.screen.center(2);
Expand All @@ -23,7 +23,7 @@

case 'none'

Screen('Fillrect', cfg.aperture.texture, transparent);
Screen('Fillrect', cfg.aperture.texture, TRANSPARENT);

case 'circle'

Expand All @@ -36,7 +36,7 @@
yCenter = cfg.screen.center(2) + cfg.aperture.yPosPix;
end

Screen('FillOval', cfg.aperture.texture, transparent, ...
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
CenterRectOnPoint([0, 0, repmat(diameter, 1, 2)], ...
xCenter, yCenter));

Expand All @@ -47,7 +47,7 @@

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

Screen('FillOval', cfg.aperture.texture, transparent, ...
Screen('FillOval', cfg.aperture.texture, TRANSPARENT, ...
CenterRectOnPoint( ...
[0, 0, repmat(cfg.ring.outerRimPix, 1, 2)], ...
xCenter, yCenter));
Expand Down Expand Up @@ -77,7 +77,7 @@

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

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

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

% Then we add the position of the bar aperture

% which one is the right and which one is the left??

Screen('FillRect', cfg.aperture.texture, cfg.color.background, ...
[0, ...
0, ...
Expand All @@ -120,7 +123,7 @@
Screen('DrawTexture', cfg.screen.win, cfg.aperture.texture, ...
cfg.screen.winRect, ...
CenterRect( ...
cfg.screen.winRect * cfg.magnify.scalingFactor, ...
cfg.screen.winRect, ...
cfg.screen.winRect), ...
thisEvent.condition - 90);
else
Expand Down Expand Up @@ -166,27 +169,14 @@

case 'bar'

extraPositons = 0;
if cfg.magnify.do
% we add some extra bar positions that we remove afterwards to
% prevent having nothing on screen for a long time
extraPositons = 12;
end

% Set parameters drifting bars
cfg.aperture.barWidthPix = cfg.stimRect(3) / (cfg.volsPerCycle + extraPositons);
cfg.aperture.barWidthPix = cfg.stimRect(3) / cfg.volsPerCycle;

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

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

cfg.aperture.barPosPix = barPosPix;

% Width of bar in degrees of VA (needed for saving)
Expand Down
28 changes: 28 additions & 0 deletions src/drawFieldOfVIew.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function drawFieldOfVIew(cfg)
% drawFieldOfVIew(cfg)
%
% draws a red rectangle on the screen to materialize the field of view of
% the participant. This can be used during debugging to help design the
% stimuli if you know the FOV of the participant will be obstructed by
% something

if isfield(cfg.screen, 'effectiveFieldOfView') && ...
numel(cfg.screen.effectiveFieldOfView) == 2

RED = [255 0 0];
penWidth = 2;

fov = cfg.screen.effectiveFieldOfView;

fov = CenterRect( ...
[0, 0, fov(1), fov(2)], ...
cfg.screen.winRect);

Screen('FrameRect', ...
cfg.screen.win, ...
RED, ...
fov, ...
penWidth);
end

end
9 changes: 9 additions & 0 deletions src/initPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@

%% Visual

% Make sure we have black splash screen
Screen('Preference', 'VisualDebugLevel', 1);

% Get the screen numbers and draw to the external screen if avaliable
cfg.screen.idx = max(Screen('Screens'));

if isfield(cfg.screen, 'resolution')
[newWidth, newHeight, newHz] = deal(cfg.screen.resolution{:});
cfg.screen.oldResolution = Screen('Resolution', cfg.screen.idx, ...
newWidth, newHeight, newHz);
end

cfg = openWindow(cfg);

% window size info
Expand Down
1 change: 1 addition & 0 deletions src/setDefaultsPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

fieldsToSet.screen.monitorWidth = 42;
fieldsToSet.screen.monitorDistance = 134;
fieldsToSet.screen.resolution = {[], [], []};

% fixation cross or dot
fieldsToSet.fixation.type = 'cross';
Expand Down
9 changes: 5 additions & 4 deletions tests/test_setDefaultsPTB.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ function test_setDefaultsPtbAudio()
'debug', struct('do', true, 'transpWin', true, 'smallWin', true), ...
'color', struct( ...
'background', [0 0 0]), ...
'text', struct('font', 'Courier New', 'size', 18, 'style', 1), ...
'screen', struct( ...
'monitorWidth', 42, ...
'monitorDistance', 134));
'text', struct('font', 'Courier New', 'size', 18, 'style', 1));

expectedCFG.screen.monitorWidth = 42;
expectedCFG.screen.monitorDistance = 134;
expectedCFG.screen.resolution = {[], [], []};

% fixation cross or dot
expectedCFG.fixation.type = 'cross';
Expand Down