how do I change the position where a gabor patch is displayed (Psychtoolbox)?

5 vues (au cours des 30 derniers jours)
Ash
Ash le 13 Jan 2023
Réponse apportée : Voss le 13 Jan 2023
I was trying to add x and y coordinates to a gabor patch I generated but I can't figure out where to add this argument in a way where it will actually change the position rather than just presenting the gabor centrally.
% Clear the workspace and the screen
sca;
Unrecognized function or variable 'sca'.
close all;
clear;
% Setup PTB with some default values
PsychDefaultSetup(2);
% Set the screen number to the external secondary monitor if there is one
% connected
screenNumber = max(Screen('Screens'));
% Define black, white and grey
white = WhiteIndex(screenNumber);
grey = white / 2;
% Open the screen
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, grey,...
[], 32, 2, [], [], kPsychNeedRetinaResolution);
% Get the vertical refresh rate of the monitor
ifi = Screen('GetFlipInterval', window);
% Set maximum priority level
topPriorityLevel = MaxPriority(window);
Priority(topPriorityLevel);
%--------------------
% Gabor information
%--------------------
% Dimension of the region where will draw the Gabor in pixels
gaborDimPix = windowRect(4) / 10;
% Sigma of Gaussian
sigma = gaborDimPix / 8;
% Obvious Parameters
orientation = 0;
contrast = 10;
aspectRatio = 600.0;
phase = 1;
x=60;
y=20;
% Spatial Frequency (Cycles Per Pixel)
% One Cycle = Grey-Black-Grey-White-Grey i.e. One Black and One White Lobe
numCycles = 12;
freq = .12;
% Build a procedural gabor texture (Note: to get a "standard" Gabor patch
% we set a grey background offset, disable normalisation, and set a
% pre-contrast multiplier of 0.5).
backgroundOffset = [0.5 0.5 0.5 0.5];
disableNorm = 1;
preContrastMultiplier = 0.5;
gabortex = CreateProceduralGabor(window, gaborDimPix, gaborDimPix, [],...
backgroundOffset, disableNorm, preContrastMultiplier);
% Randomise the phase of the Gabors and make a properties matrix.
propertiesMat = [phase, freq, sigma, contrast, aspectRatio, x, y, 0];
%------------------------------------------
% Draw stuff
%------------------------------------------
% FLip to the vertical retrace rate
vbl = Screen('Flip', window);
% We will update the stimulus on each frame
waitframes = 1;
% We choose an arbitary value at which our Gabor will drift
phasePerFrame = 4 * pi;
while ~KbCheck
% Draw the Gabor. By default PTB will draw this in the center of the screen
% for us.
Screen('DrawTextures', window, gabortex, [], [], orientation, [], 1, 100, [],...
kPsychDontDoRotation, propertiesMat');
% Flip to the screen
vbl = Screen('Flip', window, vbl + (waitframes - 0.5 ) * ifi);
% Update the phase element of the properties matrix (we could if we
% want update any or all of the properties on each frame. Here the
% Gabor will drift to the left.
propertiesMat(1) = propertiesMat(1) + phasePerFrame;
end
% Clear screen
sca;

Réponses (1)

Voss
Voss le 13 Jan 2023
According to the documentation:
you can specify the location(s) to draw to as the fifth input argument to Screen, destinationRect(s). destinationRect(s) should be a 4-by-n matrix, for drawing to n locations.

Catégories

En savoir plus sur Timing and presenting 2D and 3D stimuli dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by