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