Introduction to Neural Networks
Mapping image coordinates to cortical coordinates

Off[SetDelayed::write]
Off[General::spell1]

Log polar model of image to striate cortex

We'll define an image-based coordinate system, e.g. to define pictures on a screen that one might look at. We'll loosely refer to this as the retinal coordinate system (ignoring the fact that there is a non-cartesian mapping of a flat screen to the approximately hemispherical retina). In other words, we'll treat the retina as if it is a flat screen.

Define Retina to Cortex map: u[x,y], v[x,y]

For complex variables:

w = log (z + ε),  
    where Re[z] ≥ 0
w = 2  log (ε) - log (ε - z),  
    where Re[z] < 0

A conformal map--i.e. preserves angles.

ϵ>0 keeps the log finite at the fovea (x=0,y=0). Express in terms of real variables, the complex log map for positive real can be written as:

Clear[u, v, ε, ε1, xf, yf, 
        xfε, yfε];
{u[x_, y_], 
          v[x_, y_]} := {Log[(x + ε)^2 + (y + ε)^2 ], 
          ArcTan[(y + ε)/(x + ε)]};

Find inverse map, from cortex to retina: xf[u,v], yf[u,v]

Solve[{u1 == u[x, y], v1 == v[x, y]}, {x, y}]

Use above (2nd) solution to define inverse maps:

{xfε[u1_, 
            v1_, ε_], 
          yfε[u1_, 
            v1_, ε_]} := {Cot[
              v1] (ε - ε Tan[
                    v1] - (ε/(1 + Tan[v1]^2)) - ((ε Tan[v1]^2)/(1 + Tan[v1]^2)) + (((Sqrt[(E^u1)]) Tan[v1])/(Sqrt[1 + Tan[v1]^2]))), ((-ε - ε Tan[v1]^2 + (Sqrt[(E^u1)]) Tan[v1] (Sqrt[1 + Tan[v1]^2]))/(1 + Tan[v1]^2))};

We'll use a fixed foveal offset ε1=.01 for the inverse functions xf[], yf[]

ε1 =  .01; ε  =  ε1;
{xf[u1_, v1_], 
          yf[u1_, v1_]} := {xfε[u1, v1, ε1], 
          yfε[u1, v1, ε1]};

Label fovea and 4 additional points defined on a circular retinal region: Red dot marks foveal coordinates

Define 5 points on retina

x0 = ε1;  
    y0 = x0;    
r = 0.5; θ = Pi/4;

x1 = x0;  x2  = r;
y1 =  -r;  y2 = r;

rlowleft = {x1, y1};  rhighleft = {x1, y2};
rlowright = {r*Cos[θ], -r*Sin[θ]};  
    rhighright = {r*Cos[θ], 
        r*Sin[θ]};

rfov =  {x0, y0};

Make graph of 5 retinal and corresponding cortical positions

Now map the five points to cortex

clowleft = {u[x1, y1], v[x1, y1]};  
    chighleft = {u[x1, y2], v[x1, y2]};
clowright = {u[r*Cos[θ], -r*Sin[θ]], 
          v[r*Cos[θ], -r*
              Sin[θ]]};
chighright = {u[r*Cos[θ], r*Sin[θ]], 
          v[r*Cos[θ], r*Sin[θ]]};
cfov =  {u[x0, y0], v[x0, y0]};

Make graph for retina

gret = 
        Show[Graphics[{{RGBColor[0, 0, 1], 
                Disk[rlowleft,  .02]}, {RGBColor[0, 1, 1], 
                Disk[rhighleft,  .02]}, {RGBColor[1, 0, 1], 
                Disk[rlowright,  .02]}, {RGBColor[1, 1, 0], 
                Disk[rhighright,  .02]}, {RGBColor[1, 0, 0], 
                Disk[rfov,  .02]}}, AspectRatio -> Automatic, 
            Axes -> Automatic, 
            DisplayFunction -> Identity]];

Make graph for cortex

gcor = 
        Show[Graphics[{{RGBColor[0, 0, 1], 
                Disk[clowleft,  .2]}, {RGBColor[0, 1, 1], 
                Disk[chighleft,  .2]}, {RGBColor[1, 0, 1], 
                Disk[clowright,  .2]}, {RGBColor[1, 1, 0], 
                Disk[chighright,  .2]}, {RGBColor[1, 0, 0], 
                Disk[cfov,  .2]}}, AspectRatio -> Automatic, 
            Axes -> Automatic, 
            DisplayFunction -> Identity]];

Show[GraphicsArray[{gret, gcor}]];

Note how points on a circle in the retina map to vertical line on the cortex graph.

Polar angle: Response to rotating spokes on the retina

Clear[polarFunction]
polarFunction[x_, y_, f_,  θ_] := 
        Cos[2*Pi*(f)*ArcTan[(y)/(x)] + θ];

Make rotating spokes graphics

Define a series of plots where contrast on a ring varies sinusoidally, and the phase shifts from one frame to the next

gpolar = 
        Table[DensityPlot[
            If[Sqrt[x^2 + y^2] ≤ r, 
              polarFunction[x, y, 2, θ], 1], {x, x0, r}, {y, -r, 
              r}, PlotPoints -> 120, Mesh -> False, 
            AspectRatio -> Automatic, Frame -> None, 
            DisplayFunction -> Identity], {θ, 
            0, (2*Pi - Pi/4), Pi/4}];

Define graphics predicting the cortical response to the rotating spokes

gtranspolar = 
        Table[DensityPlot[
            polarFunction[xf[u1, v1], yf[u1, v1], 2, θ], {u1, 
              cfov[[1]], u[x2, y1]}, {v1, v[x1, y1], 
              v[x1, y2]}, 
PlotPoints -> 100, 
            Mesh -> False, AspectRatio -> Automatic, 
            Frame -> None, DisplayFunction -> Identity], {θ, 
            0, (2*Pi - Pi/4), Pi/4}];

Show movies of retinal spokes stimulus (on left) with cortical response (on right)

Table[
        Show[GraphicsArray[{Show[gpolar[[i]], gret], 
              Show[gtranspolar[[i]], gcor]}], 
          DisplayFunction -> $DisplayFunction], {i, 1, 
          Length[gpolar]}];

Log Radial: Response to contracting rings on retina

Clear[radialFunction]
radialFunction[x_, y_, f_,  θ_] := 
        Cos[2*Pi*(f)*
              Log[Sqrt[
                    x^2 + (y)^2] + ε1] + θ];
Plot[radialFunction[x, 0, 1,  0], {x, 0,  .5}];

Make contracting rings retinal stimulus

gradial = 
        Table[DensityPlot[
            If[Sqrt[x^2 + y^2] ≤ r, 
              radialFunction[x, y, 3, θ], 1], {x, x0, r}, {y, -r, 
              r}, PlotPoints -> 120, Mesh -> False, 
            AspectRatio -> Automatic, Frame -> False, 
            DisplayFunction -> Identity], {θ, 
            0, (2*Pi - Pi/4), Pi/4}];

Define graphics predicting the cortical response to the rotating spokes

gtransradial = 
        Table[DensityPlot[
            radialFunction[xf[u1, v1], yf[u1, v1], 3, θ], {u1, 
              cfov[[1]], u[x2, y1]}, {v1, v[x1, y1], 
              v[x1, y2]}, 
PlotPoints -> 100, 
            Mesh -> False, AspectRatio -> Automatic, 
            Frame -> None, DisplayFunction -> Identity], {θ, 
            0, (2*Pi - Pi/4), Pi/4}];

Show movies of retinal rings stimulus (on left) with cortical response (on right)

Table[
        Show[GraphicsArray[{Show[gradial[[i]], gret], 
              Show[gtransradial[[i]], gcor]}], 
          DisplayFunction -> $DisplayFunction], {i, 1, 
          Length[gradial]}];

Read in image file & map it to cortex

Read in gray scale image

getinputpattern := 
        Module[{image}, 
          image = Import[
              Experimental`FileBrowse[False]]; 
image = 
            image /. Graphics -> List; 
image = 
            N[image[[1, 1]]]];

grayscaleretimage  =  getinputpattern;

Interpolate

retimageFunction = 
      ListInterpolation[
        Transpose[
          grayscaleretimage], {{ε1, r}, {-r, 
            r}}]

gcdan = 
        DensityPlot[
          retimageFunction[xf[u1, v1], yf[u1, v1]], {u1, cfov[[1]], 
            u[x2, y1]}, {v1, v[x1, y1], 
            v[x1, y2]}, 
PlotPoints -> 100, 
          Mesh -> False, AspectRatio -> Automatic, 
          Frame -> None, DisplayFunction -> Identity];

gretdan = 
        DensityPlot[
          If[Sqrt[x^2 + y^2] ≤ r, retimageFunction[x, y], 
            1], {x, ε1, r}, {y, -r, 
            r}, 
PlotPoints -> 100, 
          Mesh -> False, AspectRatio -> Automatic, 
          Frame -> None, DisplayFunction -> Identity];

Show[
        GraphicsArray[{Show[gretdan, gret, DisplayFunction -> Identity], 
            Show[gcdan, gcor, 
              DisplayFunction -> Identity]}]];

As before, the red dot markes the fovea.

References

Engel, S. A., Rumelhart, D. E., Wandell, B. A., Lee, A. T., Glover, G. H., Chichilnisky, E.-J., & Shadlen, M. N. (1994, 16 June 1994). fMRI of human visual cortex. Nature, 369, 525.

Schwartz, E. L. (1977). Spatial mapping in the primate sensory projection: analytic structure and relevance to perception. Biol Cybern, 25(4), 181-194.

Schwartz, E. L., Christman, D. R., & Wolf, A. P. (1984). Human primary visual cortex topography imaged via positron tomography. Brain Res, 294(2), 225-230.

Schwartz, E., Tootell, R. B., Silverman, M. S., Switkes, E., & De Valois, R. L. (1985). On the mathematical structure of the visuotopic mapping of macaque striate cortex. Science, 227(4690), 1065-1066.

Sereno, M. I., McDonald, C. T., & Allman, J. M. (1994). Analysis of retinotopic maps in extrastriate cortex. Cereb Cortex, 4(6), 601-620.