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 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