diff --git a/src/aperture/apertureTexture.m b/src/aperture/apertureTexture.m index 001010f..e541abc 100644 --- a/src/aperture/apertureTexture.m +++ b/src/aperture/apertureTexture.m @@ -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); @@ -23,7 +23,7 @@ case 'none' - Screen('Fillrect', cfg.aperture.texture, transparent); + Screen('Fillrect', cfg.aperture.texture, TRANSPARENT); case 'circle' @@ -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)); @@ -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)); @@ -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), ... @@ -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, ... @@ -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 @@ -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 - % 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) diff --git a/src/drawFieldOfVIew.m b/src/drawFieldOfVIew.m new file mode 100644 index 0000000..7a15385 --- /dev/null +++ b/src/drawFieldOfVIew.m @@ -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 diff --git a/src/initPTB.m b/src/initPTB.m index d92d211..6e669a8 100644 --- a/src/initPTB.m +++ b/src/initPTB.m @@ -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 diff --git a/src/setDefaultsPTB.m b/src/setDefaultsPTB.m index 286ac44..2ed1dff 100644 --- a/src/setDefaultsPTB.m +++ b/src/setDefaultsPTB.m @@ -29,6 +29,7 @@ fieldsToSet.screen.monitorWidth = 42; fieldsToSet.screen.monitorDistance = 134; + fieldsToSet.screen.resolution = {[], [], []}; % fixation cross or dot fieldsToSet.fixation.type = 'cross'; diff --git a/tests/test_setDefaultsPTB.m b/tests/test_setDefaultsPTB.m index b184f48..7db37ed 100644 --- a/tests/test_setDefaultsPTB.m +++ b/tests/test_setDefaultsPTB.m @@ -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';