Changeset 726
- Timestamp:
- 03/11/10 15:24:33 (2 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 4 modified
-
examples/HH_cond_exp2.py (added)
-
src/moose/__init__.py (modified) (2 diffs)
-
src/moose/cells.py (modified) (3 diffs)
-
src/moose/recording.py (added)
-
src/moose/simple_example.py (added)
-
src/moose/simulator.py (added)
-
src/neuron/__init__.py (modified) (1 diff)
-
src/neuron/simulator.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/moose/__init__.py
r601 r726 1 """Interfacing MOOSE to PyNN""" 1 # encoding: utf-8 2 """ 3 MOOSE implementation of the PyNN API 4 5 Authors: Subhasis Ray and Andrew Davison 6 7 $Id:$ 8 """ 9 2 10 import moose 3 import Neuron 4 from cells import * 5 from pyNN import common 11 from pyNN.moose import simulator 12 from pyNN import common, recording 13 common.simulator = simulator 14 recording.simulator = simulator 6 15 7 def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, debug=False, **extra_params): 16 from pyNN.moose.cells import * 17 from pyNN.moose.recording import * 18 19 import logging 20 logger = logging.getLogger("PyNN") 21 22 # ============================================================================== 23 # Functions for simulation set-up and control 24 # ============================================================================== 25 26 def setup(timestep=0.1, min_delay=0.1, max_delay=10.0, **extra_params): 8 27 """ 9 28 Should be called at the very beginning of a script. … … 11 30 simulator but not by others. 12 31 """ 13 common.setup(timestep, min_delay, max_delay, debug, **extra_params) 14 ctx = moose.PyMooseBase.getContext() 15 ctx.setClock(0, timestep, 0) 32 common.setup(timestep, min_delay, max_delay, **extra_params) 33 simulator.state.dt = timestep 16 34 return 0 17 35 18 36 def end(compatible_output=True): 19 37 """Do any necessary cleaning up before exiting.""" 38 for recorder in simulator.recorder_list: 39 recorder.write(gather=True, compatible_output=compatible_output) 20 40 moose.PyMooseBase.endSimulation() 21 22 def create(cellclass, cellparams=None, n=1):23 """24 Create n cells all of the same type.25 If n > 1, return a list of cell ids/references.26 If n==1, return just the single id.27 """28 assert n > 0, 'n must be a positive integer'29 cell_gids = []30 if isinstance(cellclass, type):31 for i in range(n):32 print cellclass, cellparams33 cell_type = cellclass(cellparams)34 cell = eval("Neuron."+cell_type.moose_name)(**cell_type.parameters)35 cell_gids.append(cell.id)36 cell_gids = [ID(gid) for gid in cell_gids]37 elif isinstance(cellclass, str): # celltype is not a standard cell38 cellclass = eval(cellclass)39 for i in range(n):40 cell = cellclass(**cellparams)41 cell_gids.append(cell.id)42 cell_gids = [ID(gid) for gid in cell_gids]43 else:44 raise Exception("Invalid cell type")45 for id in cell_gids:46 id.cellclass = cellclass47 if n == 1:48 return cell_gids[0]49 else:50 return cell_gids51 41 52 def record(source, filename):53 dataDir = Neutral("/data")54 probe = Table(source.name, dataDir)55 probe.step_mode = 356 probe.connect("inputRequest", source, "Vm")57 58 42 def run(simtime): 59 43 """Run the simulation for simtime""" 60 moose.step(simtime) 44 simulator.run(simtime) 45 46 47 # ============================================================================== 48 # Functions returning information about the simulation state 49 # ============================================================================== 50 51 get_current_time = common.get_current_time 52 get_time_step = common.get_time_step 53 get_min_delay = common.get_min_delay 54 get_max_delay = common.get_max_delay 55 num_processes = common.num_processes 56 rank = common.rank 57 58 # ============================================================================== 59 # Low-level API for creating, connecting and recording from individual neurons 60 # ============================================================================== 61 62 create = common.create 63 64 #connect = common.connect 65 66 #set = common.set 67 68 record = common.build_record('spikes', simulator) 69 70 record_v = common.build_record('v', simulator) 71 72 record_gsyn = common.build_record('gsyn', simulator) 73 74 -
trunk/src/moose/cells.py
r601 r726 1 from pyNN import common, cells 1 import moose 2 from pyNN import standardmodels, cells 3 4 mV = 1e-3 5 ms = 1e-3 6 nA = 1e-9 7 8 class SingleCompHH(moose.Neutral): 9 10 def __init__(self, path, GbarNa=0.0, GbarK=0.0, GLeak=0.0, Cm=1.0, 11 ENa=40*mV, EK=-90*mV, VLeak=-65*mV, Voff=-63*mV, ESynE=0*mV, 12 ESynI=-70*mV, tauE=2*ms, tauI=5*ms, inject=0*nA, initVm=-65*mV): 13 moose.Neutral.__init__(self, path) 14 self.comp = moose.Compartment("compartment", self) 15 print "compartment is at %s" % self.comp.path 16 print locals() 17 self.comp.initVm = initVm 18 self.comp.Rm = 1/GLeak 19 self.comp.Cm = Cm 20 self.comp.Em = VLeak 21 self.comp.inject = inject 22 self.na = moose.HHChannel("na", self.comp) 23 self.na.Ek = ENa 24 self.na.Gbar = GbarNa 25 self.na.Xpower = 3 26 self.na.Ypower = 1 27 self.na.setupAlpha("X", 3.2e5 * (13*mV+Voff), -3.2e5, -1, -(13*mV+Voff), -4*mV, # alpha 28 -2.8e5 * (40*mV+Voff), 2.8e5, -1, -(40*mV+Voff), 5*mV) # beta 29 self.na.setupAlpha("Y", 128, 0, 0, -(17*mV+Voff), 18*mV, # alpha 30 4.0e3, 0, 1, -(40*mV+Voff), -5*mV) # beta 31 32 self.k = moose.HHChannel("k", self.comp) 33 self.k.Ek = EK 34 self.k.Gbar = GbarK 35 self.k.Xpower = 4 36 self.k.setupAlpha("X", 3.2e4 * (15*mV+Voff), -3.2e4, -1, -(15*mV+Voff), -5*mV, 37 500, 0, 0, -(10*mV+Voff), 40*mV) 38 39 #self.synE = moose.SynChan("excitatory", self.comp) 40 #self.synE.Ek = ESynE 41 #self.synE.tau1 = 1e-6 42 #self.synE.tau2 = tauE 43 #self.synE.Gbar = 1e-9 44 #self.synI = moose.SynChan("inhibitory", self.comp) 45 #self.synI.Ek = ESynI 46 #self.synI.tau1 = 1e-6 47 #self.synI.tau2 = tauI 48 #self.synI.Gbar = 1e-9 49 50 #self.comp.connect("channel", self.synE, "channel") 51 #self.comp.connect("channel", self.synI, "channel") 52 self.comp.connect("channel", self.na, "channel") 53 self.comp.connect("channel", self.k , "channel") 54 55 self.comp.useClock(0) 56 self.comp.useClock(1, "init") 57 58 def record_v(self): 59 self.vmTable = moose.Table("Vm", self) 60 self.vmTable.stepMode = 3 61 self.vmTable.connect("inputRequest", self.comp, "Vm") 62 self.vmTable.useClock(2) 63 print "vmTable is at %s" % self.vmTable.path 64 #moose.PyMooseBase.getContext().useClock(0, self.comp.path+"/##") 65 66 #a = SingleCompHH("/comp", 1e-9, 1e-9, 1e-9, 1e-12, -0.06, 0.08, -0.06, 0.001, 0.05, -0.05, 1e-2, 2e-2, 1e-9, -0.06) 67 #print "Successfully setup SingleCompHH" 68 69 2 70 3 71 class HH_cond_exp(cells.HH_cond_exp): 4 72 """Single compartment cell with an Na channel and a K channel""" 5 translations = common.build_translations(73 translations = standardmodels.build_translations( 6 74 ('gbar_Na', 'GbarNa', 1e-9), 7 75 ('gbar_K', 'GbarK', 1e-9), … … 11 79 ('e_rev_Na', 'ENa', 1e-3), 12 80 ('e_rev_K', 'EK', 1e-3), 13 ('e_rev_leak', 'V leak', 1e-3),81 ('e_rev_leak', 'VLeak', 1e-3), 14 82 ('e_rev_E', 'ESynE', 1e-3), 15 83 ('e_rev_I', 'ESynI', 1e-3), … … 19 87 ('v_init', 'initVm', 1e-3), 20 88 ) 21 mo ose_name = "SingleCompHH"89 model = SingleCompHH 22 90 23 91 -
trunk/src/neuron/__init__.py
r719 r726 59 59 simulator.state.cvode.active(int(extra_params['use_cvode'])) 60 60 if extra_params.has_key('rtol'): 61 simulator.state.cvode.rtol(float(extra_params['rtol']))61 simulator.state.cvode.rtol(float(extra_params['rtol'])) 62 62 if extra_params.has_key('atol'): 63 63 simulator.state.cvode.atol(float(extra_params['atol'])) -
trunk/src/neuron/simulator.py
r713 r726 2 2 """ 3 3 Implementation of the "low-level" functionality used by the common 4 implementation of the API .4 implementation of the API, for the NEURON simulator. 5 5 6 6 Functions and classes useable by the common implementation:
