Contents
- display an image in cogent with dimensions in visual angle
- calculate screen dimensions in degrees
- make stimulus array
- start up cogent
- set screen coordinates to visual angle
- make grid of points
- make a radial pattern of gabors
- load image into sprite
- put stimulus up on display in different locations
- same display with eccentricity scaling
- all done
display an image in cogent with dimensions in visual angle
Elliot Freeman 02/07
scrDimH = 100; %% horizontal screen dimension (mm) scrDimV = 75; %% vertical screen dimension (mm) viewDist = 570; %% viewing distance (mm) window = 0; bg = [.5, .5, .5]; stimRGB = [1 0 0];
calculate screen dimensions in degrees
scrDegH = visang(viewDist, [], scrDimH); % horizontal screen dimension in degrees scrDegV = visang(viewDist, [], scrDimV); % vertical screen dimension in degrees
Error using ==> evalin Undefined command/function 'visang'.
make stimulus array
imSize = 50; % image size: n X n lamda = 5; % wavelength (number of pixels per cycle) theta = 0; % grating orientation sigma = 5; % gaussian standard deviation in pixels phase = 0.25; % phase (0 -> 1) trim = .005; % trim off edges of gaussian with values < trim
start up cogent
config_display(window); config_keyboard; start_cogent
set screen coordinates to visual angle
this command rescales the display coordinates left to right edges now go from -scrDegH/2 to scrDegH/2 lower and upper edges now go from -scrDegV/2 to scrDegV/2 Zero is always at the centre.
cgscale(scrDegH);
make grid of points
make coordinates for a regular grid
nItemsPerRow = 5; % how many elements per row pos = linspace(-scrDegV, scrDegV, nItemsPerRow) /2; % 2dimensional grid of position pos = pos * .8; % scale a bit to stop falling off edge of screen [gridX gridY] = meshgrid(pos); % make grid npos = length(pos) .^2; % total number of elements cgellipse(gridX, gridY, ones(npos,1), ones(npos,1), 'f'); % put up ellipses cgflip(bg(1), bg(2), bg(3)); % show it waitkeydown(inf)
make a radial pattern of gabors
[theta radius] = cart2pol(gridX, gridY); % find orientation and radius from centre for each position theta = ((-theta / (pi*2)) * 360); % convert from radians to degrees of orientation theta = theta + 90; % add 90: radial pattern; add 0: circular pattern
load image into sprite
for i = 1:npos % make gabors varying in orientation im = gaborFn(imSize, lamda, sigma, theta(i), phase); % gabor function im = (im + 1) / 2; % convert values -1:1 to 0:1 % transpose and split into 3 colour channels im = im'; imRGB = [im(:) im(:) im(:)]; % reassemble into 3-column array cgloadarray(i, imSize, imSize, imRGB); end
put stimulus up on display in different locations
if cgdrawsprite has no width/height arguments (or they are 0,0) the image is displayed unscaled i.e. all pixels are normal size
for i = 1: npos cgdrawsprite(i, gridX(i), gridY(i)); % put stimulus in successive grid positions end cgflip(bg(1), bg(2), bg(3)); % show it waitkeydown(inf)
same display with eccentricity scaling
if cgdrawsprite has width/height arguments, the image dimensions are in visual angle
for i = 1:npos % put stimulus in successive grid positions with different sizes cgdrawsprite(i, gridX(i), gridY(i), radius(i)/2, radius(i)/2); end cgflip(bg(1), bg(2), bg(3)); % show it
all done
waitkeydown(inf) cgshut;