neuromodels.models.HodgkinHuxley¶
- class neuromodels.models.HodgkinHuxley(V_rest=- 65.0, Cm=1.0, gbar_K=36.0, gbar_Na=120.0, gbar_L=0.3, E_K=- 77.0, E_Na=50.0, E_L=- 54.4)[source]¶
Class for representing the Hodgkin-Huxley model.
The Hodgkin–Huxley model describes how action potentials in neurons are initiated and propagated. From a biophysical point of view, action potentials are the result of currents that pass through ion channels in the cell membrane. In an extensive series of experiments on the giant axon of the squid, Hodgkin and Huxley succeeded to measure these currents and to describe their dynamics in terms of differential equations.
All model parameters can be accessed (get or set) as class attributes. Solutions are available as class attributes after calling the class method
solve().- Parameters
- V_rest
float Resting potential of neuron in units \(mV\), default=-65.0.
- Cm
float Membrane capacitance in units \(\mu F/cm^2\), default=1.0.
- gbar_K
float Potassium conductance in units \(mS/cm^2\), default=36.0.
- gbar_Na
float Sodium conductance in units \(mS/cm^2\), default=120.0.
- gbar_L
float Leak conductance in units \(mS/cm^2\), default=0.3.
- E_K
float Potassium reversal potential in units \(mV\), default=-77.0.
- E_Na
float Sodium reversal potential in units \(mV\), default=50.0.
- E_L
float Leak reversal potential in units \(mV\), default=-54.4.
- V_rest
Notes
Default parameter values as given by Hodgkin and Huxley (1952).
References
Hodgkin, A. L., Huxley, A.F. (1952). “A quantitative description of membrane current and its application to conduction and excitation in nerve”. J. Physiol. 117, 500-544.
Examples
>>> import matplotlib.pyplot as plt >>> from pylfi.models import HodgkinHuxley
Initialize the Hodgkin-Huxley system; model parameters can either be set in the constructor or accessed as class attributes:
>>> hh = HodgkinHuxley(V_rest=-70) >>> hh.gbar_K = 36
The simulation parameters needed are the simulation time
T, the time stepdt, and the inputstimulus, the latter either as a constant, callable or ndarray withshape=(int(T/dt)+1,):>>> T = 50. >>> dt = 0.025 >>> def stimulus(t): ... return 10 if 10 <= t <= 40 else 0
The system is solved by calling the class method
solveand the solutions can be accessed as class attributes:>>> hh.solve(stimulus, T, dt) >>> t = hh.t >>> V = hh.V
>>> plt.plot(t, V) >>> plt.xlabel('Time [ms]') >>> plt.ylabel('Membrane potential [mV]') >>> plt.show()
(Source code, png, hires.png, pdf)
another
- Attributes
- V_rest
float Model parameter: Resting potential.
- Cm
float Model parameter: Membrane capacitance.
- gbar_K
float Model parameter: Potassium conductance.
- gbar_Na
float Model parameter: Sodium conductance.
- gbar_L
float Model parameter: Leak conductance.
- E_K
float Model parameter: Potassium reversal potential.
- E_Na
float Model parameter: Sodium reversal potential.
- E_L
float Model parameter: Leak reversal potential.
- tndarray
Solution: Array of time points
t.- Vndarray
Solution: Array of voltage values
Vatt.- nndarray
Solution: Array of state variable values
natt.- mndarray
Solution: Array of state variable values
matt.- hndarray
Solution: Array of state variable values
hatt.
- V_rest
Methods
__call__(t, y)RHS of the Hodgkin-Huxley ODEs.
solve(stimulus, T, dt[, y0])Solve the Hodgkin-Huxley equations.
- solve(stimulus, T, dt, y0=None, **kwargs)[source]¶
Solve the Hodgkin-Huxley equations.
The equations are solved on the interval
(0, T]and the solutions evaluted at a given interval. The solutions are not returned, but stored as class attributes.If multiple calls to solve are made, they are treated independently, with the newest one overwriting any old solution data.
- Parameters
- stimulus{
int,float},callableor ndarray, shape=(int(T/dt)+1,) Input stimulus in units \(\mu A/cm^2\). If callable, the call signature must be
(t).- T
float End time in milliseconds (\(ms\)).
- dt
float Time step where solutions are evaluated.
- y0array_like, shape=(4,)
Initial state of state variables
V,n,m,h. If None, the default Hodgkin-Huxley model’s initial conditions will be used; \(y_0 = (V_0, n_0, m_0, h_0) = (V_{rest}, n_\infty(V_0), m_\infty(V_0), h_\infty(V_0))\).- **kwargs
Arbitrary keyword arguments are passed along to
scipy.integrate.solve_ivp.
- stimulus{
Notes
The ODEs are solved numerically using the function
scipy.integrate.solve_ivp.If
stimulusis passed as an array, it and the time array, defined byTanddt, will be used to create an interpolation function viascipy.interpolate.interp1d.solve_ivpis an ODE solver with adaptive step size. If the keyword argumentfirst_stepis not specified, the solver will empirically select an initial step size with the functionselect_initial_step(found here https://github.com/scipy/scipy/blob/master/scipy/integrate/_ivp/common.py#L64).This function calculates two proposals and returns the smallest. It first calculates an intermediate proposal,
h0, that is based on the initial condition (y0) and the ODE’s RHS evaluated for the initial condition (f0). For the standard Hodgkin-Huxley model, however, this estimated step size will be very large due to unfortunate circumstances (becausenorm(y0) > 0whilenorm(f0) ~= 0). Sinceh0only is an intermediate calculation, it is not used or returned by the solver. However, it is used to calculate the next proposal,h1, by calling the RHS. Normally, this procedure poses no problem, but can fail if an object with a limited interval is present in the RHS, such as aninterp1dobject.In the case of the standard Hodgkin-Huxley model, one might be tempted to pass the stimulus as an array to the solver. In order for
solve_ivpto be able to evaluate the stimulus, it must be passed as a callable or constant. Thus, if an array is passed to the solver, an interpolation function must be created, in this implementation done withinterp1d, forsolve_ivpto be able to evaluate it. For the reasons explained above, the program will hence terminate unless thefirst_stepkeyword is specified and is set to a sufficiently small value. In this implementation,first_step=dtis already set insolve_ivp.The
solve_ivpkeywordmax_stepshould be considered to be specified for stimuli over short time spans, in order to ensure that the solver does not step over them.Note that
first_stepstill needs to specified even ifmax_stepis.select_initial_stepwill be called regardless iffirst_stepis not specified, and the calls for calculating h1 will be done before checking whetherh0is larger than than the max allowed step size or not. Thus will only specifyingmax_stepstill result in program termination ifstimulusis passed as an array. (Will not be a problem in this implementation sincefirst_stepis already specified.)