Tutorial in Systems Neurophysiology and Modeling Exercise #3: 2-D receptive fields part 1 - simple cells; orientation, spatial frequency and phase dependence. In this exercise, we will explore the properties of two-dimensional RF models. Step 1: We will start with a model Simple Cell based on a 2-D Gabor: x xc RF(x,y) exp 2x * cos 2 x * exp y y c x 2 2 2 y This RF is a Gabor in the x dimension multiplied by a simple Gaussian in the y dimension. It might not be obvious how to construct such a beast, so I’ll give you a hand. There is more than one way to accomplish this, but I think the easiest is to first set up a two-dimensional coordinate system. Start by specifying the range: xmin xmax ymin ymax = = = = -1.0; 1.0; -1.0; 1.0; and grain dx dy = 0.01; = 0.01; for x and y: Now, define one-dimensional vectors: x y = xmin:dx:xmax; = ymin:dy:ymax; Convert these to two-dimensional matrices: x2 y2 = ones(1,length(x))'*x; = y'*ones(1,length(y)); Each coordinate pair (x2ij, y2ij) specifies a single point in the 2-D plane. Now, it is easy to construct the RF. For simplicity, we’ll calculate the x and y parts separately and then multiply them together: Gx Gy Simple = ((exp(-(x2-xc).^2/sigx.^2)) .*(cos(2 * pi * wx * x2 + dtor * phi))); = (exp(-(y2-yc).^2/sigy.^2)); = Gx .* Gy; Note that the functions exp and cos are just as happy taking 2D matrix arguments as they are with 1D vectors or scalar arguments. Also note that we are using .* (array multiplication) to multiply rather than * (matrix multiplication). At this point you might want to plot the result. Matlab provides many ways to plot functions of two variables. A good choice in this case is to plot the RF profile as a gray-scale image. First, we need to replace the default color table with a linear gray table so that we get a grayscale image that faithfully represents the RF. Without going into the complexities of Matlab color management, just try the following: gmax = 256; gramp = ((0:(gmax-1))./(gmax-1))'; glin = [gramp gramp gramp]; figure(1); clf; colormap(glin); This will construct a 256 x 3 array of color values that go from 0 to 1.0. The function ‘colormap’ installs this array as the color table for the figure. The result is that image values in the range 0255 are mapped onto different shades of gray. To plot the x-component of the RF, try the following: subplot(3,2,1); image(gmax.*(0.5 + 0.5*Gx)); axis image; axis off; I’ll leave it as an exercise for you to figure out why we need to shift and scale the function Gx. The y-component can be drawn in a similar manner: subplot(3,2,3); image(gmax.*(0.5 + 0.5*Gy)); axis image; axis off; And, finally, the full RF: subplot(3,2,5); image(gmax.*(0.5+0.5*Simple)); axis image; axis off; Step 2: To test the properties of the RF, we want to see how it responds to stimuli called cosine gratings. Previously, we used one-dimensional cosine stimuli. A cosine grating is the same thing, just extended to two dimensions: I(x,y) cos(2 * * s * x ) Note that there is no variation in the y-dimension. The result is something that looks like a fuzzy bar pattern. Now, you might object that the stimulus above only describes a vertically oriented grating. How do we make gratings with different orientations? The answer is that we simply use a coordinate transformation: xrot xcos() y sin() and substitute xrot for x. So, now let’s set up a loop to vary both the orientation and spatial frequency of the stimulus. First, define the stimulus parameters and allocate a 2D array for storing the results: thetas sfreqs Sresp = -90:30:90; = 0.25 * 2.^(0:0.5:5); = zeros(length(sfreqs),length(thetas)); Now, the loops: for j = 1:length(sfreqs) for i = 1:length(thetas) theta wc phic xrot grating = = = = = thetas(i); sfreqs(j); 0.0; x2 * cos(dtor*theta) + y2 * sin(dtor*theta); cos(2 * pi * wc * xrot + phic); Sresp(j,i)= dx * dy * sum(sum(Simple.*grating)); subplot(3,2,2); image(255.*(0.5 + 0.5*grating)); axis image; axis off; drawnow; subplot(3,2,4); contour(thetas, sfreqs, Sresp.^0.5, 12, 'c'); axis([-90 90 0 max(sfreqs)]); drawnow; end; end; It should be obvious that the orientation and spatial frequency tuning are more or less separable. However, you can get some interesting interactions between sf tuning and orientation for certain parameter choices. Why might you get different sf tuning for stimuli at the preferred orientation compared to stimuli orthogonal to the preferred orientation? It should also be obvious that the preferred spatial frequency of the cell is related to the wx term in the Gabor. It might not be obvious that the broadness of spatial frequency tuning (aka the spatial frequency bandwidth) is related to the sigx term. When you increase the sigx term, how does the sf tuning width change? How do you account for this change? Similarly, the orientation bandwidth is related to the aspect ratio: sigy/sigx. What happens to the breadth of orientation tuning when sigy increases relative to sigx? How is this similar to the change in sf tuning? Step 3: One of the distinguishing features of simple cells is that they have spatially separate on and off regions. As a result, their response to cosine gratings depends on the phase of the stimulus wrt the center of the receptive field. We will now test the phase response using the optimal stimulus. First, find the preferred orientation and spatial frequency from the response calculated above: [i, j] = find (Sresp == max(max(Sresp))); wspeak = sfreqs(i); thetapeak = thetas(j); Next, setup a vector of phase angles, phi, and allocate storage for the responses, Sresp_phi: phis = -360:15:360; Sresp_phi = zeros(1,length(phis)); Finally, run through the phases and plot the result: for i = 1:length(phis) phic xrot = dtor*phis(i); = x2 * cos(dtor*thetapeak) + y2 * sin(dtor*thetapeak); grating = cos(2 * pi * wspeak * xrot + phic); Sresp_phi(i) = dx * dy * sum(sum(Simple.*grating)); subplot(3,2,2); image(255.*(0.5 + 0.5*grating)); axis image; axis off; subplot(3,2,6); plot(phis, Sresp_phi); drawnow; end; If you are running this on a fast computer, you might notice that the stimulus appears to drift slowly to the left as we change its phase. In practice, when physiologists test cortical neurons with cosine grating stimuli, they will drift (i.e move) the stimuli for an integer number of cycles. Simple cells will respond to this type of stimulation with a temporally modulated response. If you average over enough stimulus presentations, the response will approximate a cosine! If you record the responses of a visual neuron with cosine gratings of all spatial frequencies, orientations and phases, you have effectively computed something closely related to the Fourier Transform of the cell’s spatial weighing function. If the cell is linear or nearly linear, you should be able to take the set of responses and derive the swf by computing the inverse Fourier Transform. This is one way to map the receptive field of a visual neuron. Can you think of others?