def mkcells(): types = ['TC', 'RE', 'PY', 'IN'] tD = {k: {'cel': [], 'ncl': [], 'stims': [], 'predi': {}} for k in types} for pre, ei in zip(types, ['ampapost', 'gabaapost', 'ampapost', 'gabaapost']): tD[pre]['targ'] = {} for post in types: tD[pre]['targ'][post] = ei tD['PY']['targ']['PY'], tD['TC']['targ']['PY'] = 'ampapostPY', 'ampapostTC' for k in ['TC', 'RE']: tD[k]['num'] = nthalamiccells for i in range(nthalamiccells): tD[k]['cel'].append(h.__getattribute__('s' + k)()) for k in ['PY', 'IN']: tD[k]['num'] = ncorticalcells for i in range(ncorticalcells): tD[k]['cel'].append(h.__getattribute__('s' + k)()) tD['RE']['T'], tD['TC']['T'] = {n: barname(n) for n in it2l}, { n: barname(n) for n in ['ittccustom', 'it'] } for v in tD.itervalues(): v['gnabar'] = v['cel'][0].soma[0].gnabar_hh2 return tD
def __init__(self, mechname): #set variables in case of exception so that __del__ still works. self.nc = None self.stim = None self.syn = None self.vc = None self.s = None self.mechname = mechname constructor = h.__getattribute__(mechname) self.soma = h.Section(name='soma') s = self.soma s.L = 10. s.diam = 10. / h.PI s.insert('pas') seg = s(0.5) seg.e_pas = -65.0 seg.g_pas = 0.0001 self.syn = constructor(seg) self.stim = h.NetStim() self.stim.number = 2 self.stim.interval = 5 self.stim.start = 1 self.nc = h.NetCon(self.stim, self.syn) self.nc.delay = 1 self.nc.weight[0] = .001 if use_voltage_clamp: self.vc = h.SEClamp(seg) self.vc.amp1 = -65.0 self.vc.dur1 = 1e9
def getGlobals(mechNames, origGlob={}): """ Function for/to <short description of `netpyne.conversion.neuronPyHoc.getGlobals`> Parameters ---------- mechNames : <type> <Short description of mechNames> **Default:** *required* origGlob : dict <Short description of origGlob> **Default:** ``{}`` **Options:** ``<option>`` <description of option> """ includeGlobs = ['celsius', 'v_init', 'clamp_resist'] endings = tuple(['_' + name for name in mechNames]) glob = {} # compare with original for k in dir(h): if k.endswith(endings) or k in includeGlobs: try: v = float(h.__getattribute__(k)) if k not in origGlob or origGlob[k] != v: glob[k] = float(v) except: pass return glob
def _get_class_from_help_dict(name): result = _get_from_help_dict(name) if not result: return '' methods = dir(h.__getattribute__(name)) for m in methods: if name + '.' + m in _help_dict: result += '\n\n\n%s.%s:\n\n%s' % (name, m, _help_dict[name + '.' + m]) return result
def getGlobals(mechNames, origGlob={}): includeGlobs = ['celsius', 'v_init', 'clamp_resist'] endings = tuple(['_' + name for name in mechNames]) glob = {} # compare with original for k in dir(h): if k.endswith(endings) or k in includeGlobs: try: v = float(h.__getattribute__(k)) if k not in origGlob or origGlob[k] != v: glob[k] = float(v) except: pass return glob
# $Id: labels.py,v 1.4 2012/09/24 17:35:22 samn Exp $ from neuron import h h.load_file("labels.hoc") # has variables needed by network hvars = [a for a in dir(h) if h.name_declared(a, 2) == 5] # 5 if a scalar or double variable CTYP = [s.s for s in h.CTYP] CTYPi = len(CTYP) for s in CTYP: globals()[s] = int(h.__getattribute__(s)) E = int(h.E2) I = int(h.I2) STYP = [s.s for s in h.STYP] STYPi = len(STYP) for s in STYP: globals()[s] = int(h.__getattribute__(s)) try: # most of these are defined in labels.hoc and syncode.hoc # ice - return True iff arg1 is an inhibitory cell ice = h.ice IsLTS = h.IsLTS # returns true iff arg1 is LTS cell SOMA = h.SOMA DEND = h.DEND AXON = h.AXON except: print 'something unhandled in labels.py additions 1'
def __init__(self, region, d=0, name=None, charge=0, initial=0): """ region = Extracellular object (TODO? or list of objects) name = string of the name of the NEURON species (e.g. ca) d = diffusion constant charge = charge of the molecule (used for converting currents to concentration changes) initial = initial concentration alpha = volume fraction - either a single value for the whole region or a Vector giving a value for each voxel tortuosity = increase in path length due to obstacles, effective diffusion coefficient d/tortuosity^2. - either a single value for the whole region or a Vector giving a value for each voxel. NOTE: For now, only define this AFTER the morphology is instantiated. In the future, this requirement can be relaxed. TODO: remove this limitation """ warnings.warn('Note that changing the morphology after initialization in models with Extracellular regions is not yet supported (This is printed everytime regardless of whether there is an attempt to change morphology)') _extracellular_diffusion_objects[self] = None # ensure 3D points exist h.define_shape() self._region = region self._species = name self._charge = charge self._xlo, self._ylo, self._zlo = region._xlo, region._ylo, region._zlo self._dx = region._dx self._d = d self._nx = region._nx self._ny = region._ny self._nz = region._nz self._xhi, self._yhi, self._zhi = region._xhi, region._yhi, region._zhi self._states = h.Vector(self._nx * self._ny * self._nz) self.states = self._states.as_numpy().reshape(self._nx, self._ny, self._nz) if initial is None: try: self._initial = h.__getattribute__(name + "o0_" + name + "_ion") except: self._initial = 0 else: self._initial = initial if(numpy.isscalar(region.alpha)): self.alpha = self._alpha = region.alpha else: self.alpha = region.alpha self._alpha = region._alpha._ref_x[0] if(numpy.isscalar(region.tortuosity)): self.tortuosity = self._tortuosity = region.tortuosity else: self.tortuosity = region.tortuosity self._tortuosity = region._tortuosity._ref_x[0] # TODO: if allowing different diffusion rates in different directions, verify that they go to the right ones self._grid_id = insert(0, self._states._ref_x[0], self._nx, self._ny, self._nz, self._d, self._d, self._d, self._dx, self._dx, self._dx, self._alpha, self._tortuosity) self._str = '_species[%d]' % self._grid_id self._name = name # set up the ion mechanism and enable active Nernst potential calculations self._ion_register() self._update_pointers()
def Section(self, name): h("create " + name) return h.__getattribute__(name)