Calculating Firing Frequency
Posted: Thu Dec 14, 2017 10:08 am
Hello, I am new to NEURON (most of my experience is with Matlab, some Python). I am trying to calculate the firing frequency for a given current injection. I am having difficulty understanding how to use NetCon per viewtopic.php?t=2299. Could you clarify the steps once I have soma.v(.5) generated?
Here is example code for a single soma - current injection:
load_file("nrngui.hoc")
load_file("BaseClamp.ses") // opens voltage graph, run control, point manager
tstop = 500
// Build Cell
create soma
access soma
soma nseg = 1
soma diam = 18.8
soma L = 18.8
soma Ra = 123.0
soma insert hh
soma cm=1
//Stimulation
objectvar stim
stim = new IClamp(0.5)
stim.del = 100
stim.dur = 100
stim.amp = 0.1
// Identify spikes from v(.5)
objref nc, nil
spikeTotal = 0
freq= 0
soma nc = new NetCon(&v(.5), nil)
nc.threshold = 0 // watch out! only one threshold per presyn location
nc.record("handle()")
proc handle() {
print "called handle() at time ", t, " when soma.v(.5) = ", soma.v(.5)
stoprun = 1 // Will stop but may go one extra step. Also with
// local step the cells will be at different times.
// So may wish to do a further...
cvode.event(t+1e-6)
spikeTotal = spikeTotal + 1
}
cvode_active(1) // optional. but fixed step will probably do one extra time step
cvode.condition_order(2) // optional. but much more accurate event time evaluation.
run()
freq = spikeTotal / (stim.dur)
print "after run(), t = ", t, " and soma.v(.5) = ", soma.v(.5)
print "Frequency: ",freq,"/n SpikeTotal: ",spikeTotal
Here is example code for a single soma - current injection:
load_file("nrngui.hoc")
load_file("BaseClamp.ses") // opens voltage graph, run control, point manager
tstop = 500
// Build Cell
create soma
access soma
soma nseg = 1
soma diam = 18.8
soma L = 18.8
soma Ra = 123.0
soma insert hh
soma cm=1
//Stimulation
objectvar stim
stim = new IClamp(0.5)
stim.del = 100
stim.dur = 100
stim.amp = 0.1
// Identify spikes from v(.5)
objref nc, nil
spikeTotal = 0
freq= 0
soma nc = new NetCon(&v(.5), nil)
nc.threshold = 0 // watch out! only one threshold per presyn location
nc.record("handle()")
proc handle() {
print "called handle() at time ", t, " when soma.v(.5) = ", soma.v(.5)
stoprun = 1 // Will stop but may go one extra step. Also with
// local step the cells will be at different times.
// So may wish to do a further...
cvode.event(t+1e-6)
spikeTotal = spikeTotal + 1
}
cvode_active(1) // optional. but fixed step will probably do one extra time step
cvode.condition_order(2) // optional. but much more accurate event time evaluation.
run()
freq = spikeTotal / (stim.dur)
print "after run(), t = ", t, " and soma.v(.5) = ", soma.v(.5)
print "Frequency: ",freq,"/n SpikeTotal: ",spikeTotal