Exemplo n.º 1
0
def electrode(Re, Ce, v_el='v_el', vm='vm', i_inj='i_inj', i_cmd='i_cmd'):
    '''
    An intracellular electrode modeled as an RC circuit,
    or multiple RC circuits in series (if Re, Ce are lists).
    v_el = electrode (=recording) potential
    vm = membrane potential
    i_inj = current entering the membrane
    i_cmd = electrode command current (None = no injection)
    Returns an Equations() object.
    '''
    if isSequenceType(Re):
        if len(Re) != len(Ce) or len(Re) < 2:
            raise TypeError, "Re and Ce must have the same length"
        v_mid, i_mid = [], []
        for i in range(len(Re) - 1):
            v_mid.append('v_mid_' + str(i) + unique_id())
            i_mid.append('i_mid_' + str(i) + unique_id())
        eqs = electrode(Re[0], Ce[0], v_mid[0], vm, i_inj, i_mid[0])
        for i in range(1, len(Re) - 1):
            eqs + electrode(Re[i], Ce[i], v_mid[i], v_mid[i - 1], i_mid[i - 1], i_mid[i])
        eqs += electrode(Re[-1], Ce[-1], v_el, v_mid[-1], i_mid[-1], i_cmd)
        return eqs
    else:
        if Ce > 0 * farad:
            return Equations('''
            dvr/dt = ((vm-vr)/Re+ic)/Ce : mV
            ie = (vr-vm)/Re : nA''', vr=v_el, vm=vm, ic=i_cmd, ie=i_inj, \
            Re=Re, Ce=Ce)
        else: # ideal electrode - pb here
            return Equations('''
            vr = vm+Re*ic : volt
            ie = ic : amp''', vr=v_el, vm=vm, ic=i_cmd, ie=i_inj)
Exemplo n.º 2
0
def K_current_HH(gmax, EK, current_name=None):
    '''
    Hodkin-Huxley K+ current.
    Resting potential is 0 mV.
    '''
    current_name = current_name or unique_id()
    return Current('''
    I=gmax*n**4*(EK-vm) : amp
    dn/dt=alphan*(1-n)-betan*n : 1
    alphan=.01*(10*mV-vm)/(exp(1-.1*vm/mV)-1)/mV/ms : Hz
    betan=.125*exp(-.0125*vm/mV)/ms : Hz
    ''', gmax=gmax, EK=EK, I=current_name, current_name=current_name)
Exemplo n.º 3
0
def Na_current_HH(gmax, ENa, current_name=None):
    '''
    Hodkin-Huxley Na+ current.
    '''
    current_name = current_name or unique_id()
    return Current('''
    I=gmax*m**3*h*(ENa-vm) : amp
    dm/dt=alpham*(1-m)-betam*m : 1
    dh/dt=alphah*(1-h)-betah*h : 1
    alpham=.1*(25*mV-vm)/(exp(2.5-.1*vm/mV)-1)/mV/ms : Hz
    betam=4*exp(-.0556*vm/mV)/ms : Hz
    alphah=.07*exp(-.05*vm/mV)/ms : Hz
    betah=1./(1+exp(3.-.1*vm/mV))/ms : Hz
    ''', gmax=gmax, ENa=ENa, I=current_name, current_name=current_name)
Exemplo n.º 4
0
def electrode(Re, Ce, v_el='v_el', vm='vm', i_inj='i_inj', i_cmd='i_cmd'):
    '''
    An intracellular electrode modeled as an RC circuit,
    or multiple RC circuits in series (if Re, Ce are lists).
    v_el = electrode (=recording) potential
    vm = membrane potential
    i_inj = current entering the membrane
    i_cmd = electrode command current (None = no injection)
    Returns an Equations() object.
    '''
    if isSequenceType(Re):
        if len(Re) != len(Ce) or len(Re) < 2:
            raise TypeError, "Re and Ce must have the same length"
        v_mid, i_mid = [], []
        for i in range(len(Re) - 1):
            v_mid.append('v_mid_' + str(i) + unique_id())
            i_mid.append('i_mid_' + str(i) + unique_id())
        eqs = electrode(Re[0], Ce[0], v_mid[0], vm, i_inj, i_mid[0])
        for i in range(1, len(Re) - 1):
            eqs + electrode(Re[i], Ce[i], v_mid[i], v_mid[i - 1], i_mid[i - 1],
                            i_mid[i])
        eqs += electrode(Re[-1], Ce[-1], v_el, v_mid[-1], i_mid[-1], i_cmd)
        return eqs
    else:
        if Ce > 0 * farad:
            return Equations('''
            dvr/dt = ((vm-vr)/Re+ic)/Ce : mV
            ie = (vr-vm)/Re : nA''', vr=v_el, vm=vm, ic=i_cmd, ie=i_inj, \
            Re=Re, Ce=Ce)
        else:  # ideal electrode - pb here
            return Equations('''
            vr = vm+Re*ic : volt
            ie = ic : amp''',
                             vr=v_el,
                             vm=vm,
                             ic=i_cmd,
                             ie=i_inj)
Exemplo n.º 5
0
def leak_current(gl, El, current_name=None):
    '''
    Leak current: gl*(El-vm)
    '''
    current_name = current_name or unique_id()
    return Current('I=gl*(El-vm) : amp', gl=gl, El=El, I=current_name, current_name=current_name)