Using natural scenes and natural movies as stimulus

Natural scene

In this example a static image is shown in 80 ms after a 40 ms delay.

import pylgn
import pylgn.kernels.spatial as spl
import pylgn.kernels.temporal as tpl
import quantities as pq

# create network
network = pylgn.Network()

# create integrator
integrator = network.create_integrator(nt=8, nr=9, dt=1*pq.ms, dr=0.1*pq.deg)

# create kernels
Wg_r = spl.create_dog_ft()
Wg_t = tpl.create_biphasic_ft()

# create neurons
ganglion = network.create_ganglion_cell(kernel=(Wg_r, Wg_t))

# create stimulus
stimulus = pylgn.stimulus.create_natural_image(filenames="natural_scene.png",
                                               delay=40*pq.ms,
                                               duration=80*pq.ms)
network.set_stimulus(stimulus, compute_fft=True)

# compute
network.compute_response(ganglion)

# visulize
pylgn.plot.animate_cube(ganglion.response,
                        title="Ganglion cell responses",
                        dt=integrator.dt.rescale("ms"))

The response of the ganglion cells is shown as a heatmap from blue to red (low to high response).

../_images/natural_scene.gif

Natural movie

Natural movies can be given as GIFs:

stimulus = pylgn.stimulus.create_natural_movie(filenames="natural_scene.gif")

Note

If GIF file do not have a “duration” key (time between frames) 30 ms is used by default. See Pillow documentation for details.