Page 1 of 1

firing frequency

Posted: Fri May 04, 2018 8:07 am
by fabien tell
Hello Ted,
I know that this topic has already been addressed in the forum but despite many trials I couldn’t make it to work properly. So I have to "abdicate".
I wrote the code thereafter. I got the correct number of spikes but I did not understant how to extract the timing from the netcon vector and to transform them in ISI.

Code: Select all

// frequence meter
objref rec, nil , inter_spike, time, spike_indx
spike_indx = new Vector()


inter_spike = new Vector()
time = new Vector () 
soma rec = new NetCon(&v(0.5), nil) // create a netcon that watch the soma to reach a threshold 
rec.threshold = -20  // record indexes when V crosses threshold
rec.record(spike_indx)
time.record(&t)

proc freqmeter () {
   
 nbspike = spike_indx.size()
 print "nb of spikes ", nbspike
 inter_spike=spike_indx.c 
 inter_spike.deriv 
 print inter_spike
}
I got :

nb of spikes 8 //correct
Vector[12] // ?

Thanks a lot

Re: firing frequency

Posted: Fri May 04, 2018 10:12 am
by ted
You got all the difficult stuff right, but instead of printing the contents of the Vector that holds the ISIs, you gave NEURON a print command that told it to print the name of that Vector. Instead of
print inter_spike
you want to use the Vector class's print method
inter_spike.print
(read about it in the documentation of the Vector class)

FYI given an objref foo,
print foo
tells NEURON to print the name of the particular object to which foo refers. That can be useful information during program development and debugging. This should be documented somewhere in the Programmer's Reference, but if it is, I can't find it.

Re: firing frequency

Posted: Fri May 04, 2018 11:21 am
by fabien tell
Hello Ted,

Thanks a lot. I'll try on monday.
I should expect to get 7 time intervals on the screen, right ?
Then if I need to send them into a file, I should proceed in the same way (using the right command of course).

To get the average ISI,I only need to sum all the values and divide them by nbspike -1 .

Code: Select all

somme= 0
for i=0 to nbspike-1 {

somme = somme + inter_spike[i]
 }
 
 Isi_avg= somme/(nbspike-1)
My I use a command like sum or Sd or Var if it does exist ?

Thanks a lot

Re: firing frequency

Posted: Fri May 04, 2018 12:53 pm
by ted
I should expect to get 7 time intervals on the screen, right ?
Yes.
My I use a command like sum or Sd or Var if it does exist ?
The Vector class has a lot of useful built-in functions, including sum, mean, stderr, stdev, var -- see
https://www.neuron.yale.edu/neuron/stat ... tml#Vector

Many cells show a slight variation of ISI, either slowing or speeding up a bit before reaching a steady firing rate. If that happens with your model, you might want to ignore the spikes that happen before a particular time. This file
https://www.neuron.yale.edu/ftp/ted/neu ... zation.zip
contains an exercise from the NEURON Summer Course that shows how to do this. The source code includes a serial implementation that you should be able to run without doing anything special; you might find some reusable bits in there. There is also a parallel implementation, but it requires MPI to be installed on your computer. If you are using Windows and need MPI, I highly recommend Microsoft's free implementation of MPI https://msdn.microsoft.com/en-us/librar ... 85%29.aspx