コード例 #1
0
def test_nml2(nogui=True):
    global SCRIPT_DIR
    filename = os.path.join(SCRIPT_DIR, 'test_files/passiveCell.nml')
    mu.info('Loading: %s' % filename)
    nml = moose.mooseReadNML2(filename)
    if not nml:
        mu.warn("Failed to parse NML2 file")
        return

    assert nml, "Expecting NML2 object"
    msoma = nml.getComp(nml.doc.networks[0].populations[0].id, 0, 0)
    data = moose.Neutral('/data')
    pg = nml.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')

    simtime = 150e-3
    moose.reinit()
    moose.start(simtime)
    print("Finished simulation!")
    yvec = vm.vector
    injvec = inj.vector * 1e12
    m1, u1 = np.mean(yvec), np.std(yvec)
    m2, u2 = np.mean(injvec), np.std(injvec)
    assert np.isclose(m1, -0.0456943), m1
    assert np.isclose(u1, 0.0121968), u1
    assert np.isclose(m2, 26.64890), m2
    assert np.isclose(u2, 37.70607574), u2
コード例 #2
0
ファイル: test_neuroml2.py プロジェクト: hrani/moose-core
def run( nogui = True ):
    global SCRIPT_DIR
    filename = os.path.join(SCRIPT_DIR, 'test_files/passiveCell.nml' )
    mu.info('Loading: %s' % filename )
    nml = moose.mooseReadNML2( filename )
    if not nml:
        mu.warn( "Failed to parse NML2 file" )
        return

    assert nml, "Expecting NML2 object"
    msoma = nml.getComp(nml.doc.networks[0].populations[0].id,0,0)
    data = moose.Neutral('/data')
    pg = nml.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')

    simtime = 150e-3
    moose.reinit()
    moose.start(simtime)
    print("Finished simulation!")
    t = np.linspace(0, simtime, len(vm.vector))
    yvec = vm.vector
    injvec = inj.vector * 1e12
    m1, u1 = np.mean( yvec ), np.std( yvec )
    m2, u2 = np.mean( injvec ), np.std( injvec )
    assert np.isclose( m1, -0.0456943 ), m1
    assert np.isclose( u1, 0.0121968 ), u1
    assert np.isclose( m2, 26.64890 ), m2
    assert np.isclose( u2, 37.70607574 ), u2
    quit( 0 )
コード例 #3
0
ファイル: run_cell.py プロジェクト: dilawar/moose-examples
def run(nogui):
    
    filename = 'passiveCell.nml'
    print('Loading: %s'%filename)
    reader = moose.mooseReadNML2( filename )
    assert reader
    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
    
    for i in range(8):
        moose.setClock( i, simdt )
    moose.setClock( 8, plotdt )
    moose.reinit()
    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()
コード例 #4
0
ファイル: run_cell.py プロジェクト: upibhalla/moose-examples
def run(nogui):

    filename = 'passiveCell.nml'
    print('Loading: %s' % filename)
    reader = moose.mooseReadNML2(filename)
    assert reader
    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

    for i in range(8):
        moose.setClock(i, simdt)
    moose.setClock(8, plotdt)
    moose.reinit()
    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()
コード例 #5
0
# Load in the libraries and functions needed to create the model
import moose
import numpy as np
import pylab as plt
import plot_channel as pc
import util as u

# Use plt.ion to show the graphs that will be created for each channel type and for the simulation
plt.ion()

# Read the NML model into MOOSE
#filename = 'MScellupdated2.nml'
#filename = 'MScellupdated_SecDendRE.nml'
filename = 'MScellupdated_primDend.nml'
reader = moose.mooseReadNML2(filename)

# Define the variables to be used for the somatic current injection
pulse_dur = 400e-3
pulse_amp = 0.26e-9
pulse_delay1 = 100e-3
pulse_delay2 = 1e9

# Define the variables needed to view the underlying curves for the channel kinetics
plot_powers = True
VMIN = -120e-3
VMAX = 50e-3
CAMIN = 0.01e-3
CAMAX = 40e-3
channelList = ('kAf', 'kAs', 'kIR', 'Krp', 'naF')

# Graph the curves
コード例 #6
0
# Load in the libraries and functions needed to create the model
import moose
import numpy as np
import pylab as plt
import plot_channel as pc
import util as u

# Use plt.ion to show the graphs that will be created for each channel type and for the simulation
plt.ion()

# Read the NML model into MOOSE
#filename = 'MScellupdated2.nml'
#filename = 'MScellupdated_SecDendRE.nml'
filename = 'MScellupdated_primDend.nml'
reader = moose.mooseReadNML2(filename)

# Define the variables to be used for the somatic current injection
pulse_dur = 400e-3
pulse_amp = 0.26e-9
pulse_delay1 = 100e-3
pulse_delay2 = 1e9

# Define the variables needed to view the underlying curves for the channel kinetics
plot_powers = True
VMIN = -120e-3
VMAX = 50e-3
CAMIN = 0.01e-3
CAMAX = 40e-3
channelList = ('kAf','kAs','kIR','Krp','naF')

# Graph the curves
コード例 #7
0
# Load in the libraries and functions needed to create the model
import moose

import numpy as np
import pylab as plt

# Set plt to show the graphs that will be created for each channel type
plt.ion()

# Read the NML model into MOOSE
filename = 'MScellupdated.nml'
reader = moose.mooseReadNML2(filename, verbose=1)