def main():
# Schedule the whole lot
moose.setClock( 4, 0.1 ) # for the computational objects
moose.setClock( 5, 0.1 ) # clock for the solver
moose.setClock( 8, 1.0 ) # for the plots
# The wildcard uses # for single level, and ## for recursive.
#compartment = makeModel()
moose.loadModel( '../Genesis_files/M1719.cspace', '/model', 'ee' )
compartment = moose.element( 'model/kinetics' )
compartment.name = 'compartment'
ksolve = moose.Ksolve( '/model/compartment/ksolve' )
stoich = moose.Stoich( '/model/compartment/stoich' )
stoich.compartment = compartment
stoich.ksolve = ksolve
#ksolve.stoich = stoich
stoich.path = "/model/compartment/##"
state = moose.SteadyState( '/model/compartment/state' )
moose.useClock( 5, '/model/compartment/ksolve', 'process' )
moose.useClock( 8, '/model/graphs/#', 'process' )
moose.reinit()
state.stoich = stoich
#state.showMatrices()
state.convergenceCriterion = 1e-7
moose.le( '/model/graphs' )
a = moose.element( '/model/compartment/a' )
b = moose.element( '/model/compartment/b' )
c = moose.element( '/model/compartment/c' )
for i in range( 0, 100 ):
getState( ksolve, state )
moose.start( 100.0 ) # Run the model for 100 seconds.
b = moose.element( '/model/compartment/b' )
c = moose.element( '/model/compartment/c' )
# move most molecules over to b
b.conc = b.conc + c.conc * 0.95
c.conc = c.conc * 0.05
moose.start( 100.0 ) # Run the model for 100 seconds.
# move most molecules back to a
c.conc = c.conc + b.conc * 0.95
b.conc = b.conc * 0.05
moose.start( 100.0 ) # Run the model for 100 seconds.
# Iterate through all plots, dump their contents to data.plot.
displayPlots()
quit()
def main():
"""
Simulate a pseudo-STDP protocol and plot the STDP kernel
that emerges from Ca plasticity of Graupner and Brunel 2012.
Author: Aditya Gilra, NCBS, Bangalore, October, 2014.
"""
# ###########################################
# Neuron models
# ###########################################
## Leaky integrate and fire neuron
Vrest = -65e-3 # V # resting potential
Vt_base = -45e-3 # V # threshold
Vreset = -55e-3 # V # in current steps, Vreset is same as pedestal
R = 1e8 # Ohm
tau = 10e-3 # s
refrT = 2e-3 # s
# ###########################################
# Initialize neuron group
# ###########################################
## two neurons: index 0 will be presynaptic, 1 will be postsynaptic
network = moose.LIF( 'network', 2 );
moose.le( '/network' )
network.vec.Em = Vrest
network.vec.thresh = Vt_base
network.vec.refractoryPeriod = refrT
network.vec.Rm = R
network.vec.vReset = Vreset
network.vec.Cm = tau/R
network.vec.inject = 0.
network.vec.initVm = Vrest
#############################################
# Ca Plasticity parameters: synapses (not for ExcInhNetBase)
#############################################
### Cortical slice values -- Table Suppl 2 in Graupner & Brunel 2012
### Also used in Higgins et al 2014
#tauCa = 22.6936e-3 # s # Ca decay time scale
#tauSyn = 346.3615 # s # synaptic plasticity time scale
### in vitro values in Higgins et al 2014, faster plasticity
#CaPre = 0.56175 # mM
#CaPost = 1.2964 # mM
### in vivo values in Higgins et al 2014, slower plasticity
##CaPre = 0.33705 # mM
##CaPost = 0.74378 # mM
#delayD = 4.6098e-3 # s # CaPre is added to Ca after this delay
## proxy for rise-time of NMDA
#thetaD = 1.0 # mM # depression threshold for Ca
#thetaP = 1.3 # mM # potentiation threshold for Ca
#gammaD = 331.909 # factor for depression term
#gammaP = 725.085 # factor for potentiation term
#J = 5e-3 # V # delta function synapse, adds to Vm
#weight = 0.43 # initial synaptic weight
## gammaP/(gammaP+gammaD) = eq weight w/o noise
## see eqn (22), noiseSD also appears
## but doesn't work here,
## weights away from 0.4 - 0.5 screw up the STDP rule!!
#bistable = True # if bistable is True, use bistable potential for weights
#noisy = False # use noisy weight updates given by noiseSD
#noiseSD = 3.3501 # if noisy, use noiseSD (3.3501 from Higgins et al 2014)
########################################
## DP STDP curve (Fig 2C) values -- Table Suppl 1 in Graupner & Brunel 2012
tauCa = 20e-3 # s # Ca decay time scale
tauSyn = 150.0 # s # synaptic plasticity time scale
CaPre = 1.0 # arb
CaPost = 2.0 # arb
delayD = 13.7e-3 # s # CaPre is added to Ca after this delay
# proxy for rise-time of NMDA
thetaD = 1.0 # mM # depression threshold for Ca
thetaP = 1.3 # mM # potentiation threshold for Ca
gammaD = 200.0 # factor for depression term
gammaP = 321.808 # factor for potentiation term
J = 5e-3 # V # delta function synapse, adds to Vm
weight = 0.5 # initial synaptic weight
# gammaP/(gammaP+gammaD) = eq weight w/o noise
# see eqn (22), noiseSD also appears
# but doesn't work here,
# weights away from 0.4 - 0.5 screw up the STDP rule!!
bistable = True # if bistable is True, use bistable potential for weights
noisy = False # use noisy weight updates given by noiseSD
noiseSD = 2.8284 # if noisy, use noiseSD (3.3501 in Higgins et al 2014)
##########################################
syn = moose.GraupnerBrunel2012CaPlasticitySynHandler( '/network/syn' )
syn.numSynapses = 1 # 1 synapse
# many pre-synaptic inputs can connect to a synapse
# synapse onto postsynaptic neuron
moose.connect( syn, 'activationOut', network.vec[1], 'activation' )
#.........这里部分代码省略.........
def readMorphML(self,cell,params={},lengthUnits="micrometer"):
"""
returns cellDict = { cellname: (segDict, cableDict) } # note: single cell only
where segDict = { segid1 : [ segname,(proximalx,proximaly,proximalz),
(distalx,distaly,distalz),diameter,length,[potential_syn1, ... ] ] , ... }
segname is "<name>_<segid>" because 1) guarantees uniqueness,
& 2) later scripts obtain segid from the compartment's name!
and cableDict = { cablegroupname : [campartment1name, compartment2name, ... ], ... }.
params is dict which can contain, combineSegments and/or createPotentialSynapses,
both boolean.
"""
if lengthUnits in ['micrometer','micron']:
self.length_factor = 1e-6
else:
self.length_factor = 1.0
cellname = cell.attrib["name"]
moose.Neutral('/library') # creates /library in MOOSE tree; elif present, wraps
_logger.info("Loading cell %s into /library ." % cellname)
#~ moosecell = moose.Cell('/library/'+cellname)
#using moose Neuron class - in previous version 'Cell' class Chaitanya
moosecell = moose.Neuron('/library/'+cellname)
self.cellDictBySegmentId[cellname] = [moosecell,{}]
self.cellDictByCableId[cellname] = [moosecell,{}]
self.segDict = {}
if 'combineSegments' in params:
self.combineSegments = params['combineSegments']
else:
self.combineSegments = False
if 'createPotentialSynapses' in params:
self.createPotentialSynapses = params['createPotentialSynapses']
else:
self.createPotentialSynapses = False
_logger.info("readMorphML using combineSegments = %s" % self.combineSegments)
###############################################
#### load cablegroups into a dictionary
self.cablegroupsDict = {}
self.cablegroupsInhomoparamsDict = {}
## Two ways of specifying cablegroups in neuroml 1.x
## <cablegroup>s with list of <cable>s
cablegroups = cell.findall(".//{"+self.mml+"}cablegroup")
for cablegroup in cablegroups:
cablegroupname = cablegroup.attrib['name']
self.cablegroupsDict[cablegroupname] = []
self.cablegroupsInhomoparamsDict[cablegroupname] = []
for cable in cablegroup.findall(".//{"+self.mml+"}cable"):
cableid = cable.attrib['id']
self.cablegroupsDict[cablegroupname].append(cableid)
# parse inhomogenous_params
for inhomogeneous_param in cablegroup.findall(".//{"+self.mml+"}inhomogeneous_param"):
metric = inhomogeneous_param.find(".//{"+self.mml+"}metric")
if metric.text == 'Path Length from root':
inhomoparamname = inhomogeneous_param.attrib['name']
inhomoparamvar = inhomogeneous_param.attrib['variable']
self.cablegroupsInhomoparamsDict[cablegroupname].append(\
(inhomoparamname,inhomoparamvar))
else:
_logger.warning('Only "Path Length from root" metric is '
' supported currently, ignoring %s ' % metric.text
)
## <cable>s with list of <meta:group>s
cables = cell.findall(".//{"+self.mml+"}cable")
for cable in cables:
cableid = cable.attrib['id']
cablegroups = cable.findall(".//{"+self.meta+"}group")
for cablegroup in cablegroups:
cablegroupname = cablegroup.text
if cablegroupname in self.cablegroupsDict:
self.cablegroupsDict[cablegroupname].append(cableid)
else:
self.cablegroupsDict[cablegroupname] = [cableid]
###################################################
## load all mechanisms in this cell into /library for later copying
## set which compartments have integrate_and_fire mechanism
self.intFireCableIds = {} # dict with keys as Compartments/cableIds which are IntFire
# with mechanismnames as values
for mechanism in cell.findall(".//{"+self.bio+"}mechanism"):
mechanismname = mechanism.attrib["name"]
passive = False
if "passive_conductance" in mechanism.attrib:
if mechanism.attrib['passive_conductance'] in ["true",'True','TRUE']:
passive = True
if not passive:
## if channel does not exist in library load it from xml file
if not moose.exists("/library/"+mechanismname):
_logger.info("Loading mechanism %s into library." % mechanismname)
cmlR = ChannelML(self.nml_params)
model_filename = mechanismname+'.xml'
model_path = neuroml_utils.find_first_file(model_filename,self.model_dir)
if model_path is not None:
cmlR.readChannelMLFromFile(model_path)
else:
raise IOError(
'For mechanism {0}: files {1} not found under {2}.'.format(
mechanismname, model_filename, self.model_dir)
)
#.........这里部分代码省略.........
请发表评论