本文整理汇总了Python中moose.vec函数的典型用法代码示例。如果您正苦于以下问题:Python vec函数的具体用法?Python vec怎么用?Python vec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: find_max_voxel
def find_max_voxel(): #added by Chaitanya
spineCa = len(moose.vec( '/model/chem/spine/Ca' ))
dendCa = len(moose.vec( '/model/chem/dend/DEND/Ca' ))
Ca = len([ x.Ca * 0.0001 for x in moose.wildcardFind( '/model/elec/##[ISA=CaConcBase]') ])
spineCaM = len(moose.vec( '/model/chem/spine/Ca_CaM' ))
psdCaM = len(moose.vec( '/model/chem/psd/Ca_CaM' ))
return max(spineCa, dendCa, Ca, spineCaM, psdCaM)
示例2: 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}
示例3: 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}
示例4: showVisualization
def showVisualization():
makeModel()
elec = moose.element( '/model/elec' )
elec.setSpineAndPsdMesh( moose.element('/model/chem/spine'), moose.element('/model/chem/psd') )
eHead = moose.wildcardFind( '/model/elec/#head#' )
oldDia = [ i.diameter for i in eHead ]
graphs = moose.Neutral( '/graphs' )
#makePlot( 'psd_x', moose.vec( '/model/chem/psd/x' ), 'getN' )
#makePlot( 'head_x', moose.vec( '/model/chem/spine/x' ), 'getN' )
makePlot( 'dend_x', moose.vec( '/model/chem/dend/x' ), 'getN' )
dendZ = makePlot( 'dend_z', moose.vec( '/model/chem/dend/z' ), 'getN' )
makePlot( 'head_z', moose.vec( '/model/chem/spine/z' ), 'getN' )
psdZ = makePlot( 'psd_z', moose.vec( '/model/chem/psd/z' ), 'getN' )
diaTab = makePlot( 'headDia', eHead, 'getDiameter' )
# print diaTab[0].vector[-1]
# return
dendrite = moose.element("/model/elec/dend")
dendrites = [dendrite.path + "/" + str(i) for i in range(len(dendZ))]
# print dendrites
moose.reinit()
spineHeads = moose.wildcardFind( '/model/elec/#head#')
# print moose.wildcardFind( '/model/elec/##')
# print "dendZ", readValues(dendZ)
# print dendrite
app = QtGui.QApplication(sys.argv)
viewer = create_viewer("/model/elec", dendrite, dendZ, diaTab, psdZ)
viewer.showMaximized()
viewer.start()
return app.exec_()
示例5: saveNeuronPlots
def saveNeuronPlots( fig, rdes ):
#fig = plt.figure( figsize=(12, 10), facecolor='white' )
#fig.subplots_adjust( left = 0.18 )
plt.figure(1)
ax = plt.subplot(222)
cleanAx( ax, 'C' )
plt.ylabel( 'Vm (mV)', fontsize = 16 )
vtab = moose.element( '/graphs/vtab' )
t = np.arange( 0, len( vtab.vector ), 1 ) * vtab.dt
plt.plot( t, vtab.vector * 1000, label="Vm" )
#plt.legend()
ax = plt.subplot(223)
cleanAx( ax, 'D', showXlabel = True )
pcatab = list( moose.vec( '/graphs/pcatab' ) )[0::50]
t = np.arange( 0, len( pcatab[0].vector ), 1 ) * pcatab[0].dt
for i in pcatab:
plt.plot( t, i.vector * 1000 )
plt.ylabel( '[Ca] (uM)', fontsize = 16 )
plt.xlabel( 'Time (s)', fontsize = 16 )
ax = plt.subplot(224)
cleanAx( ax, 'E', showXlabel = True )
rtab = list( moose.vec( '/graphs/rtab' ) )[0::50]
t = np.arange( 0, len( rtab[0].vector ), 1 ) * rtab[0].dt
for i in rtab:
plt.plot( t, i.vector )
plt.ylabel( '# of inserted GluRs', fontsize = 16 )
plt.xlabel( 'Time (s)', fontsize = 16 )
'''
示例6: makeGraphics
def makeGraphics( cPlotDt, ePlotDt ):
plt.ion()
fig = plt.figure( figsize=(10,16) )
chem = fig.add_subplot( 411 )
chem.set_ylim( 0, 0.006 )
plt.ylabel( 'Conc (mM)' )
plt.xlabel( 'time (seconds)' )
for x in moose.wildcardFind( '/graphs/chem/#[ISA=Table]' ):
pos = numpy.arange( 0, x.vector.size, 1 ) * cPlotDt
line1, = chem.plot( pos, x.vector, label=x.name )
plt.legend()
elec = fig.add_subplot( 412 )
plt.ylabel( 'Vm (V)' )
plt.xlabel( 'time (seconds)' )
for x in moose.wildcardFind( '/graphs/elec/#[ISA=Table]' ):
pos = numpy.arange( 0, x.vector.size, 1 ) * ePlotDt
line1, = elec.plot( pos, x.vector, label=x.name )
plt.legend()
ca = fig.add_subplot( 413 )
plt.ylabel( '[Ca] (mM)' )
plt.xlabel( 'time (seconds)' )
for x in moose.wildcardFind( '/graphs/ca/#[ISA=Table]' ):
pos = numpy.arange( 0, x.vector.size, 1 ) * ePlotDt
line1, = ca.plot( pos, x.vector, label=x.name )
plt.legend()
lenplot = fig.add_subplot( 414 )
plt.ylabel( 'Ca (mM )' )
plt.xlabel( 'Voxel#)' )
spineCa = moose.vec( '/model/chem/spine/Ca' )
dendCa = moose.vec( '/model/chem/dend/DEND/Ca' )
line1, = lenplot.plot( range( len( spineCa ) ), spineCa.conc, label='spine' )
line2, = lenplot.plot( range( len( dendCa ) ), dendCa.conc, label='dend' )
ca = [ x.Ca * 0.0001 for x in moose.wildcardFind( '/model/elec/##[ISA=CaConcBase]') ]
line3, = lenplot.plot( range( len( ca ) ), ca, label='elec' )
spineCaM = moose.vec( '/model/chem/spine/CaM_dash_Ca4' )
line4, = lenplot.plot( range( len( spineCaM ) ), spineCaM.conc, label='spineCaM' )
psdCaM = moose.vec( '/model/chem/psd/CaM_dash_Ca4' )
line5, = lenplot.plot( range( len( psdCaM ) ), psdCaM.conc, label='psdCaM' )
plt.legend()
fig.canvas.draw()
raw_input()
'''
for x in moose.wildcardFind( '/graphs/##[ISA=Table]' ):
t = numpy.arange( 0, x.vector.size, 1 )
pylab.plot( t, x.vector, label=x.name )
pylab.legend()
pylab.show()
'''
print 'All done'
示例7: main
def main():
"""
transportBranchingNeuron:
This example illustrates bidirectional transport
embedded in the branching pseudo 1-dimensional geometry of a neuron.
This means that diffusion and transport only happen along the axis of
dendritic segments, not radially from inside to outside a dendrite,
nor tangentially around the dendrite circumference.
In this model there is a molecule **a** starting at the soma, which is
transported out to the dendrites. There is another molecule, **b**,
which is initially present at the dendrite tips, and is transported
toward the soma.
This example uses an external model file to specify a binary branching
neuron. This model does not have any spines. The electrical model is
used here purely for the geometry and is not part of the computations.
In this example we build trival chemical model just having
molecules **a** and **b** throughout the neuronal geometry, using
the makeChemModel function.
The model is set up to run using the Ksolve for integration and the
Dsolve for handling diffusion.
The display has three parts:
a. Animated pseudo-3D plot of neuronal geometry, where each point
represents a diffusive voxel and moves in the y-axis to show
changes in concentration of molecule a.
b. Similar animated pseudo-3D plot for molecule b.
c. Time-series plot that appears after the simulation has
ended. The plots are for the first and last diffusive voxel,
that is, the soma and the tip of one of the apical dendrites.
"""
chemdt = 0.1 # Tested various dts, this is reasonable.
diffdt = 0.01
plotdt = 1
animationdt = 5
runtime = 600
makeModel()
plotlist = makeDisplay()
# Schedule the whole lot
for i in range( 11, 17 ):
moose.setClock( i, chemdt ) # for the chem objects
moose.setClock( 10, diffdt ) # for the diffusion
moose.setClock( 18, plotdt ) # for the output tables.
moose.reinit()
a = moose.vec( '/model/chem/compt0/a' )
b = moose.vec( '/model/chem/compt0/b' )
a0 = sum( a.n )
b0 = sum( b.n )
for i in range( 0, runtime, animationdt ):
moose.start( animationdt )
plotlist[4].set_text( "time = %d" % i )
updateDisplay( plotlist )
print 'mass consv a = ', a0, sum( a.n ), ', b = ', b0, sum( b.n )
finalizeDisplay( plotlist, plotdt )
示例8: testRename
def testRename(self):
"""Rename an element in a Id and check if that was effective. This
tests for setting values also."""
id1 = moose.vec(path='/alpha', n=1, dtype='Neutral')
id2 = moose.vec('alpha')
id1[0].name = 'bravo'
self.assertEqual(id1.path, '/bravo')
self.assertEqual(id2.path, '/bravo')
示例9: main
def main():
numpy.random.seed( 1234 )
rdes = buildRdesigneur()
rdes.buildModel( '/model' )
assert( moose.exists( '/model' ) )
moose.element( '/model/elec/hsolve' ).tick = -1
for i in range( 0, 10 ):
moose.setClock( i, 100 )
for i in range( 10, 18 ):
moose.setClock( i, dt )
moose.setClock( 18, plotdt )
moose.reinit()
buildPlots()
# Run for baseline, tetanus, and post-tetanic settling time
print 'starting...'
t1 = time.time()
moose.start( baselineTime )
caPsd = moose.vec( '/model/chem/psd/Ca_input' )
caDend = moose.vec( '/model/chem/dend/DEND/Ca_input' )
castim = (numpy.random.rand( len( caPsd.concInit ) ) * 0.8 + 0.2) * psdTetCa
caPsd.concInit = castim
caDend.concInit = numpy.random.rand( len( caDend.concInit ) ) * dendTetCa
moose.start( tetTime )
caPsd.concInit = basalCa
caDend.concInit = basalCa
moose.start( interTetTime )
caPsd.concInit = castim
caDend.concInit = numpy.random.rand( len( caDend.concInit ) ) * dendTetCa
moose.start( tetTime )
caPsd.concInit = basalCa
caDend.concInit = basalCa
moose.start( postTetTime )
caPsd.concInit = ltdCa
caDend.concInit = ltdCa
moose.start( ltdTime )
caPsd.concInit = basalCa
caDend.concInit = basalCa
moose.start( postLtdTime )
print 'real time = ', time.time() - t1
if do3D:
app = QtGui.QApplication(sys.argv)
compts = moose.wildcardFind( "/model/elec/#[ISA=compartmentBase]" )
ecomptPath = map( lambda x : x.path, compts )
morphology = moogli.read_morphology_from_moose(name = "", path = "/model/elec")
morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \
[0.0, 0.5, 1.0, 1.0], [1.0, 0.0, 0.0, 0.9] )
viewer = moogli.DynamicMorphologyViewerWidget(morphology)
def callback( morphology, viewer ):
moose.start( 0.1 )
return True
viewer.set_callback( callback, idletime = 0 )
viewer.showMaximized()
viewer.show()
app.exec_()
displayPlots()
示例10: testCompareId
def testCompareId(self):
"""Test the rich comparison between ids"""
id1 = moose.vec('A', n=2, dtype='Neutral')
id2 = moose.vec('B', n=4, dtype='Neutral')
id3 = moose.vec('A')
self.assertTrue(id1 < id2)
self.assertEqual(id1, id3)
self.assertTrue(id2 > id1)
self.assertTrue(id2 >= id1)
self.assertTrue(id1 <= id2)
示例11: updatePlots
def updatePlots( plotlist, time ):
a = moose.vec( '/model/compartment/a' )
b = moose.vec( '/model/compartment/b' )
c = moose.vec( '/model/compartment/c' )
d = moose.vec( '/model/compartment/d' )
plotlist[2].set_text( "time = %g" % time )
plotlist[3].set_ydata( a.conc )
plotlist[4].set_ydata( b.conc )
plotlist[5].set_ydata( c.conc )
plotlist[6].set_ydata( d.conc )
示例12: updateGraphics
def updateGraphics( plotlist ):
spineCa = moose.vec( '/model/chem/spine/Ca' )
dendCa = moose.vec( '/model/chem/dend/DEND/Ca' )
plotlist[5].set_ydata( spineCa.conc )
plotlist[6].set_ydata( dendCa.conc )
ca = [ x.Ca * 0.0001 for x in moose.wildcardFind( '/model/elec/##[ISA=CaConcBase]') ]
plotlist[7].set_ydata( ca )
spineCaM = moose.vec( '/model/chem/spine/Ca_CaM' )
plotlist[8].set_ydata( spineCaM.conc )
psdCaM = moose.vec( '/model/chem/psd/Ca_CaM' )
plotlist[9].set_ydata( psdCaM.conc )
plotlist[4].canvas.draw()
示例13: updateDisplay
def updateDisplay( plotlist ):
Ca = moose.vec( '/model/chem/compt0/Ca' )
Ca_input = moose.vec( '/model/chem/compt0/Ca_input' )
plotlist[5].set_ydata( Ca.conc )
plotlist[6].set_ydata( Ca_input.conc )
Ca = moose.vec( '/model/chem/compt1/Ca' )
plotlist[7].set_ydata( Ca.conc )
Ca = moose.vec( '/model/chem/compt2/Ca' )
Ca_input = moose.vec( '/model/chem/compt2/Ca_input' )
plotlist[8].set_ydata( Ca.conc )
plotlist[9].set_ydata( Ca_input.conc )
plotlist[4].canvas.draw()
示例14: loadChem
def loadChem( neuroCompt, spineCompt, psdCompt ):
# We need the compartments to come in with a volume of 1 to match the
# original CubeMesh.
assert( neuroCompt.volume == 1.0 )
assert( spineCompt.volume == 1.0 )
assert( psdCompt.volume == 1.0 )
assert( neuroCompt.mesh.num == 1 )
print 'volume = ', neuroCompt.mesh[0].volume
#assert( neuroCompt.mesh[0].volume == 1.0 )
#an unfortunate mismatch
# So we'll have to resize the volumes of the current compartments to the
# new ones.
modelId = moose.loadModel( 'diffonly.g', '/model', 'ee' )
#moose.le( '/model/model' )
#moose.le( '/model/model/kinetics' )
#moose.le( '/model/model/kinetics/PSD' )
#moose.le( '/model/model/kinetics/SPINE' )
moose.delete( moose.vec( '/model/model/kinetics/PSD/kreac' ) )
moose.delete( moose.vec( '/model/model/kinetics/SPINE/kreac' ) )
#moose.le( '/model/model/kinetics/PSD' )
#moose.le( '/model/model/kinetics/SPINE' )
pCaCaM = moose.element( '/model/model/kinetics/PSD/Ca_CaM' )
pCaCaM.concInit = 0.001
dCaCaM = moose.element( '/model/model/kinetics/PSD/Ca_CaM' )
sCaCaM = moose.element( '/model/model/kinetics/SPINE/Ca_CaM' )
print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
#moose.delete( moose.vec( '/model/model/kinetics/SPINE/Ca_CaM' ) )
#CaCaM2 = moose.element( '/model/model/kinetics/SPINE/Ca_CaM' )
#CaCaM2.concInit = 0.001
chem = moose.element( '/model/model' )
chem.name = 'chem'
oldS = moose.element( '/model/chem/compartment_1' )
oldP = moose.element( '/model/chem/compartment_2' )
oldN = moose.element( '/model/chem/kinetics' )
print 'oldvols[p,s,d] = ', oldP.volume, oldS.volume, oldN.volume
print 'newvols[p,s,d] = ', psdCompt.mesh[0].volume, spineCompt.mesh[0].volume, neuroCompt.mesh[0].volume
oldN.volume = neuroCompt.mesh[0].volume
oldS.volume = spineCompt.mesh[0].volume
oldP.volume = psdCompt.mesh[0].volume
print 'after redoing vols'
print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
moveCompt( '/model/chem/kinetics/SPINE', oldS, spineCompt )
moveCompt( '/model/chem/kinetics/PSD', oldP, psdCompt )
# Need to do the DEND last because the oldN is /kinetics,
# and it will be deleted.
moveCompt( '/model/chem/kinetics/DEND', oldN, neuroCompt )
print 'after moving to new compts'
print "CaCaM.concInit[p,s,d] = ", pCaCaM.concInit, sCaCaM.concInit, dCaCaM.concInit
示例15: printPsd
def printPsd( name ):
# Print the vol, the path dist from soma, the electrotonic dist, and N
psdR = moose.vec( '/model/chem/psd/tot_PSD_R' )
neuronVoxel = moose.element( '/model/chem/spine' ).neuronVoxel
elecComptMap = moose.element( '/model/chem/dend' ).elecComptMap
print(("len( neuronVoxel = ", len( neuronVoxel), min( neuronVoxel), max( neuronVoxel)))
print((len( elecComptMap), elecComptMap[0], elecComptMap[12]))
neuron = moose.element( '/model/elec' )
ncompts = neuron.compartments
d = {}
j = 0
for i in ncompts:
#print i
d[i] = j
j += 1
f = open( name + ".txt", 'w' )
for i in range( len( psdR ) ):
n = psdR[i].n
conc = psdR[i].conc
vol = psdR[i].volume
compt = elecComptMap[ neuronVoxel[i] ]
#print compt
segIndex = d[compt[0]]
p = neuron.geometricalDistanceFromSoma[ segIndex ]
L = neuron.electrotonicDistanceFromSoma[ segIndex ]
s = str( i ) + " " + str(n) + " " + str( conc ) + " " + str(p) + " " + str(L) + "\n"
f.write( s )
f.close()