def makeModel(): moose.Neutral('/library') # Here we illustrate building the chem proto directly. This is not # good practice as it takes the model definition away from the # declaration of prototypes. makeChemProto('cProto') rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ meshLambda = 1e-6, \ cellProto = [['makeCellProto()', 'elec' ]] ,\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spineSpacing', str( spineSpacing ), \ 'spineSpacingDistrib', str( spineSpacingDistrib ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', 0, 2e-9 ], \ ] \ ) rdes.buildModel('/model')
def makeModel(): moose.Neutral('/library') makeCellProto('cellProto') makeChemProto('cProto') makeSpineProto2('spine') rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ stealCellFromLibrary = True, \ meshLambda = 1e-6, \ cellProto = [['cellProto', 'elec' ]] ,\ spineProto = [['spineProto', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( spineSpacingDistrib ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', False, 0, 2e-9 ], \ ] \ ) rdes.buildModel('/model')
def makeModel(): moose.Neutral('/library') makeCellProto('cellProto') makeChemProto() #moose.SBML.readSBML('/home/vinu/Documents/Biophysics/new_mod/detailed_models/oct01_volScale/mv1.xml','/model') rdes = rd.rdesigneur( useGssa=False, turnOffElec=True, chemDt=0.01, diffDt=0.01, chemPlotDt=0.1, combineSegments=False, stealCellFromLibrary=True, diffusionLength=50e-9, cellProto=[['cellProto', 'elec']], chemProto=[['hydra', 'chem']], chemDistrib=[["chem", "#", "install", "1"]] #plotList = [ #['psd/z', '1', '.', 'n', 'z n' ] #['psd/z', '1', '.', 'n', 'z n' ] #], ) moose.seed(100) rdes.buildModel('/model') moose.element('/model/chem/dend/Rad').nInit = 30e-9 ## moose.element('/model/chem/dend/stoich').allowNegative=1 print 'built model'
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_()
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_()
def test(): makeFuncRate() rdes = rd.rdesigneur( turnOffElec=True, #This subdivides the 50-micron cylinder into 2 micron voxels diffusionLength=2e-6, cellProto=[['somaProto', 'soma', 5e-6, 50e-6]], chemProto=[['chem', 'chem']], chemDistrib=[['chem', 'soma', 'install', '1']], plotList=[['soma', '1', 'dend/A', 'conc', 'A conc', 'wave'], ['soma', '1', 'dend/C', 'conc', 'C conc', 'wave']], ) rdes.buildModel() C = moose.element('/model/chem/dend/C') C.vec.concInit = [1 + np.sin(x / 5.0) for x in range(len(C.vec))] moose.reinit() moose.start(10) if plot_: rdes.display() ts = moose.wildcardFind('/##[TYPE=Table2]') mat = [] for t in ts: if 'plot1' in t.path: mat.append(t.vector) mat = np.matrix(mat) exMean, exStd = 1.1619681711817156, 0.6944155817587526 assert np.isclose(np.mean(mat), exMean), mp.mean(mat) assert np.isclose(np.std(mat), exStd), mp.std(mat) assert (np.isclose(np.mean(mat, axis=0), exMean).all()) assert (np.isclose(np.std(mat, axis=0), exStd).all()) assert (np.isclose(0.0, np.std(mat, axis=1)).all())
def makeModel(): cd = [ ['glu', 'soma', 'Gbar', str(gluGbar)], ['GABA', 'soma', 'Gbar', str(gabaGbar)], ['K_A', 'soma', 'Gbar', str(K_A_Gbar)] ] cd.extend( spikingDistrib ) rdes = rd.rdesigneur( elecPlotDt = elecPlotDt, stealCellFromLibrary = True, verbose = False, chanProto = [ ['make_glu()', 'glu'],['make_GABA()', 'GABA'], ['make_K_A()','K_A'], ['make_Na()', 'Na'],['make_K_DR()', 'K_DR'], ], cellProto = [['somaProto', 'cellBase', dia, dia]], passiveDistrib = [[ '#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA) ]], chanDistrib = cd, stimList = [ ['soma', '1','glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, gluOnset, gluOnset + inputDuration) ], ['soma', '1','GABA', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, gabaOnset, gabaOnset + inputDuration) ], ], plotList = [['soma', '1','.', 'Vm']], ) moose.element( '/library/GABA' ).Ek = -0.07 rdes.buildModel()
def makeModel(): moose.Neutral('/library') makeCellProto('cellProto') makeChemProto('cProto') rdes = rd.rdesigneur( useGssa=False, turnOffElec=True, chemDt=0.1, diffDt=0.1, combineSegments=False, stealCellFromLibrary=True, diffusionLength=1e-6, cellProto=[['cellProto', 'elec']], spineProto=[['makePassiveSpine()', 'spine']], chemProto=[['cProto', 'chem']], spineDistrib=[[ 'spine', '#', str(spineSpacing), str(spineSpacingDistrib), str(spineSize), str(spineSizeDistrib), str(spineAngle), str(spineAngleDistrib) ]], chemDistrib=[["chem", "#dend#,#psd#", "install", "1"]], adaptorList=[ ['psd/z', 'n', 'spine', 'psdArea', 50.0e-15, 500e-15], ]) moose.seed(1234) rdes.buildModel('/model') print('built model') x = moose.vec('/model/chem/dend/x') x.concInit = 0.0 for i in range(0, 20): x[i].concInit = concInit
def test_proto(): # Boilerplate rdes = rd.rdesigneur( elecPlotDt = elecPlotDt, elecDt = elecDt, cellProto = [['somaProto', 'soma', sm_diam, sm_len]], chanProto = [[ str(sdir_ / 'Na_Chan_Migliore2018_.Na_Chan()'), 'Na']], chanDistrib = [ ['Na', 'soma', 'Gbar', '360'] ], passiveDistrib = [ ['#', 'RM', str(RM), 'CM', str(CM), 'initVm', str(Vrest), 'Em', str(Vrest)], ], stimList = [['soma', '1', '.', 'vclamp', '-0.065 + (t>0.1 && t<0.2) * 0.02' ]], plotList = [ ['soma', '1', '.', 'Vm', 'Soma membrane potential'], ['soma', '1', 'vclamp', 'current', 'Soma holding current'], ] ) rdes.buildModel() print('rdes is built') if moose.exists('/model/elec/soma/vclamp'): moose.element( '/model/elec/soma/vclamp' ).gain = CM*sm_area/elecDt moose.element( '/model/elec/soma/vclamp' ).tau = 5*elecDt moose.element( '/model/elec/soma/vclamp' ).ti = elecDt*2 moose.element( '/model/elec/soma/vclamp' ).td = 0 moose.reinit() print('[INFO] Reinit') moose.start( 0.3 ) rdes.display()
def buildRdesigneur(): ################################################################## # Here we define which prototypes are to be loaded in to the system. # Each specification has the format # source [localName] # source can be any of # filename.extension, # Identify type of file by extension, load it. # function(), # func( name ) builds object of specified name # file.py:function() , # load Python file, run function(name) in it. # moose.Classname # Make obj moose.Classname, assign to name. # path # Already loaded into library or on path. # After loading the prototypes, there should be an object called 'name' # in the library. ################################################################## spineProto = [ \ ['makeSpineProto()', 'spine' ] ] ################################################################## # Here we define what goes where, and any parameters. Each distribution # has the format # protoName, path, field, expr, [field, expr]... # where # protoName identifies the prototype to be placed on the cell # path is a MOOSE wildcard path specifying where to put things # field is the field to assign. # expr is a math expression to define field value. This uses the # muParser. Built-in variables are p, g, L, len, dia. # The muParser provides most math functions, and the Heaviside # function H(x) = 1 for x > 0 is also provided. ################################################################## passiveDistrib = [ [ ".", "#", "RM", "2.8", "CM", "0.01", "RA", "1.5", \ "Em", "-58e-3", "initVm", "-65e-3" ], \ [ ".", "#axon#", "RA", "0.5" ] \ ] spineDistrib = [ \ ["spine", '#apical#', "spineSpacing", "20e-6", \ "spineSpacingDistrib", "2e-6", \ "angle", "0", \ "angleDistrib", str( 2*PI ), \ "size", "1", \ "sizeDistrib", "0.5" ] \ ] ###################################################################### # Having defined everything, now to create the rdesigneur and proceed # with creating the model. ###################################################################### rdes = rd.rdesigneur( combineSegments = combineSegments, \ stealCellFromLibrary = True, \ passiveDistrib = passiveDistrib, \ spineDistrib = spineDistrib, \ spineProto = spineProto \ ) return rdes
def main(): ######## Put your favourite cell model here ###### ##This one is from PMID 19146814: Peng et al Neuron 2009 filename = 'cells/K-18.CNG.swc' moose.Neutral( '/library' ) rdes = rd.rdesigneur( \ cellProto = [[ filename, 'elec' ] ],\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spacing', spineSpacing, \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ] \ ) rdes.buildModel('/model') moose.reinit() compts = moose.wildcardFind( "/model/elec/#[ISA=CompartmentBase]" ) compts[0].inject = inject ################## Now we set up the display ######################## print "Setting Up 3D Display" app = QtGui.QApplication(sys.argv) vm_viewer = create_vm_viewer(rdes) vm_viewer.showMaximized() vm_viewer.start() return app.exec_()
def makeModel(): spineAngle = numpy.pi / 2.0 spineAngleDistrib = 0.0 moose.Neutral('/library') makeCellProto('cellProto') makeChemProto('cProto') makeSpineProto2('spine') rdes = rd.rdesigneur( elecDt = 50e-6, chemDt = 5e-3, useGssa = False, \ combineSegments = False, \ stealCellFromLibrary = True, \ diffusionLength = 1e-6, \ cellProto = [['cellProto', 'elec' ]] ,\ spineProto = [['spineProto', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', str( spineSpacing ), str( spineSpacingDistrib ), str( spineSize ), str( spineSizeDistrib ), str( spineAngle ), str( spineAngleDistrib ) ] ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', False, 0, 2e-9 ], \ ] \ ) rdes.buildModel('/model')
def main(): library = moose.Neutral('/library') #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] ) makeDendProto() makeChemProto() rdes = rd.rdesigneur( turnOffElec=True, chemPlotDt=0.1, diffusionLength=params['diffusionL'], #cellProto=[['cell','soma']], cellProto=[['elec', 'dend']], chemProto=[['hydra', 'hydra']], chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']], plotList=[ ['soma', '1', 'dend/A', 'n', '# of A'], ['soma', '1', 'dend/B', 'n', '# of B'], ], # moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']] ) moose.le('/library') moose.le('/library/hydra') #moose.showfield( '/library/soma/soma' ) rdes.buildModel() #moose.element('/model/chem/dend/B').vec[50].nInit=15.5 A = moose.element('/model/chem/dend/A') B = moose.element('/model/chem/dend/B') C = moose.element('/model/chem/dend/C') A.diffConst = 1e-13 B.diffConst = 50 * 1e-12 C.diffConst = 0.8 * 1e-12 avec = moose.vec('/model/chem/dend/A').n savec = avec.size randper = np.random.uniform(1, 2, savec) #for i in range(0,savec-1,1): #moose.element('/model/chem/dend/A').vec[i].nInit = randper[i] moose.element('/model/chem/dend/A').vec[50].nInit = 100 moose.element('/model/chem/dend/B').vec[50].nInit = 100 moose.element('/model/chem/dend/C').vec.nInit = 0 storeAvec = [] storeBvec = [] storeCvec = [] moose.reinit() for i in range(1, 4000, 10): moose.start(10) avec = moose.vec('/model/chem/dend/A').n bvec = moose.vec('/model/chem/dend/B').n cvec = moose.vec('/model/chem/dend/C').n storeAvec.append(avec) storeBvec.append(bvec) storeCvec.append(cvec) trialNum = '1' fileName = 'mechano.xml' writeXML(storeAvec, trialNum, fileName) return storeAvec, storeBvec, storeCvec
def loadModel(filename, chanProto, chanDistrib, passiveDistrib): """Load the model and insert channels """ global modelName global nchans, ncompts # Load in the swc file. modelName = "elec" cellProto = [ ( filename, modelName ) ] rdes = rd.rdesigneur( cellProto = cellProto , combineSegments = True , passiveDistrib = passiveDistrib , chanProto = chanProto , chanDistrib = chanDistrib ) rdes.buildModel('/model') compts = moose.wildcardFind( "/model/%s/#[ISA=CompartmentBase]"%modelName ) setupStimuls( compts[0] ) for compt in compts: vtab = moose.Table( '%s/vm' % compt.path ) moose.connect( vtab, 'requestOut', compt, 'getVm' ) _records[compt.path] = vtab nchans = len(set([x.path for x in moose.wildcardFind('/model/elec/##[TYPE=ZombieHHChannel]')]) ) _logger.info("Total channels: %s" % nchans) return _records
def main(): ######## Put your favourite cell model here ###### ##This one is from PMID 19146814: Peng et al Neuron 2009 filename = 'cells/K-18.CNG.swc' moose.Neutral('/library') rdes = rd.rdesigneur( \ cellProto = [[ filename, 'elec' ] ],\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spacing', spineSpacing, \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ] \ ) rdes.buildModel('/model') moose.reinit() compts = moose.wildcardFind("/model/elec/#[ISA=CompartmentBase]") compts[0].inject = inject ################## Now we set up the display ######################## print("Setting Up 3D Display") app = QtGui.QApplication(sys.argv) vm_viewer = create_vm_viewer(rdes) vm_viewer.showMaximized() vm_viewer.start() return app.exec_()
def makeModel(): spineAngle= numpy.pi / 2.0 spineAngleDistrib = 0.0 moose.Neutral( '/library' ) makeCellProto( 'cellProto' ) makeChemProto( 'cProto' ) makeSpineProto2( 'spine' ) rdes = rd.rdesigneur( elecDt = 50e-6, chemDt = 5e-3, useGssa = False, \ combineSegments = False, \ stealCellFromLibrary = True, \ diffusionLength = 1e-6, \ cellProto = [['cellProto', 'elec' ]] ,\ spineProto = [['spineProto', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', str( spineSpacing ), str( spineSpacingDistrib ), str( spineSize ), str( spineSizeDistrib ), str( spineAngle ), str( spineAngleDistrib ) ] ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', False, 0, 2e-9 ], \ ] \ ) rdes.buildModel( '/model' )
def makeModel(): moose.Neutral( '/library' ) makeCellProto( 'cellProto' ) makeChemProto( 'cProto' ) makeSpineProto2( 'spine' ) rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ stealCellFromLibrary = True, \ meshLambda = 1e-6, \ cellProto = [['cellProto', 'elec' ]] ,\ spineProto = [['spineProto', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( spineSpacingDistrib ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', False, 0, 2e-9 ], \ ] \ ) rdes.buildModel( '/model' )
def makeModel(): segLen = length / numDendSeg rdes = rd.rdesigneur( stealCellFromLibrary = True, elecPlotDt = elecPlotDt, verbose = False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto = [['ballAndStick', 'soma', dia, segLen, dia, length,numDendSeg]], chanProto = [['make_glu()', 'glu'],['make_NMDA()', 'nmda']], passiveDistrib = [[ '#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA) ]], chanDistrib = [ ['glu', 'dend10,dend20,dend30,dend40', 'Gbar', str(gluGbar)], ['nmda', 'dend10,dend20,dend30,dend40', 'Gbar', str(nmdaGbar)], ], stimList = [ ['dend10', '1','glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[0].onset, rec[0].onset + inputDuration) ], ['dend20', '1','glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[1].onset, rec[1].onset + inputDuration) ], ['dend30', '1','glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[2].onset, rec[2].onset + inputDuration) ], ['dend40', '1','glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[3].onset, rec[3].onset + inputDuration) ], ], plotList = [['soma,dend10,dend20,dend30,dend40', '1', '.', 'Vm' ]], ) rdes.buildModel() #for i in moose.wildcardFind( '/model/elec/dend#/glu/sh/synapse/synInput_rs' ): #i.refractT = 0.0 moose.connect( '/model/elec/dend10/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend10/nmda/sh/synapse', 'addSpike' ) moose.connect( '/model/elec/dend20/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend20/nmda/sh/synapse', 'addSpike' ) moose.connect( '/model/elec/dend30/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend30/nmda/sh/synapse', 'addSpike' ) moose.connect( '/model/elec/dend40/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend40/nmda/sh/synapse', 'addSpike' )
def makeModel(): moose.Neutral( '/library' ) makeCellProto( 'cellProto' ) makeChemProto( 'cProto' ) makeSpineProto2( 'spine' ) rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ stealCellFromLibrary = True, \ diffusionLength = 1e-6, \ cellProto = [['cellProto', 'elec' ]] ,\ spineProto = [['spineProto', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( spineSpacingDistrib ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ], \ chemDistrib = [ \ [ "chem", "dend", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/z', 'n', 'spine', 'psdArea', 10.0e-15, 300e-15 ], \ ] \ ) rdes.buildModel( '/model' ) x = moose.vec( '/model/chem/dend/x' ) x.concInit = 0.0 for i in range( 0,20 ): x[i].concInit = concInit
def makeModel(): moose.Neutral( '/library' ) # Here we illustrate building the chem proto directly. This is not # good practice as it takes the model definition away from the # declaration of prototypes. makeChemProto( 'cProto' ) rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ meshLambda = 1e-6, \ cellProto = [['makeCellProto()', 'elec' ]] ,\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ chemProto = [['cProto', 'chem' ]] ,\ spineDistrib = [ \ ['spine', '#', \ 'spineSpacing', str( spineSpacing ), \ 'spineSpacingDistrib', str( spineSpacingDistrib ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ], \ chemDistrib = [ \ [ "chem", "#", "install", "1" ] \ ], adaptorList = [ \ [ 'psd/Ca', 'conc', '.', 'inject', 0, 2e-9 ], \ ] \ ) rdes.buildModel( '/model' )
def test(): """Test """ rdes = rd.rdesigneur( elecDt=50e-6, chemDt=0.002, diffDt=0.002, chemPlotDt=0.02, useGssa=False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] cellProto=[['ballAndStick', 'soma', 12e-6, 12e-6, 4e-6, 100e-6, 2]], chemProto=[[ os.path.join(sdir_, '../py_rdesigneur/chem/chanPhosph3compt.g'), 'chem' ]], spineProto=[['makeActiveSpine()', 'spine']], chanProto=[['make_Na()', 'Na'], ['make_K_DR()', 'K_DR'], ['make_K_A()', 'K_A'], ['make_Ca()', 'Ca'], ['make_Ca_conc()', 'Ca_conc']], passiveDistrib=[['soma', 'CM', '0.01', 'Em', '-0.06']], spineDistrib=[['spine', '#dend#', '50e-6', '1e-6']], chemDistrib=[['chem', '#', 'install', '1']], chanDistrib=[['Na', 'soma', 'Gbar', '300'], ['K_DR', 'soma', 'Gbar', '250'], ['K_A', 'soma', 'Gbar', '200'], ['Ca_conc', 'soma', 'tau', '0.0333'], ['Ca', 'soma', 'Gbar', '40']], adaptorList=[['psd/chan_p', 'n', 'glu', 'modulation', 0.1, 1.0], ['Ca_conc', 'Ca', 'spine/Ca', 'conc', 0.00008, 8]], # Syn input basline 1 Hz, and 40Hz burst for 1 sec at t=20. Syn weight # is 0.5, specified in 2nd argument as a special case stimLists. stimList=[[ 'head#', '0.5', 'glu', 'periodicsyn', '1 + 40*(t>10 && t<11)' ]], plotList=[ ['soma', '1', '.', 'Vm', 'Membrane potential'], ['#', '1', 'spine/Ca', 'conc', 'Ca in Spine'], ['#', '1', 'dend/DEND/Ca', 'conc', 'Ca in Dend'], ['#', '1', 'spine/Ca_CaM', 'conc', 'Ca_CaM'], ['head#', '1', 'psd/chan_p', 'conc', 'Phosph gluR'], ['head#', '1', 'psd/Ca_CaM_CaMKII', 'conc', 'Active CaMKII'], ]) moose.seed(123) rdes.buildModel() moose.reinit() moose.start(25) data = [] v = moose.wildcardFind('/##[TYPE=Table]')[0].vector assert np.allclose( (v.mean(), v.std()), (-0.06777396715033643, 0.008550767915889)), (v.mean(), v.std()) for t in moose.wildcardFind('/##[TYPE=Table2]'): data.append(t.vector) m = np.mean(data, axis=1) u = np.std(data, axis=1) assert m.shape[0] == 67 assert np.allclose(m, A, atol=1e-5), m - A assert np.allclose(u, B, atol=1e-5), u - B
def main(): """ This example illustrates loading a model from an SWC file, inserting spines, and viewing it. """ app = QtGui.QApplication(sys.argv) filename = 'barrionuevo_cell1zr.CNG.swc' #filename = 'h10.CNG.swc' moose.Neutral('/library') rdes = rd.rdesigneur( \ cellProto = [[ filename, 'elec' ] ],\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ spineDistrib = [ \ ['spine', '#apical#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ] \ ) rdes.buildModel('/model') moose.reinit() # Now we set up the display compts = moose.wildcardFind("/model/elec/#[ISA=CompartmentBase]") compts[0].inject = inject ecomptPath = [x.path for x in compts] morphology = moogli.extensions.moose.read(path="/model/elec", vertices=15) #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] ) #morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, gnuplot ) #viewer = moogli.DynamicMorphologyViewerWidget(morphology) viewer = moogli.Viewer("Viewer") viewer.attach_shapes(morphology.shapes.values()) view = moogli.View("main-view") viewer.attach_view(view) #viewer.set_background_color( 1.0, 1.0, 1.0, 1.0 ) def callback(morphology, viewer): moose.start(frameRunTime) Vm = [moose.element(x).Vm for x in compts] morphology.set_color("group_all", Vm) currTime = moose.element('/clock').currentTime #print currTime, compts[0].Vm if (currTime < runtime): return True return False #viewer.set_callback( callback, idletime = 0 ) #viewer.showMaximized() viewer.show() app.exec_()
def test_msgs(): if moose.exists('/model'): moose.delete('/model') rdes = rd.rdesigneur( stimList=[['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8']], plotList=[['soma', '1', '.', 'Vm', 'Soma membrane potential']]) rdes.buildModel() msgs = moose.listmsg(rdes.soma) assert len(msgs) == 3, msgs
def makeModel(): segLen = length / numDendSeg rdes = rd.rdesigneur( stealCellFromLibrary=True, elecPlotDt=elecPlotDt, verbose=False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto=[[ 'ballAndStick', 'soma', dia, segLen, dia, length, numDendSeg ]], chanProto=[['make_glu()', 'glu'], ['make_NMDA()', 'nmda']], passiveDistrib=[['#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA)]], chanDistrib=[ ['glu', 'dend10,dend20,dend30,dend40', 'Gbar', str(gluGbar)], ['nmda', 'dend10,dend20,dend30,dend40', 'Gbar', str(nmdaGbar)], ], stimList=[ [ 'dend10', '1', 'glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[0].onset, rec[0].onset + inputDuration) ], [ 'dend20', '1', 'glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[1].onset, rec[1].onset + inputDuration) ], [ 'dend30', '1', 'glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[2].onset, rec[2].onset + inputDuration) ], [ 'dend40', '1', 'glu', 'periodicsyn', '{}*(t>{:.3f} && t<{:.3f})'.format( inputFreq, rec[3].onset, rec[3].onset + inputDuration) ], ], plotList=[['soma,dend10,dend20,dend30,dend40', '1', '.', 'Vm']], ) rdes.buildModel() #for i in moose.wildcardFind( '/model/elec/dend#/glu/sh/synapse/synInput_rs' ): #i.refractT = 0.0 moose.connect('/model/elec/dend10/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend10/nmda/sh/synapse', 'addSpike') moose.connect('/model/elec/dend20/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend20/nmda/sh/synapse', 'addSpike') moose.connect('/model/elec/dend30/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend30/nmda/sh/synapse', 'addSpike') moose.connect('/model/elec/dend40/glu/sh/synapse/synInput_rs', 'spikeOut', '/model/elec/dend40/nmda/sh/synapse', 'addSpike')
def test_reac_rates(): makeFuncRate() rdes = rd.rdesigneur( turnOffElec=True, #This subdivides the 50-micron cylinder into 2 micron voxels diffusionLength=2e-6, cellProto=[['somaProto', 'soma', 5e-6, 50e-6]], chemProto=[['chem', 'chem']], chemDistrib=[['chem', 'soma', 'install', '1']], plotList=[['soma', '1', 'dend/A', 'conc', 'A conc', 'wave'], ['soma', '1', 'dend/C', 'conc', 'C conc', 'wave']], ) rdes.buildModel() C = moose.element('/model/chem/dend/C') C.vec.concInit = [1 + np.sin(x / 5.0) for x in range(len(C.vec))] moose.reinit() moose.start(10) E = (np.array([ 0.76793869, 0.69093771, 0.61740932, 0.55290337, 0.50043755, 0.46090277, 0.43395074, 0.41882627, 0.41492281, 0.42206285, 0.4405646, 0.47111808, 0.51443061, 0.57058404, 0.63814939, 0.71337226, 0.79003606, 0.86055299, 0.91814872, 0.95908718, 0.9836508, 0.99540289, 0.99934529, 0.99998887, 0.99999589, 1., 1.19866933, 1.38941834, 1.56464247, 1.71735609, 1.84147098, 1.93203909, 1.98544973, 1.9995736, 1.97384763, 1.90929743, 1.8084964, 1.67546318, 1.51550137, 1.33498815, 1.14112001, 0.94162586, 0.7444589, 0.55747956, 0.38814211, 0.2431975, 0.12842423, 0.04839793, 0.006309, 0.00383539 ]), np.array([ 1.35368806e-01, 1.74391515e-01, 2.08263083e-01, 2.34835055e-01, 2.53957994e-01, 2.66695461e-01, 2.74465660e-01, 2.78476408e-01, 2.79468906e-01, 2.77640055e-01, 2.72631277e-01, 2.63551810e-01, 2.49094224e-01, 2.27869755e-01, 1.99072915e-01, 1.63375068e-01, 1.23566311e-01, 8.42635843e-02, 5.04491469e-02, 2.55522217e-02, 1.02890632e-02, 2.90344842e-03, 4.13990858e-04, 7.03942852e-06, 2.60159221e-06, 0.00000000e+00, 0.00000000e+00, 2.22044605e-16, 0.00000000e+00, 0.00000000e+00, 2.22044605e-16, 2.22044605e-16, 2.22044605e-16, 2.22044605e-16, 4.44089210e-16, 0.00000000e+00, 2.22044605e-16, 2.22044605e-16, 0.00000000e+00, 2.22044605e-16, 2.22044605e-16, 0.00000000e+00, 1.11022302e-16, 0.00000000e+00, 0.00000000e+00, 2.77555756e-17, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00 ])) A = [] for t in moose.wildcardFind('/##[TYPE=Table2]'): A.append(t.vector) m = np.mean(A, axis=1) u = np.std(A, axis=1) # multithreaded version given different results. assert np.allclose(m, E[0], rtol=1e-3), (m - E[0]) assert np.allclose(u, E[1], rtol=1e-3), (u - E[1]) print('all done')
def main(): library = moose.Neutral('/library') makePassiveSoma('cell', params['dendL'], params['dendDia']) makeChemProto() rdes = rd.rdesigneur( turnOffElec=True, chemPlotDt=0.1, diffusionLength=params['diffusionL'], cellProto=[['cell', 'soma']], chemProto=[['hydra', 'hydra']], chemDistrib=[['hydra', 'soma', 'install', '1']], plotList=[['soma', '1', 'dend/A', 'n', '# of A'], ['soma', '1', 'dend/B', 'n', '# of B']], # moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']] ) moose.le('/library') moose.le('/library/hydra') moose.showfield('/library/soma/soma') rdes.buildModel() #moose.element('/model/chem/dend/B').vec[50].nInit=15.5 A = moose.vec('/model/chem/dend/A') #B = moose.vec('/model/chem/dend/B') # A.concInit=1 # B.concInit=10 moose.element('/model/chem/dend/B').vec[50].nInit = 100 #moose.element('/model/chem/dend/B').vec[25].nInit=0 #A.nInit=1 #B.nInit=15 #Adot = moose.element('/model/chem/dend/A/Adot') #Bdot = moose.element('/model/chem/dend/B/Bdot') #print "\n\n\t\t Before Run", Adot, Bdot, A.nInit, B.nInit, A.n, B.n, A.concInit, B.concInit moose.reinit() moose.start(500) #print "\n\n\t\t After Run", A.nInit, B.nInit, A.n, B.n, A.concInit, B.concInit # rdes.display() # rdes.displayMoogli( 1, 400, 0.001 ) avec = moose.vec('/model/chem/dend/A').n bvec = moose.vec('/model/chem/dend/B').n #tab = moose.element( '/model/graphs/plot0') #dt = tab.dt #tvec=[] #tvec.append( tab.vector ) # xplot = [] # xplot.append( avec ) ## t = np.arange( 0, len( tvec[0] ), 1.0 ) * dt plt.plot(avec) #print bvec, len(bvec), bvec return bvec, avec
def test(): """ Test CICR. >>> test() # doctest: +NORMALIZE_WHITESPACE Rdesigneur: Elec model has 5 compartments and 2 spines on 4 compartments. Chem part of model has the following compartments: | In dend, 40 voxels X 19 pools | In spine, 2 voxels X 1 pools | In psd, 2 voxels X 1 pools | In dend_endo, 40 voxels X 2 pools True """ rdes = rd.rdesigneur( turnOffElec=False, chemDt=0.002, chemPlotDt=0.02, diffusionLength=1e-6, numWaveFrames=50, useGssa=False, addSomaChemCompt=False, addEndoChemCompt=True, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSeg] cellProto=[['ballAndStick', 'soma', 10e-6, 10e-6, 2e-6, 40e-6, 4]], spineProto=[['makeActiveSpine()', 'spine']], chemProto=[[ os.path.join(sdir_, '../py_rdesigneur/chem/CICRspineDend.g'), 'chem' ]], spineDistrib=[['spine', '#dend#', '10e-6', '0.1e-6']], chemDistrib=[['chem', 'dend#,spine#,head#', 'install', '1']], adaptorList=[['Ca_conc', 'Ca', 'spine/Ca', 'conc', 0.00008, 8]], stimList=[ ['head0', '0.5', 'glu', 'periodicsyn', '1 + 40*(t>5 && t<6)'], ['head0', '0.5', 'NMDA', 'periodicsyn', '1 + 40*(t>5 && t<6)'], ['dend#', 'g>10e-6 && g<=31e-6', 'dend/IP3', 'conc', '0.0006'], ], plotList=[ ['head#', '1', 'spine/Ca', 'conc', 'Spine Ca conc'], ['dend#', '1', 'dend/Ca', 'conc', 'Dend Ca conc'], ['dend#', '1', 'dend/Ca', 'conc', 'Dend Ca conc', 'wave'], ['dend#', '1', 'dend_endo/CaER', 'conc', 'ER Ca conc', 'wave'], ['soma', '1', '.', 'Vm', 'Memb potl'], ], ) moose.seed(1234) rdes.buildModel() moose.reinit() moose.start(2) data = [] for t in moose.wildcardFind('/##[TYPE=Table2]'): data.append(t.vector[::20]) res = np.mean(data, axis=1) assert np.allclose(res, expected, rtol=1e-4, atol=1e-4), \ "Total error %s" % np.sum(res - expected) return True
def test2(): if moose.exists('/model'): moose.delete('/model') rdes = rd.rdesigneur( stimList=[['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8']], plotList=[['soma', '1', '.', 'Vm', 'Soma membrane potential']]) rdes.buildModel() moose.reinit() moose.start(0.3)
def load(): rdes = rd.rdesigneur( turnOffElec = True, chanProto = [['make_HH_Na()', 'Na'], ['make_HH_K()', 'K']], chanDistrib = [ ['Na', 'soma', 'Gbar', '1200' ], ['K', 'soma', 'Gbar', '360' ]], ) rdes.buildModel() return rdes.model
def panelBCsingleCompt(fig): rdes = rd.rdesigneur( useGssa=False, turnOffElec=True, chemPlotDt=1.0, diffusionLength=params['dendLength'], spineProto=[['makePassiveSpine()', 'spine']], spineDistrib=[[ 'spine', '#', str(0.8 * params['dendLength']), '1e-7', '1.4', '0' ]], cellProto=[['cell', 'soma']], chemProto=[[params['chemModel'], 'chem']], chemDistrib=[['chem', 'soma', 'install', '1']], plotList=[ ['soma', '1', 'dend/DEND/P_MAPK', 'conc', '[dend P_MAPK]'], ['#head#', '1', 'psd/Ca', 'conc', '[PSD Ca]'], ['#head#', '1', 'spine/Ca', 'conc', '[spine Ca]'], ['soma', '1', 'dend/DEND/Ca', 'conc', '[dend Ca]'], ], ) #moose.le( '/library/chem/kinetics' ) moose.element('/library/chem/kinetics/DEND/Ca_activate_Raf' ).Kf = params['CaActivateRafKf'] rdes.buildModel() baseCa = params['baseCa'] / 50.0 Ca_input = moose.vec('/model/chem/psd/Ca_input') Ca_input.concInit = baseCa moose.vec('/model/chem/dend/DEND/Ca_input').concInit = baseCa moose.reinit() moose.start(50) Ca_input.concInit = params['stimAmplitude'] moose.start(1) Ca_input.concInit = baseCa moose.start(49) # Here is another pulse stimulus Ca_input.concInit = params['stimAmplitude'] moose.start(1) Ca_input.concInit = baseCa moose.start(99) # Here is the step stimulus Ca_input.concInit = params['stimAmplitude'] moose.start(50) Ca_input.concInit = baseCa moose.start(50) mapkPvec = moose.element('/model/graphs/plot0').vector * 1000 cavec = moose.element('/model/graphs/plot3').vector * 1000 t = np.arange(0, len(cavec) * rdes.chemPlotDt, rdes.chemPlotDt) xticks = ['0', '', '100', '', '200', '', '300'] ax = plotBoilerplate('B', (2, 0), 'Time (s)', 'Ca ($\mu$M)', xticks) plt.plot(t, cavec) ax = plotBoilerplate('C', (2, 1), 'Time (s)', 'MAPK-P ($\mu$M)', xticks) plt.plot(t, mapkPvec) print "Finished panelBC for single Compt dynamics" moose.delete('/model')
def makeYmodel(): segLen = dendLength / numDendSeg rdes = rd.rdesigneur( stealCellFromLibrary=True, verbose=False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto=[[ 'ballAndStick', 'cellBase', dendDia, segLen, dendDia, dendLength, numDendSeg ]], passiveDistrib=[[ '#', 'RM', str(dendRM), 'CM', str(dendCM), 'RA', str(dendRA) ]], stimList=[['soma', '1', '.', 'inject', stimStr]], ) # Build the arms of the Y for a branching cell. pa = moose.element('/library/cellBase') x = length y = 0.0 dx = length / (numDendSeg * np.sqrt(2.0)) dy = dx prevc1 = moose.element('/library/cellBase/dend{}'.format(numDendSeg - 1)) prevc2 = prevc1 for i in range(numDendSeg): c1 = rd.buildCompt(pa, 'branch1_{}'.format(i), RM=RM, CM=CM, RA=RA, dia=dia, x=x, y=y, dx=dx, dy=dy) c2 = rd.buildCompt(pa, 'branch2_{}'.format(i), RM=RM, CM=CM, RA=RA, dia=dia, x=x, y=-y, dx=dx, dy=-dy) moose.connect(prevc1, 'axial', c1, 'raxial') moose.connect(prevc2, 'axial', c2, 'raxial') prevc1 = c1 prevc2 = c2 x += dx y += dy rdes.buildModel()
def main(): library = moose.Neutral('/library') #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] ) makeDendProto() makeChemProto() rdes = rd.rdesigneur( turnOffElec=True, chemPlotDt=0.1, diffusionLength=params['diffusionL'], #cellProto=[['cell','soma']], cellProto=[['elec', 'dend']], chemProto=[['hydra', 'hydra']], chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']], plotList=[['soma', '1', 'dend/A', 'n', '# of A'], ['soma', '1', 'dend/B', 'n', '# of B']], # moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']] ) moose.le('/library') moose.le('/library/hydra') #moose.showfield( '/library/soma/soma' ) rdes.buildModel() #moose.element('/model/chem/dend/B').vec[50].nInit=15.5 A = moose.element('/model/chem/dend/A') B = moose.element('/model/chem/dend/B') C = moose.element('/model/chem/dend/C') A.diffConst = 1e-13 B.diffConst = 0 C.diffConst = 0 B.motorConst = 1e-06 C.motorConst = -1e-06 # A.concInit=1 # B.concInit=10 avec = moose.vec('/model/chem/dend/A').n savec = avec.size for i in range(0, savec - 1, 1): moose.element('/model/chem/dend/A').vec[i].nInit = np.random.uniform( 0, 1) print moose.element('/model/chem/dend/A').vec[i].nInit print 'simulation start' moose.reinit() #moose.start(2) for t in range(0, 4000, 500): moose.start(500) print 'in loop', t avec = moose.vec('/model/chem/dend/A').n plt.plot(avec) avec = moose.vec('/model/chem/dend/A').n bvec = moose.vec('/model/chem/dend/B').n cvec = moose.vec('/model/chem/dend/C').n #plt.plot(bvec) return bvec, avec, cvec
def test2( ): if moose.exists( '/model' ): moose.delete( '/model' ) rdes = rd.rdesigneur( stimList = [['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8' ]], plotList = [['soma', '1', '.', 'Vm', 'Soma membrane potential']] ) rdes.buildModel() moose.reinit() moose.start( 0.3 )
def load(): rdes = rd.rdesigneur( elecDt = 50e-6, chemDt = 0.002, diffDt = 0.002, chemPlotDt = 0.02, turnOffElec = True, #FindSim needs to create Vclamp and then solver. useGssa = False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] cellProto = [['ballAndStick', 'soma', 12e-6, 12e-6, 4e-6, 100e-6, 1 ]], chemProto = [['models/CaMKII_MAPK_7.g', 'chem']], spineProto = [['makeActiveSpine()', 'spine']], chanProto = [ ['make_Na()', 'Na'], ['make_K_DR()', 'K_DR'], ['make_K_A()', 'K_A' ], ['make_glu()', 'glu' ], ['make_Ca()', 'Ca' ], ['make_Ca_conc()', 'Ca_conc' ] ], passiveDistrib = [['soma', 'CM', '0.01', 'Em', '-0.06']], spineDistrib = [['spine', '#dend#', '100e-6', '1e-6']], chemDistrib = [['chem', '#', 'install', '1' ]], chanDistrib = [ ['Na', 'soma', 'Gbar', '300' ], ['K_DR', 'soma', 'Gbar', '250' ], ['K_A', 'soma', 'Gbar', '200' ], ['glu', 'dend#', 'Gbar', '20' ], ['Ca_conc', 'soma', 'tau', '0.0333' ], ['Ca', 'soma', 'Gbar', '40' ] ], adaptorList = [ [ 'psd/tot_phospho_R', 'n', 'glu', 'modulation', 1.0, 0.3 ], [ 'Ca_conc', 'Ca', 'psd/Ca', 'conc', 0.00008, 3 ] ], # Syn wt is 0.2, specified in 2nd argument stimList = [['head#', '0.2','glu', 'periodicsyn', '0']], ) moose.seed(1234567) rdes.buildModel() #moose.element( '/model/chem/dend/ksolve' ).numThreads = 4 #moose.showfield( '/model/chem/dend/ksolve' ) #moose.element( '/model/chem/dend/ksolve' ).method = "rk4" moose.delete( '/model/stims/stim0') inputElm = moose.element( '/model/elec/head0/glu/sh/synapse/synInput_rs' ) inputElm.name = 'synInput' moose.connect( inputElm, 'spikeOut', '/model/elec/head0/glu/sh/synapse', 'addSpike' ) #moose.showmsg( '/model/elec/head0/glu/sh/synapse/synInput_rs' ) #import presettle_CaMKII_MAPK7_init moose.reinit() return rdes.model
def main(): library = moose.Neutral('/library') #makePassiveSoma( 'cell', params['dendL'], params['dendDia'] ) makeDendProto() makeChemProto() rdes = rd.rdesigneur( turnOffElec=True, chemPlotDt=0.1, diffusionLength=params['diffusionL'], #cellProto=[['cell','soma']], cellProto=[['elec', 'dend']], chemProto=[['hydra', 'hydra']], chemDistrib=[['hydra', '#soma#,#dend#', 'install', '1']], plotList=[['soma', '1', 'dend/A', 'n', '# of A'], ['soma', '1', 'dend/B', 'n', '# of B']], # moogList = [['soma', '1', 'dend/A', 'n', 'num of A (number)']] ) moose.le('/library') moose.le('/library/hydra') #moose.showfield( '/library/soma/soma' ) rdes.buildModel() #moose.element('/model/chem/dend/B').vec[50].nInit=15.5 A = moose.element('/model/chem/dend/A') B = moose.element('/model/chem/dend/B') A.diffConst = 1e-13 B.diffConst = 1e-12 moose.element('/model/chem/dend/A').vec[25].nInit = 0.1 moose.element('/model/chem/dend/B').vec[25].nInit = 0.1 moose.element('/model/chem/dend/A').vec[30].nInit = 0.1 moose.element('/model/chem/dend/B').vec[30].nInit = 0.1 moose.element('/model/chem/dend/A').vec[45].nInit = 0.1 moose.element('/model/chem/dend/B').vec[45].nInit = 0.1 storeAvec = [] storeBvec = [] for i in range(50): moose.element('/model/chem/dend/space').vec[i].nInit = moose.element( '/model/chem/dend/mesh').vec[i].Coordinates[0] print moose.element('/model/chem/dend/space').vec[i].nInit moose.reinit() for i in range(1, 5000, 10): moose.start(10) avec = moose.vec('/model/chem/dend/A').n bvec = moose.vec('/model/chem/dend/B').n storeAvec.append(avec) storeBvec.append(bvec) bvec = moose.vec('/model/chem/dend/B').n avec = moose.vec('/model/chem/dend/A').n svec = moose.vec('/model/chem/dend/space').n return svec, bvec, avec, storeAvec, storeBvec
def main(): """ This example illustrates loading a model from an SWC file, inserting spines, and viewing it. """ app = QtGui.QApplication(sys.argv) filename = 'barrionuevo_cell1zr.CNG.swc' #filename = 'h10.CNG.swc' moose.Neutral( '/library' ) rdes = rd.rdesigneur( \ cellProto = [[ filename, 'elec' ] ],\ spineProto = [['makeSpineProto()', 'spine' ]] ,\ spineDistrib = [ \ ['spine', '#apical#', \ 'spacing', str( spineSpacing ), \ 'spacingDistrib', str( minSpacing ), \ 'angle', str( spineAngle ), \ 'angleDistrib', str( spineAngleDistrib ), \ 'size', str( spineSize ), \ 'sizeDistrib', str( spineSizeDistrib ) ] \ ] \ ) rdes.buildModel( '/model' ) moose.reinit() # Now we set up the display compts = moose.wildcardFind( "/model/elec/#[ISA=CompartmentBase]" ) compts[0].inject = inject ecomptPath = [x.path for x in 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] ) morphology.create_group( "group_all", ecomptPath, -0.08, 0.02, \ gnuplot ) viewer = moogli.DynamicMorphologyViewerWidget(morphology) viewer.set_background_color( 1.0, 1.0, 1.0, 1.0 ) def callback( morphology, viewer ): moose.start( frameRunTime ) Vm = [moose.element( x ).Vm for x in compts] morphology.set_color( "group_all", Vm ) currTime = moose.element( '/clock' ).currentTime #print currTime, compts[0].Vm if ( currTime < runtime ): return True return False viewer.set_callback( callback, idletime = 0 ) viewer.showMaximized() viewer.show() app.exec_()
def loadModel(filename, args): """Load the model and insert channels """ global modelName global nchans, ncompts # Load in the swc file. modelName = "elec" cellProto = [ ( filename, modelName ) ] passiveDistrib = [] chanDistrib = [] if args.insert_channels: chanProto = [ ['./chans/hd.xml'], ['./chans/kap.xml'], ['./chans/kad.xml'], ['./chans/kdr.xml'], ['./chans/na3.xml'], ['./chans/nax.xml'], ] passiveDistrib = [ [ ".", "#", "RM", "2.8", "CM", "0.01", "RA", "1.5", "Em", "-58e-3", "initVm", "-65e-3" ], [ ".", "#axon#", "RA", "0.5" ] ] for c in _args.insert_channels: chanDistrib.append( c.split(";")) rdes = rd.rdesigneur( cellProto = cellProto , combineSegments = True , passiveDistrib = passiveDistrib , chanProto = chanProto , chanDistrib = chanDistrib ) rdes.buildModel('/model') compts = moose.wildcardFind( "/model/%s/#[ISA=CompartmentBase]"%modelName ) setupStimuls( compts[0] ) for compt in compts: vtab = moose.Table( '%s/vm' % compt.path ) moose.connect( vtab, 'requestOut', compt, 'getVm' ) _records[compt.path] = vtab nchans = len(set([x.path for x in moose.wildcardFind('/model/elec/##[TYPE=ZombieHHChannel]')]) ) _logger.info("Total channels: %s" % nchans)
def runPanelCDEF(name, dist, seqDt, numSpine, seq, stimAmpl): preStim = 10.0 blanks = 20 rdes = rd.rdesigneur( useGssa=False, turnOffElec=True, chemPlotDt=0.1, #diffusionLength = params['diffusionLength'], diffusionLength=1e-6, cellProto=[['cell', 'soma']], chemProto=[['dend', name]], chemDistrib=[['dend', 'soma', 'install', '1']], plotList=[['soma', '1', 'dend' + '/A', 'n', '# of A']], ) rdes.buildModel() #for i in range( 20 ): #moose.setClock( i, 0.02 ) A = moose.vec('/model/chem/dend/A') Z = moose.vec('/model/chem/dend/Z') print moose.element('/model/chem/dend/A/Adot').expr print moose.element('/model/chem/dend/B/Bdot').expr print moose.element('/model/chem/dend/Ca/CaStim').expr phase = moose.vec('/model/chem/dend/phase') ampl = moose.vec('/model/chem/dend/ampl') vel = moose.vec('/model/chem/dend/vel') vel.nInit = 1e-6 * seqDt ampl.nInit = stimAmpl stride = int(dist) / numSpine phase.nInit = 10000 Z.nInit = 0 for j in range(numSpine): k = blanks + j * stride Z[k].nInit = 1 phase[k].nInit = preStim + seq[j] * seqDt moose.reinit() runtime = 50 snapshot = preStim + seqDt * (numSpine - 0.8) print snapshot #snapshot = 26 moose.start(snapshot) avec = moose.vec('/model/chem/dend/A').n moose.start(runtime - snapshot) tvec = [] for i in range(5): tab = moose.element('/model/graphs/plot0[' + str(blanks + i * stride) + ']') dt = tab.dt tvec.append(tab.vector) moose.delete('/model') return dt, tvec, avec
def runPanelCDEF( name, dist, seqDt, numSpine, seq, stimAmpl ): preStim = 10.0 blanks = 20 rdes = rd.rdesigneur( useGssa = False, turnOffElec = True, chemPlotDt = 0.1, #diffusionLength = params['diffusionLength'], diffusionLength = 1e-6, cellProto = [['cell', 'soma']], chemProto = [['dend', name]], chemDistrib = [['dend', 'soma', 'install', '1' ]], plotList = [['soma', '1', 'dend' + '/A', 'n', '# of A']], ) rdes.buildModel() #for i in range( 20 ): #moose.setClock( i, 0.02 ) A = moose.vec( '/model/chem/dend/A' ) Z = moose.vec( '/model/chem/dend/Z' ) print(moose.element( '/model/chem/dend/A/Adot' ).expr) print(moose.element( '/model/chem/dend/B/Bdot' ).expr) print(moose.element( '/model/chem/dend/Ca/CaStim' ).expr) phase = moose.vec( '/model/chem/dend/phase' ) ampl = moose.vec( '/model/chem/dend/ampl' ) vel = moose.vec( '/model/chem/dend/vel' ) vel.nInit = 1e-6 * seqDt ampl.nInit = stimAmpl stride = int( dist ) / numSpine phase.nInit = 10000 Z.nInit = 0 for j in range( numSpine ): k = int(blanks + j * stride) Z[k].nInit = 1 phase[k].nInit = preStim + seq[j] * seqDt moose.reinit() runtime = 50 snapshot = preStim + seqDt * (numSpine - 0.8) print(snapshot) #snapshot = 26 moose.start( snapshot ) avec = moose.vec( '/model/chem/dend/A' ).n moose.start( runtime - snapshot ) tvec = [] for i in range( 5 ): tab = moose.element( '/model/graphs/plot0[' + str( blanks + i * stride ) + ']' ) dt = tab.dt tvec.append( tab.vector ) moose.delete( '/model' ) return dt, tvec, avec
def makeModel(): rdes = rd.rdesigneur( elecPlotDt=elecPlotDt, stealCellFromLibrary=True, verbose=False, #chanProto = [['make_glu()', 'glu'],['make_GABA()', 'GABA']], chanProto=[ [ChP + '.Na_Chan()', 'Na'], [ChP + '.KDR_Chan()', 'K_DR'], [ChP + '.KA_Chan()', 'K_A'], [ChP + '.KM_Chan()', 'K_M'], [ChP + '.h_Chan()', 'h'], [ChP + '.CaT_Chan()', 'Ca_T'], [ChP + '.CaR_Chan()', 'Ca_R'], [ChP + '.CaL_Chan()', 'Ca_L'], [ChP + '.CaN_Chan()', 'Ca_N'], [ChP + '.Ca_Conc()', 'Ca_conc'], [ChP + '.KBK_Chan()', 'K_BK'], [ChP + '.KSK_Chan()', 'K_SK'], ], # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto=[['somaProto', 'cellBase', diameter, diameter]], passiveDistrib=[['#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA)]], chanDistrib=[ ['Ca_conc', 'soma', 'tau', str(Ca_tau)], ['Na', 'soma', 'Gbar', str(Na_Gbar)], ['K_DR', 'soma', 'Gbar', str(K_DR_Gbar)], ['K_A', 'soma', 'Gbar', str(K_A_Gbar)], ['K_M', 'soma', 'Gbar', str(K_M_Gbar)], ['h', 'soma', 'Gbar', str(h_Gbar)], ['Ca_T', 'soma', 'Gbar', str(Ca_T_Gbar)], ['Ca_R', 'soma', 'Gbar', str(Ca_R_Gbar)], ['Ca_L', 'soma', 'Gbar', str(Ca_L_Gbar)], ['Ca_N', 'soma', 'Gbar', str(Ca_N_Gbar)], ['K_BK', 'soma', 'Gbar', str(K_BK_Gbar)], ['K_SK', 'soma', 'Gbar', str(K_SK_Gbar)], ], plotList=[['soma', '1', '.', 'Vm'], ['soma', '1', 'Ca_conc', 'Ca']]) moose.element('/library/Ca_conc').CaBasal = 0.1e-3 rdes.buildModel() for i in moose.wildcardFind('/model/elec/soma/#[ISA=ChanBase]'): i.modulation = 1e-6 moose.element('/model/elec/soma/Na').modulation = 1 moose.element('/model/elec/soma/K_DR').modulation = 1 moose.element('/model/elec/soma/Ca_conc').B = Ca_B
def makeModel(): segLen = length / numDendSeg rdes = rd.rdesigneur( stealCellFromLibrary = True, elecPlotDt = elecPlotDt, verbose = False, # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto = [['ballAndStick', 'soma', dia, segLen, dia, length, numDendSeg]], passiveDistrib = [[ '#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA) ]], stimList = [['soma', '1', '.', 'inject', stimStr ]], plotList = [['dend3,dend18,dend33,dend49', '1', '.', 'Vm' ]], ) rdes.buildModel()
def makeModel(): rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ cellPortion = "/model/elec/#", \ meshLambda = 1e-6, \ adaptorList = [ \ ( 'psd', '.', 'inject', 'Ca', False, 0, 2e-9 ) \ ], \ addSpineList = [ \ ( 'spine', '#', \ spineSpacing, spineSpacingDistrib, spineSizeDistrib, \ 0.0, 0.0, numpy.pi, numpy.pi / 2.0 ) \ ] ) # Make a 'bare' spine: No synchans, no ion chans, no Ca. rdes.addSpineProto( 'spine', RM, RA, CM, \ synList = (), chanList = (), caTau = 0.0 ) elec = moose.Neutral('/tempelec') ''' ecompt = rdes._buildCompt( elec, 'dend', 100e-6, 2.0e-6, 0, RM, RA, CM ) ecompt.x0 = 0 ecompt.x = 0 ecompt.y0 = 0 ecompt.y = 0 ecompt.z0 = 0 ecompt.z = 100e-6 ''' ecompt = [] for i in range(numDendSegments): ec = rdes._buildCompt(elec, 'dend' + str(i), segLen, 2.0e-6, i * segLen, RM, RA, CM) ecompt.append(ec) if i > 0: moose.connect(ecompt[i - 1], 'raxial', ec, 'axial') for i in ecompt: i.z0 = i.x0 i.x0 = 0 i.z = i.x i.x = 0 chem = moose.Neutral('/tempchem') for i in ('dend', 'spine', 'psd'): compt = moose.CubeMesh('/tempchem/' + i) compt.volume = 1e-18 ca = moose.Pool('/tempchem/' + i + '/Ca') ca.concInit = 0.08e-3 ca.diffConst = 1e-12 rdes.buildFromMemory('/tempelec', '/tempchem')
def makeModel(): rdes = rd.rdesigneur( useGssa = False, \ combineSegments = False, \ cellPortion = "/model/elec/#", \ meshLambda = 1e-6, \ adaptorList = [ \ ( 'psd', '.', 'inject', 'Ca', False, 0, 2e-9 ) \ ], \ addSpineList = [ \ ( 'spine', '#', \ spineSpacing, spineSpacingDistrib, spineSizeDistrib, \ 0.0, 0.0, numpy.pi, numpy.pi / 2.0 ) \ ] ) # Make a 'bare' spine: No synchans, no ion chans, no Ca. rdes.addSpineProto( 'spine', RM, RA, CM, \ synList = (), chanList = (), caTau = 0.0 ) elec = moose.Neutral( '/tempelec' ) ''' ecompt = rdes._buildCompt( elec, 'dend', 100e-6, 2.0e-6, 0, RM, RA, CM ) ecompt.x0 = 0 ecompt.x = 0 ecompt.y0 = 0 ecompt.y = 0 ecompt.z0 = 0 ecompt.z = 100e-6 ''' ecompt = [] for i in range( numDendSegments ): ec = rdes._buildCompt( elec, 'dend' + str(i), segLen, 2.0e-6, i * segLen, RM, RA, CM ) ecompt.append( ec ) if i > 0: moose.connect( ecompt[i-1], 'raxial', ec, 'axial' ) for i in ecompt: i.z0 = i.x0 i.x0 = 0 i.z = i.x i.x = 0 chem = moose.Neutral( '/tempchem' ) for i in ( 'dend', 'spine', 'psd' ): compt = moose.CubeMesh( '/tempchem/' + i ) compt.volume = 1e-18 ca = moose.Pool( '/tempchem/' + i + '/Ca' ) ca.concInit = 0.08e-3 ca.diffConst = 1e-12 rdes.buildFromMemory( '/tempelec', '/tempchem' )
def main(): app = QtGui.QApplication(sys.argv) filename = 'barrionuevo_cell1zr.CNG.swc' #filename = 'h10.CNG.swc' moose.Neutral( '/library' ) rdes = rd.rdesigneur() rdes.addSpineProto( 'spine', RM, RA, CM, \ synList = (), chanList = (), caTau = 0.0 ) moose.Neutral( '/model' ) cell = moose.loadModel( filename, '/model/testSwc' ) cell[0].spineSpecification = [ 'spine #apical# '+ spineArgLine, \ 'spine #dend# ' + spineArgLine ] cell[0].parseSpines() # moose.le( cell ) for i in range( 8 ): moose.setClock( i, simdt ) hsolve = moose.HSolve( '/model/testSwc/hsolve' ) hsolve.dt = simdt hsolve.target = '/model/testSwc/soma' moose.reinit() # Now we set up the display compts = moose.wildcardFind( "/model/testSwc/#[ISA=CompartmentBase]" ) compts[0].inject = inject ecomptPath = map( lambda x : x.path, compts ) morphology = moogli.read_morphology_from_moose(name = "", path = "/model/testSwc") 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( frameRunTime ) Vm = map( lambda x: moose.element( x ).Vm, compts ) morphology.set_color( "group_all", Vm ) currTime = moose.element( '/clock' ).currentTime #print currTime, compts[0].Vm if ( currTime < runtime ): return True return False viewer.set_callback( callback, idletime = 0 ) viewer.showMaximized() viewer.show() app.exec_()
def makeModel(): rdes = rd.rdesigneur( elecPlotDt = elecPlotDt, stealCellFromLibrary = True, verbose = False, #chanProto = [['make_glu()', 'glu'],['make_GABA()', 'GABA']], chanProto = [ ['make_Na()', 'Na'], ['make_K_DR()', 'K_DR'], ['make_K_A()', 'K_A'], ['make_Ca()', 'Ca'], ['make_Ca_conc()', 'Ca_conc'], ['make_K_AHP()', 'K_AHP'], ['make_K_C()', 'K_Ca'], ], # cellProto syntax: ['ballAndStick', 'name', somaDia, somaLength, dendDia, dendLength, numDendSegments ] # The numerical arguments are all optional cellProto = [['somaProto', 'cellBase', diameter, diameter]], passiveDistrib = [[ '#', 'RM', str(RM), 'CM', str(CM), 'RA', str(RA) ]], chanDistrib = [ ['Ca_conc', 'soma', 'tau', '0.01333' ], ['Na', 'soma', 'Gbar', '100' ], ['K_DR', 'soma', 'Gbar', '100' ], ['K_A', 'soma', 'Gbar', '100' ], ['Ca', 'soma', 'Gbar', '100' ], ['K_Ca', 'soma', 'Gbar', '100' ], ['K_AHP', 'soma', 'Gbar', '10' ], ], plotList = [['soma', '1','.', 'Vm'], ['soma', '1', 'Ca_conc', 'Ca']] ) moose.element( '/library/Ca_conc' ).CaBasal=0.08e-3 rdes.buildModel() for i in moose.wildcardFind( '/model/elec/soma/#[ISA=ChanBase]' ): i.modulation = 1e-6 moose.element( '/model/elec/soma/Na' ).modulation = 1 moose.element( '/model/elec/soma/K_DR' ).modulation = 1
import moose import pylab import rdesigneur as rd rdes = rd.rdesigneur( chanProto = [['make_HH_Na()', 'Na'], ['make_HH_K()', 'K']], chanDistrib = [ ['Na', 'soma', 'Gbar', '1200' ], ['K', 'soma', 'Gbar', '360' ]], stimList = [['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 1e-8' ]], plotList = [['soma', '1', '.', 'Vm', 'Membrane potential']] ) rdes.buildModel() moose.reinit() moose.start( 0.3 ) rdes.display()
def buildRdesigneur(): path = os.path.abspath(os.path.dirname('currentStep_CA3PC-Narayanan2010_v1.0.py')) cellProto = [ [ "./cells/" + elecFileNames[0], "elec" ] ] chanProto = [ [path+'/proto20.make_Ca_conc()', 'Ca_conc'], \ ['./chans/CaL.xml'], \ ['./chans/CaN.xml'], \ ['./chans/CaT.xml'], \ ['./chans/hd.xml'], \ ['./chans/kad.xml'], \ [path+'/proto20.make_K_AHP()', 'kahp'], \ ['./chans/kap.xml'], \ [path+'/proto20.make_K_C()', 'kca'], \ ['./chans/kdr.xml'], \ ['./chans/km.xml'], \ ['./chans/na3.xml'] \ ] spineProto = [\ ['makeSpineProto()', 'spine'] ] chemProto = [] passiveDistrib = [ [ ".", "#", "RM", "6", "CM", "0.0075", "RA", "2", \ "Em", "-65e-3", "initVm", "-65e-3" ] \ ] chanDistrib = [ \ ["Ca_conc", "#soma#,#dend#", "tau", "0.0133" ], \ ["CaL", "#dend#,#soma#", "Gbar", "p < 50e-6 ? 25 : 0" ], \ ["CaN", "#soma#,#dend#", "Gbar", "28" ], \ ["CaT", "#soma#,#dend#", "Gbar", "2.5" ], \ ["hd", "#dend#,#soma#", "Gbar", "0.1*(1+1.75*p/100)" ], \ ["kad", "#dend#", "Gbar", "p >= 100e-6 ? 1e-3*(7+(11*p)/100) : 0" ], \ ["kad", "#soma#", "Gbar", "70" ], \ ["kahp", "#", "Gbar", "3" ], \ ["kap", "#dend#", "Gbar", "p < 100e-6 ? 1e-3*(7+(11*p)/100 : 0" ], \ ["kap", "#soma#", "Gbar", "70" ], \ ["kca", "#soma#,#dend#", "Gbar", "8" ], \ #["kdr", "#soma#,#dend#", "Gbar", "300"], \ ["kdr", "#soma#,#dend#", "Gbar", "88"], \ #["M", "#soma#,#dend#", "Gbar", "p < 100e-6 ? 1 : 0" ], \ ["M", "#soma#,#dend#", "Gbar", "p < 100e-6 ? 0.1 : 0" ], \ #["na3", "#soma#,#dend#", "Gbar", "250" ], \ ["na3", "#soma#,#dend#", "Gbar", "180" ] \ ] spineDistrib = [ \ ["spine", '#apical#', "spineSpacing", "20e-6", \ "spineSpacingDistrib", "2e-6", \ "angle", "0", \ "angleDistrib", str( 2*PI ), \ "size", "1", \ "sizeDistrib", "0.5" ] \ ] chemDistrib = [] adaptorList = [] rd.addSpineProto() rdes = rd.rdesigneur( useGssa = useGssa, \ combineSegments = combineSegments, \ stealCellFromLibrary = True, \ passiveDistrib = passiveDistrib, \ spineDistrib = spineDistrib, \ chanDistrib = chanDistrib, \ chemDistrib = chemDistrib, \ cellProto = cellProto, \ chanProto = chanProto, \ chemProto = chemProto, \ adaptorList = adaptorList ) return rdes
def buildRdesigneur(): ################################################################## # Here we define which prototypes are to be loaded in to the system. # Each specification has the format # source [localName] # source can be any of # filename.extension, # Identify type of file by extension, load it. # function(), # func( name ) builds object of specified name # file.py:function() , # load Python file, run function(name) in it. # moose.Classname # Make obj moose.Classname, assign to name. # path # Already loaded into library or on path. # After loading the prototypes, there should be an object called 'name' # in the library. ################################################################## cellProto = [ ['ca1_minimal.p', 'elec'] ] spineProto = [ ['makeSpineProto()', 'spine' ]] chemProto = [ ['CaMKII_merged77.g', 'chem'] ] ################################################################## # Here we define what goes where, and any parameters. Each distribution # has the format # protoName, path, field, expr, [field, expr]... # where # protoName identifies the prototype to be placed on the cell # path is a MOOSE wildcard path specifying where to put things # field is the field to assign. # expr is a math expression to define field value. This uses the # muParser. Built-in variables are p, g, L, len, dia. # The muParser provides most math functions, and the Heaviside # function H(x) = 1 for x > 0 is also provided. ################################################################## chemRange = "H(1.1e-6 - dia) * H(p - 1300e-6)" spineDistrib = [ \ ["spine", '#apical#', \ "spineSpacing", chemRange + " * 5e-6", \ "spineSpacingDistrib", "1e-6", \ "angle", "0", \ "angleDistrib", "0", \ "size", "1", \ "sizeDistrib", "0" ] \ ] chemDistrib = [ \ [ "chem", "#apical#", "install", chemRange ] ] ###################################################################### # Here we define the mappings across scales. Format: # sourceObj sourceField destObj destField couplingExpr [wildcard][spatialExpn] # where the coupling expression is anything a muParser can evaluate, # using the input variable x. For example: 8e-5 + 300*x # For now, let's use existing adaptors which take an offset and scale. ###################################################################### adaptorList = [ [ 'Ca_conc', 'Ca', 'psd/Ca_input', 'concInit', 8e-5, 1 ], [ 'Ca_conc', 'Ca', 'dend/Ca_dend_input', 'concInit', 8e-5, 1 ], [ 'psd/tot_PSD_R', 'n', 'glu', 'Gbar', 0, 0.01 ], ] ###################################################################### # Having defined everything, now to create the rdesigneur and proceed # with creating the model. ###################################################################### rdes = rd.rdesigneur( useGssa = useGssa, \ combineSegments = combineSegments, \ stealCellFromLibrary = True, \ spineDistrib = spineDistrib, \ chemDistrib = chemDistrib, \ cellProto = cellProto, \ spineProto = spineProto, \ chemProto = chemProto ) return rdes
dx = comptLen * np.cos( theta ) dy = comptLen * np.sin( theta ) r = np.sqrt( x * x + y * y ) theta += comptLen / r compt = rd.buildCompt( axon, 'axon' + str(i), RM = RM, RA = RA, CM = CM, x = x, y = y, dx = dx, dy = dy, dia = comptDia ) moose.connect( prev, 'axial', compt, 'raxial' ) prev = compt x += dx y += dy return axon moose.Neutral( '/library' ) makeAxonProto() rdes = rd.rdesigneur( chanProto = [['make_HH_Na()', 'Na'], ['make_HH_K()', 'K']], cellProto = [['elec','axon']], chanDistrib = [ ['Na', '#', 'Gbar', '1200' ], ['K', '#', 'Gbar', '360' ]], stimList = [['soma', '1', '.', 'inject', '(t>0.01 && t<0.2) * 2e-11' ]], plotList = [['soma', '1', '.', 'Vm', 'Membrane potential']], moogList = [['#', '1', '.', 'Vm', 'Vm (mV)']] ) rdes.buildModel() moose.reinit() rdes.displayMoogli( 0.00005, 0.05, 0.0 )
def test1( ): rdes = rd.rdesigneur() rdes.buildModel() moose.showfields( rdes.soma )
import moose import rdesigneur as rd rdes = rd.rdesigneur( stimList = [['soma', '1', '.', 'inject', '(t>0.1 && t<0.2) * 2e-8' ]], plotList = [['soma', '1', '.', 'Vm', 'Soma membrane potential']] ) rdes.buildModel() moose.reinit() moose.start( 0.3 ) rdes.display()
import moose import pylab import rdesigneur as rd rdes = rd.rdesigneur( turnOffElec = True, chemProto = [['make_Chem_Oscillator()', 'osc']], chemDistrib = [['osc', 'soma', 'install', '1' ]], plotList = [['soma', '1', 'dend/a', 'conc', 'Concentration of a'], ['soma', '1', 'dend/b', 'conc', 'Concentration of b']], moogList = [['soma', '1', 'dend/a', 'conc', 'a Conc', 0, 360 ]] ) rdes.buildModel() bv = moose.vec( '/model/chem/dend/b' ) bv[0].concInit *= 2 bv[-1].concInit *= 2 moose.reinit() rdes.displayMoogli( 1, 400, 0.001 )
moose.connect( C, 'nOut', func.x[0], 'input' ) moose.connect( func, 'valueOut', reac, 'setNumKf' ) moose.connect( reac, 'sub', A, 'reac' ) moose.connect( reac, 'prd', B, 'reac' ) A.concInit = 1 B.concInit = 0 C.concInit = 0 reac.Kb = 1 makeFuncRate() rdes = rd.rdesigneur( turnOffElec = True, #This subdivides the 50-micron cylinder into 2 micron voxels diffusionLength = 2e-6, cellProto = [['somaProto', 'soma', 5e-6, 50e-6]], chemProto = [['chem', 'chem']], chemDistrib = [['chem', 'soma', 'install', '1' ]], plotList = [['soma', '1', 'dend/A', 'conc', 'A conc', 'wave'], ['soma', '1', 'dend/C', 'conc', 'C conc', 'wave']], ) rdes.buildModel() C = moose.element( '/model/chem/dend/C' ) C.vec.concInit = [ 1+np.sin(x/5.0) for x in range( len(C.vec) ) ] moose.reinit() moose.start(10) rdes.display()
def buildRdesigneur(): ################################################################## # Here we define which prototypes are to be loaded in to the system. # Each specification has the format # source [localName] # source can be any of # filename.extension, # Identify type of file by extension, load it. # function(), # func( name ) builds object of specified name # file.py:function() , # load Python file, run function(name) in it. # moose.Classname # Make obj moose.Classname, assign to name. # path # Already loaded into library or on path. # After loading the prototypes, there should be an object called 'name' # in the library. ################################################################## chanProto = [ ['./chans/hd.xml'], \ ['./chans/kap.xml'], \ ['./chans/kad.xml'], \ ['./chans/kdr.xml'], \ ['./chans/na3.xml'], \ ['./chans/nax.xml'], \ ['./chans/CaConc.xml'], \ ['./chans/Ca.xml'], \ ['./chans/NMDA.xml'], \ ['./chans/Glu.xml'] \ ] spineProto = [ \ ['makeSpineProto()', 'spine' ] ] chemProto = [ \ ['./chem/' + 'psd53.g', 'ltpModel'] \ ] ################################################################## # Here we define what goes where, and any parameters. Each distribution # has the format # protoName, path, field, expr, [field, expr]... # where # protoName identifies the prototype to be placed on the cell # path is a MOOSE wildcard path specifying where to put things # field is the field to assign. # expr is a math expression to define field value. This uses the # muParser. Built-in variables are p, g, L, len, dia. # The muParser provides most math functions, and the Heaviside # function H(x) = 1 for x > 0 is also provided. ################################################################## passiveDistrib = [ [ ".", "#", "RM", "2.8", "CM", "0.01", "RA", "1.5", \ "Em", "-58e-3", "initVm", "-65e-3" ], \ [ ".", "#axon#", "RA", "0.5" ] \ ] chanDistrib = [ \ ["hd", "#dend#,#apical#", "Gbar", "5e-2*(1+(p*3e4))" ], \ ["kdr", "#", "Gbar", "p < 50e-6 ? 500 : 100" ], \ ["na3", "#soma#,#dend#,#apical#", "Gbar", "250" ], \ ["nax", "#soma#,#axon#", "Gbar", "1250" ], \ ["kap", "#axon#,#soma#", "Gbar", "300" ], \ ["kap", "#dend#,#apical#", "Gbar", \ "300*(H(100-p*1e6)) * (1+(p*1e4))" ], \ ["Ca_conc", "#dend#,#apical#", "tau", "0.0133" ], \ ["kad", "#soma#,#dend#,#apical#", "Gbar", \ "300*H(p - 100e-6)*(1+p*1e4)" ], \ ["Ca", "#dend#,#apical#", "Gbar", "50" ], \ ["glu", "#dend#,#apical#", "Gbar", "200*H(p-200e-6)" ], \ ["NMDA", "#dend#,#apical#", "Gbar", "2*H(p-200e-6)" ] \ ] spineDistrib = [ \ ["spine", '#apical#', "spineSpacing", "20e-6", \ "spineSpacingDistrib", "2e-6", \ "angle", "0", \ "angleDistrib", str( 2*PI ), \ "size", "1", \ "sizeDistrib", "0.5" ] \ ] chemDistrib = [ \ [ "ltpModel", "#apical#", "install", "1"] ] ###################################################################### # Here we define the mappings across scales. Format: # sourceObj sourceField destObj destField couplingExpr [wildcard][spatialExpn] # where the coupling expression is anything a muParser can evaluate, # using the input variable x. For example: 8e-5 + 300*x # For now, let's use existing adaptors which take an offset and scale. ###################################################################### adaptorList = [ [ 'Ca_conc', 'Ca', 'psd/Ca_input', 'concInit', 8e-5, 1 ], [ 'Ca_conc', 'Ca', 'dend/Ca_dend_input', 'concInit', 8e-5, 1 ], [ 'psd/tot_PSD_R', 'n', 'glu', 'Gbar', 0, 0.01 ], ] ###################################################################### # Having defined everything, now to create the rdesigneur and proceed # with creating the model. ###################################################################### rdes = rd.rdesigneur( useGssa = useGssa, \ combineSegments = combineSegments, \ stealCellFromLibrary = True, \ passiveDistrib = passiveDistrib, \ spineDistrib = spineDistrib, \ chanDistrib = chanDistrib, \ chemDistrib = chemDistrib, \ spineProto = spineProto, \ chanProto = chanProto, \ chemProto = chemProto, \ adaptorList = adaptorList ) return rdes
import moose import pylab import rdesigneur as rd library = moose.Neutral( '/library' ) compt = rd.make_Chem_Oscillator( 'osc' ) moose.copy( compt, '/library/osc', 'dend' ) moose.copy( compt, '/library/osc', 'psd' ) rdes = rd.rdesigneur( turnOffElec = True, cellProto = [[ './cells/h10.CNG.swc', 'elec']], spineProto = [[ 'make_passive_spine()', 'spine' ] ], spineDistrib = [ ["spine", '#apical#,#dend#', '10e-6', '1e-6' ]], #chemProto = [['./chem/psd.sbml', 'spiny']], chemProto = [['/library/osc', 'osc']], chemDistrib =[[ 'osc', '#apical#,#dend#', 'install', 'H(p - 5e-4)' ]], plotList = [['#', '1', 'psd/a', 'conc', 'conc of a in PSD']] ) rdes.buildModel() print 'Done -1' moose.reinit() print 'Done 0' moose.start( 0.05 ) print 'Done' for i in moose.wildcardFind( '/model/chem/psd/s[]' ): print i.conc
import re import rdesigneur as rd import matplotlib.pyplot as plt import numpy as np moose.Neutral( '/library' ) moose.Neutral( '/library/diffn' ) moose.CubeMesh( '/library/diffn/dend' ) A = moose.Pool( '/library/diffn/dend/A' ) A.diffConst = 1e-10 rdes = rd.rdesigneur( turnOffElec = True, diffusionLength = 1e-6, chemProto = [['diffn', 'diffn']], chemDistrib = [['diffn', 'soma', 'install', '1' ]], moogList = [ ['soma', '1', 'dend/A', 'conc', 'A Conc', 0, 360 ] ] ) rdes.buildModel() rdes.displayMoogli( 1, 2, rotation = 0, azim = -np.pi/2, elev = 0.0, block = False ) av = moose.vec( '/model/chem/dend/A' ) for i in range(10): av[i].concInit = 1 moose.reinit() plist = [] for i in range( 20 ): plist.append( av.conc[:200] ) moose.start( 2 )
# action potentials. It also shows how to deliver an interesting stimulus. # Copyright (C) Upinder S. Bhalla NCBS 2018 # Released under the terms of the GNU Public License V3. ######################################################################## import moose import pylab import rdesigneur as rd import time rdes = rd.rdesigneur( cellProto = [['ballAndStick', 'soma', 20e-6, 20e-6, 4e-6, 500e-6, 10]], chanProto = [['make_HH_Na()', 'Na'], ['make_HH_K()', 'K']], chanDistrib = [ ['Na', 'soma', 'Gbar', '1200' ], ['K', 'soma', 'Gbar', '360' ], ['Na', 'dend#', 'Gbar', '400' ], ['K', 'dend#', 'Gbar', '120' ] ], stimList = [['soma', '1', '.', 'inject', '(1+cos(t/10))*(t>31.4 && t<94) * 0.5e-9' ]], plotList = [ ['soma', '1', '.', 'Vm', 'Membrane potential'], ['soma', '1', '.', 'inject', 'Stimulus current'] ], ) rdes.buildModel() runtime = 100 moose.reinit() t0= time.time() moose.start( runtime )