Modifying variables in source

Anything that doesn't fit elsewhere.
Post Reply
ksarma

Modifying variables in source

Post by ksarma »

Hi,

I have been working on some code which directly accesses and modifies range variables through some C++ code which I added to the NEURON source and compiled in. In order to make sure that this was something I actually knew how to do, the first thing I have implemented is something which is easily implemented in hoc so that I can check it -- basically the code takes an extracellular potential from a flat file and updates the extracellular potential for the nodes in the simulation accordingly. Unfortunately, however, my code doesn't work (the hoc simulation I wrote works exactly as expected, but the simulation run using my C++ code produces odd results).

Here is the important part of the code:

Code: Select all

Section* sec = ... //(get section)
Node** nodesptr = sec->pnode;
for (int n = 1; n < sec->nnode - 2; n++) {  // avoid 0-area nodes
    Node* node = nodesptr[n];
    Prop* extracellular = nrn_mechanism(extracellular_type, node); // extracellular type has previously been found 
                                                                        // by iterating through Memb_func
    NrnProperty npExtracellular(extracellular);
    Symbol* sym = npExtracellular.find("e_extracellular");
    double* px = npExtracellular.prop_pval(sym, 0);
    *px = calculateExtracellularField(); // external routine
}
When I run the simulation and record the extracellular field, I get what I expect (that is, the hoc simulation which does this and the simulation using this code produce nearly identical extracellular results). However, the membrane potential for the hoc simulation is perturbed about how I would expect, but using the C++ code, the membrane potential is highly perturbed (~30 mV depolarization, and the extracellular field is never more than 1 or 2 mV!). I'm at a loss as to why this should happen... I can post more of the code if it would help (there's a lot of boilerplate code that I'm fairly sure works which I didn't post).


Edit: Forgot to add some declarations which happened in a previous part of the code which I didn't post
Last edited by ksarma on Tue Aug 19, 2008 2:28 pm, edited 1 time in total.
ksarma

Re: Modifying variables in source

Post by ksarma »

Oh, I forgot to add that the way I use this code is as follows:

The C++ code is wrapped by a function update_fields():

Code: Select all

int update_fields() {
    update_fields_actual();
    ret(1.);
}
which I then insert into the interpreter by updating the array in hocusr.h.

I then ensure the fields are updated through a custom advance() method in hoc:

Code: Select all

proc advance() {
    update_fields();
    fadvance();
}
hines
Site Admin
Posts: 1713
Joined: Wed May 18, 2005 3:32 pm

Re: Modifying variables in source

Post by hines »

for (int n = 1; n < sec->nnode - 2; n++) { // avoid 0-area nodes
Visiting the non-zero area nodes needs

Code: Select all

for (int n = 0; n < sec->nnode - 1; n++) 
since sec->nnode-1 is the (distal) zero area node and the proximal zero area node belongs to the
parent pnode vector.
But the extracellular voltage information is found from the node's extnode pointer to an
Extnode (see src/nrnoc/section.h)
The extracellular mechanism differs quite a bit from normal channel mechanisms since it
has to parallel the computation of membrane potential.
*px = calculateExtracellularField(); // external routine
I presume you are satisfied with the values for e_extracellular? I agree that if xraxial is infinite and
xg is large that vext should track e_extracellular.

To go further I would need all your code so that I could compare your hoc version with the results of your c++
version. Send as a zip file to michael.hines@yale.edu.
Post Reply