Calculating Firing Frequency

The basics of how to develop, test, and use models.
Post Reply
Posts: 3
Joined: Mon Nov 20, 2017 11:06 am

Calculating Firing Frequency

Post by med » 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("") // 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

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

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...
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.

freq = spikeTotal / (stim.dur)
print "after run(), t = ", t, " and soma.v(.5) = ", soma.v(.5)
print "Frequency: ",freq,"/n SpikeTotal: ",spikeTotal

Site Admin
Posts: 5169
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine

Re: Calculating Firing Frequency

Post by ted » Thu Dec 14, 2017 11:48 am

proc handle() is not particularly useful. Get rid of it.
Instead, use the Vector class's record method to capture the spike times to a Vector.
From the recorded spike times discover the interspike intervals, and from that get spike frequency.

freq = spikeTotal / (stim.dur)
fails badly if firing stops well before the end of the stimulus.
It is correct only if firing rate is constant and stimulus duration is an integer multiple of interspike interval (ISI).
Neither of these is true. In particular, during repetitive firing, the first few ISIs generated by the HH mechanism change; because of this variation, you may want to ignore the first 5 or 6 ISIs.

Post Reply