Time dependent RANGE variable

Anything that doesn't fit elsewhere.
Post Reply
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Time dependent RANGE variable

Post by mganguly »

Hi

I want to use section temperature as a RANGE variable in a modified version of the standard HH model. I have figured this out. However I want the temperature to vary with time in a way I can import from a csv/txt file containing temperature and time. Is is possible using NEURON with Python?

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

Re: Time dependent RANGE variable

Post by ted »

You could use the Vector class's play method. That said, if temperature is to be a function of both time and location, you may need a different pair of vectors for each compartment (segment) of your model. Or some other approach may be more appropriate. Can you be more specific about the dependency of temperature on location and time that you want to implement?
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Time dependent RANGE variable

Post by mganguly »

Thanks for the reply. Say I have 10 nodes in my axon geometry corresponding to 100 time points and I have a 10*100 matrix containing the values of the temperature at each node at each time point. The temperature can vary in an arbitrary fashion (since it is exported from a heat transfer model) like a Gaussian distribution or a pulsed shaped distribution.

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

Re: Time dependent RANGE variable

Post by ted »

Excellent. In one step you can read your entire matrix into a hoc Matrix. Depending on layout of your matrix--
row 0 holds the series of time values, rows 1..N hold the series of temperatures for N physical locations,
or
column 0 holds the series of time values, columns 1..N hold the series of temperatures for N physical locations--
you can use the Matrix class's getrow or getcol to copy the values into N+1 vectors (one for time, the other N vectors for the temperature sequences).

Now, how to force temperature to be spatially inhomogeneous AND to fluctuate in the course of a simulation.

NEURON's built-in celsius is a global variable, so it can't be used to represent spatially nonuniform temperature. A workaround is to use an auxiliary distributed mechanism whose sole purpose is to provide a RANGE variable that represents local temperature. This is it:

Code: Select all

NEURON {
  SUFFIX aux
  RANGE celsiusx
}
ASSIGNED {
  celsiusx (degC)
}
"Fine, how do I get my temperature-dependent mechanisms to use this celsiusx_aux(x) instead of the global celsius?"
Rewrite them so that they have a POINTER variable called celsiusx, and use that internally instead of celsius. For example, NEURON's built-in hh.mod contains these references to celsius:

Code: Select all

ASSIGNED {
  . . .
  : celsius (degC)
  celsiusx (degC)
  . . .
PROCEDURE rates(v(mV)) {
        LOCAL  alpha, beta, sum, q10
   : don't bother with TABLEs if celsius is going to change during a simulation
        : TABLE minf, mtau, hinf, htau, ninf, ntau DEPEND celsius FROM -100 TO 100 WITH 200
UNITSOFF
        : q10 = 3^((celsius - 6.3)/10)
        q10 = 3^((celsiusx - 6.3)/10)

        . . .
Just change them like so:

Code: Select all

ASSIGNED {
  . . .
  celsius (degC)
  . . .
PROCEDURE rates(v(mV)) {
        LOCAL  alpha, beta, sum, q10
        TABLE minf, mtau, hinf, htau, ninf, ntau DEPEND celsius FROM -100 TO 100 WITH 200
UNITSOFF
        q10 = 3^((celsius - 6.3)/10)
        . . .
Also, be sure to declare celsiusx to be a POINTER in the NEURON block, comment out the THREADSAFE directive because pointers aren't threadsafe, and give your new mechanism a unique SUFFIX so its name won't collide with the original mechanism that used the built-in celsius:

Code: Select all

NEURON {
:        SUFFIX hh
        SUFFIX hhx
  . . .
  POINTER celsiusx
: POINTERs aren't threadsafe.
:	THREADSAFE : assigned GLOBALs will be per thread
}
If you do everything correctly, your new mod files should pass modlunit testing and compile without error.
Next in your model specification code you need to insert these mechanisms into your sections, and after that you have to couple all the celsiusx POINTER variables in each segment to the celsiusx_aux variable in that same segment. I built a toy model with a couple of sections, plus hhx and na16 (modified versions of NEURON's builtin hh and a user's na16 mechanisms), so I had to do this:
forall for (x,0) setpointer celsiusx_hhx(x), celsiusx_aux(x)
forall for (x,0) setpointer celsiusx_na16(x), celsiusx_aux(x)
Notice that each segment's celsiusx_aux is the source of the celsiusx numerical values needed by the temperature-dependent mechanisms in that segment.

My toy cell was a ball and stick model with a soma and a dend, both having hhx and na16, and I wanted temperature to increase from 6.3 deg C at the soma end to 36.3 deg C at the distal end of dend. Which I did with
soma celsiusx_aux(0.5) = 6.3
dend for (x,0) celsiusx_aux(x) = 6.3 + 30*x
and a space plot of celsiusx_aux showed that temperature did vary with distance as desired.
All that remained was to launch a simulation and observe how the spike waveform changed with distance, because of the variation of temperature with distance along dend.

I'll email the relevant files to you in a zip file.
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Time dependent RANGE variable

Post by mganguly »

Thanks a lot for the reply and the email. Does the pointer method also take care of the time dependence of the temperature at a particular node ?
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time dependent RANGE variable

Post by ted »

You know, I made that a bit more complicated than it needs to be. Unless you have something very unusual in mind, you won't need the aux mechanism at all, and your mechanisms' celsiusx parameters should be declared to be plain old RANGE variables, not POINTERs, and your mechanisms' NEURON blocks can include the THREADSAFE declaration. And of course you won't need any setpointer statements in your hoc or python code.

To make any mechanism's celsiusx vary with time in a given compartment, you'll need to use the Vector class's play method. If you already know the detailed time course of temperature in each compartment of interest, then here's what you need to do in pseudocode:

Code: Select all

for each section of interest
  for each segment in this section where temperature is supposed to change
    read the time, temperature values for this location into a pair of Vectors
    for each mechanism in this segment that is temperature-sensitive
      use the Vector class's play method to drive the mechanism's celsiusx variable
This can all be done with hoc, Python, or a combination of hoc and Python. The Programmer's Reference has documentation on the File and Vector classes. Is that enough to get you on the right track?
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Time dependent RANGE variable

Post by mganguly »

Thanks a lot for the help. I will implement this and get back to you if I have any problems with my setup giving you more detailed explanation of what I am trying to accomplish. For your information, I am using NEURON combined with Python.
Also, Do you have a demonstration of the use of the vector.play function somewhere in the ModelDB or the documentation.

I have another nagging doubt. I tried to implement a simple HH model (for a simple pulse stimulation) on a 3 sectioned 3D axon with 5 segments each as a beginner's practice model. However the voltage traces that I observe show certain abnormalities at the section junctions and at the axon terminal. I have attached a figure of the voltage traces for your reference. I want to know the reason of these abnormal traces and what can be done to rectify them so as to make them look smooth without any abnormalities.Image
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Time dependent RANGE variable

Post by mganguly »

The link for the results plot image is :
http://imgur.com/gallery/ZB1cSRg
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time dependent RANGE variable

Post by ted »

mganguly wrote:Do you have a demonstration of the use of the vector.play function somewhere in the ModelDB or the documentation.
Have you checked the Programmer's Reference entry on the Vector class? You may already have seen the demo of temperature variation that I just emailed you, but the Programmer's Reference documentation is worth reading too.
I tried to implement a simple HH model (for a simple pulse stimulation) on a 3 sectioned 3D axon with 5 segments each as a beginner's practice model. However the voltage traces that I observe show certain abnormalities at the section junctions and at the axon terminal. I have attached a figure of the voltage traces for your reference. I want to know the reason of these abnormal traces and what can be done to rectify them so as to make them look smooth without any abnormalities.
Well, the traces in your figure are smooth. What traces are abnormal, and in what way? Other than those two comments, I can't really say anything without being able to reproduce the figure for myself.
mganguly
Posts: 29
Joined: Sun May 03, 2015 7:05 pm

Re: Time dependent RANGE variable

Post by mganguly »

Thanks for the reply. If you please look closely, the traces at node 5 and nodes 9,10, you see that the maximum voltage is not equal to that of the neighboring nodes. Also, some of the nodes at the terminals (towards the end) are not equal to the other nodes( 1,2,3,4,6,7 etc). That's what I meant by 'abnormal'. I was just wondering that shouldn't all the voltage traces show equal maximum voltages.
ted
Site Admin
Posts: 6289
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Time dependent RANGE variable

Post by ted »

mganguly wrote:I was just wondering that shouldn't all the voltage traces show equal maximum voltages.
As I wrote before, I'll have to be able to reproduce the figure. Source code?
Post Reply