Modifying variables in source
Posted: Tue Aug 19, 2008 2:24 pm
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:
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
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
}
Edit: Forgot to add some declarations which happened in a previous part of the code which I didn't post