The Vector class's play() method is the most general way to force a parameter to vary during a simulation. You have empirical data, which are probably time series data. For a single compartment model, the steps are (omitting all details):
1. read the empirical measurements of ki (in mM) and the corresponding times at which the measurements were made into a pair of Vectors; I'll call these kivec and tkivec.
2. use Vector play to make these drive the model's ki.
But there are many details.
1. The section must already contain a mechanism that contains a USEION statement (otherwise there won't be k concentrations or equilibrium potential).
2. You need to specify celsius (the operating temperature in deg C) and ko (the extracellular concentration).
3. You need to tell NEURON what policy to use to deal with k concentrations and equilibrium potential. "What??" In most models, concentrations and equilibrium potentials are assumed to be constant parameters; in a few models, ionic fluxes are allowed to change concentrations, and equilibrium potentials are computed from the concentrations at every time step, while in yet others the concentrations are allowed to change but the equilibirum potentials remain constant, or vice versa, and in some models each ionic species is treated in a different way. NEURON has something called ion_style() which lets the modeler specify exactly what is to be done (read about it in the Programmer's Reference). For your particular application, you want:
k concentrations to be treated as PARAMETERs
ek to be treated as an ASSIGNED variable
finitialize() to calculate ek at the start of the simulation
ek to be recalculated at every fadvance()
ignore the global initial concentrations ki0_k_ion and ko0_k_ion
This you do with the following ion_style statement:
ion_style("k_ion", 1, 2, 1, 1, 0)
4. You need to specify the desired value of ko (extracellular k) before the simulation is run.
5. You will probably want to use "vector play with interpolation" since it is unlikely that your experimental measurements were made at intervals of dt = 0.025 ms (or whatever you'll use in your simulations).
6. Until you're absolutely sure that things are working correctly, you'll want to see that ki and ek and v do change as expected during a simulation.
Get this http://www.neuron.yale.edu/ftp/ted/neur ... ymodel.zip
, unzip it, and use NEURON to run inittoy.hoc. toymodel.hoc contains hoc code for a single compartment model, in which I have included statements that take care of items 1-5. toymodelrig.ses is a simple GUI for launching simulations and displaying results. Click on Init & Run to see what happens, and take a look at the code in toymodel.hoc. If you see anything in the hoc file that you don't already know about, be sure to read about it in the Programmer's Reference or the NEURON Book. Then we can talk about how to generalize this to suit your particular needs (mostly what to do about a model that has more than one compartment).