Here's one way to do this, illustrated in hoc. Should work fine as long as the few assumptions stipulated below are true, and that you're using serial execution to run simulations. Pythonists are invited to post their own code that satisfies the same assumptions.
1. Create a List whose elements are Vectors that capture the firing times of your model cells.
This code assumes that you have already set up a network whose cells are instances of cell classes, and that you have appended each of the model cells to a List called "cells":
Code: Select all
// Prepare to record spike trains
objref netcon, vec, spikes, nil // nil is just a handy alias for NULLobject
spikes = new List()
for i=0,cells.count()-1 { // iterate over all cells
vec = new Vector()
netcon = new NetCon(cells.object(i), nil)
netcon.record(vec) // vec will record the firing times
spikes.append(vec) // add vec to the list of vectors that record firing times
}
objref netcon, vec // we don't need these specific references any more
2. Create an instance of the Graph class that will be where you plot your spike rasters. This code will make a graph called graster appear near the top left of your display (screen coordinates are the 5th and 6th arguments):
Code: Select all
objref graster, spikey
graster = new Graph(0)
graster.size(0,tstop,0,cells.count())
graster.view(0, 0, tstop, cells.count(), 300, 105, 300.48, 200.32)
3. Write a procedure that can be called to plot the recorded spikes on graster.
Code: Select all
proc showraster() {
graster.erase_all()
for i = 0,cells.count()-1 { // iterate over all cells
// number of elements in spikey must equal number of spikes fired by cell i
// value of each element must equal i+1
spikey = spikes.object(i).c
spikey.fill(i+1)
spikey.mark(graster, spikes.object(i), "|", 6)
}
objref spikey // we don't need this specific reference any more
}
4. Write customized init and run procedures so that initialization clears the raster plot, and executing a simulation draws marks at appropriate locations in graster.
Code: Select all
proc init() {
finitialize(v_init)
fcurrent()
graster.erase_all()
}
proc run() {
running_ = 1
stdinit()
continuerun(tstop)
showraster()
}
There you have it. Put this code into a file called raster.hoc, and modify your own model program so that it loads raster.hoc BEFORE it calls run().