Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreffle authored Aug 29, 2017
1 parent 67a838d commit c5e729e
Showing 1 changed file with 131 additions and 1 deletion.
132 changes: 131 additions & 1 deletion Ch2 Exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,46 +124,176 @@ def Ex5():

def Ex6():
'''
Performthe integrals in equations 2.31 and 2.32 for the case sigmax =
sigmay = sigma to obtain the results
(A/2) * e**(- (sigma**2 (k**2 + k**2)) / 2) * (cos(phi - psi) * e**(sigma**2 * k * K * cos(sigma)) + cos(phi - psi) * e**(-simga**2 * k * K * cos(sigma)))
and
Lt(t) = ( (alpha**6 * |w| * root(w**2 + 4alpha**2) / (w**2 + alpha**2)**4) ) * cos(w*t - delta)
with
delta = 8 * arctan (w / alpha) + arctan (2alpha/w) - PI
From these results, verify the selectivity curves in figures 2.15 and
2.16. In addition, plot delta as a function of w.
'''

def Ex7():
'''
Numerically compute the spatial part of the linear response of a
simple cellwith a separable space-time receptive field to a sinusoidal
grating, as given by equation 2.31. Use a stimulus oriented with
Phi = 0. For the spatial receptive field kernel, use equation 2.27 with
sigma*x = sigma*y = 1degrees, phi = 0, and 1/k = 0.5degrees. Plot Ls as a
function of K taking Phi = 0 and A = 50. This determines the
frequency selectivity of the cell. What is its preferred spatial
frequency? Plot Ls as a function of Phi taking 1/K = 0.5degrees and A = 50. This determines the spatial phase selectivity of the cell. What is its
preferred spatial phase?
'''

def Ex8():
'''
'''
Consider a complex cell with the spatial part of its response given by
L2,1 + L2,2, where L1 and L2 are linear responses determined by equation
2.31 with kernels given by equation 2.27 with sigmax = sigmay =
1degrees, and 1/k = 0.5degrees; and with phi = 0 for L1 and phi =
-PI/2 for L2. Use a stimulus oriented with Phi = 0. Compute and plot
L2,1 + L2,2 as a function of K taking Phi = 0 and A = 5. This
determines the spatial frequency selectivity of the cell. Compute and
plot L2,1 + L2,2 as a function of Phi taking 1/K = 0.5degrees and A =
5. This determines the spatial phase selectivity of the cell. Does the
spatial phase selectivity match what you expect for a complex cell?
'''


def Ex9():
'''
Consider the linear temporal response for a simple or complex cell
given by equation 2.32with a temporal kernel given by equation 2.29
with 1/alpha = 15 ms. Compute and plot Lt(t) for w = 6PI/s. This
determines the temporal response of the simple cell. Do not plot the
negative part of Lt(t) because the cell cannot fire at a negative rate.
Compute and plot L2t(t) for w = 6PI/s. This determines the temporal
response of a complex cell. What are the differences between the
temporal responses of the simple and complex cells?
'''

def Ex10():
'''
Compute the response of amodel simple cellwith a separable spacetime
receptive field to a moving grating
s(x, y, t) = cos(Kx - w*t) .
For Ds, use equation 2.27with sigmax = sigmay = 1degrees, Phi = 0, and 1/k = 0.5degrees. For
Dt, use equation 2.29 with 1/alpha = 15 ms. Compute the linear estimate
of the response given by equation 2.24 and assume that the actual
response is proportional to a rectified version of this linear response
estimate. Plot the response as a function of time for 1/K = 1/k = 0.5degrees
and w = 8PI/s. Plot the response amplitude as a function of w for
1/K = 1/k = 0.5degrees and as a function of K for w = 8PI/s.
'''

def Ex11():
'''
Compute the response of a model complex cell to the moving grating
s(x, y, t) = cos(Kx - w*t)
The complex cell should be modeled by squaring the unrectified
linear response estimate of a simple cells with a spatial receptive
field given by equation 2.27 with sigmax = sigmay = 1degrees, Phi = 0, and 1/k = 0.5degrees,
and adding this to the square of the unrectified linear response of
a second simple cell with identical properties except that its spatial
phase preference is Phi = -PI/2 instead of Phi = 0. Both linear responses
are computed fromequation 2.24. For both of these, use equation 2.29
with 1/alpha = 15 ms for the temporal receptive field. Plot the complex
cell response as a function of time for 1/K = 1/k = 0.5degrees and w = 8PI/s.
Plot the response amplitude as a function of w for 1/K = 1/k = 0.5degrees
and as a function of K for w = 8PI/s.
'''

def Ex12():
'''
Construct a model simple cell with the nonseparable space-time receptive
field described in the caption of figure 2.21B. Compute its
response to the moving grating
s(x, y, t) = cos(Kx - w*t) .
Plot the amplitude of the response as a function of the velocity of the
grating, w/K, using w = 8PI/s and varying K to obtain a range of both
positive and negative velocity values (use negative K values for this).
Show that the response is directionally selective.
'''

def Ex13():
'''
Construct amodel complex cell that is disparity tuned but insensitive
to the absolute position of a grating. The complex cell is constructed
by summing the squares of the unrectified linear responses of two
simple cells, but disparity effects are now included. For this exercise,
we ignore temporal factors and only consider the spatial dependence
of the response. Each simple cell response is composed of two terms
that correspond to inputs coming from the left and right eyes. Because
of disparity, the spatial phases of the image of a grating in the
two eyes, PhiL and PhiR, may be different. We write the spatial part of
the linear response estimate for a grating with the preferred spatial
frequency (k = K) and orientation (Psi = theta = 0) as
L1 = A/2 * (cos(PhiL) + cos(PhiR)) ,
assuming that phi = 0 (this equation is a generalization of equation
2.34). Let the complex cell response be proportional to L2,1 + L2,2,
where L2 is similar to L1 but with the cosine functions replaced by
sine functions. Show that the response of this neuron is tuned to the
disparity, PhiL - PhiR, but is independent of the absolute spatial phase
of the grating, PhiL + PhiR. Plot the response tuning curve as a function
of disparity. (See DeAngelis, GC, Ohzawa, I, & Freeman, RD (1991)
Depth is encoded in the visual cortex by a specialized receptive field
structure. Nature 352:156–159.)
'''

def Ex14():
'''
Determine the selectivity of the LGN receptive field of equation 2.45
to spatial frequency by computing its integrals when multiplied by
the stimulus
s = cos(Kx)
for a range of K values. Use sigmac = 0.3degrees, sigmas = 1.5degrees, B = 5, 1/alpha = 16
ms, and 1/Beta = 64 ms, and plot the resulting spatial frequency tuning
curve.
'''

def Ex15():
'''
Construct the Hubel-Wiesel model of a simple-cell spatial receptive
field, as depicted in figure 2.27A. Use difference-of-Gaussian functions
(equation 2.45) to model the LGN receptive fields. Plot the
spatial receptive field of the simple cell constructed by summing
the spatial receptive fields of the LGN cells that provide its input.
Compare the result of summing appropriately placed LGN centersurround
receptive fields (figure 2.27A) with the results of an appropriately
adjusted Gabor filter model of the simple cell that uses the
spatial kernel of equation 2.27.
'''

def Ex16():
'''
Construct the Hubel-Wiesel model of a complex cell, as depicted in
figure 2.27B. UseGabor functions (equation 2.27) to model the simple
cell responses, which should be rectified before being summed. Plot
the spatial receptive field of the complex cell constructed by summing
the different simple cell responses. Compare the responses of a complex
cell constructed by linearly summing the outputs of simple cells
(figure 2.27B) with different spatial phase preferences with the complex
cell model obtained by squaring and summing two unrectified
simple cell responses with spatial phases 90degrees apart as in exercise 8.
'''


Expand Down

0 comments on commit c5e729e

Please sign in to comment.