## Calculating Firing Frequency

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

### Calculating Firing Frequency

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("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

ted
Posts: 5335
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

### Re: Calculating Firing Frequency

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.