Esempio n. 1
0
def test_hsolve_calcium():
    for tick in range(0, 7):
        moose.setClock(tick, 10e-6)
    moose.setClock(8, 0.005)

    lib = moose.Neutral('/library')
    model = moose.loadModel(p_file, 'neuron')
    assert model, model
    pulse = moose.PulseGen('/neuron/pulse')
    inject = 100e-10
    chan_proto.chan_proto('/library/SK', param_chan.SK)
    chan_proto.chan_proto('/library/CaL12', param_chan.Cal)
    pulse.delay[0] = 8.
    pulse.width[0] = 500e-12
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    for comp in moose.wildcardFind('/neuron/#[TYPE=Compartment]'):
        new_comp = moose.element(comp)
        new_comp.initVm = -.08
        difs, difb = td.add_difshells_and_buffers(new_comp, difshell_no,
                                                  difbuf_no)
        for name in cond:
            chan = td.addOneChan(name, cond[name], new_comp)
            if 'Ca' in name:
                moose.connect(chan, "IkOut", difs[0], "influx")

            if 'SK' in name:
                moose.connect(difs[0], 'concentrationOut', chan, 'concen')

    data = moose.Neutral('/data')
    vmtab = moose.Table('/data/Vm')
    shelltab = moose.Table('/data/Ca')
    caltab = moose.Table('/data/CaL_Gk')
    sktab = moose.Table('/data/SK_Gk')
    moose.connect(vmtab, 'requestOut', moose.element('/neuron/soma'), 'getVm')
    moose.connect(shelltab, 'requestOut', difs[0], 'getC')
    moose.connect(caltab, 'requestOut', moose.element('/neuron/soma/CaL12'),
                  'getGk')
    moose.connect(sktab, 'requestOut', moose.element('/neuron/soma/SK'),
                  'getGk')

    hsolve = moose.HSolve('/neuron/hsolve')
    hsolve.dt = 10e-6
    hsolve.target = ('/neuron/soma')
    t_stop = 10.
    moose.reinit()
    moose.start(t_stop)
    vec1 = sktab.vector
    vec2 = shelltab.vector
    assert_stat(vec1, [0.0, 5.102834e-22, 4.79066e-22, 2.08408e-23])
    assert_stat(vec2, [5.0e-5, 5.075007e-5, 5.036985e-5, 2.1950117e-7])
    assert len(np.where(sktab.vector < 1e-19)[0]) == 2001
    assert len(np.where(shelltab.vector > 50e-6)[0]) == 2000
Esempio n. 2
0
def test_diffshell():
    lib = moose.Neutral('/library')
    for tick in range(0, 7):
        moose.setClock(tick, dt)
    moose.setClock(8, 0.005)  # set output clock
    model = moose.Neutral('/model')
    dend = moose.Compartment('/model/dend')
    pulse = moose.PulseGen('/model/pulse')
    data = moose.Neutral('/data')
    vmtab = moose.Table('/data/dend_Vm')
    gktab = moose.Table('/data/CaT_Gk')
    iktab = moose.Table('/data/CaT_Ik')

    dend.Cm = Cm
    dend.Rm = Rm
    dend.Em = Em
    dend.initVm = Vm_0
    dend.diameter = dend_diameter
    dend.length = dend_length

    pulse.delay[0] = 8.
    pulse.width[0] = 500e-3
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    chan = chan_proto.chan_proto('/library/CaL12', param_chan.Cal)
    m = moose.connect(pulse, 'output', dend, 'injectMsg')
    moose.connect(vmtab, 'requestOut', dend, 'getVm')
    chan = addOneChan('CaL12', gbar, dend)
    moose.connect(gktab, 'requestOut', chan, 'getGk')
    moose.connect(iktab, 'requestOut', chan, 'getIk')
    diftab = []
    buftab = []
    difs, difb = add_difshells_and_buffers(dend, difshell_no, difbuff_no)
    if pumps:
        pump = moose.MMPump('/model/dend/pump')
        pump.Vmax = kcat
        pump.Kd = km
        moose.connect(pump, "PumpOut", difs[0], "mmPump")
    if difs:
        moose.connect(chan, "IkOut", difs[0], "influx")
        moose.connect(difs[0], 'concentrationOut', chan, 'concen')

    for i, dif in enumerate(difs):
        res_dif = moose.Table('/data/' + difshell_name + str(i))
        diftab.append(res_dif)
        moose.connect(diftab[i], 'requestOut', dif, 'getC')
        if (difbuff_no):
            buftab.append([])
            for j, buf in enumerate(difb[i]):
                res_buf = moose.Table('/data/' + difshell_name + str(i) + '_' +
                                      difbuff_name + str(j))
                buftab[i].append(res_buf)
                moose.connect(buftab[i][j], 'requestOut', buf, 'getBBound')

    moose.reinit()
    if not gbar:
        for i, dif in enumerate(difs):
            if i == 0:
                dif.C = Ca_initial
            else:
                dif.C = 0
            for j, dbuf in enumerate(difb[i]):
                dbuf.bFree = dbuf.bTot

    moose.start(t_stop)
    t = np.linspace(0, t_stop, len(vmtab.vector))
    fname = 'moose_results_difshell_no_' + str(
        difshell_no) + '_difbuffer_no_' + str(difbuff_no) + '_pump_' + str(
            pumps) + '_gbar_' + str(gbar) + '.txt'
    header = 'time Vm Ik Gk'
    number = 4 + difshell_no * (difbuff_no + 1)
    res = np.zeros((len(t), number))
    res[:, 0] = t
    res[:, 1] = vmtab.vector
    res[:, 2] = iktab.vector
    res[:, 3] = gktab.vector

    for i in range(difshell_no):
        header += ' difshell_' + str(i)
        res[:, 4 + i * (difbuff_no + 1)] = diftab[i].vector
        if (difbuff_no):
            for j, buf in enumerate(buftab[i]):
                res[:, 4 + i * (difbuff_no + 1) + j + 1] = buf.vector
                header += ' difshell_' + str(i) + '_difbuff_' + str(j)
    np.savetxt(fname, res, header=header, comments='')
Esempio n. 3
0
    mean, std = np.mean(vec), np.std(vec)
    computed = [min_, max_, mean, std]
    assert np.allclose( computed, expected ),  \
        "Got %s expected %s" % (computed, expected)


if __name__ == '__main__':
    for tick in range(0, 7):
        moose.setClock(tick, 10e-6)
    moose.setClock(8, 0.005)

    lib = moose.Neutral('/library')
    model = moose.loadModel(p_file, 'neuron')
    pulse = moose.PulseGen('/neuron/pulse')
    inject = 100e-10
    chan_proto.chan_proto('/library/SK', param_chan.SK)
    chan_proto.chan_proto('/library/CaL12', param_chan.Cal)
    pulse.delay[0] = 8.
    pulse.width[0] = 500e-12
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    for comp in moose.wildcardFind('/neuron/#[TYPE=Compartment]'):
        new_comp = moose.element(comp)
        new_comp.initVm = -.08
        difs, difb = td.add_difshells_and_buffers(new_comp, difshell_no,
                                                  difbuf_no)
        for name in cond:
            chan = td.addOneChan(name, cond[name], new_comp)
            if 'Ca' in name:
                moose.connect(chan, "IkOut", difs[0], "influx")
Esempio n. 4
0
    gktab = moose.Table('/data/CaT_Gk')
    iktab = moose.Table('/data/CaT_Ik')

    dend.Cm = Cm
    dend.Rm = Rm
    dend.Em = Em
    dend.initVm = Vm_0
    dend.diameter = dend_diameter
    dend.length = dend_length

    pulse.delay[0] = 8.
    pulse.width[0] = 500e-3
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    chan = chan_proto.chan_proto('/library/CaL12',param_chan.Cal)
    m = moose.connect(pulse, 'output', dend, 'injectMsg')
    moose.connect(vmtab, 'requestOut', dend, 'getVm')
    chan = addOneChan('CaL12', gbar, dend)
    moose.connect(gktab, 'requestOut', chan, 'getGk')
    moose.connect(iktab, 'requestOut', chan, 'getIk')
    diftab = []
    buftab = []
    difs, difb = add_difshells_and_buffers(dend,difshell_no,difbuff_no)
    if pumps:
        pump = moose.MMPump('/model/dend/pump')
        pump.Vmax = kcat
        pump.Kd = km
        moose.connect(pump, "PumpOut", difs[0], "mmPump")
    if difs:
        moose.connect(chan, "IkOut", difs[0], "influx")
Esempio n. 5
0
    gktab = moose.Table('/data/CaT_Gk')
    iktab = moose.Table('/data/CaT_Ik')

    dend.Cm = Cm
    dend.Rm = Rm
    dend.Em = Em
    dend.initVm = Vm_0
    dend.diameter = dend_diameter
    dend.length = dend_length

    pulse.delay[0] = 8.
    pulse.width[0] = 500e-3
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    chan = chan_proto.chan_proto('/library/CaL12',param_chan.Cal)

    m = moose.connect(pulse, 'output', dend, 'injectMsg')

    moose.connect(vmtab, 'requestOut', dend, 'getVm')


    chan = addOneChan('CaL12', gbar, dend)

    moose.connect(gktab, 'requestOut', chan, 'getGk')
    moose.connect(iktab, 'requestOut', chan, 'getIk')
    diftab = []
    buftab = []
    difs, difb = add_difshells_and_buffers(dend,difshell_no,difbuff_no)
    if pumps:
        pump = moose.MMPump('/model/dend/pump')
    min_, max_ = np.min( vec ), np.max( vec )
    mean, std = np.mean( vec ), np.std( vec )
    computed = [ min_, max_, mean, std ]
    assert np.allclose( computed, expected ),  \
        "Got %s expected %s" % (computed, expected)

if __name__ =='__main__':
    for tick in range(0, 7):
        moose.setClock(tick,10e-6)
    moose.setClock(8, 0.005)

    lib = moose.Neutral('/library')
    model = moose.loadModel(p_file,'neuron')
    pulse = moose.PulseGen('/neuron/pulse')
    inject = 100e-10
    chan_proto.chan_proto('/library/SK',param_chan.SK)
    chan_proto.chan_proto('/library/CaL12',param_chan.Cal)
    pulse.delay[0] = 8.
    pulse.width[0] = 500e-12
    pulse.level[0] = inject
    pulse.delay[1] = 1e9

    for comp in moose.wildcardFind('/neuron/#[TYPE=Compartment]'):
        new_comp = moose.element(comp)
        new_comp.initVm = -.08
        difs, difb = td.add_difshells_and_buffers(new_comp,difshell_no,difbuf_no)
        for name in cond:
            chan = td.addOneChan(name,cond[name],new_comp)
            if 'Ca' in name:
                moose.connect(chan, "IkOut", difs[0], "influx")