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