Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The progress bar is not displayed and updated as expected. #682

Closed
Jasmine969 opened this issue Aug 2, 2024 · 1 comment
Closed

The progress bar is not displayed and updated as expected. #682

Jasmine969 opened this issue Aug 2, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Jasmine969
Copy link

Jasmine969 commented Aug 2, 2024

Hi, I just installed Brainpy 2.6.0.post20240618 on Windows 10. The Python version is 3.10.14. To test whether the installation was successful, I used the Hodgkin-Huxley examples offered in the Documentation.

I ran the code successfully and plotted the correct graph. The only regrettable thing was that the progress bar was not displayed and updated as expected, in that it was empty and the level of finish was 0% and 0/1000000 even though the simulation was completed.
image

I tested the same code on CentOS 7, with the Python and Brainpy versions kept the same. The code was run successfully but still gave an empty progress bar and a zero level of finish.
image

The code is pasted below for convenience:

import numpy as np

import brainpy as bp
import brainpy.math as bm

bm.set_platform('cpu')


class HH(bp.dyn.NeuDyn):
    def __init__(self, size, ENa=50., gNa=120., EK=-77., gK=36., EL=-54.387, gL=0.03,
                 V_th=20., C=1.0, **kwargs):
        # providing the group "size" information
        super(HH, self).__init__(size=size, **kwargs)

        # initialize parameters
        self.ENa = ENa
        self.EK = EK
        self.EL = EL
        self.gNa = gNa
        self.gK = gK
        self.gL = gL
        self.C = C
        self.V_th = V_th

        # initialize variables
        self.V = bm.Variable(bm.random.randn(self.num) - 70.)
        self.m = bm.Variable(0.5 * bm.ones(self.num))
        self.h = bm.Variable(0.6 * bm.ones(self.num))
        self.n = bm.Variable(0.32 * bm.ones(self.num))
        self.spike = bm.Variable(bm.zeros(self.num, dtype=bool))
        self.t_last_spike = bm.Variable(bm.ones(self.num) * -1e7)

        # integral functions
        self.int_V = bp.odeint(f=self.dV, method='exp_auto')
        self.int_m = bp.odeint(f=self.dm, method='exp_auto')
        self.int_h = bp.odeint(f=self.dh, method='exp_auto')
        self.int_n = bp.odeint(f=self.dn, method='exp_auto')

    def dV(self, V, t, m, h, n, Iext):
        I_Na = (self.gNa * m ** 3.0 * h) * (V - self.ENa)
        I_K = (self.gK * n ** 4.0) * (V - self.EK)
        I_leak = self.gL * (V - self.EL)
        dVdt = (- I_Na - I_K - I_leak + Iext) / self.C
        return dVdt

    def dm(self, m, t, V):
        alpha = 0.1 * (V + 40) / (1 - bm.exp(-(V + 40) / 10))
        beta = 4.0 * bm.exp(-(V + 65) / 18)
        dmdt = alpha * (1 - m) - beta * m
        return dmdt

    def dh(self, h, t, V):
        alpha = 0.07 * bm.exp(-(V + 65) / 20.)
        beta = 1 / (1 + bm.exp(-(V + 35) / 10))
        dhdt = alpha * (1 - h) - beta * h
        return dhdt

    def dn(self, n, t, V):
        alpha = 0.01 * (V + 55) / (1 - bm.exp(-(V + 55) / 10))
        beta = 0.125 * bm.exp(-(V + 65) / 80)
        dndt = alpha * (1 - n) - beta * n
        return dndt

    def update(self, x=None):
        _t = bp.share['t']
        _dt = bp.share['dt']
        x = 0. if x is None else x

        # compute V, m, h, n
        V = self.int_V(self.V, _t, self.m, self.h, self.n, x, dt=_dt)
        self.h.value = self.int_h(self.h, _t, self.V, dt=_dt)
        self.m.value = self.int_m(self.m, _t, self.V, dt=_dt)
        self.n.value = self.int_n(self.n, _t, self.V, dt=_dt)

        # update the spiking state and the last spiking time
        self.spike.value = bm.logical_and(self.V < self.V_th, V >= self.V_th)
        self.t_last_spike.value = bm.where(self.spike, _t, self.t_last_spike)

        # update V
        self.V.value = V


neu = HH(10)
runner = bp.DSRunner(neu, monitors=['V'])
inputs = np.ones(int(100000. / bm.get_dt())) * 6.  # 200 ms
runner.run(inputs=inputs)  # the running time is 200 ms
bp.visualize.line_plot(runner.mon.ts, runner.mon.V, show=True)
@Jasmine969 Jasmine969 added the bug Something isn't working label Aug 2, 2024
@Jasmine969 Jasmine969 changed the title The progress bar is not displayed correctly. The progress bar is not displayed and updated as expected. Aug 2, 2024
@Routhleck
Copy link
Member

Thank you for your feedback! We have addressed the issue and created a new Pull Request (#683) to fix the bug. We will merge the changes shortly and prepare to release a new version of BrainPy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants