# How to display Gabor stimuli toward left of screen instead of center

**URL:** <https://psychtoolbox.discourse.group/t/how-to-display-gabor-stimuli-toward-left-of-screen-instead-of-center/3314>\
**Category:** Programming Help\
**Created:** [July 30, 2020, 1:28pm UTC](https://psychtoolbox.discourse.group/t/how-to-display-gabor-stimuli-toward-left-of-screen-instead-of-center/3314 "2020-07-30T13:28:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DBermudez0](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DBermudez0](https://psychtoolbox.discourse.group/u/DBermudez0)\
**Post date:** [July 30, 2020, 1:28pm UTC](https://psychtoolbox.discourse.group/t/how-to-display-gabor-stimuli-toward-left-of-screen-instead-of-center/3314/1 "2020-07-30T13:28:45Z")

</div>

if true  
% 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;  
% Skip sync tests for demo purposes only  
Screen(‘Preference’, ‘SkipSyncTests’, 2);  
% Open the screen  
[window, windowRect] = PsychImaging(‘OpenWindow’, screenNumber, grey, [], 32, 2,…  
[], [], kPsychNeed32BPCFloat);  
% Dimension of the region where will draw the Gabor in pixels  
gaborDimPix = windowRect(4) / 2;  
% Sigma of Gaussian  
sigma = gaborDimPix / 7;  
% Obvious Parameters  
orientation = 0;  
contrast = 0.8;  
aspectRatio = 1.0;  
phase = 0;  
% Spatial Frequency (Cycles Per Pixel)  
% One Cycle = Grey-Black-Grey-White-Grey i.e. One Black and One White Lobe  
numCycles = 5;  
freq = numCycles / gaborDimPix;  
% 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.0];  
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, 0, 0, 0];  
% Draw the Gabor. By default PTB will draw this in the center of the screen  
% for us.  
Screen(‘DrawTextures’, window, gabortex, [], [], orientation, [], [], [], [],…  
kPsychDontDoRotation, propertiesMat’);  
% Flip to the screen  
Screen(‘Flip’, window);  
% Wait for a button press to exit

KbWait;

% Clear screen  
sca;  
end

I have the code above which displays a gabor patch at the center of the screen. How can I change the code so I can display the gabor stimuli towards the left of the screen instead of the default center of the screen?

---

<div class="post-metadata">

**Author:** ![Ian-Max-Andolina](https://yyz2.discourse-cdn.com/free1/user_avatar/psychtoolbox.discourse.group/ian-max-andolina/32/4_2.png) [@Ian-Max-Andolina](https://psychtoolbox.discourse.group/u/Ian-Max-Andolina)\
**Post date:** [July 30, 2020, 2:02pm UTC](https://psychtoolbox.discourse.group/t/how-to-display-gabor-stimuli-toward-left-of-screen-instead-of-center/3314/2 "2020-07-30T14:02:18Z")

</div>

If you read the documentation for DrawTextures:

```matlab
Screen DrawTextures?

```

```auto
Screen('DrawTextures', windowPointer, texturePointer(s) [, sourceRect(s)] [, destinationRect(s)] [, rotationAngle(s)] [, filterMode(s)] [, globalAlpha(s)] [, modulateColor(s)] [, textureShader] [, specialFlags] [, auxParameters]);

```

You will see the 4th parameter is `destinationRect(s)` which is a PTB drawing position defined as a [rect]angle of the order: `[left,top,right,bottom]`. Type `help PsychRects` for more info and functions for rect management…
