def _buildNeuroMesh(self): comptlist = moose.wildcardFind(self.chemid.path + '/#[ISA=ChemCompt]') sortedComptList = sorted(comptlist, key=lambda x: -x.volume) # A little juggling here to put the chem pathways onto new meshes. self.chemid.name = 'temp_chem' newChemid = moose.Neutral(self.model.path + '/chem') self.dendCompt = moose.NeuroMesh(newChemid.path + '/dend') self.dendCompt.geometryPolicy = 'cylinder' self.dendCompt.separateSpines = 0 if len(sortedComptList) == 3: self.dendCompt.separateSpines = 1 self.spineCompt = moose.SpineMesh(newChemid.path + '/spine') moose.connect(self.dendCompt, 'spineListOut', self.spineCompt, 'spineList') self.psdCompt = moose.PsdMesh(newChemid.path + '/psd') moose.connect(self.dendCompt, 'psdListOut', self.psdCompt, 'psdList', 'OneToOne') #Move the old reac systems onto the new compartments. self._moveCompt(sortedComptList[0], self.dendCompt) if len(sortedComptList) == 3: self._moveCompt(sortedComptList[1], self.spineCompt) self._moveCompt(sortedComptList[2], self.psdCompt) self.dendCompt.diffLength = self.diffusionLength self.dendCompt.subTree = self.cellPortionElist moose.delete(self.chemid) self.chemid = newChemid
def makeModel(): model = moose.Neutral('/model') # Make neuronal model. It has no channels, just for geometry cell = moose.loadModel('./branching.p', '/model/cell', 'Neutral') # We don't want the cell to do any calculations. Disable everything. for i in moose.wildcardFind('/model/cell/##'): i.tick = -1 # create container for model model = moose.element('/model') chem = moose.Neutral('/model/chem') # The naming of the compartments is dicated by the places that the # chem model expects to be loaded. compt0 = moose.NeuroMesh('/model/chem/compt0') compt0.separateSpines = 0 compt0.geometryPolicy = 'cylinder' #reacSystem = moose.loadModel( 'simpleOsc.g', '/model/chem', 'ee' ) makeChemModel(compt0) # Populate all compt with the chem system. compt0.diffLength = 1e-6 # This will be over 100 compartments. # This is the magic command that configures the diffusion compartments. compt0.subTreePath = "/model/cell/#" #compt0.cell = cell # Build the solvers. No need for diffusion in this version. ksolve0 = moose.Ksolve('/model/chem/compt0/ksolve') dsolve0 = moose.Dsolve('/model/chem/compt0/dsolve') stoich0 = moose.Stoich('/model/chem/compt0/stoich') # Configure solvers stoich0.compartment = compt0 stoich0.ksolve = ksolve0 stoich0.dsolve = dsolve0 stoich0.path = '/model/chem/compt0/#' assert (stoich0.numVarPools == 2) assert (stoich0.numProxyPools == 0) assert (stoich0.numRates == 0) moose.element('/model/chem/compt0/a[0]').concInit = aConcInit twigs = findTwigs(compt0) print(('twigs = ', twigs)) for i in twigs: e = moose.element('/model/chem/compt0/b[' + str(i) + ']') e.concInit = bConcInit # Create the output tables graphs = moose.Neutral('/model/graphs') makeTab('a_soma', '/model/chem/compt0/a[0]') makeTab('b_soma', '/model/chem/compt0/b[0]') num = twigs[0] makeTab('a_apical', '/model/chem/compt0/a[' + str(num) + ']') makeTab('b_apical', '/model/chem/compt0/b[' + str(num) + ']')
def loadChem(diffLength): chem = moose.Neutral('/model/chem') neuroCompt = moose.NeuroMesh('/model/chem/kinetics') neuroCompt.separateSpines = 1 neuroCompt.geometryPolicy = 'cylinder' spineCompt = moose.SpineMesh('/model/chem/compartment_1') moose.connect(neuroCompt, 'spineListOut', spineCompt, 'spineList', 'OneToOne') psdCompt = moose.PsdMesh('/model/chem/compartment_2') moose.connect(neuroCompt, 'psdListOut', psdCompt, 'psdList', 'OneToOne') modelId = moose.loadModel('minimal.g', '/model/chem', 'ee') neuroCompt.name = 'dend' spineCompt.name = 'spine' psdCompt.name = 'psd'
def loadChem(diffLength): chem = moose.Neutral('/model/chem') neuroCompt = moose.NeuroMesh('/model/chem/kinetics') neuroCompt.separateSpines = 1 neuroCompt.geometryPolicy = 'cylinder' spineCompt = moose.SpineMesh('/model/chem/compartment_1') moose.connect(neuroCompt, 'spineListOut', spineCompt, 'spineList', 'OneToOne') psdCompt = moose.PsdMesh('/model/chem/compartment_2') #print 'Meshvolume[neuro, spine, psd] = ', neuroCompt.mesh[0].volume, spineCompt.mesh[0].volume, psdCompt.mesh[0].volume moose.connect(neuroCompt, 'psdListOut', psdCompt, 'psdList', 'OneToOne') modelId = moose.loadModel('psd_merged31d.g', '/model/chem', 'ee') neuroCompt.name = 'dend' spineCompt.name = 'spine' psdCompt.name = 'psd'
def _buildNeuroMesh(self): comptlist = moose.wildcardFind(self.chemid.path + '/#[ISA=ChemCompt]') sortedComptList = sorted(comptlist, key=lambda x: -x.volume) self.chemid.name = 'temp_chem' newChemid = moose.Neutral(self.model.path + '/chem') self.dendCompt = moose.NeuroMesh(newChemid.path + '/dend') self.dendCompt.separateSpines = 1 self.dendCompt.geometryPolicy = 'cylinder' self.spineCompt = moose.SpineMesh(newChemid.path + '/spine') moose.connect(self.dendCompt, 'spineListOut', self.spineCompt, 'spineList') self.psdCompt = moose.PsdMesh(newChemid.path + '/psd') moose.connect(self.dendCompt, 'psdListOut', self.psdCompt, 'psdList', 'OneToOne') #Move the old reac systems onto the new compartments. self._moveCompt(sortedComptList[0], self.dendCompt) self._moveCompt(sortedComptList[1], self.spineCompt) self._moveCompt(sortedComptList[2], self.psdCompt) self.dendCompt.diffLength = self.meshLambda #print self.elecid #print self.cellPortion self.dendCompt.cellPortion(self.elecid, self.cellPortion)
def makeModel(): model = moose.Neutral('/model') # Make neuronal model. It has no channels, just for geometry cell = moose.loadModel('./spinyNeuron.p', '/model/cell', 'Neutral') # We don't want the cell to do any calculations. Disable everything. for i in moose.wildcardFind('/model/cell/##'): i.tick = -1 # create container for model model = moose.element('/model') chem = moose.Neutral('/model/chem') # The naming of the compartments is dicated by the places that the # chem model expects to be loaded. compt0 = moose.NeuroMesh('/model/chem/compt0') compt0.separateSpines = 1 compt0.geometryPolicy = 'cylinder' compt1 = moose.SpineMesh('/model/chem/compt1') moose.connect(compt0, 'spineListOut', compt1, 'spineList', 'OneToOne') compt2 = moose.PsdMesh('/model/chem/compt2') moose.connect(compt0, 'psdListOut', compt2, 'psdList', 'OneToOne') #reacSystem = moose.loadModel( 'simpleOsc.g', '/model/chem', 'ee' ) makeChemModel(compt0) # Populate all 3 compts with the chem system. makeChemModel(compt1) makeChemModel(compt2) compt0.diffLength = 2e-6 # This will be over 100 compartments. # This is the magic command that configures the diffusion compartments. compt0.subTreePath = cell.path + "/##" moose.showfields(compt0) # Build the solvers. No need for diffusion in this version. ksolve0 = moose.Ksolve('/model/chem/compt0/ksolve') ksolve1 = moose.Gsolve('/model/chem/compt1/ksolve') ksolve2 = moose.Gsolve('/model/chem/compt2/ksolve') #dsolve0 = moose.Dsolve( '/model/chem/compt0/dsolve' ) #dsolve1 = moose.Dsolve( '/model/chem/compt1/dsolve' ) #dsolve2 = moose.Dsolve( '/model/chem/compt2/dsolve' ) stoich0 = moose.Stoich('/model/chem/compt0/stoich') stoich1 = moose.Stoich('/model/chem/compt1/stoich') stoich2 = moose.Stoich('/model/chem/compt2/stoich') # Configure solvers stoich0.compartment = compt0 stoich1.compartment = compt1 stoich2.compartment = compt2 stoich0.ksolve = ksolve0 stoich1.ksolve = ksolve1 stoich2.ksolve = ksolve2 #stoich0.dsolve = dsolve0 #stoich1.dsolve = dsolve1 #stoich2.dsolve = dsolve2 stoich0.path = '/model/chem/compt0/#' stoich1.path = '/model/chem/compt1/#' stoich2.path = '/model/chem/compt2/#' assert (stoich0.numVarPools == 3) assert (stoich0.numProxyPools == 0) assert (stoich0.numRates == 4) assert (stoich1.numVarPools == 3) assert (stoich1.numProxyPools == 0) #assert( stoich1.numRates == 4 ) assert (stoich2.numVarPools == 3) assert (stoich2.numProxyPools == 0) #assert( stoich2.numRates == 4 ) #dsolve0.buildNeuroMeshJunctions( dsolve1, dsolve2 ) stoich0.buildXreacs(stoich1) stoich1.buildXreacs(stoich2) stoich0.filterXreacs() stoich1.filterXreacs() stoich2.filterXreacs() moose.element('/model/chem/compt2/a[0]').concInit *= 1.5 # Create the output tables num = compt0.numDiffCompts - 1 graphs = moose.Neutral('/model/graphs') makeTab('a_soma', '/model/chem/compt0/a[0]') makeTab('b_soma', '/model/chem/compt0/b[0]') makeTab('a_apical', '/model/chem/compt0/a[' + str(num) + ']') makeTab('b_apical', '/model/chem/compt0/b[' + str(num) + ']') makeTab('a_spine', '/model/chem/compt1/a[5]') makeTab('b_spine', '/model/chem/compt1/b[5]') makeTab('a_psd', '/model/chem/compt2/a[5]') makeTab('b_psd', '/model/chem/compt2/b[5]')
def makeNeuroMeshModel(): makeSpinyCompt() diffLength = moose.element('/n/compt').length diffLength = diffLength / 10.0 elec = moose.element('/n') elec.name = 'elec' model = moose.Neutral('/model') moose.move(elec, model) synInput = moose.element('/model/elec/compt/synInput') synInput.refractT = 47e-3 chem = moose.Neutral('/model/chem') neuroCompt = moose.NeuroMesh('/model/chem/neuroMesh') neuroCompt.separateSpines = 1 neuroCompt.diffLength = diffLength neuroCompt.geometryPolicy = 'cylinder' spineCompt = moose.SpineMesh('/model/chem/spineMesh') moose.connect(neuroCompt, 'spineListOut', spineCompt, 'spineList', 'OneToOne') psdCompt = moose.PsdMesh('/model/chem/psdMesh') moose.connect(neuroCompt, 'psdListOut', psdCompt, 'psdList', 'OneToOne') createChemModel(neuroCompt, spineCompt, psdCompt) # Put in the solvers, see how they fare. nmksolve = moose.GslStoich('/model/chem/neuroMesh/ksolve') nmksolve.path = '/model/chem/neuroMesh/##' nmksolve.compartment = moose.element('/model/chem/neuroMesh') nmksolve.method = 'rk5' nm = moose.element('/model/chem/neuroMesh/mesh') moose.connect(nm, 'remesh', nmksolve, 'remesh') #print "neuron: nv=", nmksolve.numLocalVoxels, ", nav=", nmksolve.numAllVoxels, nmksolve.numVarPools, nmksolve.numAllPools #print 'setting up smksolve' smksolve = moose.GslStoich('/model/chem/spineMesh/ksolve') smksolve.path = '/model/chem/spineMesh/##' smksolve.compartment = moose.element('/model/chem/spineMesh') smksolve.method = 'rk5' sm = moose.element('/model/chem/spineMesh/mesh') moose.connect(sm, 'remesh', smksolve, 'remesh') #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools # #print 'setting up pmksolve' pmksolve = moose.GslStoich('/model/chem/psdMesh/ksolve') pmksolve.path = '/model/chem/psdMesh/##' pmksolve.compartment = moose.element('/model/chem/psdMesh') pmksolve.method = 'rk5' pm = moose.element('/model/chem/psdMesh/mesh') moose.connect(pm, 'remesh', pmksolve, 'remesh') #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools # #print 'Assigning the cell model' # Now to set up the model. neuroCompt.cell = elec ns = neuroCompt.numSegments #assert( ns == 11 ) # dend, 5x (shaft+head) ndc = neuroCompt.numDiffCompts assert (ndc == 10) ndc = neuroCompt.mesh.num assert (ndc == 10) sdc = spineCompt.mesh.num assert (sdc == 5) pdc = psdCompt.mesh.num assert (pdc == 5) # # We need to use the spine solver as the master for the purposes of # these calculations. This will handle the diffusion calculations # between head and dendrite, and between head and PSD. smksolve.addJunction(nmksolve) #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools smksolve.addJunction(pmksolve) #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools # Have to pass a message between the various solvers. foo = moose.vec('/model/chem/spineMesh/headGluR') # oddly, numLocalFields does not work. ca = moose.element('/model/chem/neuroMesh/Ca') assert (ca.lastDimension == ndc) moose.vec('/model/chem/spineMesh/headGluR').nInit = 100 moose.vec('/model/chem/psdMesh/psdGluR').nInit = 0 # set up adaptors aCa = moose.Adaptor('/model/chem/spineMesh/adaptCa', 5) adaptCa = moose.vec('/model/chem/spineMesh/adaptCa') chemCa = moose.vec('/model/chem/spineMesh/Ca') assert (len(adaptCa) == 5) for i in range(5): path = '/model/elec/head' + str(i) + '/ca' elecCa = moose.element(path) moose.connect(elecCa, 'concOut', adaptCa[i], 'input', 'Single') moose.connect(adaptCa, 'outputSrc', chemCa, 'setConc', 'OneToOne') adaptCa.outputOffset = 0.0001 # 100 nM offset in chem. adaptCa.scale = 0.05 # 0.06 to 0.003 mM aGluR = moose.Adaptor('/model/chem/psdMesh/adaptGluR', 5) adaptGluR = moose.vec('/model/chem/psdMesh/adaptGluR') chemR = moose.vec('/model/chem/psdMesh/psdGluR') assert (len(adaptGluR) == 5) for i in range(5): path = '/model/elec/head' + str(i) + '/gluR' elecR = moose.element(path) moose.connect(adaptGluR[i], 'outputSrc', elecR, 'setGbar', 'Single') #moose.connect( chemR, 'nOut', adaptGluR, 'input', 'OneToOne' ) # Ksolve isn't sending nOut. Not good. So have to use requestOut. moose.connect(adaptGluR, 'requestOut', chemR, 'getN', 'OneToOne') adaptGluR.outputOffset = 1e-7 # pS adaptGluR.scale = 1e-6 / 100 # from n to pS adaptK = moose.Adaptor('/model/chem/neuroMesh/adaptK') chemK = moose.element('/model/chem/neuroMesh/kChan') elecK = moose.element('/model/elec/compt/K') moose.connect(adaptK, 'requestOut', chemK, 'getConc', 'OneToAll') moose.connect(adaptK, 'outputSrc', elecK, 'setGbar', 'Single') adaptK.scale = 0.3 # from mM to Siemens """
def makeModel(): numSeg = 5 diffConst = 0.0 # create container for model model = moose.Neutral('model') compt0 = moose.NeuroMesh('/model/compt0') compt0.separateSpines = 1 compt0.geometryPolicy = 'cylinder' compt1 = moose.SpineMesh('/model/compt1') moose.connect(compt0, 'spineListOut', compt1, 'spineList', 'OneToOne') compt2 = moose.PsdMesh('/model/compt2') moose.connect(compt0, 'psdListOut', compt2, 'psdList', 'OneToOne') # create molecules and reactions a = moose.Pool('/model/compt0/a') b = moose.Pool('/model/compt1/b') c = moose.Pool('/model/compt2/c') reac0 = moose.Reac('/model/compt0/reac0') reac1 = moose.Reac('/model/compt1/reac1') # connect them up for reactions moose.connect(reac0, 'sub', a, 'reac') moose.connect(reac0, 'prd', b, 'reac') moose.connect(reac1, 'sub', b, 'reac') moose.connect(reac1, 'prd', c, 'reac') # Assign parameters a.diffConst = diffConst b.diffConst = diffConst c.diffConst = diffConst a.concInit = 1 b.concInit = 12.1 c.concInit = 1 reac0.Kf = 1 reac0.Kb = 1 reac1.Kf = 1 reac1.Kb = 1 # Create a 'neuron' with a dozen spiny compartments. elec = makeNeuron(numSeg) # assign geometry to mesh compt0.diffLength = 10e-6 #compt0.cell = elec compt0.subTreePath = elec.path + "/##" # Build the solvers. No need for diffusion in this version. ksolve0 = moose.Ksolve('/model/compt0/ksolve') ksolve1 = moose.Ksolve('/model/compt1/ksolve') ksolve2 = moose.Ksolve('/model/compt2/ksolve') stoich0 = moose.Stoich('/model/compt0/stoich') stoich1 = moose.Stoich('/model/compt1/stoich') stoich2 = moose.Stoich('/model/compt2/stoich') # Configure solvers stoich0.compartment = compt0 stoich1.compartment = compt1 stoich2.compartment = compt2 stoich0.ksolve = ksolve0 stoich1.ksolve = ksolve1 stoich2.ksolve = ksolve2 stoich0.path = '/model/compt0/#' stoich1.path = '/model/compt1/#' stoich2.path = '/model/compt2/#' assert (stoich0.numVarPools == 1) assert (stoich0.numProxyPools == 1) assert (stoich0.numRates == 1) assert (stoich1.numVarPools == 1) assert (stoich1.numProxyPools == 1) assert (stoich1.numRates == 1) assert (stoich2.numVarPools == 1) assert (stoich2.numProxyPools == 0) assert (stoich2.numRates == 0) stoich0.buildXreacs(stoich1) stoich1.buildXreacs(stoich2) stoich0.filterXreacs() stoich1.filterXreacs() stoich2.filterXreacs() print((a.vec.volume, b.vec.volume, c.vec.volume)) a.vec.concInit = list(range(numSeg + 1, 0, -1)) b.vec.concInit = [5.0 * (1 + x) for x in range(numSeg)] c.vec.concInit = list(range(1, numSeg + 1)) print((a.vec.concInit, b.vec.concInit, c.vec.concInit)) # Create the output tables graphs = moose.Neutral('/model/graphs') outputA = moose.Table2('/model/graphs/concA') outputB = moose.Table2('/model/graphs/concB') outputC = moose.Table2('/model/graphs/concC') # connect up the tables a1 = moose.element('/model/compt0/a[' + str(numSeg) + ']') b1 = moose.element('/model/compt1/b[' + str(numSeg - 1) + ']') c1 = moose.element('/model/compt2/c[' + str(numSeg - 1) + ']') moose.connect(outputA, 'requestOut', a1, 'getConc') moose.connect(outputB, 'requestOut', b1, 'getConc') moose.connect(outputC, 'requestOut', c1, 'getConc')
def makeChemModel( cellId ): # create container for model r0 = 1e-6 # m r1 = 1e-6 # m num = 2800 diffLength = 1e-6 # m diffConst = 5e-12 # m^2/sec motorRate = 1e-6 # m/sec concA = 1 # millimolar model = moose.element( '/model' ) compartment = moose.NeuroMesh( '/model/compartment' ) # FIXME: No attribute cell compartment.cell = cellId compartment.diffLength = diffLength print(("cell NeuroMesh parameters: numSeg and numDiffCompt: ", compartment.numSegments, compartment.numDiffCompts)) print(("compartment.numDiffCompts == num: ", compartment.numDiffCompts, num)) assert( compartment.numDiffCompts == num ) # create molecules and reactions a = moose.Pool( '/model/compartment/a' ) b = moose.Pool( '/model/compartment/b' ) s = moose.Pool( '/model/compartment/s' ) e1 = moose.MMenz( '/model/compartment/e1' ) e2 = moose.MMenz( '/model/compartment/e2' ) e3 = moose.MMenz( '/model/compartment/e3' ) r1 = moose.Reac( '/model/compartment/r1' ) moose.connect( e1, 'sub', s, 'reac' ) moose.connect( e1, 'prd', a, 'reac' ) moose.connect( a, 'nOut', e1, 'enzDest' ) e1.Km = 1 e1.kcat = 1 moose.connect( e2, 'sub', s, 'reac' ) moose.connect( e2, 'prd', b, 'reac' ) moose.connect( a, 'nOut', e2, 'enzDest' ) e2.Km = 1 e2.kcat = 0.5 moose.connect( e3, 'sub', a, 'reac' ) moose.connect( e3, 'prd', s, 'reac' ) moose.connect( b, 'nOut', e3, 'enzDest' ) e3.Km = 0.1 e3.kcat = 1 moose.connect( r1, 'sub', b, 'reac' ) moose.connect( r1, 'prd', s, 'reac' ) r1.Kf = 0.3 # 1/sec r1.Kb = 0 # 1/sec # Assign parameters a.diffConst = diffConst/10 b.diffConst = diffConst s.diffConst = 0 #b.motorConst = motorRate # Make solvers ksolve = moose.Ksolve( '/model/compartment/ksolve' ) dsolve = moose.Dsolve( '/model/compartment/dsolve' ) stoich = moose.Stoich( '/model/compartment/stoich' ) stoich.compartment = compartment #ksolve.numAllVoxels = compartment.numDiffCompts stoich.ksolve = ksolve stoich.dsolve = dsolve stoich.path = "/model/compartment/##" assert( dsolve.numPools == 3 ) a.vec.concInit = [0.1]*num a.vec[0].concInit += 0.5 a.vec[400].concInit += 0.5 a.vec[800].concInit += 0.5 a.vec[1200].concInit += 0.5 a.vec[1600].concInit += 0.5 a.vec[2000].concInit += 0.5 a.vec[2400].concInit += 0.5 #a.vec[num/2].concInit -= 0.1 b.vec.concInit = [0.1]*num s.vec.concInit = [1]*num
def makeNeuroMeshModel(): diffLength = 20e-6 # But we only want diffusion over part of the model. numSyn = 13 elec = loadElec() synInput = moose.SpikeGen('/model/elec/synInput') synInput.refractT = 47e-3 synInput.threshold = -1.0 synInput.edgeTriggered = 0 synInput.Vm(0) synInput.refractT = 47e-3 for i in range(numSyn): name = '/model/elec/spine_head_14_' + str(i + 1) r = moose.element(name + '/glu') r.synapse.num = 1 syn = moose.element(r.path + '/synapse') moose.connect(synInput, 'spikeOut', syn, 'addSpike', 'Single') syn.weight = 0.2 * i * (numSyn - 1 - i) syn.delay = i * 1.0e-3 neuroCompt = moose.NeuroMesh('/model/neuroMesh') #print 'neuroMeshvolume = ', neuroCompt.mesh[0].volume neuroCompt.separateSpines = 1 neuroCompt.diffLength = diffLength neuroCompt.geometryPolicy = 'cylinder' spineCompt = moose.SpineMesh('/model/spineMesh') #print 'spineMeshvolume = ', spineCompt.mesh[0].volume moose.connect(neuroCompt, 'spineListOut', spineCompt, 'spineList', 'OneToOne') psdCompt = moose.PsdMesh('/model/psdMesh') #print 'psdMeshvolume = ', psdCompt.mesh[0].volume moose.connect(neuroCompt, 'psdListOut', psdCompt, 'psdList', 'OneToOne') loadChem(neuroCompt, spineCompt, psdCompt) # Put in the solvers, see how they fare. nmksolve = moose.GslStoich('/model/chem/neuroMesh/ksolve') nmksolve.path = '/model/chem/neuroMesh/##' nmksolve.compartment = moose.element('/model/chem/neuroMesh') nmksolve.method = 'rk5' nm = moose.element('/model/chem/neuroMesh/mesh') moose.connect(nm, 'remesh', nmksolve, 'remesh') #print "neuron: nv=", nmksolve.numLocalVoxels, ", nav=", nmksolve.numAllVoxels, nmksolve.numVarPools, nmksolve.numAllPools #print 'setting up smksolve' smksolve = moose.GslStoich('/model/chem/spineMesh/ksolve') smksolve.path = '/model/chem/spineMesh/##' smksolve.compartment = moose.element('/model/chem/spineMesh') smksolve.method = 'rk5' sm = moose.element('/model/chem/spineMesh/mesh') moose.connect(sm, 'remesh', smksolve, 'remesh') #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools # #print 'setting up pmksolve' pmksolve = moose.GslStoich('/model/chem/psdMesh/ksolve') pmksolve.path = '/model/chem/psdMesh/##' pmksolve.compartment = moose.element('/model/chem/psdMesh') pmksolve.method = 'rk5' pm = moose.element('/model/chem/psdMesh/mesh') moose.connect(pm, 'remesh', pmksolve, 'remesh') #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools # print('neuroMeshvolume = ', neuroCompt.mesh[0].volume) #print 'Assigning the cell model' # Now to set up the model. #neuroCompt.cell = elec neuroCompt.cellPortion( elec, '/model/elec/lat_14_#,/model/elec/spine_neck#,/model/elec/spine_head#') """ ns = neuroCompt.numSegments #assert( ns == 11 ) # dend, 5x (shaft+head) ndc = neuroCompt.numDiffCompts #print 'numDiffCompts = ', ndc assert( ndc == 145 ) ndc = neuroCompt.mesh.num #print 'NeuroMeshNum = ', ndc assert( ndc == 145 ) sdc = spineCompt.mesh.num #print 'SpineMeshNum = ', sdc assert( sdc == 13 ) pdc = psdCompt.mesh.num #print 'PsdMeshNum = ', pdc assert( pdc == 13 ) """ mesh = moose.vec('/model/chem/neuroMesh/mesh') #for i in range( ndc ): # print 's[', i, '] = ', mesh[i].volume mesh2 = moose.vec('/model/chem/spineMesh/mesh') # for i in range( sdc ): # print 's[', i, '] = ', mesh2[i].volume #print 'numPSD = ', moose.element( '/model/chem/psdMesh/mesh' ).localNumField mesh = moose.vec('/model/chem/psdMesh/mesh') #print 'psd mesh.volume = ', mesh.volume #for i in range( pdc ): # print 's[', i, '] = ', mesh[i].volume # # We need to use the spine solver as the master for the purposes of # these calculations. This will handle the diffusion calculations # between head and dendrite, and between head and PSD. smksolve.addJunction(nmksolve) #print "spine: nv=", smksolve.numLocalVoxels, ", nav=", smksolve.numAllVoxels, smksolve.numVarPools, smksolve.numAllPools smksolve.addJunction(pmksolve) #print "psd: nv=", pmksolve.numLocalVoxels, ", nav=", pmksolve.numAllVoxels, pmksolve.numVarPools, pmksolve.numAllPools ndc = neuroCompt.numDiffCompts #print 'numDiffCompts = ', ndc assert (ndc == 13) ndc = neuroCompt.mesh.num #print 'NeuroMeshNum = ', ndc assert (ndc == 13) sdc = spineCompt.mesh.num #print 'SpineMeshNum = ', sdc assert (sdc == 13) pdc = psdCompt.mesh.num #print 'PsdMeshNum = ', pdc assert (pdc == 13) """ print 'neuroCompt' for i in range( ndc ): print i, neuroCompt.stencilIndex[i] print i, neuroCompt.stencilRate[i] print 'spineCompt' for i in range( sdc * 3 ): print i, spineCompt.stencilIndex[i] print i, spineCompt.stencilRate[i] print 'psdCompt' for i in range( pdc ): print i, psdCompt.stencilIndex[i] print i, psdCompt.stencilRate[i] print 'Spine parents:' pavoxel = spineCompt.parentVoxel for i in range( sdc ): print i, pavoxel[i] """ # oddly, numLocalFields does not work. #moose.le( '/model/chem/neuroMesh' ) ca = moose.element('/model/chem/neuroMesh/DEND/Ca') assert (ca.lastDimension == ndc) """ CaNpsd = moose.vec( '/model/chem/psdMesh/PSD/PP1_PSD/CaN' ) print 'numCaN in PSD = ', CaNpsd.nInit, ', vol = ', CaNpsd.volume CaNspine = moose.vec( '/model/chem/spineMesh/SPINE/CaN_BULK/CaN' ) print 'numCaN in spine = ', CaNspine.nInit, ', vol = ', CaNspine.volume """ # set up adaptors aCa = moose.Adaptor('/model/chem/psdMesh/adaptCa', pdc) adaptCa = moose.vec('/model/chem/psdMesh/adaptCa') chemCa = moose.vec('/model/chem/psdMesh/PSD/Ca') assert (len(adaptCa) == pdc) assert (len(chemCa) == pdc) for i in range(pdc): path = '/model/elec/spine_head_14_' + str(i + 1) + '/NMDA_Ca_conc' elecCa = moose.element(path) moose.connect(elecCa, 'concOut', adaptCa[i], 'input', 'Single') moose.connect(adaptCa, 'outputSrc', chemCa, 'setConc', 'OneToOne') adaptCa.inputOffset = 0.0 # adaptCa.outputOffset = 80e-6 # 80 nM offset in chem. adaptCa.scale = 1e-5 # 520 to 0.0052 mM
def makeModel(): model = moose.Neutral('/model') # Make neuronal model. It has no channels, just for geometry cell = moose.loadModel('./spinyNeuron.p', '/model/cell', 'Neutral') # We don't want the cell to do any calculations. Disable everything. for i in moose.wildcardFind('/model/cell/##'): i.tick = -1 # create container for model model = moose.element('/model') chem = moose.Neutral('/model/chem') # The naming of the compartments is dicated by the places that the # chem model expects to be loaded. compt0 = moose.NeuroMesh('/model/chem/compt0') compt0.separateSpines = 1 compt0.geometryPolicy = 'cylinder' compt1 = moose.SpineMesh('/model/chem/compt1') moose.connect(compt0, 'spineListOut', compt1, 'spineList', 'OneToOne') compt2 = moose.PsdMesh('/model/chem/compt2') moose.connect(compt0, 'psdListOut', compt2, 'psdList', 'OneToOne') #reacSystem = moose.loadModel( 'simpleOsc.g', '/model/chem', 'ee' ) makeChemModel(compt0, True) # Populate all 3 compts with the chem system. makeChemModel(compt1, False) makeChemModel(compt2, True) compt0.diffLength = 2e-6 # This will be over 100 compartments. # This is the magic command that configures the diffusion compartments. compt0.cell = cell moose.showfields(compt0) # Build the solvers. No need for diffusion in this version. ksolve0 = moose.Ksolve('/model/chem/compt0/ksolve') if useGssa: ksolve1 = moose.Gsolve('/model/chem/compt1/ksolve') ksolve2 = moose.Gsolve('/model/chem/compt2/ksolve') else: ksolve1 = moose.Ksolve('/model/chem/compt1/ksolve') ksolve2 = moose.Ksolve('/model/chem/compt2/ksolve') dsolve0 = moose.Dsolve('/model/chem/compt0/dsolve') dsolve1 = moose.Dsolve('/model/chem/compt1/dsolve') dsolve2 = moose.Dsolve('/model/chem/compt2/dsolve') stoich0 = moose.Stoich('/model/chem/compt0/stoich') stoich1 = moose.Stoich('/model/chem/compt1/stoich') stoich2 = moose.Stoich('/model/chem/compt2/stoich') # Configure solvers stoich0.compartment = compt0 stoich1.compartment = compt1 stoich2.compartment = compt2 stoich0.ksolve = ksolve0 stoich1.ksolve = ksolve1 stoich2.ksolve = ksolve2 stoich0.dsolve = dsolve0 stoich1.dsolve = dsolve1 stoich2.dsolve = dsolve2 stoich0.path = '/model/chem/compt0/#' stoich1.path = '/model/chem/compt1/#' stoich2.path = '/model/chem/compt2/#' assert (stoich0.numVarPools == 1) assert (stoich0.numProxyPools == 0) assert (stoich0.numRates == 1) assert (stoich1.numVarPools == 1) assert (stoich1.numProxyPools == 0) if useGssa: assert (stoich1.numRates == 2) assert (stoich2.numRates == 2) else: assert (stoich1.numRates == 1) assert (stoich2.numRates == 1) assert (stoich2.numVarPools == 1) assert (stoich2.numProxyPools == 0) dsolve0.buildNeuroMeshJunctions(dsolve1, dsolve2) stoich0.buildXreacs(stoich1) stoich1.buildXreacs(stoich2) stoich0.filterXreacs() stoich1.filterXreacs() stoich2.filterXreacs() Ca_input_dend = moose.vec('/model/chem/compt0/Ca_input') print len(Ca_input_dend) for i in range(60): Ca_input_dend[3 + i * 3].conc = 2.0 Ca_input_PSD = moose.vec('/model/chem/compt2/Ca_input') print len(Ca_input_PSD) for i in range(5): Ca_input_PSD[2 + i * 2].conc = 1.0 # Create the output tables num = compt0.numDiffCompts - 1 graphs = moose.Neutral('/model/graphs') makeTab('Ca_soma', '/model/chem/compt0/Ca[0]') makeTab('Ca_d1', '/model/chem/compt0/Ca[1]') makeTab('Ca_d2', '/model/chem/compt0/Ca[2]') makeTab('Ca_d3', '/model/chem/compt0/Ca[3]') makeTab('Ca_s3', '/model/chem/compt1/Ca[3]') makeTab('Ca_s4', '/model/chem/compt1/Ca[4]') makeTab('Ca_s5', '/model/chem/compt1/Ca[5]') makeTab('Ca_p3', '/model/chem/compt2/Ca[3]') makeTab('Ca_p4', '/model/chem/compt2/Ca[4]') makeTab('Ca_p5', '/model/chem/compt2/Ca[5]')