How to make a raster plot of spikes in a network
Posted: Thu Sep 20, 2007 10:05 am
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
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
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.
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
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
or implementing a dynamically-updated raster plot, but this should be enough to get you
going.