Lists are the best way to manage collections of objects.
Example 1: calcium accumulation in a model with several sections, each of which has nseg = 1.
Step 1 (left as an exercise to the reader): Create a SectionList, and to it append all sections whose cai you want to record. For the sake of this example, suppose the SectionList is called casecs.
Step 2: Set up Vector recording of cai in each section in casecs by doing the following:
Code: Select all
objref tmpvec, veclist
veclist = new List()
forsec casecs {
tmpvec = new Vector()
tmpvec.record(&cai)
veclist.append(tmpvec)
}
objref tmpvec // to prevent careless use of tmpvec from damaging the last Vector
Example 2: calcium accumulation in a model with several sections, each of which may have any number of segments.
Step 1 (left as an exercise to the reader): Create a SectionList, and to it append all sections whose cai you want to record. For the sake of this example, suppose the SectionList is called casecs.
Step 2: Set up Vector recording of cai in each segment of each section in casecs by doing the following:
Code: Select all
objref tmpvec, tmpveclist, listofveclists
listofveclists = new List()
forsec casecs {
tmpveclist = new List()
for i=0,nseg-1 {
x = (0.5+i)/nseg
tmpvec = new Vector()
tmpvec.record(&cai(x))
tmpveclist.append(tmpvec)
}
listofveclists.append(tmpveclist)
}
objref tmpvec, tmpveclist // prevent careless damage to the last Vector and List of Vectors
For each section in SectionList casecs, there is a corresponding List in listofveclists; each such List is a set of Vectors--one Vector for each internal node of that section--which will contain the time course of cai at the middle of each internal node of that section.
Example 3: radial diffusion in a model with several sections, each of which has nseg = 1. Radial diffusion is implemented with mechanism cadifus, which uses Nannuli compartments. The concentration of ca in the jth compartment at range x is known to hoc as ca_cadifus[j](x).
Step 1 (left as an exercise to the reader): Create a SectionList, and to it append all sections whose ca you want to record. For the sake of this example, suppose the SectionList is called casecs.
Step 2: Set up Vector recording of ca in each annulus of each section in casecs by doing the following:
Code: Select all
objref tmpvec, tmpveclist, listofveclists
listofveclists = new List()
forsec casecs {
tmpveclist = new List()
for j=0,Nannuli-1 {
tmpvec = new Vector()
tmpvec.record(&ca_cadifus[j](0.5))
tmpveclist.append(tmpvec)
}
listofveclists.append(tmpveclist)
}
objref tmpvec, tmpveclist
Example 4: radial diffusion in a model with several sections, each of which may have any number of segments. Radial diffusion is implemented with mechanism cadifus, which uses Nannuli compartments. The concentration of ca in the jth compartment at range x is known to hoc as ca_cadifus[j](x).
Step 1 (left as an exercise to the reader): Create a SectionList, and to it append all sections whose cai you want to record. For the sake of this example, suppose the SectionList is called casecs.
Step 2: Set up Vector recording of ca in each annulus of each segment of each section in casecs by doing the following:
Code: Select all
objref tmpvec, tmpveclist, tmplistofveclists, listoflistsofveclists
listoflistsofveclists = new List() // for all recordings from all segments of all sections
forsec casecs {
tmplistofveclists = new List() // for all recordings from one section
for i=0,nseg-1 {
x = (0.5+i)/nseg
tmpveclist = new List() // for all recordings from one segment
for j=0,Nannuli-1 {
tmpvec = new Vector()
tmpvec.record(&ca_cadifus[j](x))
tmpveclist.append(tmpvec)
}
tmplistofveclists.append(tmpveclist)
}
listofveclists.append(tmpveclist)
}
objref tmpvec, tmpveclist
Assuming that I have made no errors in algorithm or syntax.
It would be advisable to implement incrementally, testing on small models and proceeding from simple to more complex (a few sections without annuli and containing one segment each, next a few sections without annuli but having different values of nseg, then a few sections with several annuli and nseg = 1, and finally a few sections with several annuli and several different values of nseg).