Elze Paper

Read the paper “Achieving precise display timing in visual neuroscience experiments” by Tobias Elze: Journal of Neuroscience Methods 191 (2010) 171–179. This is available online and a PDF is linkerd here.

Modify GenGrating

In class we wrote the function GenGrating (linked here). For the purposes of the rest of this assignment, the function as written has two related deficiencies. What is needed is a function that lets us specify a single frequency along with an orientation for the grating rather than separate horizontal and vertical frequencies. The current frequency arguments work as expected when only one of them is non-zero, as shown in panels A and B below. Also, as panel C illustrates, setting both frequency arguments to the same, non-zero value, produces a grating with a 45 degree orientation; however, the frequency of this tilted grating is the square root of 2 higher than what we might have expected. (Try comparing the distance spanned by 5 cycles of the grating in each figure.)

GenGrating(100, 100, 5, 0)

GenGrating(100, 100, 7, 0)

GenGrating(100, 100, 5, 5)

Write a new function, GenGrating2, that fixes these problems and has the calling sequence:

Grating = GenGrating2(Size, F, Ang)

Here Rows and Cols have been replaced with a single argument, Size, so the resulting image matrices will be square. The argument F is the frequency of the grating: i.e., the number of cycles of the grating across Size elements. The argument Ang specifies the orientation of the grating in radians. (Ang = 0 should produce a horizontal grating with vertical bars.) Hint: completing this exercise will involve using some simple trigonometry.

To view your results, you will also need the show function from class.

Generating Gabor Stimuli

Gaussian-windowed sinusoidal gratings have been used for a dizzying array of different experimental investigations. These stimuli are often referred to as Gabor patches (or simply as Gabors) after the mathematician who expounded particular theoretical advantages of their mathematical form.  As the figure below demonstrates, Gabors can be varied in many ways: e.g., size of the window, frequency the grating , and orientation of the grating.  (There are other variations not shown here. For example, still considering static Gabors, the contrast of the frequency modulation can be varied and the the window can be an oriented ellipse, not just circular. Moving Gabors have also proven to be quite useful stimuli, as are Gabors in the grating moves relative to the window.)

Your task is to write a function that generates Gabors. The calling sequence should be

Gabor = GenGabor(Size, F, Ang, Sigma)

Thinking about a Gabor as a Gaussian-windowed sinusoidal grating, should help you to see that you can generate one easily simply by combining appropriately (ah, there's the rub – but it requires only a single, simple, arithmetic, operation!) the outputs of GenGrating2, which you just wrote above,  and GenGaussBlob, which we wrote in class and is linked here. It may help to know that the upper, left Gabor above was produced with the call: GenGabor(100, 12, pi/4, 10).

Function to Create Stimuli for a Visual Search Experiment

Because Gabors can be manipulated on several well-defined physical continua, they would be useful as stimuli in a visual search experiment. The last part of this assignment is for you to write a function that generates stimulus arrays consisting of Gabors that might be used in such an experiment. Below is the calling sequence and description of the arguments such as might appear in the help section of the function you are to produce.

function canvas = MkGaborSearchArray(CanvasSz, GaborSz, Radius, StimSpecs)

% canvas = MkGaborSearchArray(CanvasSz, GaborSz, Radius, StimSpecs)

%

% Construct a matrix in canvas that can be used as the stimulus in a visual

%       search experiment based on Gabors, created by GenGabor, as stimuli.

% CanvasSz - canvas is a square matrix, this determines the number of rows

%       and columns it contains. This should be an odd number.

% GaborSz - The Gabors are generated in square patches. This gives their

%       size. This should be an odd number.

% Radius - The center of e ach of the Gabors is displayed on a circular

%       locus at this radius from the center of canvas.

% StimSpecs - This is a structure with one entry for each Gabor to be

%       included in the stimulus. Each entry should include the following

%       elements.

%   GaborAngle - The angle, in radians, where the center of this Gabor

%       should be displayed. An angle of 0 produces a stimulus directly

%       above the center of the canvas. Positive angles are clockwise from

%       there.

%   GratingFreq - The frequence of the Gabor grating.

%   GratingAng - The angle of the Gabor Grating.

%   GaborSigma - The speed of the intensity fall of in the Gabor grating

The example here was produced using the following code.

for i = 1:6

    ss(i).GaborAngle = 2 * pi * (i-1) / 6;

    ss(i).GratingFreq = 10;

    ss(i).GratingAng = 4*pi/16;

    ss(i).GaborSigma = 15;

end

ss(3).GratingAng = 6*pi/16;

canvas = MkGaborSearchArray(701, 101, 200, ss);

show(canvas);

What to Submit

Please submit a .zip file containing the following: