Gabor patches in matlab
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all. My lab is interested in using gabor patches in a new study and I have found some code online for creating them. However, I do not typically use matlab or code much and have run into a bit of a problem. The code creates a gabor patch on a grey background and allows you to easily adjust contrast, angle of display, etc. The problem is that I want to view the gabor patch as an image (using imagesc for instance) so that I can save the image and use it in eprime. Unfortunately, the code opens the image as a program so that it is displayed in full screen and requires me to press a key to get out. Could someone look at the code and give me some tips as to what I might do to change it so that the gabor opens in imagesc or some other image viewer? Thanks.
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
0 Kommentare
Antworten (1)
Kushagr Gupta
am 8 Jun. 2017
Bearbeitet: Kushagr Gupta
am 8 Jun. 2017
The code shared here is not complete and does not include the implementation of the 'screen' function which is not a MATLAB inbuilt function. That function is responsible for displaying the gabor patch on entire screen and you can modify its definition to suit your requirement.
That being said, I believe, the variable "gabortex" is what you are interested in and you can pass that to imagesc and save it in a MAT file.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!