本文整理汇总了Python中moose.connect函数的典型用法代码示例。如果您正苦于以下问题:Python connect函数的具体用法?Python connect怎么用?Python connect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createFunction
def createFunction(fb,setpool,objB,objA):
fapath1 = fb.path.replace(objB,objA)
fapath = fapath1.replace('[0]','')
if not moose.exists(fapath):
# if fb.parent.className in ['CubeMesh','CyclMesh']:
# des = moose.Function('/'+objA+'/'+fb.parent.name+'/'+fb.name)
# elif fb.parent.className in ['Pool','ZombiePool','BufPool','ZombieBufPool']:
# for akey in list(poolListina[findCompartment(fb).name]):
# if fb.parent.name == akey.name:
# des = moose.Function(akey.path+'/'+fb.name)
des = moose.Function(fapath)
else:
des = moose.element(fapath)
inputB = moose.element(fb.path+'/x').neighbors["input"]
moose.connect(des, 'valueOut', moose.element(setpool),'setN' )
inputA = []
inputA = moose.element(fapath+'/x').neighbors["input"]
if not inputA:
for src in inputB:
pool = ((src.path).replace(objB,objA)).replace('[0]','')
numVariables = des.numVars
expr = ""
expr = (des.expr+'+'+'x'+str(numVariables))
expr = expr.lstrip("0 +")
expr = expr.replace(" ","")
des.expr = expr
moose.connect( pool, 'nOut', des.x[numVariables], 'input' )
示例2: create_cell
def create_cell():
"""Create a single-compartment Hodgking-Huxley neuron with a
synaptic channel.
This uses the :func:`ionchannel.create_1comp_neuron` function for
model creation.
Returns a dict containing the neuron, the synchan and the
synhandler for accessing the synapse,
"""
neuron = create_1comp_neuron('/neuron')
#: SynChan for post synaptic neuron
synchan = moose.SynChan('/neuron/synchan')
synchan.Gbar = 1e-8
synchan.tau1 = 2e-3
synchan.tau2 = 2e-3
msg = moose.connect(neuron, 'channel', synchan, 'channel')
#: Create SynHandler to handle spike event input and set the
#: activation input of synchan
synhandler = moose.SimpleSynHandler('/neuron/synhandler')
synhandler.synapse.num = 1
synhandler.synapse[0].delay = 5e-3
moose.connect(synhandler, 'activationOut', synchan, 'activation')
return {'neuron': neuron,
'synchan': synchan,
'synhandler': synhandler}
示例3: run
def run(nogui):
reader = NML2Reader(verbose=True)
filename = 'test_files/NML2_SingleCompHHCell.nml'
print('Loading: %s'%filename)
reader.read(filename, symmetric=True)
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 = 300e-3
#moose.showmsg( '/clock' )
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
vfile = open('moose_v_hh.dat','w')
for i in range(len(t)):
vfile.write('%s\t%s\n'%(t[i],vm.vector[i]))
vfile.close()
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.figure()
test_channel_gates()
plt.show()
plt.close()
示例4: singleCompt
def singleCompt( name, params ):
mod = moose.copy( '/library/' + name + '/' + name, '/model' )
A = moose.element( mod.path + '/A' )
Z = moose.element( mod.path + '/Z' )
Z.nInit = 1
Ca = moose.element( mod.path + '/Ca' )
CaStim = moose.element( Ca.path + '/CaStim' )
runtime = params['preStimTime'] + params['stimWidth'] + params['postStimTime']
steptime = 100
CaStim.expr += ' + x2 * (t > ' + str( runtime ) + ' ) * ( t < ' + str( runtime + steptime ) + ' )'
print(CaStim.expr)
tab = moose.Table2( '/model/' + name + '/Atab' )
#for i in range( 10, 19 ):
#moose.setClock( i, 0.01 )
ampl = moose.element( mod.path + '/ampl' )
phase = moose.element( mod.path + '/phase' )
moose.connect( tab, 'requestOut', A, 'getN' )
ampl.nInit = params['stimAmplitude'] * 1
phase.nInit = params['preStimTime']
ksolve = moose.Ksolve( mod.path + '/ksolve' )
stoich = moose.Stoich( mod.path + '/stoich' )
stoich.compartment = mod
stoich.ksolve = ksolve
stoich.path = mod.path + '/##'
runtime += 2 * steptime
moose.reinit()
moose.start( runtime )
t = np.arange( 0, runtime + 1e-9, tab.dt )
return name, t, tab.vector
示例5: main
def main( runTime ):
try:
moose.delete('/acc92')
print("Deleted old model")
except Exception as e:
print("Could not clean. model not loaded yet")
moose.loadModel('acc92_caBuff.g',loadpath,'gsl')
ca = moose.element(loadpath+'/kinetics/Ca')
pr = moose.element(loadpath+'/kinetics/protein')
clockdt = moose.Clock('/clock').dts
moose.setClock(8, 0.1)#simdt
moose.setClock(18, 0.1)#plotdt
print clockdt
print " \t \t simdt ", moose.Clock('/clock').dts[8],"plotdt ",moose.Clock('/clock').dts[18]
ori = ca.concInit
tablepath = loadpath+'/kinetics/Ca'
tableele = moose.element(tablepath)
table = moose.Table2(tablepath+'.con')
x = moose.connect(table, 'requestOut', tablepath, 'getConc')
tablepath1 = loadpath+'/kinetics/protein'
tableele1 = moose.element(tablepath1)
table1 = moose.Table2(tablepath1+'.con')
x1 = moose.connect(table1, 'requestOut', tablepath1, 'getConc')
ca.concInit = ori
print("[INFO] Running for 4000 with Ca.conc %s " % ca.conc)
moose.start(4000)
ca.concInit = 5e-03
print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
moose.start(20)
ca.concInit = ori
moose.start( runTime ) #here give the interval time
ca.concInit = 5e-03
print("[INFO] Running for 20 with Ca.conc %s " % ca.conc)
moose.start(20)
ca.concInit = ori
print("[INFO] Running for 2000 with Ca.conc %s " % ca.conc)
moose.start(2000)
pylab.figure()
pylab.subplot(2, 1, 1)
t = numpy.linspace(0.0, moose.element("/clock").runTime, len(table.vector)) # sec
pylab.plot( t, table.vector, label="Ca Conc (interval- 8000s)" )
pylab.legend()
pylab.subplot(2, 1, 2)
t1 = numpy.linspace(0.0, moose.element("/clock").runTime, len(table1.vector)) # sec
pylab.plot( t1, table1.vector, label="Protein Conc (interval- 8000s)" )
pylab.legend()
pylab.savefig( os.path.join( dataDir, '%s_%s.png' % (table1.name, runTime) ) )
print('[INFO] Saving data to csv files in %s' % dataDir)
tabPath1 = os.path.join( dataDir, '%s_%s.csv' % (table.name, runTime))
numpy.savetxt(tabPath1, numpy.matrix([t, table.vector]).T, newline='\n')
tabPath2 = os.path.join( dataDir, '%s_%s.csv' % (table1.name, runTime) )
numpy.savetxt(tabPath2, numpy.matrix([t1, table1.vector]).T, newline='\n')
示例6: main
def main():
""" This example illustrates loading, running of an SBML model defined in XML format.\n
The model 00001-sbml-l3v1.xml is taken from l3v1 SBML testcase.\n
Plots are setup.\n
Model is run for 20sec.\n
As a general rule we created model under '/path/model' and plots under '/path/graphs'.\n
"""
mfile = os.path.join( script_dir, 'chem_models/00001-sbml-l3v1.xml')
runtime = 20.0
# Loading the sbml file into MOOSE, models are loaded in path/model
sbmlId = moose.readSBML(mfile,'sbml')
s1 = moose.element('/sbml/model/compartment/S1')
s2= moose.element('/sbml/model/compartment/S2')
# Creating MOOSE Table, Table2 is for the chemical model
graphs = moose.Neutral( '/sbml/graphs' )
outputs1 = moose.Table2 ( '/sbml/graphs/concS1')
outputs2 = moose.Table2 ( '/sbml/graphs/concS2')
# connect up the tables
moose.connect( outputs1,'requestOut', s1, 'getConc' );
moose.connect( outputs2,'requestOut', s2, 'getConc' );
# Reset and Run
moose.reinit()
moose.start(runtime)
示例7: setup_model
def setup_model(model_path, synapse_locations, passive=False, solver='hsolve'):
"""Set up a single cell model under `model_path` with synapses
created in the compartments listed in `synapse_locations`.
`model_path` - location where the model should be created.
`synapse_locations`: compartment names for the synapses.
"""
cell = moose.copy(make_prototype(passive), model_path)
if solver.lower() == 'hsolve':
hsolve = moose.HSolve( '%s/solve' % (cell.path))
hsolve.dt = simdt
hsolve.target = cell.path
syninfo_list = []
for compname in synapse_locations:
comppath = '%s/%s' % (cell.path, compname)
print('1111 Creating synapse in', comppath)
compartment = moose.element(comppath)
syninfo = make_synapse(compartment)
syninfo_list.append(syninfo)
# connect pulse stimulus
stim_path = '%s/%s/stim' % (cell.path, compname)
print('2222 Creating stimuls in', stim_path)
stim = moose.PulseGen(stim_path)
moose.connect(stim, 'output', syninfo['spike'], 'Vm')
syninfo['stimulus'] = stim
return {'neuron': cell,
'syninfo': syninfo_list}
示例8: make_synapse
def make_synapse(path):
"""Create a synapse with two time constants."""
syn = moose.SynChan(path)
syn.tau1 = 5.0 # ms
syn.tau2 = 1.0 # ms
syn.Gbar = 1.0 # mS
syn.Ek = 0.0
synsh = moose.SimpleSynHandler( path + '/sh' )
synsh.synapse.num = 1
# syn.bufferTime = 1.0 # ms
synsh.synapse.delay = 1.0
synsh.synapse.weight = 1.0
print(('Synapses:', len(synsh.synapse), 'w=', synsh.synapse[0].weight))
spikegen = moose.SpikeGen('%s/spike' % (syn.parent.path))
spikegen.edgeTriggered = False # Make it fire continuously when input is high
spikegen.refractT = 10.0 # With this setting it will fire at 1 s / 10 ms = 100 Hz
spikegen.threshold = 0.5
# This will send alternatind -1 and +1 to SpikeGen to make it fire
spike_stim = moose.PulseGen('%s/spike_stim' % (syn.parent.path))
spike_stim.delay[0] = 50.0
spike_stim.level[0] = 1.0
spike_stim.width[0] = 100.0
moose.connect(spike_stim, 'output', spikegen, 'Vm')
m = moose.connect(spikegen, 'spikeOut', synsh.synapse[0], 'addSpike')
return syn, spikegen
示例9: main
def main():
######## Put your favourite cell model here ######
##This one is from PMID 22730554: Suo et al J. Mol Cell Biol 2012
filename = 'cells/ko20x-07.CNG.swc'
moose.Neutral( '/library' )
rdes = rd.rdesigneur( \
cellProto = [[ filename, 'elec' ] ],\
passiveDistrib = passiveDistrib_,
chanProto = chanProto_,
chanDistrib = chanDistrib_
)
rdes.buildModel( '/model' )
moose.reinit()
################## Now we store plots ########################
somaVm = moose.Table( '/somaVm' )
moose.connect( somaVm, 'requestOut', rdes.soma, 'getVm' )
################## Now we set up the display ########################
compts = moose.wildcardFind( "/model/elec/#[ISA=CompartmentBase]" )
compts[0].inject = inject
print("Setting Up 3D Display")
app = QtGui.QApplication(sys.argv)
vm_viewer = create_vm_viewer(rdes, somaVm)
vm_viewer.show()
vm_viewer.start()
return app.exec_()
示例10: _addSpine
def _addSpine( self, parent, spineProto, pos, angle, x, y, z, size, k ):
spine = moose.copy( spineProto, parent.parent, 'spine' + str(k) )
kids = spine[0].children
coords = []
ppos = np.array( [parent.x0, parent.y0, parent.z0] )
for i in kids:
#print i.name, k
j = i[0]
j.name += str(k)
#print 'j = ', j
coords.append( [j.x0, j.y0, j.z0] )
coords.append( [j.x, j.y, j.z] )
self._scaleSpineCompt( j, size )
moose.move( i, self.elecid )
origin = coords[0]
#print 'coords = ', coords
# Offset it so shaft starts from surface of parent cylinder
origin[0] -= parent.diameter / 2.0
coords = np.array( coords )
coords -= origin # place spine shaft base at origin.
rot = np.array( [x, [0,0,0], [0,0,0]] )
coords = np.dot( coords, rot )
moose.delete( spine )
moose.connect( parent, "raxial", kids[0], "axial" )
self._reorientSpine( kids, coords, ppos, pos, size, angle, x, y, z )
示例11: create_squid
def create_squid():
"""Create a single compartment squid model."""
parent = moose.Neutral ('/n' )
compt = moose.Compartment( '/n/compt' )
Em = EREST_ACT + 10.613e-3
compt.Em = Em
compt.initVm = EREST_ACT
compt.Cm = 7.85e-9
compt.Rm = 4.2e5
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])
nachan.Ypower = 1
yGate = moose.HHGate(nachan.path + '/gateY')
yGate.setupAlpha(Na_h_params +
[VDIVS, VMIN, VMAX])
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])
kchan.Gbar = 0.2836e-3
kchan.Ek = -12e-3+EREST_ACT
moose.connect(kchan, 'channel', compt, 'channel', 'OneToOne')
return compt
示例12: make_spiny_compt
def make_spiny_compt(root_path, number,synInput):
comptLength = 100e-6
comptDia = 4e-6
numSpines = Number_Of_Spines
cell = moose.Neutral (root_path+"/cell"+str(number))
compt = create_squid(cell)
compt.inject = INJECT_CURRENT
compt.x0 = 0
compt.y0 = 0
compt.z0 = 0
compt.x = comptLength
compt.y = 0
compt.z = 0
compt.length = comptLength
compt.diameter = comptDia
for i in range( numSpines ):
r = create_spine_with_receptor( compt, cell, i, i/float(numSpines) )
r.synapse.num = 1
syn = moose.element( r.path + '/synapse' )
moose.connect( synInput, 'spikeOut', syn, 'addSpike', 'Single' )
syn.weight = 0.2
syn.delay = i * 1.0e-4
"""
示例13: test_crossing_single
def test_crossing_single():
"""This function creates an ematrix of two PulseGen elements and
another ematrix of two Table elements.
The two pulsegen elements have same amplitude but opposite phase.
Table[0] is connected to PulseGen[1] and Table[1] to Pulsegen[0].
In the plot you should see two square pulses of opposite phase.
"""
size = 2
pg = moose.PulseGen('pulsegen', size)
for ix, ii in enumerate(pg.vec):
pulse = moose.element(ii)
pulse.delay[0] = 1.0
pulse.width[0] = 2.0
pulse.level[0] = (-1)**ix
tab = moose.Table('table', size)
moose.connect(tab.vec[0], 'requestOut', pg.vec[1], 'getOutputValue', 'Single')
moose.connect(tab.vec[1], 'requestOut', pg.vec[0], 'getOutputValue', 'Single')
print 'Neighbors:'
for t in tab.vec:
print t.path
for n in moose.element(t).neighbors['requestOut']:
print 'requestOut <-', n.path
moose.setClock(0, 0.1)
moose.useClock(0, '/##', 'process')
moose.start(5)
for ii in tab.vec:
t = moose.Table(ii).vector
print len(t)
pylab.plot(t)
pylab.show()
示例14: create_population
def create_population(container, size):
"""Create a population of `size` single compartmental neurons with Na+
and K+ channels. Also create SpikeGen objects and SynChan objects
connected to these which can act as plug points for setting up
synapses later.
This uses ..ref::`ionchannel.create_1comp_neuron`.
"""
path = container.path
print path, size, type(path)
comps = create_1comp_neuron("{}/neuron".format(path), number=size)
synpath = path + "/synchan"
print synpath, size, type(size)
synchan = moose.vec(synpath, n=size, dtype="SynChan")
synchan.Gbar = 1e-8
synchan.tau1 = 2e-3
synchan.tau2 = 2e-3
m = moose.connect(comps, "channel", synchan, "channel", "OneToOne")
synhandler = moose.vec("{}/synhandler".format(path), n=size, dtype="SimpleSynHandler")
moose.connect(synhandler, "activationOut", synchan, "activation", "OneToOne")
spikegen = moose.vec("{}/spikegen".format(path), n=size, dtype="SpikeGen")
spikegen.threshold = 0.0
m = moose.connect(comps, "VmOut", spikegen, "Vm", "OneToOne")
return {"compartment": comps, "spikegen": spikegen, "synchan": synchan, "synhandler": synhandler}
示例15: make_spiny_compt
def make_spiny_compt():
comptLength = 100e-6
comptDia = 4e-6
numSpines = 5
compt = create_squid()
compt.inject = 1e-7
compt.x0 = 0
compt.y0 = 0
compt.z0 = 0
compt.x = comptLength
compt.y = 0
compt.z = 0
compt.length = comptLength
compt.diameter = comptDia
synInput = moose.SpikeGen( '/n/compt/synInput' )
synInput.refractT = 47e-3
synInput.threshold = -1.0
synInput.edgeTriggered = 0
synInput.Vm( 0 )
cell = moose.element( '/n' )
for i in range( numSpines ):
r = create_spine_with_receptor( compt, cell, i, i/float(numSpines) )
r.synapse.num = 1
syn = moose.element( r.path + '/synapse' )
moose.connect( synInput, 'spikeOut', syn, 'addSpike', 'Single' )
syn.weight = 0.2
syn.delay = i * 1.0e-4
"""