How to make a raster plot of spikes in a network

A collection of noteworthy items selected by our moderators from discussions about making and using models with NEURON.

Moderators: wwlytton, tom_morse

ted
Posts: 5795
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

How to make a raster plot of spikes in a network

This is very easy with the NetCon class's record() method--
http://www.neuron.yale.edu/neuron/stati ... tml#record
In particular, I refer to the netcon.record(tvec, idvec, id) syntax.

For example, suppose your model neurons have been appended to a List called cells, and
that each one has its spike trigger zone at its soma. Then

Code: Select all

``````objref timevec, idvec, recncs, tobj, nil
timevec = new Vector()
idvec = new Vector()
recncs = new List()
for i=0,cells.count()-1 {
cells.object(i).soma tobj = new NetCon(&v(0.5), nil)
tobj.record(timevec, idvec, i+1) // so all the spike rasters lie above the x axis
recncs.append(tobj)
}
objref tobj // so we don't accidentally mess up the last NetCon``````
If you are recording spikes from artificial spiking cells, the syntax for setting up the NetCon
changes from this form
section netcon = new NetCon(&v(x), target)
to the simpler form
netcon = new NetCon(source, target)
That is, replace the statement
cells.object(i).soma tobj = new NetCon(&v(0.5), nil)
with
tobj = new NetCon(cells.object(i), nil)

Now all you have to do is run a simulation, then after the end of the simulation, pop up a
new Graph object, and use the Vector class's mark() method to draw vertical bars | --see
http://www.neuron.yale.edu/neuron/stati ... .html#mark

Code: Select all

``````objref g
proc plotraster() {
g = new Graph()
idvec.mark(g, timevec, "|")
}

proc myrun() {
run()
plotraster()
}

// call myrun() to launch a simulation and generate a raster plot
``````
Further refinements are possible, e.g. control of position and scaling of the raster plot,
or implementing a dynamically-updated raster plot, but this should be enough to get you
going.