Plotting Percent Activity of Artificial Cell Network
Posted: Sat Oct 06, 2012 4:23 pm
I have established working hoc code for a network model based on some published connectivity data. I am interested in not just generating the rasterplot, but would like to see a plot of the % of currently firing neurons. I thought I had figured out a way of doing so by manipulating the rasterplot code in Chapter 11 of the NEURON book, by using .histogram to attempt to bin each vector in the variable spikes - followed by a plotactivity() protocol that attempts to sum the bins together and normalize the values. The modified rig.hoc file is shown here:
I tried to highlight the parts I added with //NEW.
Unfortunately nothing plots on activityPlot, and when further investigated I find that vec2 in prepraster() never contains values other than 0 (tested with a for-loop):
I'm at a real loss as to what I'm doing wrong here with trying to use .histogram. I attempted running the same code just in nrniv and the concept seems like it should work... are there any glaring mistakes you can see?
Thank you!
Code: Select all
sample_rate = 1 //ms // NEW
objref netcon, vec, spikes, nil, graster
objref spikeBins, activityPlot, vec2 // NEW
proc preprasterplot() {
spikes = new List()
spikeBins = new List() // NEW
for i=0, cells.count()-1 {
vec = new Vector()
vec2 = new Vector() // NEW
netcon = new NetCon(cells.object(i).pp,nil)
netcon.record(vec)
spikes.append(vec)
vec2 = spikes.object(i).histogram(0, tstop, sample_rate) // NEW
spikeBins.append(vec2) // NEW
}
objref netcon, vec, vec2 // NEW
graster = new Graph(0)
graster.view(0,0, tstop, cells.count(), 300, 105, 300.48, 500)
activityPlot = new Graph(0) // NEW
activityPlot.view(0,0, tstop, 100,500, 105, 300.48, 700) // NEW
}
preprasterplot()
objref spikey
proc showraster() {
graster.erase_all()
for i=0, cells.count()-1 {
spikey = spikes.object(i).c
spikey.fill(i+1)
spikey.mark(graster, spikes.object(i), "|", 6)
}
objref spikey
}
// BELOW ALL NEW
objref percent, x_values
proc showactivity(){
activityPlot.erase_all()
percent = spikeBins.object(0).c
percent.fill(0)
for i=0, cells.count()-1{
percent.add(spikeBins.object(i))
}
percent.div(cells.count())
x_values = spikeBins.object(0).c
x_values.indgen(sample_rate)
percent.line(activityPlot, x_values)
}
// END NEW
proc run() {
stdinit()
continuerun(tstop)
showraster()
showactivity() // NEW
}
Unfortunately nothing plots on activityPlot, and when further investigated I find that vec2 in prepraster() never contains values other than 0 (tested with a for-loop):
Code: Select all
proc preprasterplot() {
spikes = new List()
spikeBins = new List()
for i=0, cells.count()-1 {
vec = new Vector()
vec2 = new Vector()
netcon = new NetCon(cells.object(i).pp,nil)
netcon.record(vec)
spikes.append(vec)
vec2 = spikes.object(i).histogram(0, tstop, sample_rate)
spikeBins.append(vec2)
for j = 0, vec2.size()-1 { //TEST
if(vec2.x(j)!=0) print j
}
}
objref netcon, vec, vec2
graster = new Graph(0)
graster.view(0,0, tstop, cells.count(), 300, 105, 300.48, 500)
activityPlot = new Graph(0)
activityPlot.view(0,0, tstop, cells.count(),500, 105, 300.48, 700)
}
Thank you!