[Python] FitzHugh–Nagumo model output not resembling what is shown on Wikipedia

Discussão em 'Python' iniciado por Stack, Junho 25, 2025.

  1. Stack

    Stack Membro Participativo

    First off, I just want to mention that I am a biology researcher not trained in differential equations or dynamical systems. I am doing this as an exercise to get a bit of intuitive understanding of dynamical systems in Neuroscience.

    I am trying to implement the FitzHugh-Nagumo model as it is shown in the linked Wikipedia article. This is a dynamical model of neuronal excitability, and a simplified version of the comprehensive Hodgkin & Huxley model.

    First, I wrote some code for calculating the dynamic variables v' and w':

    def dv(V, W, R, I):
    return V - ((V**3)/3) - W + (R*I)

    def dw(V, W, a, b, tau):
    return (V+a-(b*W))/tau


    Next, I initialize some fixed parameters, identical to the ones given in the first two figures of the Wikipedia article.

    ## fixed params
    a = 0.7
    b = 0.8
    tau = 12.5
    R = 0.1
    I = 0.5


    Then, I set some initial conditions for the system. I picked an initial V to the right of the V nulcline and an initial W under the W nulcline. According to the phase portrait given in the article, this should generate oscillating spiking behavior.

    ## initial conditions
    W = -0.5
    V = 0


    Finally, I wrote a simple iterative integrator to solve the equations. This is just a basic for loop, rather than an actual ODE solver, because right now I'm just trying to understand the basic intuition of dynamical systems.

    ## timescale
    T = 200
    dt = 0.01

    # Initializing arrays to save the solution
    fV = np.zeros(int(T/dt))
    fW = np.zeros(int(T/dt))
    fW[0] = W
    fV[0] = V

    # Integrate numerically via a for loop
    for i in range(int((T/dt)-1)):
    i = i+1

    W+=dw(V, W, a, b, tau) * dt
    V+=dv(V, W, R, I) * dt

    fV=V
    fW=W


    Based on the parameters I entered into the model, I should get an oscillating output that looks like this, according to the Wikipedia article:

    [​IMG]

    However, when I implement the code myself, I get an output that looks like this, lacking the oscillating behavior:

    [​IMG]

    I am not sure what I'm doing wrong. I am not familiar with numerical integration techniques, so I'm wondering if there's something incorrect about the for loop approach. Otherwise, I checked the rest of my code for potential mistakes but couldn't find anything. Any help or insight would be much appreciated!

    Thank you!

    Continue reading...

Compartilhe esta Página