Ejemplo n.º 1
0
    def plot_curve(cls, ax, curve, chl, state, infpower=None, *args, **kwargs):

        V = np.linspace(-80,50)*unit('mV')
        #V = StdLimits.get_default_voltage_array().rescale('mV')

        (alpha, beta) = chl.get_alpha_beta_at_voltage(V, state)
        (inf, tau) = InfTauCalculator.alpha_beta_to_inf_tau(alpha, beta)
        infpower = (np.power(inf, infpower) if infpower else None)
        plot_what_lut = {
            Curve.Alpha: (alpha, 'Rate Constant', None),
            Curve.Beta: (beta, 'Rate Constant', None),
            Curve.Inf: (inf, 'Steady-State', None),
            Curve.InfPowered: (infpower, 'Steady-State', None),
            Curve.Tau: (tau, 'Time-Constant', 'ms'),
            }
        (plot_what, y_label, y_unit) = plot_what_lut[curve]

            # print kwargs

        if isinstance(ax, QuantitiesAxisNew):

            ax.plot(V, plot_what, *args, **kwargs)
            ax.set_xlabel('Voltage')
            ax.set_ylabel(y_label)

            if y_unit:
                ax.set_yunit(unit(y_unit))
        else:

            ax.plot(V, plot_what, *args, **kwargs)
            ax.set_xlabel('Voltage (mV)')
            ax.set_ylabel(y_label)
Ejemplo n.º 2
0
    def get_voltage_clamp_trace(cls, V, chl, duration, cell_area, t=np.arange(0, 300, 0.1) * unit("1:ms")) :
        from scipy.integrate import odeint
        import sympy

        v_in_mv = V.rescale('mV').magnitude

        state_names = chl.statevars.keys()
        n_states = len(state_names)
        (m_inf, m_tau) = InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[state_names[0]], V)
        m_tau_ms = m_tau.rescale('ms').magnitude

        inf_taus = [InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[stateName], V)  for stateName in state_names]
        inf_taus_ms = [(inf, tau.rescale("ms").magnitude)  for (inf, tau) in inf_taus]

        state_to_index = dict([(state, index) for state, index in enumerate(state_names)])

        def odeFunc(y, t0):
            res = [None] * n_states
            for i in range(0, n_states):
                state_inf, state_tau = inf_taus_ms[i]
                state_val = y[i]
                d_state = (state_inf - state_val) / state_tau
                res[i] = d_state
            return res

        # run the ODE for each variable:
        t = t.rescale('ms').magnitude
        y0 = np.zeros((n_states))
        res = odeint(func=odeFunc, y0=y0, t=t)

        state_functor = sympy.lambdify(state_names, sympy.sympify(chl.eqn))
        state_data = [res[:, i] for i in range(0, n_states)]

        state_equation_evaluation = state_functor(*state_data)

        cell_density = chl.conductance * cell_area
        i_chl = chl.conductance * cell_area * state_equation_evaluation * (V - chl.reversalpotential)

        return TraceFixedDT(time=t * unit('1:ms'),
                            data=i_chl.rescale('pA'))
Ejemplo n.º 3
0
    def get_voltage_clamp_trace(cls, V, chl, duration, cell_area, t=np.arange(0, 300, 0.1) * unit("1:ms")):
        from scipy.integrate import odeint
        import sympy

        v_in_mv = V.rescale("mV").magnitude

        state_names = chl.statevars.keys()
        n_states = len(state_names)
        (m_inf, m_tau) = InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[state_names[0]], V)
        m_tau_ms = m_tau.rescale("ms").magnitude

        inf_taus = [InfTauCalculator.evaluate_inf_tau_for_v(chl.statevars[stateName], V) for stateName in state_names]
        inf_taus_ms = [(inf, tau.rescale("ms").magnitude) for (inf, tau) in inf_taus]

        state_to_index = dict([(state, index) for state, index in enumerate(state_names)])

        def odeFunc(y, t0):
            res = [None] * n_states
            for i in range(0, n_states):
                state_inf, state_tau = inf_taus_ms[i]
                state_val = y[i]
                d_state = (state_inf - state_val) / state_tau
                res[i] = d_state
            return res

        # run the ODE for each variable:
        t = t.rescale("ms").magnitude
        y0 = np.zeros((n_states))
        res = odeint(func=odeFunc, y0=y0, t=t)

        state_functor = sympy.lambdify(state_names, sympy.sympify(chl.eqn))
        state_data = [res[:, i] for i in range(0, n_states)]

        state_equation_evaluation = state_functor(*state_data)

        cell_density = chl.conductance * cell_area
        i_chl = chl.conductance * cell_area * state_equation_evaluation * (V - chl.reversalpotential)

        return TraceFixedDT(time=t * unit("1:ms"), data=i_chl.rescale("pA"))
Ejemplo n.º 4
0
 def getVoltageClampTrace(cls, V, chl, duration, cellArea, t=np.arange(0,300,0.1) * unit("1:ms"), ) :
     
     from scipy.integrate import odeint
     
     vInMv = V.rescale("mV").magnitude
     
     stateNames = chl.statevars.keys()
     nStates = len(stateNames)
     m_inf, m_tau =  InfTauCalculator.evaluateInfTauForV( chl.statevars[stateNames[0]], V)
     m_tauMS = m_tau.rescale("ms").magnitude
     
     infTaus = [ InfTauCalculator.evaluateInfTauForV( chl.statevars[stateName], V)  for stateName in stateNames ]
     infTausMS = [ (inf, tau.rescale("ms").magnitude)  for (inf,tau) in infTaus ]
     
     stateToIndex = dict( [ (state,index) for state,index in enumerate(stateNames) ] ) 
     
     def odeFunc(y,t0):
         res = [None] * nStates
         for i in range(0,nStates):
             stateInf,stateTau = infTausMS[i]
             stateVal = y[i]
             dState = ( stateInf - stateVal ) / stateTau
             res[i] = dState
         return res
     
     # Run the ODE for each variable:            
     t = t.rescale("ms").magnitude
     y0 = np.zeros( (nStates, ) )
     res = odeint(func=odeFunc, y0=y0, t= t  )
     
     stateFunctor = sympy.lambdify( stateNames, sympy.sympify(chl.eqn)  )
     stateData = [ res[:,i] for i in range(0,nStates) ]
     
     stateEquationEvaluation = stateFunctor( *stateData )
     
     cellDensity = (chl.conductance * cellArea)
     iChl =  (chl.conductance * cellArea)  * stateEquationEvaluation * (V- chl.reversalpotential) 
     
     return Trace_FixedDT( time=t * unit("1:ms"), data=iChl.rescale("pA")  )
Ejemplo n.º 5
0
    def plot_inf_tau_curves(cls, ax1, ax2, calciumAlphaBetaBetaChannel, state):

        chl = calciumAlphaBetaBetaChannel

        V = StdLimits.get_default_voltage_array().rescale("mV")

        alpha, beta = cls.getResolvedAlphaBetaCurves(V, chl, state)
        inf, tau = InfTauCalculator.alpha_beta_to_inf_tau(alpha, beta)

        ax1.plot(V, inf)
        ax1.set_xlabel("Voltage")
        ax1.set_ylabel("Inf")

        ax2.setYUnit("ms")
        ax2.plot(V, tau)
        ax2.set_xlabel("Voltage")
        ax2.set_ylabel("Tau")
        def plot_inf_tau_curves(cls, ax1, ax2, calciumAlphaBetaBetaChannel, state):

            chl = calciumAlphaBetaBetaChannel

            V = StdLimits.get_default_voltage_array().rescale("mV")

            alpha, beta = cls.getResolvedAlphaBetaCurves(V, chl, state)
            inf, tau = InfTauCalculator.alpha_beta_to_inf_tau(alpha, beta)

            ax1.plot(V, inf)
            ax1.set_xlabel("Voltage")
            ax1.set_ylabel("Inf")

            ax2.setYUnit("ms")
            ax2.plot(V, tau)
            ax2.set_xlabel("Voltage")
            ax2.set_ylabel("Tau")