Choosing random dendrite

The basics of how to develop, test, and use models.
Post Reply
steve

Choosing random dendrite

Post by steve »

I have a SectionList with all my dendrite sections in it. Now I want to choose a random dendrite to connect a synapse to, I know that NEURON offers us the Random class which I can see being very useful to do this, but how would I go about choosing a random dendrite in the SectionList, it appears to me that SectionList are only useful to perform actions on all the sections it contains, not to extract a certain section from. Or am I wrong?

Thanks

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

Algorithmic placement of synapses within a SectionList

Post by ted »

The basic algorithm, in pidgin hoc pseudocode, is

Code: Select all

placed_synapse = 0
forsec seclist {
  if (placed_synapse == 0) {
    if (this is the lucky section) {
      attach a synapse to somewhere on the current section
      placed_synapse = 1 // so you won't bother testing any more
    } else {
      get ready to test the next section
    }
  }
}
This requires expansion of three items:
1. how do you decide if "this is the lucky section"?
2. how do you decide where on the current section to place the synapse?
3. how do you prepare the loop to evaluate the next section?
Details of these items depend entirely on your intention.

If all sections are equally likely to get the synapse, then

Code: Select all

placed_synapse = 0
count = 0
forsec seclist count+=1
// now pick a random integer in the range 0 . . count-1
// and assign it to a variable called lucky_section
// an exercise for the reader
whichone = 0
forsec seclist {
  if (placed_synapse == 0) {
    if (whichone == lucky_section) {
      attach a synapse to somewhere on the current section
      placed_synapse = 1
    } else {
      whichone += 1
    }
  }
}
If the likelihood of getting the synapse is proportional to section length, then just
conceptually map all sections, end to end, along a line, and pick a number that
represents a location along that line.

Code: Select all

placed_synapse = 0
total_length = 0
forsec seclist total_length+=L
// now pick a random floating point value in the range 0 . . total_length
// and assign it to a variable called synaptic_location
// an exercise for the reader
len0 = 0
len1 = 0
forsec seclist {
  if (placed_synapse == 0) {
    len1 += L
    if (len1 >= synaptic_location) {  // lucky section!
      // where to put the synapse?
      // why not at the place where synaptic_location happens to fall?
      synloc = (synaptic_location - len0)/L
      attach the synapse to synloc on the current section
      placed_synapse = 1
    } else {
      len0 = len1
    }
  }
}
Give or take a few blanks yet to be filled in, and the possibility of a typo here or there,
that should do it.

Exercise for the reader: what modifications would be necessary to make likelihood
of synaptic placement proportional to surface area?

rth
Posts: 41
Joined: Thu Jun 21, 2012 4:47 pm

Re: Choosing random dendrite

Post by rth »

Ted,

But code above ensures that one section will have ONLY ONE synapse. It is not truly randomly chosen section from list. For example I want 50 synapses in random sections from SectionList and random position within each section. Position isn't problem, but how I can randomly choose section in SectionList?

If SectionList would have .counter() and .object() functions (as List has), I can get total number of sections in SectionList and select section by random generator. But there is no such functionality..... as far as I know.

Thank you,
Ruben

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

Re: Choosing random dendrite

Post by ted »

rth wrote:But code above ensures that one section will have ONLY ONE synapse.
Right, but I don't have to tell rth how to allow more than one synapse to be attached to any given location. What I will do is to suggest how to do this
I want 50 synapses in random sections from SectionList and random position within each section. Position isn't problem, but how I can randomly choose section in SectionList?
OK, you're starting out with a SectionList that references the sections that are to be innervated, and you know how many synaptic mechanisms you want to create. What you haven't provided is a definition of "random synaptic placement."

Experimental evidence suggests that the most appropriate way to specify synaptic density is "# synapses/unit area." Yes, a lot of people use "# synapses/unit length" but for this discussion let's say it's per unit area.

So here's an algorithm to think about.
Start by calculating the cumulative sum of surface area for the sections in your SectionList.
This can be done by

Code: Select all

// $o1 is a SectionList that contains the sections of interest
obfunc makecusum() { local i  localobj tmpvec
  tmpvec = new Vector()
  forsec $o1 for (x,0) tmpvec.append(area(x))
  for i=1,tmpvec.size()-1 tmpvec.x[i]+=tmpvec.x[i-1]
  return tmpvec
}
objref acusum
acusum = new Vector()
acusum = makecusum(myseclist) // change myseclist to the name of your SectionList
Think of this as a mapping that relates each segment in these sections to a different interval on the line 0..totalarea. Clearly you want to do this _AFTER_ spatial discretization of the model.

Then

Code: Select all

REPEAT
  draw a number from the uniform distribution 0..totalarea
  discover which segment in which section corresponds to this number
    (i.e. the segment that corresponds to the largest cusum value that is still <= the random number*)
  create a synaptic mechanism and attach it to this segment
UNTIL all desired synapses have been created
*--the Vector class has methods that can be used to return the index of the element that satisfies a particular inequality criterion.

rth
Posts: 41
Joined: Thu Jun 21, 2012 4:47 pm

Re: Choosing random dendrite

Post by rth »

Thank you Ted! I've got your idea to make a uniform distribution over the surface. I like it more than my previous one.

We try to place synapses randomly at some distance from soma to mimic experimental data. So I have bunch of segments trunk[0] ... trunk[79] and apical[1]... apical[98], each of which has MORE than one segment (usually 5-7). As you can see synapse located at x=0.1 and located at x=0.8 for the same compartment may be different.

I thought to (1) create SectionList with all my compartments, (2) randomly choose compartment from the list, (3) randomly choose location within compartment, (4) check distance to soma, (7) if distance in required range - (8) check if there is no synaptic mechanisms at this segment - (8) make a synapse. I just want to draw NEURON's fathers attraction that functions .count() and .object() for SectionList object may be useful in future.

Thank you again,
Ruben

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

Re: Choosing random dendrite

Post by ted »

It is completely an accident of the history of NEURON's evolution over time that sections are not full-fledged objects. In situations where it is necessary to manage them as objects, you could try using the SectionRef class. Think of SectionRef as a wrapper for sections. For example, suppose you have a model cell and you want to create a List whose elements are SectionRefs, where each SectionRef refers to one of the model cell's sections.

Code: Select all

oc>objref srlist
oc>srlist = new List()
oc>forall srlist.append(new SectionRef())
oc>srlist.count
	79 
oc>for i=0,srlist.count()-1 srlist.o(i).sec { print secname() }
soma
dendrite_1[0]
dendrite_1[1]
 . . . etc. . . .
Or if you only want your list to refer to the sections in a SectionList called sl, you could
forsec sl srlist.append(new SectionRef())

And of course once you have a List you also have .count() and .o() (or .object()).

rth
Posts: 41
Joined: Thu Jun 21, 2012 4:47 pm

Re: Choosing random dendrite

Post by rth »

Thank you Ted!
That is exactly what I looked for! Wonderful!

Post Reply