How to print values of a variable defined in NET_RECEIVE?

Moderator: wwlytton

Post Reply
Krishna Chaitanya
Posts: 70
Joined: Wed Jan 18, 2012 12:25 am
Location: University of Pavia

How to print values of a variable defined in NET_RECEIVE?

Post by Krishna Chaitanya » Sat Feb 11, 2012 10:39 pm

Hi Ted,

Is there a way to print values of a variable defined in NET_RECEIVE block into a file? And is there a way to update a variable in mod file for each dt directly from hoc file? Thank you.

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

Re: How to print values of a variable defined in NET_RECEIVE

Post by ted » Sun Feb 12, 2012 12:29 pm

These are highly specific technical questions, posed at a very low level. I can provide answers taht are technically correct, but without knowing what motivates the questions (what are you trying to accomplish?) I'm not sure that these answers will not lead you down a blind alley, let alone be useful to you.
Krishna Chaitanya wrote:Is there a way to print values of a variable defined in NET_RECEIVE block into a file?
One tactic would be to declare a RANGE variable in the NEURON block, make it an ASSIGNED variable, and put an appropriate assignment statement in the NET_RECEIVE block. This variable can then be recorded to a Vector in the course of simulation, and saved to a file after completion of the run.

Code: Select all

And is there a way to update a variable in mod file for each dt directly from hoc file?
Presumably you want to implement variation of a parameter in time, or apply a predetermined driving function to a model. Read the time series into a pair of Vectors (one for the values of the variable, the other for the times at which these values are valid), then use the Vector class's play method. You'll need to know about the File class, the Vector class, and the Vector class's play method. These are documented in the Programmer's reference, and you'll find further discussion and several examples in the FAQ list (see link on NEURON's Documentation page http://www.neuron.yale.edu/neuron/docs) and various places in the NEURON Forum as well.

Krishna Chaitanya
Posts: 70
Joined: Wed Jan 18, 2012 12:25 am
Location: University of Pavia

Re: How to print values of a variable defined in NET_RECEIVE

Post by Krishna Chaitanya » Sun Feb 12, 2012 10:10 pm

Hi Ted,

I think I did not made myself clear with the second question. Suppose I have a synaptic current parameter (Isyn) in my mod file which I have to update from a particular time (say, t=20 msec). The calculation of Isyn involves an exponential function which I do not want to include in mod file. I want to do that calculation in hoc file and then update the value of Isyn parameter from t=20 msec in the mod file. How can this be done? Thank you.

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

Re: How to print values of a variable defined in NET_RECEIVE

Post by ted » Mon Feb 13, 2012 10:02 am

I want to do that calculation in hoc file
You mean you want the hoc interpreter to do the calculation.
Krishna Chaitanya wrote:Suppose I have a synaptic current parameter (Isyn) in my mod file which I have to update from a particular time (say, t=20 msec).
. . .
I want to do that calculation in hoc file and then update the value of Isyn parameter from t=20 msec in the mod file.
If you want to change a parameter at a particular time, cvode.event() is the way to do it. Suppose the objref that points to an instance of your synaptic mechanism is called foo, and your function is called myfunc. Then

Code: Select all

cvode.event(t1, "foo.Isyn = myfunc()")
If you want this to happen every time your synaptic mechanism receives an input event, use the NetCon class's record method. During model setup, when you use a NetCon to attach a spike source to your synaptic mechanism, be sure to create another NetCon that will exeucte the code. Example:

Code: Select all

// pre is a spike source
// foo is the synaptic mechanism
objref nc[2], nil
nc[0] = new NetCon(pre, foo)
nc[1] = new NetCon(pre, nil) // nil is NULLobject, i.e. a "dummy" target
nc[1].record("foo.Isyn = myfunc()")
I want to do that calculation in hoc
You'll pay a performance penalty. NMODL code is compiled, so it executes much faster than hoc code does. However, slowing may not be noticeable if myfunc is small and is called only a few times.

Post Reply