Beispiel #1
0
def createSpine(parentCompt, parentObj, index, frac, length, dia, theta):
    """Create spine of specified dimensions and index"""
    RA = 1.0
    RM = 1.0
    CM = 0.01
    shaftDia = dia / 5.0
    sname = 'shaft' + str(index)
    hname = 'head' + str(index)
    shaft = moose.SymCompartment(parentObj.path + '/' + sname)
    moose.connect(parentCompt, 'cylinder', shaft, 'proximalOnly', 'Single')
    x = parentCompt.x0 + frac * (parentCompt.x - parentCompt.x0)
    y = parentCompt.y0 + frac * (parentCompt.y - parentCompt.y0)
    z = parentCompt.z0 + frac * (parentCompt.z - parentCompt.z0)
    shaft.x0 = x
    shaft.y0 = y
    shaft.z0 = z
    sy = y + length * math.cos(theta * math.pi / 180.0)
    sz = z + length * math.sin(theta * math.pi / 180.0)
    shaft.x = x
    shaft.y = sy
    shaft.z = sz
    shaft.diameter = dia / 2.0
    shaft.length = length
    xa = math.pi * shaftDia * shaftDia / 4
    circumference = math.pi * shaftDia
    shaft.Ra = RA * length / xa
    shaft.Rm = RM / (length * circumference)
    shaft.Cm = CM * length * circumference
    shaft.Em = EREST_ACT
    shaft.initVm = EREST_ACT

    head = moose.SymCompartment(parentObj.path + '/' + hname)
    moose.connect(shaft, 'distal', head, 'proximal', 'Single')
    head.x0 = x
    head.y0 = sy
    head.z0 = sz
    hy = sy + length * math.cos(theta * math.pi / 180.0)
    hz = sz + length * math.sin(theta * math.pi / 180.0)
    head.x = x
    head.y = hy
    head.z = hz
    head.diameter = dia
    head.length = length
    xa = math.pi * dia * dia / 4.0
    circumference = math.pi * dia
    head.Ra = RA * length / xa
    head.Rm = RM / (length * circumference)
    head.Cm = CM * length * circumference
    head.Em = EREST_ACT
    head.initVm = EREST_ACT
    #print head.Rm, head.Ra, head.Cm, head.diameter, head.length
    #print shaft.Rm, shaft.Ra, shaft.Cm, shaft.diameter, shaft.length
    return head
def test_symcompartment():
    """This example demonstrates the use of SymCompartment class of MOOSE."""
    model = moose.Neutral('model')
    soma = moose.SymCompartment('%s/soma' % (model.path))
    soma.Em = -60e-3
    soma.Rm = 1000402560
    soma.Cm = 2.375043912e-11
    soma.Ra = 233957.7812
    d1 = moose.SymCompartment('%s/d1' % (model.path))
    d1.Rm = 397887392
    d1.Cm = 2.261946489e-12
    d1.Ra = 24867960
    d2 = moose.SymCompartment('%s/d2' % (model.path))
    d2.Rm = 2.877870285e+10
    d2.Cm = 8.256105218e-13
    d2.Ra = 20906072
    moose.connect(d1, 'proximal', soma, 'distal')
    moose.connect(d2, 'proximal', soma, 'distal')
    moose.connect(d1, 'sibling', d2, 'sibling')
    pg = moose.PulseGen('/model/pulse')
    pg.delay[0] = 10e-3
    pg.width[0] = 20e-3
    pg.level[0] = 1e-6
    pg.delay[1] = 1e9
    moose.connect(pg, 'output', d1, 'injectMsg')
    data = moose.Neutral('/data')
    tab_soma = moose.Table('%s/soma_Vm' % (data.path))
    tab_d1 = moose.Table('%s/d1_Vm' % (data.path))
    tab_d2 = moose.Table('%s/d2_Vm' % (data.path))
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.connect(tab_d1, 'requestOut', d1, 'getVm')
    moose.connect(tab_d2, 'requestOut', d2, 'getVm')
    moose.setClock(0, simdt)
    moose.setClock(1, simdt)
    moose.setClock(2, simdt)
    moose.useClock(
        0, '/model/##[ISA=Compartment]', 'init'
    )  # This is allowed because SymCompartment is a subclass of Compartment
    moose.useClock(1, '/model/##', 'process')
    moose.useClock(2, '/data/##[ISA=Table]', 'process')
    moose.reinit()
    moose.start(simtime)
    t = np.linspace(0, simtime, len(tab_soma.vector))
    data_matrix = np.vstack((t, tab_soma.vector, tab_d1.vector, tab_d2.vector))
    np.savetxt('symcompartment.txt', data_matrix.transpose())
    pylab.plot(t, tab_soma.vector, label='Vm_soma')
    pylab.plot(t, tab_d1.vector, label='Vm_d1')
    pylab.plot(t, tab_d2.vector, label='Vm_d2')
    pylab.show()
Beispiel #3
0
def test_symcompartment():
    model = moose.Neutral('model')
    soma = moose.SymCompartment('%s/soma' % (model.path))
    soma.Em = -60e-3
    soma.Rm = 1e9
    soma.Cm = 1e-11
    soma.Ra = 1e6
    d1 = moose.SymCompartment('%s/d1' % (model.path))
    d1.Rm = 1e8
    d1.Cm = 1e-10
    d1.Ra = 1e7
    d2 = moose.SymCompartment('%s/d2' % (model.path))
    d2.Rm = 1e8
    d2.Cm = 1e-10
    d2.Ra = 2e7
    moose.connect(d1, 'proximal', soma, 'distal')
    moose.connect(d2, 'proximal', soma, 'distal')
    moose.connect(d1, 'sibling', d2, 'sibling')
    pg = moose.PulseGen('/model/pulse')
    pg.delay[0] = 10e-3
    pg.width[0] = 20e-3
    pg.level[0] = 1e-6
    pg.delay[1] = 1e9
    moose.connect(pg, 'output', d1, 'injectMsg')
    data = moose.Neutral('/data')
    tab_soma = moose.Table('%s/soma_Vm' % (data.path))
    tab_d1 = moose.Table('%s/d1_Vm' % (data.path))
    tab_d2 = moose.Table('%s/d2_Vm' % (data.path))
    moose.connect(tab_soma, 'requestOut', soma, 'getVm')
    moose.connect(tab_d1, 'requestOut', d1, 'getVm')
    moose.connect(tab_d2, 'requestOut', d2, 'getVm')
    moose.setClock(0, simdt)
    moose.setClock(1, simdt)
    moose.setClock(2, simdt)
    moose.useClock(
        0, '/model/##[ISA=Compartment]', 'init'
    )  # This is allowed because SymCompartment is a subclass of Compartment
    moose.useClock(1, '/model/##', 'process')
    moose.useClock(2, '/data/##[ISA=Table]', 'process')
    moose.reinit()
    moose.start(simtime)
    t = np.linspace(0, simtime, len(tab_soma.vector))
    data_matrix = np.vstack((t, tab_soma.vector, tab_d1.vector, tab_d2.vector))
    np.savetxt('symcompartment.txt', data_matrix.transpose())
    pylab.plot(t, tab_soma.vector, label='Vm_soma')
    pylab.plot(t, tab_d1.vector, label='Vm_d1')
    pylab.plot(t, tab_d2.vector, label='Vm_d2')
    pylab.show()
def createSquid():
    """Create a single compartment squid model."""
    parent = moose.Neutral('/n')
    elec = moose.Neutral('/n/elec')
    compt = moose.SymCompartment('/n/elec/compt')
    Em = EREST_ACT + 10.613e-3
    compt.Em = Em
    compt.initVm = EREST_ACT
    compt.Cm = 7.85e-9 * 0.5
    compt.Rm = 4.2e5 * 5.0
    compt.Ra = 7639.44e3
    compt.length = 100e-6
    compt.diameter = 4e-6
    nachan = moose.HHChannel('/n/elec/compt/Na')
    nachan.Xpower = 3
    xGate = moose.HHGate(nachan.path + '/gateX')
    xGate.setupAlpha(Na_m_params + [VDIVS, VMIN, VMAX])
    xGate.useInterpolation = 1
    nachan.Ypower = 1
    yGate = moose.HHGate(nachan.path + '/gateY')
    yGate.setupAlpha(Na_h_params + [VDIVS, VMIN, VMAX])
    yGate.useInterpolation = 1
    nachan.Gbar = 0.942e-3
    nachan.Ek = 115e-3 + EREST_ACT
    moose.connect(nachan, 'channel', compt, 'channel', 'OneToOne')

    kchan = moose.HHChannel('/n/elec/compt/K')
    kchan.Xpower = 4.0
    xGate = moose.HHGate(kchan.path + '/gateX')
    xGate.setupAlpha(K_n_params + [VDIVS, VMIN, VMAX])
    xGate.useInterpolation = 1
    kchan.Gbar = 0.2836e-3
    kchan.Ek = -12e-3 + EREST_ACT
    moose.connect(kchan, 'channel', compt, 'channel', 'OneToOne')
    return compt
Beispiel #5
0
def makeChannelPrototypes():
    """Create channel prototypes for readcell."""
    library = moose.Neutral('/library')
    moose.setCwe('/library')
    compt = moose.SymCompartment('/library/symcompartment')
    Em = EREST_ACT + 10.613e-3
    compt.Em = Em
    compt.initVm = EREST_ACT
    compt.Cm = 7.85e-9 * 0.5
    compt.Rm = 4.2e5 * 5.0
    compt.Ra = 7639.44e3
    nachan = moose.HHChannel('/library/Na')
    nachan.Xpower = 3
    xGate = moose.HHGate(nachan.path + '/gateX')
    xGate.setupAlpha(Na_m_params + [VDIVS, VMIN, VMAX])
    xGate.useInterpolation = 1
    nachan.Ypower = 1
    yGate = moose.HHGate(nachan.path + '/gateY')
    yGate.setupAlpha(Na_h_params + [VDIVS, VMIN, VMAX])
    yGate.useInterpolation = 1
    nachan.Gbar = 0.942e-3
    nachan.Ek = 115e-3 + EREST_ACT

    kchan = moose.HHChannel('/library/K')
    kchan.Xpower = 4.0
    xGate = moose.HHGate(kchan.path + '/gateX')
    xGate.setupAlpha(K_n_params + [VDIVS, VMIN, VMAX])
    xGate.useInterpolation = 1
    kchan.Gbar = 0.2836e-3
    kchan.Ek = -12e-3 + EREST_ACT
Beispiel #6
0
def create_squid():
    """Create a single compartment squid model."""
    parent = moose.Neutral('/n')
    compt = moose.SymCompartment('/n/compt')
    Em = EREST_ACT + 10.613e-3
    compt.Em = Em
    compt.initVm = EREST_ACT
    compt.Cm = 7.85e-9 * 0.5
    compt.Rm = 4.2e5 * 5.0
    compt.Ra = 7639.44e3
    nachan = moose.HHChannel('/n/compt/Na')
    nachan.Xpower = 3
    xGate = moose.HHGate(nachan.path + '/gateX')
    xGate.setupAlpha(Na_m_params + [VDIVS, VMIN, VMAX])
    #This is important: one can run without it but the output will diverge.
    xGate.useInterpolation = 1
    nachan.Ypower = 1
    yGate = moose.HHGate(nachan.path + '/gateY')
    yGate.setupAlpha(Na_h_params + [VDIVS, VMIN, VMAX])
    yGate.useInterpolation = 1
    nachan.Gbar = 0.942e-3
    nachan.Ek = 115e-3 + EREST_ACT
    moose.connect(nachan, 'channel', compt, 'channel', 'OneToOne')

    kchan = moose.HHChannel('/n/compt/K')
    kchan.Xpower = 4.0
    xGate = moose.HHGate(kchan.path + '/gateX')
    xGate.setupAlpha(K_n_params + [VDIVS, VMIN, VMAX])
    xGate.useInterpolation = 1
    kchan.Gbar = 0.2836e-3
    kchan.Ek = -12e-3 + EREST_ACT
    moose.connect(kchan, 'channel', compt, 'channel', 'OneToOne')
    return compt