def makeChemProto(name='hydra'):
        chem=moose.Neutral('/library/'+name)
        compt=moose.CubeMesh('/library/'+name + '/' + name)
        A=moose.Pool(compt.path+'/A')
        B=moose.Pool(compt.path+'/B')
        
        #A.diffConst=params['diffA']
        #B.diffConst=params['diffB']
        Adot = moose.Function( A.path + '/Adot' )
        Bdot = moose.Function( B.path + '/Bdot' )
       
        Adot.expr="-x0+(x0^2/(1+0.01*x0^2))*x1"
        Bdot.expr="x0-(x0^2/(1+0.01*x0^2))*x1"

 
        
        print moose.showmsg(Adot)
        Adot.x.num = 2 #2
        Bdot.x.num = 2 #2
        moose.connect( A, 'nOut', Adot.x[0], 'input' )
        moose.connect( B, 'nOut', Adot.x[1], 'input' )
        moose.connect( Adot, 'valueOut', A, 'increment' )

        moose.connect( A, 'nOut', Bdot.x[0], 'input' )
        moose.connect( B, 'nOut', Bdot.x[1], 'input' )
        moose.connect( Bdot, 'valueOut', B, 'increment' )
コード例 #2
0
ファイル: vis_s.py プロジェクト: vinuvargheseijk/fhn_bis
def makeChemProto(name='hydra'):
    chemCompt = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    #Adot.expr="1*(-x0+x1*(0.05*+(x0^2/(1^2+x0^2))))"
    #Bdot.expr="-1*(-x0+x1*(0.05*+(x0^2/(1^2+x0^2))))"
    Adot.expr = "0*x0+0*x1"
    Bdot.expr = "0*x0+0*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2
    Bdot.x.num = 2
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
コード例 #3
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Adot.expr = "11.8*x1-x0+0"
    Bdot.expr = "x0-(0.1*x1^3-6.3*x1^2+100*x1)"
    #Adot.expr="x0+0.0001*x1^3"
    #Bdot.expr="x0-0.001*x1^3"
    #Adot.expr="0.0000118*x1-0.000001x0"
    #Bdot.expr="x0-0.0000001*x1^3-0.0000063*x1^2+0.001*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2  #2
    Bdot.x.num = 2  #2
    A.nInit = 0.01
    B.nInit = 10
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
コード例 #4
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Adot.expr = "k*(b*(0.05*+(a^n/(K^n+a^n)))-a)"
    Bdot.expr = "-k*(b*(0.05*+(a^n/(K^n+a^n)))-a)"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 3  #2
    Bdot.x.num = 3  #2
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
コード例 #5
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    C = moose.Pool(compt.path + '/C')
    space = moose.Pool(compt.path + '/space')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Cdot = moose.Function(C.path + '/Cdot')
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    Adot.expr = "0.5*exp(-1.5*x2/(50*1e-06))*x0^2*x1-(0.1+0.01)*x0+0.01*x1"
    Bdot.expr = "-0.5*exp(-1.5*x2/(50*1e-06))*x0^2*x1+0.1*x0-0.01*x1+0.01"

    print moose.showmsg(Adot)
    Adot.x.num = 3  #2
    Bdot.x.num = 3  #2
    #A.nInit=10
    #B.nInit=5
    A.nInit = 0
    B.nInit = 0
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(space, 'nOut', Adot.x[2], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(space, 'nOut', Bdot.x[2], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
コード例 #6
0
def main():
    soma_l = 50E-6
    soma_d = 25E-6
    soma_RM = 1  #20000
    soma_CM = 10E-3  #1E-6
    soma_RA = 4.0
    simtime = 300E-3  # seconds
    simdt = 1E-3  #50E-6 # seconds

    soma = create_compartment('soma', soma_l, soma_d, soma_RM, soma_CM,
                              soma_RA)
    soma.Em = -65E-3
    soma.initVm = -65E-3

    inj_duration = 100E-3
    inj_amplitude = 1E-9  #0.188E-9
    pulse_1 = create_pulse_generator(soma, inj_duration, inj_amplitude)

    vmtab = create_output_table()
    moose.connect(vmtab, 'requestOut', soma, 'getVm')
    moose.showmsg(soma)

    #moose.setClock(4, simdt)

    moose.reinit()
    moose.start(simtime)

    plot_vm_table(vmtab, simtime, simdt)
    plt.axvline(x=50E-3 + soma_RM * soma_CM, color='red')
    plt.show()
コード例 #7
0
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    Adot.expr = "0.1*((x0^2/x1)+1)-1.5*x0+0.5*x0"
    Bdot.expr = "0*x0+0.1*x0^2-1.5*x1+1*x1"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 2  #2
    Bdot.x.num = 2  #2
    #A.nInit=10
    #B.nInit=5
    A.nInit = 1
    B.nInit = 1
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')
    return compt
コード例 #8
0
ファイル: run_cell.py プロジェクト: pgleeson/moose-core
def run(nogui):
    
    reader = NML2Reader(verbose=True)

    filename = 'test_files/passiveCell.nml'
    print('Loading: %s'%filename)
    reader.read(filename)
    
    
    msoma = reader.getComp(reader.doc.networks[0].populations[0].id,0,0)
    print(msoma)
    
    
    data = moose.Neutral('/data')
    
    pg = reader.getInput('pulseGen1')
    
    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')
    
    
    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')
    
    simdt = 1e-6
    plotdt = 1e-4
    simtime = 150e-3
    
    if (1):
        #moose.showmsg( '/clock' )
        for i in range(8):
            moose.setClock( i, simdt )
        moose.setClock( 8, plotdt )
        moose.reinit()
    else:
        utils.resetSim([model.path, data.path], simdt, plotdt, simmethod='ee')
        moose.showmsg( '/clock' )
        
    moose.start(simtime)
    
    print("Finished simulation!")
    
    t = np.linspace(0, simtime, len(vm.vector))
    
    if not nogui:
        import matplotlib.pyplot as plt

        plt.subplot(211)
        plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
        plt.legend()
        plt.title('Vm')
        plt.subplot(212)
        plt.title('Input')
        plt.plot(t, inj.vector * 1e9, label='injected (nA)')
        #plt.plot(t, gK.vector * 1e6, label='K')
        #plt.plot(t, gNa.vector * 1e6, label='Na')
        plt.legend()
        plt.show()
        plt.close()
コード例 #9
0
def desensitization(synchan, SynParams):
    '''
    Key equations to be implemented
    dep.expression = "x = x*"+str(dep_constant)+"y*"+str(SynParams.dep_per_spike)
    weight.expression = "weight*1/(1+x)/simdt"
    facsynchan uses:  (1+fac)/(1+dep)/simdt
    x above is dep, and we didn't have fac, hence 1/(1+x)
    weight is the current synaptic weight
    '''
    sh = moose.element(synchan).children[0]

    deppath = synchan.path + '/dep'
    weightpath = synchan.path + '/weight'
    dep = moose.Func(deppath)
    weight = moose.Func(weightpath)
    help_dep = moose.Func(deppath + "/help")

    activation = moose.Func(deppath + "/activation")
    activation_help = moose.Func(deppath + "/activation/help")

    y = moose.Func(deppath + "/y")
    condition = moose.Func(deppath + "/condition")

    help_dep.tick = synchan.tick
    dep.tick = synchan.tick
    weight.tick = synchan.tick
    activation.tick = synchan.tick
    activation_help.tick = synchan.tick
    y.tick = synchan.tick
    condition.tick = synchan.tick

    #x*exp(dt/tau)+y*dep_per_spike, where x is output of self!
    dep_const = np.exp(-synchan.dt / SynParams.dep_tau)
    dep.expr = "x*" + str(dep_const) + "+y*" + str(SynParams.dep_per_spike)
    help_dep.expr = "x"
    weight.expr = "z*(1./(1+x))/" + str(synchan.dt)
    activation.expr = "x+y"
    activation_help.expr = "x"
    y.expr = "x"
    condition.expr = "x&&(x==y)"

    moose.connect(dep, "valueOut", weight, "xIn")
    moose.connect(condition, 'valueOut', dep, 'yIn')
    moose.connect(condition, 'valueOut', weight, 'zIn')
    moose.connect(condition, 'valueOut', activation, 'zIn')
    moose.connect(sh, 'activationOut', activation, 'yIn')
    moose.connect(sh, 'activationOut', y, 'xIn')

    moose.connect(activation, "valueOut", condition, "xIn")
    moose.connect(y, "valueOut", condition, "yIn")
    moose.connect(condition, "valueOut", y, "zIn")
    moose.connect(activation, "valueOut", activation_help, "xIn")
    moose.connect(activation_help, "valueOut", activation, "xIn")
    moose.connect(dep, 'valueOut', help_dep, 'xIn')
    moose.connect(help_dep, 'valueOut', dep, 'xIn')

    moose.connect(weight, "valueOut", synchan, 'activation')
    moose.showmsg(synchan)
    return condition, activation
コード例 #10
0
ファイル: run_cell.py プロジェクト: pgleeson/moose-core
def run(nogui):

    reader = NML2Reader(verbose=True)

    filename = 'test_files/passiveCell.nml'
    print('Loading: %s' % filename)
    reader.read(filename)

    msoma = reader.getComp(reader.doc.networks[0].populations[0].id, 0, 0)
    print(msoma)

    data = moose.Neutral('/data')

    pg = reader.getInput('pulseGen1')

    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')

    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', msoma, 'getVm')

    simdt = 1e-6
    plotdt = 1e-4
    simtime = 150e-3

    if (1):
        #moose.showmsg( '/clock' )
        for i in range(8):
            moose.setClock(i, simdt)
        moose.setClock(8, plotdt)
        moose.reinit()
    else:
        utils.resetSim([model.path, data.path], simdt, plotdt, simmethod='ee')
        moose.showmsg('/clock')

    moose.start(simtime)

    print("Finished simulation!")

    t = np.linspace(0, simtime, len(vm.vector))

    if not nogui:
        import matplotlib.pyplot as plt

        plt.subplot(211)
        plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
        plt.legend()
        plt.title('Vm')
        plt.subplot(212)
        plt.title('Input')
        plt.plot(t, inj.vector * 1e9, label='injected (nA)')
        #plt.plot(t, gK.vector * 1e6, label='K')
        #plt.plot(t, gNa.vector * 1e6, label='Na')
        plt.legend()
        plt.show()
        plt.close()
コード例 #11
0
def test_hhcomp():
    """Create and simulate a single spherical compartment with
    Hodgkin-Huxley Na and K channel.

    Plots Vm, injected current, channel conductances.

    """
    model = moose.Neutral('/model')
    data = moose.Neutral('/data')    
    comp, na, k = create_hhcomp(parent=model.path)
    print comp.Rm, comp.Cm, na.Ek, na.Gbar, k.Ek, k.Gbar
    pg = moose.PulseGen('%s/pg' % (model.path))
    pg.firstDelay = 20e-3
    pg.firstWidth = 40e-3
    pg.firstLevel = 1e-9
    pg.secondDelay = 1e9
    moose.connect(pg, 'output', comp, 'injectMsg')
    inj = moose.Table('%s/pulse' % (data.path))
    moose.connect(inj, 'requestOut', pg, 'getOutputValue')
    vm = moose.Table('%s/Vm' % (data.path))
    moose.connect(vm, 'requestOut', comp, 'getVm')
    gK = moose.Table('%s/gK' % (data.path))
    moose.connect(gK, 'requestOut', k, 'getGk')
    gNa = moose.Table('%s/gNa' % (data.path))
    moose.connect(gNa, 'requestOut', na, 'getGk')
    simdt = 1e-6
    plotdt = 1e-4
    simtime = 100e-3
    if (1):
        moose.showmsg( '/clock' )
        for i in range(8):
            moose.setClock( i, simdt )
        moose.setClock( 8, plotdt )
        moose.reinit()
    else:
        utils.resetSim([model.path, data.path], simdt, plotdt, simmethod='ee')
        moose.showmsg( '/clock' )
    moose.start(simtime)
    t = np.linspace(0, simtime, len(vm.vector))
    plt.subplot(211)
    plt.plot(t, vm.vector * 1e3, label='Vm (mV)')
    plt.plot(t, inj.vector * 1e9, label='injected (nA)')
    plt.legend()
    plt.title('Vm')
    plt.subplot(212)
    plt.title('Conductance (uS)')
    plt.plot(t, gK.vector * 1e6, label='K')
    plt.plot(t, gNa.vector * 1e6, label='Na')
    plt.legend()
    plt.show()
    plt.close()
コード例 #12
0
def desensitization(synchan, SynParams):
    sh = moose.element(synchan).children[0]

    deppath = synchan.path + '/dep'
    weightpath = synchan.path + '/weight'
    dep = moose.Func(deppath)
    weight = moose.Func(weightpath)
    help_dep = moose.Func(deppath + "/help")

    activation = moose.Func(deppath + "/activation")
    activation_help = moose.Func(deppath + "/activation/help")

    y = moose.Func(deppath + "/y")
    condition = moose.Func(deppath + "/condition")

    help_dep.tick = synchan.tick
    dep.tick = synchan.tick
    weight.tick = synchan.tick
    activation.tick = synchan.tick
    activation_help.tick = synchan.tick
    y.tick = synchan.tick
    condition.tick = synchan.tick

    dep_const = np.exp(-synchan.dt / SynParams.dep_tau)
    dep.expr = "x*" + str(dep_const) + "+y*" + str(SynParams.dep_per_spike)
    help_dep.expr = "x"
    weight.expr = "z*(1./(1+x))/" + str(synchan.dt)
    activation.expr = "x+y"
    activation_help.expr = "x"
    y.expr = "x"
    condition.expr = "x&&(x==y)"

    moose.connect(dep, "valueOut", weight, "xIn")
    moose.connect(condition, 'valueOut', dep, 'yIn')
    moose.connect(condition, 'valueOut', weight, 'zIn')
    moose.connect(condition, 'valueOut', activation, 'zIn')
    moose.connect(sh, 'activationOut', activation, 'yIn')
    moose.connect(sh, 'activationOut', y, 'xIn')

    moose.connect(activation, "valueOut", condition, "xIn")
    moose.connect(y, "valueOut", condition, "yIn")
    moose.connect(condition, "valueOut", y, "zIn")
    moose.connect(activation, "valueOut", activation_help, "xIn")
    moose.connect(activation_help, "valueOut", activation, "xIn")
    moose.connect(dep, 'valueOut', help_dep, 'xIn')
    moose.connect(help_dep, 'valueOut', dep, 'xIn')

    moose.connect(weight, "valueOut", synchan, 'activation')
    moose.showmsg(synchan)
    return condition, activation
コード例 #13
0
def makeChemProto(name='hydra'):
    maxs = 0.05
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    S = moose.Pool(compt.path + '/S')
    space = moose.Pool(compt.path + '/space')
    #C=moose.Pool(compt.path+'/C')
    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Sdot = moose.Function(S.path + '/Sdot')
    spacedot = moose.Function(space.path + '/spacedot')
    #Cdot = moose.Function( C.path + '/Cdot' )
    #Adot.expr="0.001*((x0^2/x1)+1)-1*x0+0.5*x0"
    #Bdot.expr="0*x0+0.001*x0^2-1*x1+1*x1"
    #Adot.expr="-x0+x1(0.067+(1*x0^2)/(1+x0^2))"
    #Bdot.expr="x0-x1(0.067+(1*x0^2)/(1+x0^2))"
    Adot.expr = "-x0+x1*(0.067+(1*x0^2)/(1+x0^2))+(t<20)*(0.05/2)*(1+cos(" + str(
        np.pi) + "*x3))*x1*x2+(t>20)*(t<25)*(0.05/4)*(cos(" + str(
            np.pi) + "*(t-20)/5))*(1+cos(" + str(np.pi) + "*x3))*x1*x2"
    Bdot.expr = "x0-x1*(0.067+(1*x0^2)/(1+x0^2))-(t<20)*(0.05/2)*(1+cos(" + str(
        np.pi) + "*x3))*x1*x2-(t>20)*(t<25)*(0.05/4)*(cos(" + str(
            np.pi) + "*(t-20)/5))*(1+cos(" + str(np.pi) + "*x3))*x1*x2"
    Sdot.expr = "0"
    spacedot.expr = "0"
    #Cdot.expr="0*x0+0.11*x1-0.11*x2+0.1*x0^2-0.1*(x1+x2)"

    print "$$$$> ", Adot, Bdot
    print Adot.expr, Bdot.expr
    print moose.showmsg(Adot)
    Adot.x.num = 4  #2
    Bdot.x.num = 4  #2
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(S, 'nOut', Adot.x[2], 'input')
    moose.connect(space, 'nOut', Adot.x[3], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(S, 'nOut', Bdot.x[2], 'input')
    moose.connect(space, 'nOut', Bdot.x[3], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    return compt
コード例 #14
0
ファイル: HW_3_2.py プロジェクト: sriram161/moose_practice
def soma_five_dend():
    soma_l = 50E-6
    soma_d = 25E-6
    soma_RM = 1  #20000
    soma_CM = 10E-3  #1E-6
    soma_RA = 4.0
    simtime = 0.3  # seconds
    simdt = 50E-6  #50E-6 # seconds
    dend_n = 5

    soma = create_compartment('soma', soma_l, soma_d, soma_RM, soma_CM,
                              soma_RA)
    soma_Em = -65E-3
    soma_initVm = -65E-3

    inj_duration = 100E-3
    inj_amplitude = 1E-9  #0.188E-9
    pulse_1 = create_pulse_generator(soma, inj_duration, inj_amplitude)

    vmtab = create_output_table()
    moose.connect(vmtab, 'requestOut', soma, 'getVm')
    moose.showmsg(soma)

    moose.setClock(4, simdt)

    bunch = create_n_dends('dend_', dend_n, 100E-6, 2E-6, soma_RM, soma_CM,
                           soma_RA)
    for item in bunch.values():
        item.Em = soma.Em
        item.initVm = soma.initVm
    bunch = connect_n_serial(bunch)
    moose.connect(soma, 'axialOut', list(bunch.values())[0], 'handleAxial')
    dend_vm_tab = create_output_table(table_name='dend3Vm')
    moose.connect(dend_vm_tab, 'requestOut',
                  list(bunch.values())[int(np.median(range(len(bunch))))],
                  'getVm')

    moose.reinit()
    moose.start(simtime)

    plot = plot_vm_table(simtime,
                         vmtab,
                         dend_vm_tab,
                         title="Soma Vs Dend voltage compare.")
    plot.legend(['soma', 'dend'])
    plt.grid(True)
    plt.show()
コード例 #15
0
def test_simple():
    """First test.
    >>> test_simple() # doctest: +NORMALIZE_WHITESPACE
    Rdesigneur: Elec model has 1 compartments and 0 spines on 0 compartments.
    <BLANKLINE>
    [/model[0]/elec[0]/soma[0]]
    Cm              =7.853981633975e-09
    Em              =-0.0544
    Im              =1.3194689277024895e-08
    Ra              =7639437.268410473
    Rm              =424413.1773342278
    Vm              =-0.06
    className       =ZombieCompartment
    diameter        =0.0005
    dt              =0.0
    fieldIndex      =0
    idValue         =455
    index           =0
    initVm          =-0.065
    inject          =0.0
    length          =0.0005
    name            =soma
    numData         =1
    numField        =1
    path            =/model[0]/elec[0]/soma[0]
    tick            =-2
    x               =0.0005
    x0              =0.0
    y               =0.0
    y0              =0.0
    z               =0.0
    z0              =0.0
    <BLANKLINE>
    INCOMING:
    /model[0]/elec[0]/soma ('parentMsg',) <--- /model[0]/elec ('childOut',)                                         
    OUTGOING:
    """
    rdes = rd.rdesigneur()
    rdes.buildModel()
    moose.showfields(rdes.soma)
    moose.showmsg(rdes.soma)
コード例 #16
0
ファイル: HW_3_2.py プロジェクト: sriram161/moose_practice
def soma_one_dend():
    soma_l = 50E-6
    soma_d = 25E-6
    soma_RM = 1  #20000
    soma_CM = 10E-3  #1E-6
    soma_RA = 4.0
    simtime = 0.3  # seconds
    simdt = 50E-6  #50E-6 # seconds

    soma = create_compartment('soma', soma_l, soma_d, soma_RM, soma_CM,
                              soma_RA)
    soma_Em = -65E-3
    soma_initVm = -65E-3

    inj_duration = 100E-3
    inj_amplitude = 1E-9  #0.188E-9
    pulse_1 = create_pulse_generator(soma, inj_duration, inj_amplitude)

    vmtab = create_output_table()
    moose.connect(vmtab, 'requestOut', soma, 'getVm')
    moose.showmsg(soma)

    moose.setClock(4, simdt)

    dend1 = create_compartment('dend1', 100E-6, 2E-6, soma_RM, soma_CM,
                               soma_RA)
    dend1.Em = soma.Em
    dend1.initVm = soma.initVm
    moose.connect(soma, 'axialOut', dend1, 'handleAxial')
    dend1_vm_tab = create_output_table(table_name='dend1Vm')
    moose.connect(dend1_vm_tab, 'requestOut', dend1, 'getVm')
    moose.showmsg(dend1)

    moose.reinit()
    moose.start(simtime)

    plot_vm_table(vmtab, simtime)
    plot_vm_table(dend1_vm_tab, simtime)
    plt.axvline(x=50E-3 + soma_RM * soma_CM, color='red')
    plt.show()
コード例 #17
0
def main():
    neuron = moose.Neutral("/neuron")
    inputs = moose.Neutral("/inputs")
    outputs = moose.Neutral("/outputs")

    soma = create_spherical_compartment("/neuron/soma", 25e-6, 20e-6, 2.8, 4.0,
                                        0.03)
    pulse = create_pulse('/inputs/somaPulse', 50e-3, 100e-3, 1e-9, soma)
    vmtable = create_table('outputs/somaVmTable', soma, "getVm")
    print(soma.tick)
    print(soma.dt)
    moose.reinit()
    moose.start(300e-3)
    moose.showfields(vmtable)
    moose.showmsg(soma)
    moose.showmsg(pulse)
    moose.showmsg(vmtable)

    plot_table(vmtable)
    pyplot.show()
コード例 #18
0
ファイル: __main__.py プロジェクト: ziemowit-s/moose_nerp
model = create_model_sim.setupNeurons(model, network=not net.single)
all_neur_types = model.neurons
# FSIsyn,neuron = cell_proto.neuronclasses(FSI)
# all_neur_types.update(neuron)
population, connections, plas = create_network.create_network(model, net, all_neur_types)

###### Set up stimulation - could be current injection or plasticity protocol
# set num_inject=0 to avoid current injection
if net.num_inject < np.inf:
    inject_pop = inject_func.inject_pop(population['pop'], net.num_inject)
else:
    inject_pop = population['pop']
# Does setupStim work for network?
# create_model_sim.setupStim(model)
pg = inject_func.setupinj(model, param_sim.injection_delay, param_sim.injection_width, inject_pop)
moose.showmsg(pg)

##############--------------output elements
if net.single:
    # fname=model.param_stim.Stimulation.Paradigm.name+'_'+model.param_stim.location.stim_dendrites[0]+'.npz'
    # simpath used to set-up simulation dt and hsolver
    simpath = ['/' + neurotype for neurotype in all_neur_types]
    create_model_sim.setupOutput(model)
else:  # population of neurons
    spiketab, vmtab, plastab, catab = net_output.SpikeTables(model, population['pop'], net.plot_netvm, plas,
                                                             net.plots_per_neur)
    # simpath used to set-up simulation dt and hsolver
    simpath = [net.netname]
    clocks.assign_clocks(simpath, param_sim.simdt, param_sim.plotdt, param_sim.hsolve, model.param_cond.NAME_SOMA)
if model.synYN and (param_sim.plot_synapse or net.single):
    # overwrite plastab above, since it is empty
コード例 #19
0
ファイル: class10_notes.py プロジェクト: jkopsick/NEUR634
# Looping through synparams dictionary and creates synaptic channels
# Moose uses GHK current equation to solve how calcium affects the NMDA
# channel -- temp, extCa, and condFraction required for solving this
for key, params in synparams.items():
    if key == 'nmda':
        chan = moose.NMDAChan('/cell2/dend/' + key)
        chan.KMg_A = params['mgparams']['A']
        chan.KMg_B = params['mgparams']['B']
        chan.CMg = params['mgparams']['conc']
        chan.temperature = params['temperature']
        chan.extCa = params['extCa']
        chan.condFraction = params['condFraction']
    else:
        chan = moose.SynChan('/cell2/dend/' + key)
    chan.Gbar = params['Gbar']
    chan.tau1 = params['tau1']
    chan.tau2 = params['tau2']
    chan.Ek = params['Erev']

# Below code is just an example -- in HW we will modify our existing CaPool
# code

capool = moose.CaConc('/cell2/dend/capool')
moose.showfield(capool)

nmdachan = moose.element('/cell2/dend/nmda')
moose.connect(nmdachan, 'ICaOut', capool, 'current')
moose.connect(capool, 'concOut', nmdachan, 'setIntCa')

moose.showmsg(nmdachan)
コード例 #20
0
ファイル: assgn_2.py プロジェクト: sriram161/moose_practice
moose.reinit()

# start simulation at 0 nA injection current.
moose.start(0.3)
moose.showfields(soma)  # check Vm

soma.inject = -1E-12
# reset simulation
moose.reint()
# start simulation at -1pA injection current.
moose.start(0.3)
moose.showfields(soma)

# Creation of pulse generator.
pulse = moose.PulseGen('pulse')
moose.showfield('pulse')
pulse.delay[0] = 50E-3  # First delay.
pulse.width[0] = 100E03  # Pulse width.
pulse.level[0] = 1E-9  # Pulse amplitude.
pulse.delat[1] = 1E9

moose.getFieldNames(
    'PulseGen',
    'srcFinfo')  # returns list of message outlets for a moose element class.
moose.getFieldNames(
    'Compartment',
    'destFinfo')  # returns list of message inlets for a moose element class.
soma.getFieldNames('destFinfo')
moose.showmsg(
    'soma')  # shows  message connetions statistics of the moose element.
コード例 #21
0
ファイル: __main__.py プロジェクト: neurord/spspine
model=create_model_sim.setupNeurons(model,network=not net.single)
all_neur_types=model.neurons
#FSIsyn,neuron = cell_proto.neuronclasses(FSI)
#all_neur_types.update(neuron)
population,connections,plas=create_network.create_network(model, net, all_neur_types)

###### Set up stimulation - could be current injection or plasticity protocol
# set num_inject=0 to avoid current injection
if net.num_inject<np.inf :
    inject_pop=inject_func.inject_pop(population['pop'],net.num_inject)
else:
    inject_pop=population['pop']
#Does setupStim work for network?
#create_model_sim.setupStim(model)
pg=inject_func.setupinj(model, param_sim.injection_delay,param_sim.injection_width,inject_pop)
moose.showmsg(pg)

##############--------------output elements
if net.single:
    #fname=model.param_stim.Stimulation.Paradigm.name+'_'+model.param_stim.location.stim_dendrites[0]+'.npz'
    #simpath used to set-up simulation dt and hsolver
    simpath=['/'+neurotype for neurotype in all_neur_types]
    create_model_sim.setupOutput(model)
else:   #population of neurons
    spiketab,vmtab,plastab,catab=net_output.SpikeTables(model, population['pop'], net.plot_netvm, plas, net.plots_per_neur)
    #simpath used to set-up simulation dt and hsolver
    simpath=[net.netname]
    clocks.assign_clocks(simpath, param_sim.simdt, param_sim.plotdt, param_sim.hsolve,model.param_cond.NAME_SOMA)
if model.synYN and (param_sim.plot_synapse or net.single):
    #overwrite plastab above, since it is empty
    syntab, plastab, stp_tab=tables.syn_plastabs(connections,model)
コード例 #22
0
print(neuron)
print(soma)
print("l=" + str(soma.length))
print("d=" + str(soma.diameter))
print("Rm=" + str(soma.Rm))
print("Vm=" + str(soma.Vm))
print("Cm=" + str(soma.Cm))
print("Em=" + str(soma.Em))
print("initVm=" + str(soma.initVm))
print(dend)

moose.reinit()
moose.start(0.3)
print(soma.Vm)
soma.inject=1e-9
moose.reinit()
moose.start(0.3)
print(soma.Vm)
soma.inject = 0

def create_pulse(pulsename,pulsedelay,pulsewidth,pulselevel,pulsecomp):
	pulse = moose.PulseGen(pulsename)
	pulse.delay[0]=pulsedelay
	pulse.width[0]=pulsewidth
	pulse.level[0]=pulselevel
	pulse.level[1]=1e-9
	pulse.delay[1]=1e9
	moose.connect(pulse,'output',pulsecomp,'injectMsg')
pulse = create_pulse('pulse',0,0,0,soma)
print(moose.showmsg(soma))
コード例 #23
0
        chan.tau2 = params['tau2']
        chan.Ek = params['Erev']

# Test to check NMDA creation.
moose.le('/cell2/dend')

for key, params in synparams.items():
    if key == 'nmda':
        chan = moose.NMDAChan('/cell2/dend/' + key)
        chan.KMg_A = params['mgparams']['A']
        chan.KMg_B = params['mgparams']['B']
        chan.CMg = params['mgparams']['conc']
        chan.temperature = params['temperature']
        chan.extCa = params['extCa']
        chan.condFraction = params['condFraction']
    else:
        chan = moose.SynChan('/cell2/dend/' + key)
        chan.Gbar = params['Gbar']
        chan.tau1 = params['tau1']
        chan.tau2 = params['tau2']
        chan.Ek = params['Erev']

m = moose.connect(nmdachan, 'ICaOut', capool, 'current')

capool = moose.CaConc('/cell2/dend/capool')
moose.showfield(capool)

m = moose.connect(capool, 'concOut', nmdachan, 'setIntCa')

moose.showmsg('/cell2')
コード例 #24
0
pfile = "layer2.p"
swcfile = "538ser3sl5-cell1-2-a.CNG.swc"
container1 = "cell1"
container2 = "cell2"
cell1 = moose.loadModel(pfile, container1)
cell2 = moose.loadModel(swcfile, container2)
print("P file:")
moose.le("/cell1")
print("SWC file:")
moose.le("/cell2")
moose.showfield("/cell2/soma")
moose.showfield("/cell2/soma_1_0")
moose.showfield("/cell2/soma_2_0")

moose.showmsg("cell1/soma")
moose.showmsg("cell2/soma")

#import neuron
from neuron import h, gui

print("\n\n\n DOING NEURON NOW! \n\n\n")

soma = h.Section(name="soma")
dir(soma)
soma.insert("pas")
soma.nseg = 3
h.psection(sec=soma)

dend = h.Section(name="dend")
dend.connect(soma, 1)
コード例 #25
0
ファイル: class_9_concise.py プロジェクト: jkopsick/NEUR634
soma_pulse = u.createPulse(soma, 'rollingWave', pulse_dur, pulse_amp,
                           pulse_delay, pulse_delay2)
soma_Vm, soma_Iex = u.createDataTables(soma, data, soma_pulse)
dend_Vm, dend_Iex = u.createDataTables(dend, data, soma_pulse)
synchan = moose.SynChan('/neuron/swagginDend/glu')
synchan.Gbar = 1e-8
synchan.tau1 = 2e-3
synchan.tau2 = 2e-3
synchan.Ek = -0.010
msg = moose.connect(dend, 'channel', synchan, 'channel')
sh = moose.SimpleSynHandler('/neuron/swagginDend/glu/synhandler')
moose.connect(sh, 'activationOut', synchan, 'activation')
sh.synapse.num = 1
sh.synapse[0].delay = 1e-3

moose.showmsg(sh)
moose.showmsg(synchan)
moose.showfield(sh.synapse[0])

# the commands above specify and connect the randSpike to a synapse on the
# dendrite
pre_syn = moose.RandSpike('presyn_input')
pre_syn.rate = 10
pre_syn.refractT = 1e-3
sh.synapse.num = 1
sh.synapse[0].delay = 5e-3
moose.connect(pre_syn, 'spikeOut', sh.synapse[0], 'addSpike')

# commands above connect another spike from a pre-synaptic neuron to the
# synapse
pre_syn2 = moose.RandSpike('pre_syn2')
def makeChemProto(name='hydra'):
    chem = moose.Neutral('/library/' + name)
    compt = moose.CubeMesh('/library/' + name + '/' + name)
    A = moose.Pool(compt.path + '/A')
    B = moose.Pool(compt.path + '/B')
    C = moose.Pool(compt.path + '/C')
    D = moose.Pool(compt.path + '/D')
    E = moose.Pool(compt.path + '/E')
    F = moose.Pool(compt.path + '/F')
    Z1 = moose.Pool(compt.path + '/Z1')
    Z2 = moose.Pool(compt.path + '/Z2')

    #A.diffConst=params['diffA']
    #B.diffConst=params['diffB']
    Adot = moose.Function(A.path + '/Adot')
    Bdot = moose.Function(B.path + '/Bdot')
    Cdot = moose.Function(C.path + '/Cdot')
    Ddot = moose.Function(D.path + '/Ddot')
    Edot = moose.Function(E.path + '/Edot')
    Fdot = moose.Function(F.path + '/Fdot')
    #Zdot = moose.Function( Z.path + '/Zdot' )

    #Adot.expr="x6*(1+x7)*(-x0+(5/(1+x1^3))*(2-x0-x3))"
    #Bdot.expr="x6*(1+x7)*(0*x0-x1+(3+2*(x2^3/(1+x1^3)))*(1/(1+x0^3))*(2-x1-x4))"
    #Cdot.expr="x6*(1+x7)*(0*x0+0*x1-0*x2+0.1*((0.2+0.3*(x0^3/(0.85^3+x0^3)))-x2^2*(0.2+1*x1^3/(0.85^3+x1^3))))"

    Adot.expr = "x6*(1+x7)*(-x0+(4.5/(1+x1^3))*(2-x0-x3))"
    Bdot.expr = "x6*(1+x7)*(0*x0-x1+(3+0.5*(x2^3/(1+x1^3)))*(1/(1+x0^3))*(2-x1-x4))"
    Cdot.expr = "x6*(1+x7)*(0*x0+0*x1-0*x2+0.5*((0.2+0.3*(x0^3/(0.85^3+x0^3)))-x2^2*(0.2+1*x1^3/(0.85^3+x1^3))))"

    #Ddot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2-x3+(5/(1+x4^3))*(2-x0-x3))"
    #Edot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3-x4+(3+2*(x5^3/(1+x4^3)))*(1/(1+x3^3))*(2-x1-x4))"
    #Fdot.expr="(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3+0*x4-0*x5+0.1*((0.2+0.3*(x3^3/(0.85^3+x3^3)))-x5^2*(0.2+1*x4^3/(0.85^3+x4^3))))"

    Ddot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2-x3+(4.5/(1+x4^3))*(2-x0-x3))"
    Edot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3-x4+(3+0.5*(x5^3/(1+x4^3)))*(1/(1+x3^3))*(2-x1-x4))"
    Fdot.expr = "(1+x6)*x7*(0*x0+0*x1+0*x2+0*x3+0*x4-0*x5+0.5*((0.2+0.3*(x3^3/(0.85^3+x3^3)))-x5^2*(0.2+1*x4^3/(0.85^3+x4^3))))"

    print moose.showmsg(Adot)
    Adot.x.num = 8  #2
    Bdot.x.num = 8  #2
    Cdot.x.num = 8  #2
    Ddot.x.num = 8  #2
    Edot.x.num = 8  #2
    Fdot.x.num = 8  #2
    #A.nInit=10
    #B.nInit=5
    moose.connect(A, 'nOut', Adot.x[0], 'input')
    moose.connect(B, 'nOut', Adot.x[1], 'input')
    moose.connect(C, 'nOut', Adot.x[2], 'input')
    moose.connect(D, 'nOut', Adot.x[3], 'input')
    moose.connect(E, 'nOut', Adot.x[4], 'input')
    moose.connect(F, 'nOut', Adot.x[5], 'input')
    moose.connect(Z1, 'nOut', Adot.x[6], 'input')
    moose.connect(Z2, 'nOut', Adot.x[7], 'input')
    moose.connect(Adot, 'valueOut', A, 'increment')

    moose.connect(A, 'nOut', Bdot.x[0], 'input')
    moose.connect(B, 'nOut', Bdot.x[1], 'input')
    moose.connect(C, 'nOut', Bdot.x[2], 'input')
    moose.connect(D, 'nOut', Bdot.x[3], 'input')
    moose.connect(E, 'nOut', Bdot.x[4], 'input')
    moose.connect(F, 'nOut', Bdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Bdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Bdot.x[7], 'input')
    moose.connect(Bdot, 'valueOut', B, 'increment')

    moose.connect(A, 'nOut', Cdot.x[0], 'input')
    moose.connect(B, 'nOut', Cdot.x[1], 'input')
    moose.connect(C, 'nOut', Cdot.x[2], 'input')
    moose.connect(D, 'nOut', Cdot.x[3], 'input')
    moose.connect(E, 'nOut', Cdot.x[4], 'input')
    moose.connect(F, 'nOut', Cdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Cdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Cdot.x[7], 'input')
    moose.connect(Cdot, 'valueOut', C, 'increment')

    moose.connect(A, 'nOut', Ddot.x[0], 'input')
    moose.connect(B, 'nOut', Ddot.x[1], 'input')
    moose.connect(C, 'nOut', Ddot.x[2], 'input')
    moose.connect(D, 'nOut', Ddot.x[3], 'input')
    moose.connect(E, 'nOut', Ddot.x[4], 'input')
    moose.connect(F, 'nOut', Ddot.x[5], 'input')
    moose.connect(Z1, 'nOut', Ddot.x[6], 'input')
    moose.connect(Z2, 'nOut', Ddot.x[7], 'input')
    moose.connect(Ddot, 'valueOut', D, 'increment')

    moose.connect(A, 'nOut', Edot.x[0], 'input')
    moose.connect(B, 'nOut', Edot.x[1], 'input')
    moose.connect(C, 'nOut', Edot.x[2], 'input')
    moose.connect(D, 'nOut', Edot.x[3], 'input')
    moose.connect(E, 'nOut', Edot.x[4], 'input')
    moose.connect(F, 'nOut', Edot.x[5], 'input')
    moose.connect(Z1, 'nOut', Edot.x[6], 'input')
    moose.connect(Z2, 'nOut', Edot.x[7], 'input')
    moose.connect(Edot, 'valueOut', E, 'increment')

    moose.connect(A, 'nOut', Fdot.x[0], 'input')
    moose.connect(B, 'nOut', Fdot.x[1], 'input')
    moose.connect(C, 'nOut', Fdot.x[2], 'input')
    moose.connect(D, 'nOut', Fdot.x[3], 'input')
    moose.connect(E, 'nOut', Fdot.x[4], 'input')
    moose.connect(F, 'nOut', Fdot.x[5], 'input')
    moose.connect(Z1, 'nOut', Fdot.x[6], 'input')
    moose.connect(Z2, 'nOut', Fdot.x[7], 'input')
    moose.connect(Fdot, 'valueOut', F, 'increment')
    return compt
コード例 #27
0
ファイル: multisim.py プロジェクト: ziemowit-s/moose_nerp
def moose_main(corticalinput):
    import numpy as np
    import matplotlib.pyplot as plt
    # plt.ion()

    import moose

    from moose_nerp.prototypes import (create_model_sim,
                                       clocks,
                                       inject_func,
                                       create_network,
                                       tables,
                                       net_output)
    from moose_nerp import d1opt as model
    from moose_nerp import str_net as net

    # additional, optional parameter overrides specified from with python terminal
    # model.Condset.D1.NaF[model.param_cond.prox] /= 3
    # model.Condset.D1.KaS[model.param_cond.prox] *= 3

    net.connect_dict['D1']['ampa']['extern1'].dend_loc.postsyn_fraction = 0.8
    net.param_net.tt_Ctx_SPN.filename = corticalinput
    print('cortical_fraction = {}'.format(net.connect_dict['D1']['ampa']['extern1'].dend_loc.postsyn_fraction))
    model.synYN = True
    model.plasYN = True
    model.calYN = True
    model.spineYN = True
    net.single = True
    create_model_sim.setupOptions(model)
    param_sim = model.param_sim
    param_sim.useStreamer = True
    param_sim.plotdt = .1e-3
    param_sim.stim_loc = model.NAME_SOMA
    param_sim.stim_paradigm = 'inject'
    param_sim.injection_current = [0]  # [-0.2e-9, 0.26e-9]
    param_sim.injection_delay = 0.2
    param_sim.injection_width = 0.4
    param_sim.simtime = 21
    net.num_inject = 0
    net.confile = 'str_connect_plas_simd1opt_{}_corticalfraction_{}'.format(net.param_net.tt_Ctx_SPN.filename, 0.8)

    if net.num_inject == 0:
        param_sim.injection_current = [0]
    #################################-----------create the model: neurons, and synaptic inputs
    model = create_model_sim.setupNeurons(model, network=not net.single)
    all_neur_types = model.neurons
    # FSIsyn,neuron = cell_proto.neuronclasses(FSI)
    # all_neur_types.update(neuron)
    population, connections, plas = create_network.create_network(model, net, all_neur_types)

    ###### Set up stimulation - could be current injection or plasticity protocol
    # set num_inject=0 to avoid current injection
    if net.num_inject < np.inf:
        inject_pop = inject_func.inject_pop(population['pop'], net.num_inject)
    else:
        inject_pop = population['pop']
    # Does setupStim work for network?
    # create_model_sim.setupStim(model)
    pg = inject_func.setupinj(model, param_sim.injection_delay, param_sim.injection_width, inject_pop)
    moose.showmsg(pg)

    ##############--------------output elements
    if net.single:
        # fname=model.param_stim.Stimulation.Paradigm.name+'_'+model.param_stim.location.stim_dendrites[0]+'.npz'
        # simpath used to set-up simulation dt and hsolver
        simpath = ['/' + neurotype for neurotype in all_neur_types]
        create_model_sim.setupOutput(model)
    else:  # population of neurons
        spiketab, vmtab, plastab, catab = net_output.SpikeTables(model, population['pop'], net.plot_netvm, plas,
                                                                 net.plots_per_neur)
        # simpath used to set-up simulation dt and hsolver
        simpath = [net.netname]
        clocks.assign_clocks(simpath, param_sim.simdt, param_sim.plotdt, param_sim.hsolve, model.param_cond.NAME_SOMA)
    if model.synYN and (param_sim.plot_synapse or net.single):
        # overwrite plastab above, since it is empty
        syntab, plastab, stp_tab = tables.syn_plastabs(connections, model)
        nonstim_plastab = tables.nonstimplastabs(plas)

    # Streamer to prevent Tables filling up memory on disk
    # This is a hack, should be better implemented
    if param_sim.useStreamer == True:
        allTables = moose.wildcardFind('/##[ISA=Table]')
        streamer = moose.Streamer('/streamer')
        streamer.outfile = 'plas_simd1opt_{}_corticalfraction_{}.npy'.format(net.param_net.tt_Ctx_SPN.filename, 0.8)
        moose.setClock(streamer.tick, 0.1)
        for t in allTables:
            if any(s in t.path for s in ['plas', 'VmD1_0', 'extern', 'Shell_0']):
                streamer.addTable(t)
            else:
                t.tick = -2

    ################### Actually run the simulation
    def run_simulation(injection_current, simtime):
        print(u'◢◤◢◤◢◤◢◤ injection_current = {} ◢◤◢◤◢◤◢◤'.format(injection_current))
        pg.firstLevel = injection_current
        moose.reinit()
        moose.start(simtime, True)

    traces, names = [], []
    for inj in param_sim.injection_current:
        run_simulation(injection_current=inj, simtime=param_sim.simtime)

    weights = [w.value for w in moose.wildcardFind('/##/plas##[TYPE=Function]')]
    plt.figure()
    plt.hist(weights, bins=100)
    plt.title('plas_sim_{}_corticalfraction_{}'.format(net.param_net.tt_Ctx_SPN.filename, cortical_fraction))
    plt.savefig('plas_simd1opt_{}_corticalfraction_{}.png'.format(net.param_net.tt_Ctx_SPN.filename, 0.8))
    if param_sim.useStreamer == True:
        import atexit
        atexit.register(moose.quit)
    return weights
コード例 #28
0
synchan.Gbar = 1E-8
synchan.tau1 = 2E-3
synchan.tau2 = 2E-3
synchan.Ek = -10E-3

# Connections

moose.connect(soma, 'axialOut', dend, 'handleAxial')
moose.connect(dend, 'channel', synchan, 'channel')

sh = moose.SimpleSynHandler(synchan.path + '/synhandler')

moose.connect(sh, 'activationOut', synchan, 'activation')
sh.synapse.num = 1
sh.synapse[0].delay = 1E-3
moose.showmsg(sh)

presyn = moose.RandSpike('presyn_input')
presyn.rate = 1.3
presyn.refractT = 1E-3
moose.connect(presyn, 'spikeOut', sh.synapse[0], 'addSpike')

sh.synapse.num = 2
sh.synapse[1].delay = 0.1E-3

presyn2 = moose.RandSpike('presyn_input2')
presyn2.rate = 3.5
presyn2.refractT = 1E-3
moose.connect(presyn2, 'spikeOut', sh.synapse[1], 'addSpike')

spiketable1 = moose.Table('spikes1')