Vector manipulation and play

Anything that doesn't fit elsewhere.
Post Reply
lara

Vector manipulation and play

Post by lara »

Ok, what I want to do is record some variables (voltages) during a run and during the same run play an algebraic expression (product of two recorded voltages) of these recorded variables back into another variable (synaptic weights), but I can't work out how to do this---any ideas???????
ted
Site Admin
Posts: 6394
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: Vector manipulation and play

Post by ted »

lara wrote:Ok, what I want to do is record some variables (voltages) during a run and during the same run play an algebraic expression (product of two recorded voltages) of these recorded variables back into another variable (synaptic weights), but I can't work out how to do this---any ideas???????
Lots.

1. These are two separate problems.

2. Record the voltages with the Vector class's record() method, as usual.

3. You could use a custom proc advance() to adjust the synaptic weight
at every time step

Code: Select all

proc advance() {
  fadvance()
   . . . compute and assign new weight here . . .
}
but of course this would slow your simulation and does not generalize
well to multiple synapses. Faster would be to write a mechanism in
NMODL that uses POINTERs to access the voltages in question, and
then does something to modulate the synaptic weight; I don't know
if a NetCon's weight can be accessed from NMODL via a POINTER
or whether some inline C code would be necessary (or even possible).
If it isn't possible, there is still a trick that could be used to affect a single
synaptic mechanism per segment but it would not be "input stream
specific."
hines
Site Admin
Posts: 1711
Joined: Wed May 18, 2005 3:32 pm

Post by hines »

I did an experiment to see if one can use pointers to weights and it indeed works. Consider the NEURONDEMO after choosing the Synchronizing Net demo.

oc>NetCon[5].weight
-0.3
oc>objref pp
oc>pp = new Pointer(&NetCon[5].weight)
oc>pp.val
-0.3
oc>pp.val = -1
oc>NetCon[5].weight
-1
oc>

Of course the usual caveats concerning pointers apply. i.e be sure
the thing it points to does not go out of existence.
lara

Post by lara »

Thanks for your advice :-). While I haven't got it to work yet, I have some more ideas to work with now.

Tried the following (only relevant part of code included)

//Record voltage data at '1' end = output end of soma for all neurons

for i=0,ncells-1{
recvtemp = new Vector()
recvtemp.record(&cells.soma.v(1))}
//The recording of voltages works fine


proc advance() {
fadvance()
cells[0].nclist.object(1).weight=recvtemp[0].mul(recvtemp[1])
}

//This bit of code immediately above doesn't work (which doesn't surprise me), haven't used fadvance or advance before so maybe I need to pass extra parameters, but I think it is the assignment statement which is causing problems in that recvtemp[0] and recvtemp[1] are vectors so that recvtemp[0].mul(recvtemp[1]) is a vector too and what I really want on the RHS is the product of the latest entries to be added to these vectors respectively, not sure how to do that, tried various things with record, play etc directly in the assignment statement and using pointers but these didn't work (though in these cases I was pretty unsure what I was doing)

Actually NMODL is probably the way to go, I think I can see that it would work, so I just have to work out how to get it to actually work!!

I am used to programming in procedural languages so find it quite hard to work out whether lines of code in my main .hoc program are being implemented at every timestep or only once at the start of the simulation. Is there anyway to somehow check/see whether a line of code is getting implemented at every timestep or not? or Is there any info available anywhere with advice on the onject-orientated nature of NEURON and/or how best to implement such mid-simulation calculations??

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

Post by ted »

Is there anyway to somehow check/see whether a line of code is getting implemented at every timestep or not?
Embed print statements.
Best to try new ideas in the small, i.e. on a toy problem with minimal
complexity.
Is there any info available anywhere with advice on the onject-orientated nature of NEURON
Read chapter 13 of the NEURON Book. Get it here:
http://www.neuron.yale.edu/ftp/ted/book/revisions/
and/or how best to implement such mid-simulation calculations??
It is generally best to avoid adding hoc statements to the main
computational loop. If it is mandatory, try to cobble up a mod
file that does it.
Post Reply