def loadGran98NeuroML_L123(filename, params): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename,params=params) print "Number of compartments =",\ len(moose.Neuron(populationDict['CA1group'][1][0].path).children) soma_path = populationDict['CA1group'][1][0].path + '/Seg0_soma_0_0' somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm') #somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') #somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print "Reinit MOOSE ... " resetSim(['/elec', '/cells'], simdt, plotdt, simmethod='hsolve') # from moose.utils print "Running ... " moose.start(runtime) tvec = arange(0.0, runtime, simdt) plot(tvec, somaVm.vector[1:]) title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') print "Showing plots ..." show()
def loadXMLModel(self, filename, target): """Load a model in some XML format. Looks inside the XML to figure out if this is a neuroML or an SBML file and calls the corresponding loader functions. Currently only SBML and neuroML are support. In future 9ml support will be provided as the specification becomes stable. """ with open(filename, 'r') as xmlfile: for line in xmlfile: self._xmlreader.feed(line) if self._saxhandler.model_type is not None: break ret = self._saxhandler.model_type self._saxhandler.model_type = None self._xmlreader.reset() if ret == MooseHandler.type_neuroml: #self._context.loadModel(filename, target) neuromlR = NeuroML() populationDict, projectionDict = neuromlR.readNeuroMLFromFile(filename) elif ret == MooseHandler.type_sbml: print 'Unsupported in GUI Mode' return ret
def _loadElec(self, efile, elecname, combineSegments): library = moose.Neutral('/library') if (efile[len(efile) - 2:] == ".p"): self.elecid = moose.loadModel(efile, self.model.path + '/' + elecname) else: nm = NeuroML() nm.readNeuroMLFromFile( efile, \ params = {'combineSegments': combineSegments, \ 'createPotentialSynapses': True } ) if moose.exists('/cells'): kids = moose.wildcardFind('/cells/#') else: kids = moose.wildcardFind( '/library/#[ISA=Neuron],/library/#[TYPE=Neutral]') if (kids[0].name == 'spine'): kids = kids[1:] assert (len(kids) > 0) self.elecid = kids[0] temp = moose.wildcardFind(self.elecid.path + '/#[ISA=CompartmentBase]') moose.move(self.elecid, self.model) self.elecid.name = elecname self._transformNMDAR(self.elecid.path) kids = moose.wildcardFind('/library/##[0]') for i in kids: i.tick = -1
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['Gran'][1][0].path + '/Soma_0' somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm') somaCa = setupTable('somaCa', moose.CaConc(soma_path + '/Gran_CaPool_98'), 'Ca') somaIKCa = setupTable('somaIKCa', moose.HHChannel(soma_path + '/Gran_KCa_98'), 'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print("Reinit MOOSE ... ") resetSim(['/elec', '/cells'], simdt, plotdt, simmethod='ee') # from moose.utils print("Running ... ") moose.start(runtime) tvec = arange(0.0, runtime, plotdt) plot(tvec, somaVm.vector[1:]) title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') figure() plot(tvec, somaCa.vector[1:]) title('Soma Ca') xlabel('time (s)') ylabel('Ca conc (mol/m^3)') figure() plot(tvec, somaIKCa.vector[1:]) title('KCa current (A)') xlabel('time (s)') ylabel('') print("Showing plots ...") show()
def _loadElec( self, efile, elecname, combineSegments ): library = moose.Neutral( '/library' ) if ( efile[ len( efile ) - 2:] == ".p" ): self.elecid = moose.loadModel( efile, self.model.path + '/' + elecname ) else: nm = NeuroML() nm.readNeuroMLFromFile( efile, \ params = {'combineSegments': combineSegments, \ 'createPotentialSynapses': True } ) if moose.exists( '/cells' ): kids = moose.wildcardFind( '/cells/#' ) else: kids = moose.wildcardFind( '/library/#[ISA=Neuron],/library/#[TYPE=Neutral]' ) if ( kids[0].name == 'spine' ): kids = kids[1:] assert( len( kids ) > 0 ) self.elecid = kids[0] temp = moose.wildcardFind( self.elecid.path + '/#[ISA=CompartmentBase]' ) moose.move( self.elecid, self.model ) self.elecid.name = elecname self._transformNMDAR( self.elecid.path ) kids = moose.wildcardFind( '/library/##[0]' ) for i in kids: i.tick = -1
def loadGran98NeuroML_L123(filename, nogui=False): neuromlR = NeuroML() populationDict, projectionDict = neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict["Gran"][1][0].path + "/Soma_0" somaVm = setupTable("somaVm", moose.Compartment(soma_path), "Vm") somaCa = setupTable("somaCa", moose.CaConc(soma_path + "/Gran_CaPool_98"), "Ca") somaIKCa = setupTable("somaIKCa", moose.HHChannel(soma_path + "/Gran_KCa_98"), "Gk") soma = moose.Compartment(soma_path) print ("Reinit MOOSE ... ") resetSim(["/elec", "/cells"], simdt, plotdt, simmethod="ee") # from moose.utils print ("Running ... ") moose.start(runtime) print ("Finished simulation of %s seconds" % runtime) if not nogui: from pylab import * tvec = arange(0.0, runtime, plotdt) plot(tvec, somaVm.vector[1:]) title("Soma Vm") xlabel("time (s)") ylabel("Voltage (V)") figure() plot(tvec, somaCa.vector[1:]) title("Soma Ca") xlabel("time (s)") ylabel("Ca conc (mol/m^3)") figure() plot(tvec, somaIKCa.vector[1:]) title("KCa current (A)") xlabel("time (s)") ylabel("") print "Showing plots ..." show()
def _loadElec(self, efile, elecname): if (efile[len(efile) - 2:] == ".p"): self.elecid = moose.loadModel(efile, '/library/' + elecname)[0] print(self.elecid) elif (efile[len(efile) - 4:] == ".swc"): self.elecid = moose.loadModel(efile, '/library/' + elecname)[0] else: nm = NeuroML() print("in _loadElec, combineSegments = ", self.combineSegments) nm.readNeuroMLFromFile( efile, \ params = {'combineSegments': self.combineSegments, \ 'createPotentialSynapses': True } ) if moose.exists('/cells'): kids = moose.wildcardFind('/cells/#') else: kids = moose.wildcardFind( '/library/#[ISA=Neuron],/library/#[TYPE=Neutral]') if (kids[0].name == 'spine'): kids = kids[1:] assert (len(kids) > 0) self.elecid = kids[0] temp = moose.wildcardFind(self.elecid.path + '/#[ISA=CompartmentBase]') transformNMDAR(self.elecid.path) kids = moose.wildcardFind('/library/##[0]') for i in kids: i.tick = -1
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['Gran'][1][0].path+'/Soma_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') ## Am not able to plot KDr gating variable X when running under hsolve #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') print "Reinit MOOSE ... " resetSim(['/elec',cells_path], simdt, plotdt, simmethod='hsolve') print "Running ... " moose.start(runtime) tvec = arange(0.0,runtime*2.0,plotdt) tvec = tvec[ : somaVm.vector.size ] plot(tvec,somaVm.vector) title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') figure() plot(tvec,somaCa.vector) title('Soma Ca') xlabel('time (s)') ylabel('Ca conc (mol/m^3)') figure() plot(tvec,somaIKCa.vector) title('soma KCa current') xlabel('time (s)') ylabel('KCa current (A)') print "Showing plots ..." show()
def runSTGNeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma1_path = populationDict['AB_PD'][1][0].path+'/Soma_0' soma1Vm = setupTable('somaVm',moose.Compartment(soma1_path),'Vm') soma2_path = populationDict['LP'][1][0].path+'/Soma_0' soma2Vm = setupTable('somaVm',moose.Compartment(soma2_path),'Vm') soma3_path = populationDict['PY'][1][0].path+'/Soma_0' soma3Vm = setupTable('somaVm',moose.Compartment(soma3_path),'Vm') #somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/CaPool_STG'),'Ca') #somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/KCa_STG'),'Ik') #somaCaE = setupTable('somaCaE',moose.HHChannel(soma_path+'/CaT_STG/nernst'),'E') ## Am not able to plot KDr gating variable X when running under hsolve #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') print "Reinit MOOSE ... " resetSim(['/elec',cells_path], simdt, plotdt, simmethod='hsolve') print "Running ... " moose.start(runtime) tvec = arange(0.0,runtime+2*plotdt,plotdt) tvec = tvec[ : soma1Vm.vec.size ] plot(tvec,soma1Vm.vec,label='AB_PD',color='g',linestyle='dashed') plot(tvec,soma2Vm.vec,label='LP',color='r',linestyle='solid') plot(tvec,soma3Vm.vec,label='PY',color='b',linestyle='dashed') legend() title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') print "Showing plots ..." show()
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['Gran'][1][0].path+'/Soma_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print("Reinit MOOSE ... ") resetSim(['/elec','/cells'],simdt,plotdt,simmethod='ee') # from moose.utils print("Running ... ") moose.start(runtime) tvec = arange(0.0,runtime,plotdt) plot(tvec,somaVm.vector[1:]) title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') figure() plot(tvec,somaCa.vector[1:]) title('Soma Ca') xlabel('time (s)') ylabel('Ca conc (mol/m^3)') figure() plot(tvec,somaIKCa.vector[1:]) title('KCa current (A)') xlabel('time (s)') ylabel('') print("Showing plots ...") show()
def _loadElec( self, efile, elecname ): if ( efile[ len( efile ) - 2:] == ".p" ): self.elecid = moose.loadModel( efile, '/library/' + elecname)[0] print self.elecid elif ( efile[ len( efile ) - 4:] == ".swc" ): self.elecid = moose.loadModel( efile, '/library/' + elecname)[0] else: nm = NeuroML() print "in _loadElec, combineSegments = ", self.combineSegments nm.readNeuroMLFromFile( efile, \ params = {'combineSegments': self.combineSegments, \ 'createPotentialSynapses': True } ) if moose.exists( '/cells' ): kids = moose.wildcardFind( '/cells/#' ) else: kids = moose.wildcardFind( '/library/#[ISA=Neuron],/library/#[TYPE=Neutral]' ) if ( kids[0].name == 'spine' ): kids = kids[1:] assert( len( kids ) > 0 ) self.elecid = kids[0] temp = moose.wildcardFind( self.elecid.path + '/#[ISA=CompartmentBase]' ) transformNMDAR( self.elecid.path ) kids = moose.wildcardFind( '/library/##[0]' ) for i in kids: i.tick = -1
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['CA1group'][1][0].path+'/Seg0_soma_0_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') soma = moose.Compartment(soma_path) moose.reinit() moose.start(runtime) tvec = np.arange(0.0,runtime,simdt) res = count.spike_train_simple_stat( somaVm.vector ) return res['number of spikes']
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['CA1group'][1][0].path + '/Seg0_soma_0_0' somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm') soma = moose.Compartment(soma_path) moose.reinit() moose.start(runtime) tvec = np.arange(0.0, runtime, simdt) res = count.spike_train_simple_stat(somaVm.vector) return res['number of spikes']
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['Gran'][1][0].path+'/Soma_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print "Reinit MOOSE ... " resetSim(['/elec','/cells'],simdt,plotdt,simmethod='ee') # from moose.utils print "Running ... " moose.start(runtime) print 'Finished simulation for', runtime, 'seconds'
def loadModel(filename): global soma_, cellSpikeTable_ neuromlR = NeuroML() neuromlR.readNeuroMLFromFile(filename) libcell = moose.Neuron('/library/CA1soma') CA1Cellid = moose.copy(libcell,moose.Neutral('/cells'),'CA1') CA1Cell = moose.Neuron(CA1Cellid) spikeGen = moose.SpikeGen(CA1Cell.path+'/spikeGen') spikeGen.threshold = -30e-3 # V soma_ = moose.Compartment(CA1Cell.path+'/Seg0_soma_0_0') soma_.inject = 0 # by default the cell has a current injection moose.connect(soma_,'VmOut',spikeGen,'Vm') table_path = moose.Neutral(CA1Cell.path+'/data').path cellSpikeTable_ = moose.Table(table_path+'/spikesTable') moose.connect(spikeGen,'spikeOut', cellSpikeTable_,'input')
def loadGran98NeuroML_L123(filename,params): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename,params=params) print "Number of compartments =",\ len(moose.Neuron(populationDict['CA1group'][1][0].path).children) soma_path = populationDict['CA1group'][1][0].path+'/Seg0_soma_0_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') #somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') #somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print "Reinit MOOSE ... " resetSim(['/elec','/cells'],simdt,plotdt,simmethod='hsolve') # from moose.utils print "Running ... " moose.start(runtime) tvec = arange(0.0,runtime,simdt)
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma_path = populationDict['Gran'][1][0].path + '/Soma_0' somaVm = setupTable('somaVm', moose.Compartment(soma_path), 'Vm') somaCa = setupTable('somaCa', moose.CaConc(soma_path + '/Gran_CaPool_98'), 'Ca') somaIKCa = setupTable('somaIKCa', moose.HHChannel(soma_path + '/Gran_KCa_98'), 'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print "Reinit MOOSE ... " resetSim(['/elec', '/cells'], simdt, plotdt, simmethod='ee') # from moose.utils print "Running ... " moose.start(runtime) print 'Finished simulation for', runtime, 'seconds'
def loadGran98NeuroML_L123(filename): neuromlR = NeuroML() populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) # readNeuroMLFromFile returns populationDict = { 'populationname1':(cellname,{int(instanceid1):moosecell, ... }) , ... } # and projectionDict = { 'projectionname1':(source,target,[(syn_name1,pre_seg_path,post_seg_path),...]) , ... } soma_path = populationDict['Gran'][1][0].path+'/Soma_0' somaVm = setupTable('somaVm',moose.Compartment(soma_path),'Vm') somaCa = setupTable('somaCa',moose.CaConc(soma_path+'/Gran_CaPool_98'),'Ca') somaIKCa = setupTable('somaIKCa',moose.HHChannel(soma_path+'/Gran_KCa_98'),'Gk') #KDrX = setupTable('ChanX',moose.HHChannel(soma_path+'/Gran_KDr_98'),'X') soma = moose.Compartment(soma_path) print "Reinit MOOSE ... " resetSim(['/elec','/cells'],simdt,plotdt,simmethod='ee') # from moose.utils print "Running ... " moose.start(runtime) # plotting tvec = arange(0.0,runtime,plotdt) plot(tvec,somaVm.vector[1:]) title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') figure() plot(tvec,somaCa.vector[1:]) title('Soma Ca') xlabel('time (s)') ylabel('Ca conc (mol/m^3)') figure() plot(tvec,somaIKCa.vector[1:]) title('KCa current (A)') xlabel('time (s)') ylabel('') print "Showing plots ..." show()
def loadRunSTGNeuroML_L123(filename): 'Loads and runs the pyloric rhythm generator from NeuroML files.' # for graded synapses, else NeuroML event-based are used from load_synapses import load_synapses moose.Neutral('/library') # set graded to False to use event based synapses # if False, neuroml event-based synapses get searched for and loaded # True to load graded synapses graded_syn = True #graded_syn = False if graded_syn: load_synapses() neuromlR = NeuroML() ## readNeuroMLFromFile below returns: # This returns # populationDict = { # 'populationname1':('cellName',{('instanceid1'):moosecell, ... }) # , ... # } # (cellName and instanceid are strings, mooosecell is a moose.Neuron object instance) # and # projectionDict = { # 'projName1':('source','target',[('syn_name1','pre_seg_path','post_seg_path') # ,...]) # , ... # } populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma1_path = populationDict['AB_PD'][1][0].path+'/Soma_0' soma1Vm = setupTable('somaVm',moose.Compartment(soma1_path),'Vm') soma2_path = populationDict['LP'][1][0].path+'/Soma_0' soma2Vm = setupTable('somaVm',moose.Compartment(soma2_path),'Vm') soma3_path = populationDict['PY'][1][0].path+'/Soma_0' soma3Vm = setupTable('somaVm',moose.Compartment(soma3_path),'Vm') # monitor channel current channel_path = soma1_path + '/KCa_STG' channel_Ik = setupTable('KCa_Ik',moose.element(channel_path),'Ik') # monitor Ca capool_path = soma1_path + '/CaPool_STG' capool_Ca = setupTable('CaPool_Ca',moose.element(capool_path),'Ca') # monitor synaptic current soma2 = moose.element(soma2_path) print "Children of",soma2_path,"are:" for child in soma2.children: print child.className, child.path if graded_syn: syn_path = soma2_path+'/DoubExpSyn_Ach__cells-0-_AB_PD_0-0-_Soma_0' syn = moose.element(syn_path) else: syn_path = soma2_path+'/DoubExpSyn_Ach' syn = moose.element(syn_path) syn_Ik = setupTable('DoubExpSyn_Ach_Ik',syn,'Ik') print "Reinit MOOSE ... " resetSim(['/elec',cells_path], simdt, plotdt, simmethod='hsolve') print "Using graded synapses? = ", graded_syn print "Running model filename = ",filename," ... " moose.start(runtime) tvec = np.arange(0.0,runtime+2*plotdt,plotdt) tvec = tvec[ : soma1Vm.vector.size ] fig = plt.figure(facecolor='w',figsize=(10,6)) axA = plt.subplot2grid((3,2),(0,0),rowspan=3,colspan=1,frameon=False) img = plt.imread( 'STG.png' ) imgplot = axA.imshow( img ) for tick in axA.get_xticklines(): tick.set_visible(False) for tick in axA.get_yticklines(): tick.set_visible(False) axA.set_xticklabels([]) axA.set_yticklabels([]) ax = plt.subplot2grid((3,2),(0,1),rowspan=1,colspan=1) ax.plot(tvec,soma1Vm.vector*1000,label='AB_PD',color='g',linestyle='solid') ax.set_xticklabels([]) ax.set_ylabel('AB_PD (mV)') ax = plt.subplot2grid((3,2),(1,1),rowspan=1,colspan=1) ax.plot(tvec,soma2Vm.vector*1000,label='LP',color='r',linestyle='solid') ax.set_xticklabels([]) ax.set_ylabel('LP (mV)') ax = plt.subplot2grid((3,2),(2,1),rowspan=1,colspan=1) ax.plot(tvec,soma3Vm.vector*1000,label='PY',color='b',linestyle='solid') ax.set_ylabel('PY (mV)') ax.set_xlabel('time (s)') fig.tight_layout() fig = plt.figure(facecolor='w') plt.plot(tvec,soma2Vm.vector*1000,label='LP',color='r',linestyle='solid') plt.plot(tvec,soma3Vm.vector*1000,label='PY',color='b',linestyle='solid') plt.legend() plt.xlabel('time (s)') plt.ylabel('Soma Vm (mV)') plt.figure(facecolor='w') plt.plot(tvec,channel_Ik.vector,color='b',linestyle='solid') plt.title('KCa current; Ca conc') plt.xlabel('time (s)') plt.ylabel('Ik (Amp)') plt.twinx() plt.plot(tvec,capool_Ca.vector,color='r',linestyle='solid') plt.ylabel('Ca (mol/m^3)') plt.figure(facecolor='w') plt.plot(tvec,syn_Ik.vector,color='b',linestyle='solid') plt.title('Ach syn current in '+soma2_path) plt.xlabel('time (s)') plt.ylabel('Isyn (S)') print "Showing plots ..." plt.show()
import sys sys.path.append('.') import moose from moose.utils import * from moose.neuroml.NeuroML import NeuroML from pylab import * SIMDT = 25e-6 # s PLOTDT = 25e-6 # s RUNTIME = 1.0 # s injectmax = 2e-12 # Amperes neuromlR = NeuroML() neuromlR.readNeuroMLFromFile('cells_channels/CA1soma.morph.xml') libcell = moose.Neuron('/library/CA1soma') CA1Cellid = moose.copy(libcell,moose.Neutral('/cells'),'CA1') CA1Cell = moose.Neuron(CA1Cellid) #printCellTree(CA1Cell) ## edge-detect the spikes using spike-gen (table does not have edge detect) spikeGen = moose.SpikeGen(CA1Cell.path+'/spikeGen') spikeGen.threshold = -30e-3 # V CA1CellSoma = moose.Compartment(CA1Cell.path+'/Seg0_soma_0_0') CA1CellSoma.inject = 0 # by default the cell has a current injection moose.connect(CA1CellSoma,'VmOut',spikeGen,'Vm') ## save spikes in table table_path = moose.Neutral(CA1Cell.path+'/data').path CA1CellSpikesTable = moose.Table(table_path+'/spikesTable')
RM_soma = 6.29013 # for somatic compartments RM (uniform) RM_end = 3.1916 # for non somatic compartments RM (uniform) RM_halfdist = 100.05 RM_slope = 50.48 CM = 1.0595e-6 * 1e4 # for somatic compartments CM (uniform) RA = 2.18 # for non somatic compartments RA (uniform) sag_cond = 1.9359 # sag conductance multiplier as used in NEURON simulation for HCN on #sag_cond = 0 # sag conductance multiplier as used in NEURON simulation for HCN off initVm = -62e-3 #: Resting membrane potential E_leak = -69e-3 libraryName = '/library' cell_path = '/library/CA1' # Read in the CA1 cell morphology filename = 'CA1_nrn_morph_nobiophys_Ri04.xml' neuromlR = NeuroML() neuromlR.readNeuroMLFromFile(filename) # Re-create the python variable pointing to the CA1_cell to limit results just to # type compartment (excludes the spines and allows for createDataTables function to # work properly) CA1_cell = moose.wildcardFind(cell_path + '/' + '#[TYPE=Compartment]') # Define the origin to be used in the simulation as the center of the soma, as the soma is defined by # multiple compartments soma_xloc = CA1_cell[0].x0 + ( CA1_cell[0].x - CA1_cell[0].x0) / 2 # x for center of compartment soma_yloc = CA1_cell[0].y0 + ( CA1_cell[0].y - CA1_cell[0].y0) / 2 # x for center of compartment soma_zloc = CA1_cell[0].z0 + ( CA1_cell[0].z - CA1_cell[0].z0) / 2 # x for center of compartment
def loadSTGNeuroML_L123(filename): neuromlR = NeuroML() ## readNeuroMLFromFile below returns: # This returns # populationDict = { # 'populationname1':('cellName',{('instanceid1'):moosecell, ... }) # , ... # } # (cellName and instanceid are strings, mooosecell is a moose.Neuron object instance) # and # projectionDict = { # 'projName1':('source','target',[('syn_name1','pre_seg_path','post_seg_path') # ,...]) # , ... # } populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma1_path = populationDict['AB_PD'][1][0].path+'/Soma_0' soma1Vm = setupTable('somaVm',moose.Compartment(soma1_path),'Vm') soma2_path = populationDict['LP'][1][0].path+'/Soma_0' soma2Vm = setupTable('somaVm',moose.Compartment(soma2_path),'Vm') soma3_path = populationDict['PY'][1][0].path+'/Soma_0' soma3Vm = setupTable('somaVm',moose.Compartment(soma3_path),'Vm') # monitor channel current channel_path = soma1_path + '/KCa_STG' channel_Ik = setupTable('KCa_Ik',moose.element(channel_path),'Ik') # monitor Ca capool_path = soma1_path + '/CaPool_STG' capool_Ca = setupTable('CaPool_Ca',moose.element(capool_path),'Ca') # monitor synaptic current soma2 = moose.element(soma2_path) print "Children of",soma2_path,"are:" for child in soma2.children: print child.className, child.path if graded_syn: syn_path = soma2_path+'/DoubExpSyn_Ach__cells-0-_AB_PD_0-0-_Soma_0' syn = moose.element(syn_path) else: syn_path = soma2_path+'/DoubExpSyn_Ach' syn = moose.element(syn_path) syn_Ik = setupTable('DoubExpSyn_Ach_Ik',syn,'Ik') print "Reinit MOOSE ... " resetSim(['/elec',cells_path], simdt, plotdt, simmethod='ee') print "Running ... " moose.start(runtime) tvec = arange(0.0,runtime+2*plotdt,plotdt) tvec = tvec[ : soma1Vm.vector.size ] figure(facecolor='w') plot(tvec,soma1Vm.vector,label='AB_PD',color='g',linestyle='solid') plot(tvec,soma2Vm.vector,label='LP',color='r',linestyle='solid') plot(tvec,soma3Vm.vector,label='PY',color='b',linestyle='solid') legend() title('Soma Vm') xlabel('time (s)') ylabel('Voltage (V)') figure(facecolor='w') plot(tvec,channel_Ik.vector,color='b',linestyle='solid') title('KCa current; Ca conc') xlabel('time (s)') ylabel('Ik (Amp)') twinx() plot(tvec,capool_Ca.vector,color='r',linestyle='solid') ylabel('Ca (mol/m^3)') figure(facecolor='w') plot(tvec,syn_Ik.vector,color='b',linestyle='solid') title('Ach syn current in '+soma2_path) xlabel('time (s)') ylabel('Isyn (S)') print "Showing plots ..." show()
import sys sys.path.append('.') import moose from moose.utils import * from moose.neuroml.NeuroML import NeuroML from pylab import * SIMDT = 25e-6 # s PLOTDT = 25e-6 # s RUNTIME = 2.0 # s injectmax = 20e-12 # Amperes neuromlR = NeuroML() neuromlR.readNeuroMLFromFile('cells_channels/Granule_98.morph.xml') libcell = moose.Neuron('/library/Granule_98') granCellid = moose.copy(libcell,moose.Neutral('/cells'),'granCell') granCell = moose.Neuron(granCellid) ## edge-detect the spikes using spike-gen (table does not have edge detect) spikeGen = moose.SpikeGen(granCell.path+'/spikeGen') spikeGen.threshold = 0e-3 # V granCellSoma = moose.Compartment(granCell.path+'/Soma_0') moose.connect(granCellSoma,'VmOut',spikeGen,'Vm') ## save spikes in table table_path = moose.Neutral(granCell.path+'/data').path granCellSpikesTable = moose.Table(table_path+'/spikesTable') moose.connect(spikeGen,'spikeOut',granCellSpikesTable,'input')
def loadRunSTGNeuroML_L123(filename): 'Loads and runs the pyloric rhythm generator from NeuroML files.' # for graded synapses, else NeuroML event-based are used from load_synapses import load_synapses moose.Neutral('/library') # set graded to False to use event based synapses # if False, neuroml event-based synapses get searched for and loaded # True to load graded synapses graded_syn = True #graded_syn = False if graded_syn: load_synapses() neuromlR = NeuroML() ## readNeuroMLFromFile below returns: # This returns # populationDict = { # 'populationname1':('cellName',{('instanceid1'):moosecell, ... }) # , ... # } # (cellName and instanceid are strings, mooosecell is a moose.Neuron object instance) # and # projectionDict = { # 'projName1':('source','target',[('syn_name1','pre_seg_path','post_seg_path') # ,...]) # , ... # } populationDict, projectionDict = \ neuromlR.readNeuroMLFromFile(filename) soma1_path = populationDict['AB_PD'][1][0].path + '/Soma_0' soma1Vm = setupTable('somaVm', moose.Compartment(soma1_path), 'Vm') soma2_path = populationDict['LP'][1][0].path + '/Soma_0' soma2Vm = setupTable('somaVm', moose.Compartment(soma2_path), 'Vm') soma3_path = populationDict['PY'][1][0].path + '/Soma_0' soma3Vm = setupTable('somaVm', moose.Compartment(soma3_path), 'Vm') # monitor channel current channel_path = soma1_path + '/KCa_STG' channel_Ik = setupTable('KCa_Ik', moose.element(channel_path), 'Ik') # monitor Ca capool_path = soma1_path + '/CaPool_STG' capool_Ca = setupTable('CaPool_Ca', moose.element(capool_path), 'Ca') # monitor synaptic current soma2 = moose.element(soma2_path) print "Children of", soma2_path, "are:" for child in soma2.children: print child.className, child.path if graded_syn: syn_path = soma2_path + '/DoubExpSyn_Ach__cells-0-_AB_PD_0-0-_Soma_0' syn = moose.element(syn_path) else: syn_path = soma2_path + '/DoubExpSyn_Ach' syn = moose.element(syn_path) syn_Ik = setupTable('DoubExpSyn_Ach_Ik', syn, 'Ik') print "Reinit MOOSE ... " resetSim(['/elec', cells_path], simdt, plotdt, simmethod='hsolve') print "Using graded synapses? = ", graded_syn print "Running model filename = ", filename, " ... " moose.start(runtime) tvec = np.arange(0.0, runtime + 2 * plotdt, plotdt) tvec = tvec[:soma1Vm.vector.size] fig = plt.figure(facecolor='w', figsize=(10, 6)) axA = plt.subplot2grid((3, 2), (0, 0), rowspan=3, colspan=1, frameon=False) img = plt.imread('STG.png') imgplot = axA.imshow(img) for tick in axA.get_xticklines(): tick.set_visible(False) for tick in axA.get_yticklines(): tick.set_visible(False) axA.set_xticklabels([]) axA.set_yticklabels([]) ax = plt.subplot2grid((3, 2), (0, 1), rowspan=1, colspan=1) ax.plot(tvec, soma1Vm.vector * 1000, label='AB_PD', color='g', linestyle='solid') ax.set_xticklabels([]) ax.set_ylabel('AB_PD (mV)') ax = plt.subplot2grid((3, 2), (1, 1), rowspan=1, colspan=1) ax.plot(tvec, soma2Vm.vector * 1000, label='LP', color='r', linestyle='solid') ax.set_xticklabels([]) ax.set_ylabel('LP (mV)') ax = plt.subplot2grid((3, 2), (2, 1), rowspan=1, colspan=1) ax.plot(tvec, soma3Vm.vector * 1000, label='PY', color='b', linestyle='solid') ax.set_ylabel('PY (mV)') ax.set_xlabel('time (s)') fig.tight_layout() fig = plt.figure(facecolor='w') plt.plot(tvec, soma2Vm.vector * 1000, label='LP', color='r', linestyle='solid') plt.plot(tvec, soma3Vm.vector * 1000, label='PY', color='b', linestyle='solid') plt.legend() plt.xlabel('time (s)') plt.ylabel('Soma Vm (mV)') plt.figure(facecolor='w') plt.plot(tvec, channel_Ik.vector, color='b', linestyle='solid') plt.title('KCa current; Ca conc') plt.xlabel('time (s)') plt.ylabel('Ik (Amp)') plt.twinx() plt.plot(tvec, capool_Ca.vector, color='r', linestyle='solid') plt.ylabel('Ca (mol/m^3)') plt.figure(facecolor='w') plt.plot(tvec, syn_Ik.vector, color='b', linestyle='solid') plt.title('Ach syn current in ' + soma2_path) plt.xlabel('time (s)') plt.ylabel('Isyn (S)') print "Showing plots ..." plt.show()
import sys sys.path.append('.') import moose from moose.utils import * from moose.neuroml.NeuroML import NeuroML from pylab import * SIMDT = 25e-6 # s PLOTDT = 25e-6 # s RUNTIME = 2.0 # s injectmax = 20e-12 # Amperes neuromlR = NeuroML() neuromlR.readNeuroMLFromFile('cells_channels/Granule_98.morph.xml') libcell = moose.Neuron('/library/Granule_98') granCellid = moose.copy(libcell, moose.Neutral('/cells'), 'granCell') granCell = moose.Neuron(granCellid) ## edge-detect the spikes using spike-gen (table does not have edge detect) spikeGen = moose.SpikeGen(granCell.path + '/spikeGen') spikeGen.threshold = 0e-3 # V granCellSoma = moose.Compartment(granCell.path + '/Soma_0') moose.connect(granCellSoma, 'VmOut', spikeGen, 'Vm') ## save spikes in table table_path = moose.Neutral(granCell.path + '/data').path granCellSpikesTable = moose.Table(table_path + '/spikesTable') moose.connect(spikeGen, 'spikeOut', granCellSpikesTable, 'input')