Hi, I im trying to create a vector with the spike time (time wich there`s a spike) using NetCon. I read about NetCon but don't know how to start. Also, it say`s that to use NetCon, we must have a CVode? Maybe a litle hint could help to start the code.
BUGS
NetCon can currently only be used if a CVode object exists
http://www.neuron.yale.edu/neuron/stati ... tml#NetCon
Find spike time
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Find spike time
Hint: use the working example that is provided in the documentation oftony wrote:Hi, I im trying to create a vector with the spike time (time wich there`s a spike) using NetCon. I read about NetCon but don't know how to start.
the record() method, which I quote here:
Code: Select all
objref vec, netcon, nil
vec = new Vector()
netcon = new NetCon(source, nil)
netcon.record(vec)
objref netcon
trigger zone is the "watched" location--that is, when creating the NetCon
you may wish to use the syntax
section netcon = new NetCon(&v(x), nil)
where section(x) is the spike trigger zone.
Code: Select all
Also, it say`s that to use NetCon, we must have a CVode?
^ syntax error--not a contraction or possessive form
load_file("nrngui.hoc")
you automatically get an instance of the CVode class (even if you don't
activate variable time step integration). So everything should work fine.
More spike times
I decided to try out Ted's advice using NetCon.record to create a vector of spike times. I decided to use the tutorial by Andrew Gillies and David Sterratt to play with this (since many newbies *should* have done this tutorial).
Here is the hoc code with some changes. There are 4 subthalamic cells; the first one gets synaptic input from the other three which are driven by an IClamp. The goal was to get a vector of spike times (spkt) and spike id numbers (spkid) so that I could go back and figure out which cell spiked at what time.
Now bring up the "RunControl" from the Tools menu, hit "Init & Run" and then from the prompt you can type:
and,
to get a list of spike times and the id number that says which cell is associated with each spike time.
So, here are my questions for the NEURON sages:
1) Why does the code fragment for netcon.record (Prog Ref) include the final,? (I can comment it out and get the same results.)
2) How could I return the value of the last NetCon[id] so that I could change the numbers in the spkid vector to be more straight forward?
3) Did I do this right, or how would you improve this?
Here is the hoc code with some changes. There are 4 subthalamic cells; the first one gets synaptic input from the other three which are driven by an IClamp. The goal was to get a vector of spike times (spkt) and spike id numbers (spkid) so that I could go back and figure out which cell spiked at what time.
Code: Select all
load_file("nrngui.hoc")
objref cvode
cvode = new CVode(0)
begintemplate SThcell
public soma, treeA, treeB, nclist
create soma, treeA[1], treeB[1]
objectvar f, nclist
proc init() {local i, me, child1, child2
create soma
nclist = new List()
soma {
nseg = 1
diam = 18.8
L = 18.8
Ra = 123.0
insert hh
gnabar_hh=0.25
gl_hh = .0001666
el_hh = -60.0
}
f = new File()
f.ropen("treeA.dat")
ndendA = f.scanvar()
create treeA[ndendA]
for i = 0,ndendA-1 {
me = f.scanvar() - 1
child1 = f.scanvar() - 1
child2 = f.scanvar() - 1
treeA[me] {
nseg = 1
diam = f.scanvar()
L = f.scanvar()
Ra = 123
// initialise and clear the 3D information
pt3dclear()
pt3dadd(f.scanvar(),f.scanvar(),f.scanvar(),diam)
pt3dadd(f.scanvar(),f.scanvar(),f.scanvar(),diam)
insert pas
g_pas = .0001666
e_pas = -60.0
if (child1 >= 0) {
//printf("connecting tree A dendrite %d (0 end) to parent %d (1 end)\n",child1,me)
connect treeA[child1](0), 1
}
if (child2 >= 0) {
//printf("connecting tree A dendrite %d (0 end) to parent %d (1 end)\n",child2,me)
connect treeA[child2](0), 1
}
}
}
f.close()
f.ropen("treeB.dat")
ndendB = f.scanvar()
create treeB[ndendB]
for i = 0,ndendB-1 {
me = f.scanvar() - 1
child1 = f.scanvar() - 1
child2 = f.scanvar() - 1
treeB[me] {
nseg = 1
diam = f.scanvar()
L = f.scanvar()
Ra = 123
// initilise and clear the 3D information
pt3dclear()
pt3dadd(f.scanvar(),f.scanvar(),f.scanvar(),diam)
pt3dadd(f.scanvar(),f.scanvar(),f.scanvar(),diam)
insert pas
g_pas = .0001666
e_pas = -60.0
if (child1 >= 0) {
//printf("connecting tree B dendrite %d (0 end) to parent %d (1 end)\n",child1,me)
connect treeB[child1](0), 1
}
if (child2 >= 0) {
//printf("connecting tree B dendrite %d (0 end) to parent %d (1 end)\n",child2,me)
connect treeB[child2](0), 1
}
}
}
f.close()
// Connect things to the soma
connect treeA[0](0), soma(1)
connect treeB[0](0), soma(0)
}
endtemplate SThcell
tstop = 300
ndend = 2
nSThcells = 4
objectvar SThcells[nSThcells]
for i = 0, nSThcells-1 {
SThcells[i] = new SThcell()
}
objectvar stim[nSThcells]
for i = 1, nSThcells-1 SThcells[i].soma {
stim[i] = new IClamp(0.5)
stim[i].del = 100+(2*i)
stim[i].dur = 100
stim[i].amp = 0.15
}
// SThcells[1]&[2]&[3] -> SThcells[0].soma
maxsyn = 10
objectvar syn[maxsyn]
SThcells[0].treeA[7] syn[0] = new ExpSyn(0)
for i = 1, nSThcells-1 SThcells[i].soma {
SThcells[0].nclist.append(new NetCon(&v(1), syn[0], -20, 1, 0.5))
}
// NetCon for recording spike trains
objref spkt, spkid, netcon, nil
spkt = new Vector()
spkid = new Vector()
for i = 0, nSThcells-1 SThcells[i].soma {
netcon = new NetCon(&v(0.5), nil)
netcon.threshold = -20
netcon.record(spkt, spkid)
}
objref netcon
access SThcells[0].soma
Code: Select all
oc>spkt.printf("%6.2f\n")
Code: Select all
oc>spkid.printf(%1.0f\n")
So, here are my questions for the NEURON sages:
1) Why does the code fragment for netcon.record (Prog Ref) include the final,
Code: Select all
objref netcon
2) How could I return the value of the last NetCon[id] so that I could change the numbers in the spkid vector to be more straight forward?
3) Did I do this right, or how would you improve this?
Answering my own question #2
Whoops... I noticed that there was another argument to netcon.record that solves this. In the for loop where the spike times are recorded just change one line to,2) How could I return the value of the last NetCon[id] so that I could change the numbers in the spkid vector to be more straight forward?
Code: Select all
netcon.record(spkt, spkid, i)
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Destroying the NetCon prevents reusing the NetCon for some other purpose, which1) Why does the code fragment for netcon.record (Prog Ref) include the final,
objref netcon
would have the side effect of interfering with the recording. In the Programmer's
Reference see
http://www.neuron.yale.edu/neuron/stati ... tml#record
in particular this sentence:
Here "source" means the bit of code that watches for threshold crossing.If a source is recording a vector, that source is not destroyed when the last netcon
connecting to it is destroyed and it continues to record.
Also please read chapter 13 Object-oriented programming in The NEURON Book, if
you haven't already done so. If you don't have the book, at least read this excerpt from
the old reference manual
http://www.neuron.yale.edu/neuron/stati ... n/obj.html
(somehow I suspect that you have read one or both of these).
One suggestion: modularize the code. Makes development and debugging easier.3) Did I do this right, or how would you improve this?
Relegate the template to a file by itself.
Put the code that actually creates new cells in a second file.
Put the code that sets up synaptic connections in a third file.
Put simulation control code in a fourth file (e.g. cvode stuff, anything to do with tstop etc.).
Then use an init.hoc to pull it all together.
Code: Select all
load_file("nrngui.hoc") // or load_file("noload.hoc")
// if you don't want to see the NEURON Main Menu toolbar
load_file("cellclass.hoc") // contains the template
load_file("spawncells.hoc")
load_file("makenet.hoc")
load_file("simctrl.hoc")
// load_file("graphs.hoc") or load_file("graphs.ses") if you're plotting stuff
-
- Site Admin
- Posts: 6384
- Joined: Wed May 18, 2005 4:50 pm
- Location: Yale University School of Medicine
- Contact:
Re: Answering my own question #2
Excellent, Kelvin!kelvin wrote:Whoops... I noticed that there was another argument to netcon.record that solves this. In the for loop where the spike times are recorded just change one line to,2) How could I return the value of the last NetCon[id] so that I could change the numbers in the spkid vector to be more straight forward?Yay, now when SThcell[0] fires an AP, the spkid vector reports '0' instead of '3'.Code: Select all
netcon.record(spkt, spkid, i)