Exemplo n.º 1
0
def main(argv):
    hhModel = HodgkinAndHuxleyModel(i=None)
    vs = np.arange(10, 100, 1e-3)

    tauMs = hhModel._tauM(v=vs)
    mCBase = min(tauMs)
    mCAmp = max(tauMs)-mCBase
    mVMax = vs[np.argmax(tauMs)]
    mSigma = abs(mVMax-vs[np.argmin(abs((tauMs-mCBase)-(max(tauMs)-mCBase)*np.exp(-1)))])
    tauMsApproxFun = lambda v: mCBase+mCAmp*np.exp(-(mVMax-v)**2/mSigma**2)
    tauMsApprox = tauMsApproxFun(v=vs)

    # begin delete
    refValue = mCBase+mCAmp*np.exp(-1)
    tauMAtMVMaxPlusMSigma = hhModel._tauN(v=mVMax+mSigma)
    tauMApproxAtMVMaxPlusMSigma = tauMsApproxFun(v=mVMax+mSigma)
    closeToZero1 = abs(tauMAtMVMaxPlusMSigma-refValue)
    closeToZero2 = abs(tauMApproxAtMVMaxPlusMSigma-refValue)
    # end delete

    plt.figure()
    plt.plot(vs, tauMs, label=r"$\tau_M$(v)")
    plt.plot(vs, tauMsApprox, label=r"$\hat{\tau}_M$(v)")
    plt.axhline(y=min(tauMs[vs>60]))
    plt.xlabel("V (mv)")
    plt.ylabel("Time Constant")
    plt.legend(loc="upper right")

    plt.show()
    pdb.set_trace()
def main(argv):
    figFilename = "figures/fig2-13.eps"

    def i(t):
        return 0.0

    hhModel = HodgkinAndHuxleyModel(i=i)
    v = np.arange(-40, 100, .1)
    nInf = hhModel._nInf(v=v)
    mInf = hhModel._mInf(v=v)
    hInf = hhModel._hInf(v=v)
    tauN = hhModel._tauN(v=v)
    tauM = hhModel._tauM(v=v)
    tauH = hhModel._tauH(v=v)

    f, (ax1, ax2) = plt.subplots(1, 2)

    ax1.plot(v, nInf, label=r"$n_\infty$(V)")
    ax1.plot(v, mInf, label=r"$m_\infty$(V)")
    ax1.plot(v, hInf, label=r"$h_\infty$(V)")
    ax1.legend(loc="lower right")
    ax1.set_xlabel("V (mv)")
    ax1.set_ylabel("Probability")

    ax2.plot(v, tauN, label=r"$\tau_n$(V)")
    ax2.plot(v, tauM, label=r"$\tau_m$(V)")
    ax2.plot(v, tauH, label=r"$\tau_h$(V)")
    ax2.legend(loc="upper right")
    ax2.set_xlabel("V (mv)")
    ax2.set_ylabel("Time (ms)")

    plt.savefig(figFilename)

    pdb.set_trace()
Exemplo n.º 3
0
def main(argv):
    i0 = 0.0
    v0 = 0.0
    n0 = 0.31767691406070614
    m0 = 0.052932485257253123
    h0 = 0.5961207535084404
    t0 = 0.0
    t1 = 2.0
    t2 = 10.0
    tf = 20.0
    dt = 1e-5
    nVOneHalf = -45.0, 
    iPulse1Strength = 10.0
    iPulse2Strength = 25.0
    iPulseWidth = 0.25
    traceCol = 'grey'
    traceMarker = '.'

    def i(t):
        return(i0)
    nTSteps = round((tf-t0)/dt)
    times = np.empty(nTSteps+1)
    hhModel = HodgkinAndHuxleyModel(i=i)
    integrator = ode(hhModel.deriv).set_integrator('vode', max_step=dt)

    y0 = np.array([v0, n0, m0, h0])
    integrator.set_initial_value(y0, t0)
    ys = np.empty((4, nTSteps+1))
    ys[:, 0] = y0

    t = t0
    step = 0
    successfulIntegration = True
    while successfulIntegration and step<nTSteps:
        step = step+1
        if step%1000==0:
            print('Processing time %.05f out of %.02f' % (t, tf))
            sys.stdout.flush()
        integrator.integrate(t+dt)
        t = integrator.t
        y = integrator.y
        times[step] = t
        ys[:, step] = y

    inputCurrent = np.empty(len(times))
    for j in xrange(len(times)):
        inputCurrent[j] = i(t=times[j])
    resultsFilename = 'results/integrationHodgkinAndHuxley_noInput.npz'
    np.savez(resultsFilename, times=times, ys=ys, inputCurrent=inputCurrent)

    plt.plot(times, ys[0, :])
    plt.grid()
    plt.xlabel('Time (secs)')
    plt.ylabel('Voltage (mv)')
    plt.savefig('figures/voltageTraceIntegrationHodgkinAndHuxley_noInput.eps')
    plt.show()
    pdb.set_trace()
def main(argv):
    vs = np.arange(-40, 100, .1)
    hhModel = HodgkinAndHuxleyModel(i=None)
    approxHHModel = ApproxHodgkinAndHuxleyModel(i=None)
    nInfs = hhModel._nInf(v=vs)
    approxNInfs = approxHHModel._nInf(v=vs)
    mInfs = hhModel._mInf(v=vs)
    approxMInfs = approxHHModel._mInf(v=vs)
    hInfs = hhModel._hInf(v=vs)
    approxHInfs = approxHHModel._hInf(v=vs)
    tauNs = hhModel._tauN(v=vs)
    approxTauNs = approxHHModel._tauN(v=vs)
    tauMs = hhModel._tauM(v=vs)
    approxTauMs = approxHHModel._tauM(v=vs)
    tauHs = hhModel._tauH(v=vs)
    approxTauHs = approxHHModel._tauH(v=vs)

    plt.subplot(2, 1, 1)
    plt.plot(vs, nInfs, label=r"$n_\infty$(v)")
    plt.plot(vs, approxNInfs, label=r"$\tilde{n}_\infty$(v)")
    plt.plot(vs, mInfs, label=r"$m_\infty$(v)")
    plt.plot(vs, approxMInfs, label=r"$\tilde{m}_\infty$(v)")
    plt.plot(vs, hInfs, label=r"$h_\infty$(v)")
    plt.plot(vs, approxHInfs, label=r"$\tilde{h}_\infty$(v)")
    plt.ylabel("Proability Open")
    plt.legend()

    plt.subplot(2, 1, 2)
    plt.plot(vs, tauNs, label=r"$\tau_n$(v)")
    plt.plot(vs, approxTauNs, label=r"$\hat{\tau}_n$(v)")
    plt.plot(vs, tauMs, label=r"$\tau_m$(v)")
    plt.plot(vs, approxTauMs, label=r"$\hat{\tau}_m$(v)")
    plt.plot(vs, tauHs, label=r"$\tau_h$(v)")
    plt.plot(vs, approxTauHs, label=r"$\hat{\tau}_h$(v)")
    plt.xlabel("Voltage (mV)")
    plt.ylabel("Time Constant")
    plt.legend()

    plt.show()
Exemplo n.º 5
0
def main(argv):
    hhModel = HodgkinAndHuxleyModel(i=None)
    vs = np.arange(-40, 100, 1e-3)

    nInfs = hhModel._nInf(v=vs)
    nVOneHalf = vs[np.argmin(np.abs(nInfs - .5))]
    nK = -(vs[np.argmin(np.abs(nInfs - 1.0 / (1 + np.exp(1))))] - nVOneHalf)
    nInfsApproxFunc = lambda v: 1.0 / (1 + np.exp((nVOneHalf - v) / nK))
    nInfsApprox = nInfsApproxFunc(v=vs)

    mInfs = hhModel._mInf(v=vs)
    mVOneHalf = vs[np.argmin(np.abs(mInfs - .5))]
    mK = -(vs[np.argmin(np.abs(mInfs - 1.0 / (1 + np.exp(1))))] - mVOneHalf)
    mInfsApproxFunc = lambda v: 1.0 / (1 + np.exp((mVOneHalf - v) / mK))
    mInfsApprox = mInfsApproxFunc(v=vs)

    hInfs = hhModel._hInf(v=vs)
    hVOneHalf = vs[np.argmin(np.abs(hInfs - .5))]
    hK = -(vs[np.argmin(np.abs(hInfs - 1.0 / (1 + np.exp(1))))] - hVOneHalf)
    hInfsApproxFunc = lambda v: 1.0 / (1 + np.exp((hVOneHalf - v) / hK))
    hInfsApprox = hInfsApproxFunc(v=vs)

    tauNs = hhModel._tauN(v=vs)
    nCBase = min(tauNs)
    nCAmp = max(tauNs) - nCBase
    nVMax = vs[np.argmax(tauNs)]
    nSigma = abs(
        nVMax -
        vs[np.argmin(abs((tauNs - nCBase) -
                         (max(tauNs) - nCBase) * np.exp(-1)))])
    tauNsApproxFun = lambda v: nCBase + nCAmp * np.exp(-(nVMax - v)**2 / nSigma
                                                       **2)
    tauNsApprox = tauNsApproxFun(v=vs)

    #     tauMs = hhModel._tauM(v=vs)
    #     mCBase = min(tauMs)
    #     mCAmp = max(tauMs)-mCBase
    #     mVMax = vs[np.argmax(tauMs)]
    #     mSigma = abs(mVMax-vs[np.argmin(abs((tauMs-mCBase)-(max(tauMs)-mCBase)*np.exp(-1)))])
    #     tauMsApproxFun = lambda v: mCBase+mCAmp*np.exp(-(mVMax-v)**2/mSigma**2)
    #     tauMsApprox = tauMsApproxFun(v=vs)

    # begin delete
    refValue = mCBase + mCAmp * np.exp(-1)
    tauMAtMVMaxPlusMSigma = hhModel._tauN(v=mVMax + mSigma)
    tauMApproxAtMVMaxPlusMSigma = tauMsApproxFun(v=mVMax + mSigma)
    closeToZero1 = abs(tauMAtMVMaxPlusMSigma - refValue)
    closeToZero2 = abs(tauMApproxAtMVMaxPlusMSigma - refValue)
    pdb.set_trace()
    # end delete

    tauHs = hhModel._tauH(v=vs)
    hCBase = min(tauHs)
    hCAmp = max(tauHs) - hCBase
    hVMax = vs[np.argmax(tauHs)]
    hSigma = abs(
        hVMax -
        vs[np.argmin(abs((tauHs - hCBase) -
                         (max(tauHs) - hCBase) * np.exp(-1)))])
    tauHsApproxFun = lambda v: hCBase + hCAmp * np.exp(-(hVMax - v)**2 / hSigma
                                                       **2)
    tauHsApprox = tauHsApproxFun(v=vs)

    plt.plot(vs, nInfs, label=r"$n_{\infty}$(v)")
    plt.plot(vs, nInfsApprox, label=r"$\hat{n}_{\infty}$(v)")
    plt.plot(vs, mInfs, label=r"$m_{\infty}$(v)")
    plt.plot(vs, mInfsApprox, label=r"$\hat{m}_{\infty}$(v)")
    plt.plot(vs, hInfs, label=r"$h_{\infty}$(v)")
    plt.plot(vs, hInfsApprox, label=r"$\hat{h}_{\infty}$(v)")
    plt.xlabel("V (mv)")
    plt.ylabel("Probability")
    plt.legend(loc="lower right")

    plt.figure()
    plt.plot(vs, tauNs, label=r"$\tau_N$(v)")
    plt.plot(vs, tauNsApprox, label=r"$\hat{\tau}_N$(v)")
    #     plt.plot(vs, tauMs, label=r"$\tau_M$(v)")
    #     plt.plot(vs, tauMsApprox, label=r"$\hat{\tau}_M$(v)")
    plt.plot(vs, tauHs, label=r"$\tau_H$(v)")
    plt.plot(vs, tauHsApprox, label=r"$\hat{\tau}_H$(v)")
    plt.xlabel("V (mv)")
    plt.ylabel("Time Constant")
    plt.legend(loc="upper right")

    plt.show()
    pdb.set_trace()