Transform AlphaSynapse to Exp2Syn

Particularly useful chunks of hoc and/or NMODL code. May be pedestrian or stunningly brilliant, may make you gasp or bring tears to your eyes, but always makes you think "I wish I had written that; I'm sure going to steal it."
Post Reply
kahinou

Transform AlphaSynapse to Exp2Syn

Post by kahinou »

Hi,
I know there are several posts about the question I'm about to ask, but I still don't know how to adapt the answers to my specific case. So, sorry for the repetition of a same topic.

I am trying to transform an AlphaSynapse into "Exp2Syn" because I want to be able to vary the rise time constant and the decay time constant of the synaptic response independantly, which sounds simple. But when I do the following modifications,

Code: Select all

objref synExc_head[4][MAX_NUM_STIM] 

for i = 0, 3 {   
  for ii = 0,MAX_NUM_STIM-1 {
	head[i] synExc_head[i][ii] = new Exp2Syn(0.5)
  	if (ii < num_stim_exc[i]) {
		synExc_head[i][ii].onset = SYN_EXCIT_DEL + isi_exc*ii         	// ms
  	} else {
		synExc_head[i][ii].onset = 2*T_MAX		                                 // i.e. never happens
	}
	synExc_head[i][ii].tau1 = TAU1_exc	// ms
        synExc_head[i][ii].tau2 = TAU2_exc	// ms
	synExc_head[i][ii].gmax = UNITARY_G_exc * num_syn_exc            // nS
	synExc_head[i][ii].e = E_syn		                                 	// mV
        synExc_head[i][ii].i = 0
    }
}
(where I only added Exp2Syn, TAU1 and TAU2), I get this error message: " onset is not a public member of Exp2Syn".
I then thought that the problem is comming from the loop "for ii ". So I trasformed it to the following:

Code: Select all

objref synExc_head[4]

for i = 0, 3 {   
    head[i] synExc_head[i] = new Exp2Syn(0.5)
    synExc_head[i].tau1 = TAU1_exc	// ms
    synExc_head[i].tau2 = TAU2_exc	// ms
    synExc_head[i].e = E_syn			// mV
    synExc_head[i].i = 0
}
And I did the same everywhere synExc_head[ii] is throughout my code.
The result is then that the model works. But I get a strange shape of the EPSPs and varying TAU1 and TAU2 doesn't affect the shape (only Rm does).

Do you have any clue?
Thanks in advance.
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Transform AlphaSynapse to Exp2Syn

Post by ted »

I get this error message: " onset is not a public member of Exp2Syn"
That's a syntax error message, and it means that you need to RTM ("Read The Manual" i.e. the Programmer's Reference). For the particular questions you ask today, it's also helpful to read chapter 10 of the NEURON Book, or if you don't have the book read this preprint of that chapter https://www.neuron.yale.edu/ftp/ted/boo ... xedref.pdf.

Now a short summary that should not be taken as a substitute for the recommended reading.

AlphaSynapse was not implemented as a means to connect two cells with a synapse. It generates a single conductance transient of a particular peak amplitude that starts at a fixed time. ExpSyn and Exp2Syn are quite different, and they have different parameters than AlphaSynapse does--e.g. they have no onset or gmax parameter. They are event-driven conductance-change synaptic mechanisms, which means they do nothing until they receive an event delivered by a NetCon ("Network Connection"). Each event received by an ExpSyn or Exp2Syn triggers a conductance change whose amplitude is controlled by the NetCon's weight, but whose time course and reversal potential are specified by the point process's own parameters. Furthermore, multiple synapses of the same type (same time constants and reversal potential) that are electrically close to each other can be represented by a single ExpSyn or Exp2Syn that is driven by multiple NetCons; this is more efficient than using a separate Exp*Syn to represent each synapse.

"What is a NetCon and where do these events come from?" Explained in chapter 10 and the Programmer's Reference documentation of NetCon. Depending on what you are trying to do, you might want to use a NetStim (see Programmer's Reference) as an event source for a NetCon, or if you only want a single event, use the NetCon's event method.

Major hint: if you are using something for the first time, try it out on a toy model before you try to use it in a complex model. Suggest you make a single compartment passive model cell with an Exp2Syn that is driven by a NetCon that monitors a NetStim for events. You might even find it instructive to work through the Network Builder tutorials at http://www.neuron.yale.edu/neuron/docs
The result is then that the model works. But I get a strange shape of the EPSPs and varying TAU1 and TAU2 doesn't affect the shape (only Rm does).
The only thing worse than buggy code that fails with an error message, is buggy code that runs and generates no error message. If you replaced all AlphaSynapses with Exp2Syns, but you're not driving the Exp2Syns with events delivered by NetCons, the "EPSP" you're seeing isn't an EPSP. This means your code has two bugs: (1) none of the synaptic mechanisms is ever activated, and (2) your model is generating a spurious perturbation of membrane potential. (1) is easy to fix. (2) suggests that there is an error in the specification of the biophysical properties of your model cell, and/or that the model is not being initialized to its steady state; perhaps the model has nonuniform membrane properties?
kahinou

Re: Transform AlphaSynapse to Exp2Syn

Post by kahinou »

Thank you, Ted!

Thanks especially for the explanation of the difference between AlphaSynapse and ExpSyn/Exp2Syn, it wasn't verry clear in my mind.

However, my model is supposed to be simple: a simple neuron with a dendrite, a soma, an axon and some spines, and I'm not including any connections between this neuron and others. Thus, I would like to carry on with the alpha function.
I think I'm going to create another alpha function (AlphaSynapse1, fo exemple) which is not already built in NEURON and define it as a sum of 2 exponentials where tau1 and tau2 are explicitly shown. I am willing to create a mod. file to define AlphaSynapse1 and then set it in my hoc.file just as AlphaSynapse is set.
(2) suggests that there is an error in the specification of the biophysical properties of your model cell, and/or that the model is not being initialized to its steady state; perhaps the model has nonuniform membrane properties?
I think the bug is due to the Exp2Syn I created because when I come back to AlphaSynapse, there is no signal if no synapse is activated. Whereas, with Exp2Syn, even when I set every synapse activation or current injection to zero, there is still that spike (which has the same amplitude in all sections).
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Transform AlphaSynapse to Exp2Syn

Post by ted »

kahinou wrote:However, my model is supposed to be simple
Simplicity is relative. The model may be simple in comparison to most real neurons, but code with doubly indexed objrefs that must be initialized by nested "for" loops falls short of the simplicity that is best for learning how to use unfamiliar features of a programming language. It's your time and effort, however, so spend it as you prefer.
I think I'm going to create another alpha function (AlphaSynapse1, fo exemple) which is not already built in NEURON
Sure, reinvent the wheel. But why call it AlphaSynapseanything, since the waveform it will produce is not an alpha function?
(2) suggests that there is an error in the specification of the biophysical properties of your model cell, and/or that the model is not being initialized to its steady state; perhaps the model has nonuniform membrane properties?
I think the bug is due to the Exp2Syn I created because when I come back to AlphaSynapse, there is no signal if no synapse is activated. Whereas, with Exp2Syn, even when I set every synapse activation or current injection to zero, there is still that spike (which has the same amplitude in all sections).
Very strange. Bet you 5 cents it has nothing to do with Exp2Syn.
kahinou

Re: Transform AlphaSynapse to Exp2Syn

Post by kahinou »

For sure, I have a lot to learn about NEURON!

Saying that the use of Exp2Syn doesn't recquire creation of other neurons to be connected to each other would have preveted me from saying that I don't want to use it anymore, thus creating another function. I didn't mean to reinvent anything, I am just trying to understand.
Sorry for low-level questions.
Very strange. Bet you 5 cents it has nothing to do with Exp2Syn.
I set Exp2Syn without any stimulation. When I come back to AlphaSynapse and deactivate synapses, there is no signal. I may be wrong, but my conclusion is that something was wrong with my use of Exp2Syn.

Anyway, the model works when I introduce NetSim.

Thanks for you help
ted
Site Admin
Posts: 6286
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Transform AlphaSynapse to Exp2Syn

Post by ted »

kahinou wrote:Sorry for low-level questions.
There's nothing wrong with "low-level" questions. The only wrong questions are the questions that should have been asked, but weren't.
my conclusion is that something was wrong with my use of Exp2Syn.
That may be true, but it won't cause the problem that you observed. My suspicion is that something else is wrong with your code, and it needs to be discovered soon, or else you will waste a lot of time.

For example, PYR01.hoc that you sent a couple of weeks ago specifies a model cell that has nonuniform membrane properties, so NEURON's default initialization will not put the cell in its resting state at the start of a simulation. That can easily cause strange waveforms to appear in a simulation, even in the absence of synaptic input. This model cell needs a customized initialization.

runSpine01.hoc, which you sent at the same time, has problems of its own that will only become apparent when you examine simulation results--for example these bits of code

Code: Select all

for i =0, 4{    
    dv.record(&head[i].v(.5))
}
and

Code: Select all

for i =0, 4{
    recv.record(&head[i].v(.5))
    rect.record(&t)
}
will not do what you expect them to do, but they won't generate error messages. Programming errors that do not generate error messages are the hardest kind of problem to detect. Other bugs may also be present, but in a file as long and complex as runSpine01.hoc it may be difficult to discover them.

If you want me to look at your current program to try to discover the cause of the most recent problem, zip up whatever hoc and ses files are necessary and email them to me, and let me know which is the main file and how to launch a simulation.
Post Reply