def get_mech_globals(mechname, var=-1): ms = h.MechanismStandard(mechname, var) name = h.ref('') mech_globals = {} for j in range(ms.count()): ms.name(name, j) mech_globals[name[0]] = getattr(h, name[0]) return mech_globals
def pname(msname): s = h.ref('') for i in range(-1, 4): ms = h.MechanismStandard(msname, i) print('\n', msname, ' vartype=%d' % i) # vartype = 1 -> PARAMETER for j in range(int(ms.count())): k = ms.name(s, j) print('%-5d %-20s size=%d' % (j, s[0], k))
def cellran(gid, nclist): r = h.Random() r.Random123(gid) r.uniform(1.0, 1.1) cell = pc.gid2cell(gid) for sec in cell.all: sec.L *= r.repick() for seg in sec: seg.diam *= r.repick() seg.cm *= r.repick() #print 'diam ', seg.diam, 'cm ', seg.cm #mechanism variables for mech in seg: ms = h.MechanismStandard(mech.name(), 1) for i in range(int(ms.count())): varname = h.ref("") sz = ms.name(varname, i) n = varname[0] x = seg.__getattribute__(n) setattr(seg, n, x * r.repick()) #print n, seg.__getattribute__(n) #point process parameters for p in seg.point_processes(): n = p.hname() n = n[:n.index('[')] if n == 'HalfGap': continue ms = h.MechanismStandard(n, 1) for i in range(int(ms.count())): varname = h.ref("") ms.name(varname, i) x = p.__getattribute__(varname[0]) setattr(p, varname[0], x * r.repick()) #print varname[0], p.__getattribute__(varname[0]) #netcons targeting the cell for nc in nclist: if nc.postcell() == cell: nc.weight[0] *= r.repick() nc.delay *= r.repick() pc.threshold(gid, pc.threshold(gid) + r.uniform(-9, 0))
def get_mech_globals(mechname): ms = h.MechanismStandard(mechname, -1) name = h.ref('') mech_globals = [] integer2 = int(ms.count()) for j in range(integer2): ms.name(name, j) mech_globals.append(name[0]) return mech_globals
def uses_pointer(mechname): # do not get involved with POINTER ms = h.MechanismStandard(mechname, 0) for i in range(int(ms.count())): n = h.ref("") ms.name(n, i) if ms.get(n[0]) == -1e+300: return True return False
def barname(mech='it'): '''return the name of a gbar (max conductance) for a given mechanism name''' l = [] pname, ms = h.ref(''), h.MechanismStandard(mech, 1) for i in range(int(ms.count())): ms.name(pname, i) l.append(pname[0]) ll = [x for x in l if 'bar' in x] if len(ll) != 1: raise Exception("Can't identify proper parameter for %s: %s" % (mech, ll)) return ll[0]
def get_rangevars(mech_name): ms = h.MechanismStandard(mech_name) suffix = '_' + mech_name lensuffix = len(suffix) mname = h.ref('') result = [] for i in range(int(ms.count())): ms.name(mname, i) my_mname = mname[0] if my_mname.endswith(suffix): my_mname = my_mname[:-lensuffix] result.append({'type': 'NEURONMECH', 'mech': mech_name, 'var': my_mname, 'name': mech_name + '.' + my_mname}) return result
def mechVarList (): msname = h.ref('') varList = {} for i, mechtype in enumerate(['mechs','pointps']): mt = h.MechanismType(i) # either distributed mechs (0) or point process (1) varList[mechtype] = {} for j in xrange(int(mt.count())): mt.select(j) mt.selected(msname) ms = h.MechanismStandard(msname[0], 1) # PARAMETER (modifiable) varList[mechtype][msname[0]] = [] propName = h.ref('') for var in xrange(int(ms.count())): k = ms.name(propName, var) varList[mechtype][msname[0]].append(propName[0]) return varList
def get_rangevars(mech_name): ms = h.MechanismStandard(mech_name) suffix = "_" + mech_name lensuffix = len(suffix) mname = h.ref("") result = [] for i in range(int(ms.count())): ms.name(mname, i) my_mname = mname[0] if my_mname.endswith(suffix): my_mname = my_mname[:-lensuffix] result.append({ "type": "NEURONMECH", "mech": mech_name, "var": my_mname, "name": mech_name + "." + my_mname, }) return result
def ptype(): msname = h.ref('') propList = {} for i, mechtype in enumerate(['mechs', 'pointps']): mt = h.MechanismType( i) # either distributed mechs (0) or point process (1) propList[mechtype] = {} for j in range(int(mt.count())): mt.select(j) mt.selected(msname) print('\n\n', msname[0], ' mechanismtype=%d' % j) pname(msname[0]) ms = h.MechanismStandard(msname[0], 1) # PARAMETER (modifiable) propList[mechtype][msname[0]] = [] propName = h.ref('') for prop in range(int(ms.count())): k = ms.name(propName, prop) propList[mechtype][msname[0]].append(propName[0]) print(propList)
def setchans(mun=3, pnafjr=0.0, gnamult=1.0, gcabar=None, gcavfac=1.0, tyli=['TC', 'RE', 'PY', 'IN']): it2 = it2l[mun] ms = h.MechanismStandard(it2, 1) print "Using %s channels" % it2 gcab = gcabar if gcabar else 3e-3 for k in ['TC', 'RE']: vals = thalDict[k] for ce in vals['cel']: ce.soma[0].gnabar_hh2nafjr = pnafjr * gnamult * vals[ 'gnabar'] # what is this?? ce.soma[0].gnabar_hh2 = (1 - pnafjr) * gnamult * vals['gnabar'] for ce in thalDict['RE'][ 'cel']: # just set the RE one for now; corrD=3.777 for surface correction (Cav32RE3cc.hoc:105:257) sec = ce.soma[0] for v in thalDict['RE']['T'].values(): sec.__setattr__(v, 0.0) # turn all off sec.__setattr__(thalDict['RE']['T'][it2], gcab * gcavfac)
def mechVarList(): """ Function for/to <short description of `netpyne.conversion.neuronPyHoc.mechVarList`> """ msname = h.ref('') varList = {} for i, mechtype in enumerate(['mechs', 'pointps']): mt = h.MechanismType( i) # either distributed mechs (0) or point process (1) varList[mechtype] = {} for j in range(int(mt.count())): mt.select(j) mt.selected(msname) ms = h.MechanismStandard(msname[0], 1) # PARAMETER (modifiable) varList[mechtype][msname[0]] = [] propName = h.ref('') for var in range(int(ms.count())): k = ms.name(propName, var) varList[mechtype][msname[0]].append(propName[0]) return varList
action['marker_mouseovers'] = pointprocess_mouseovers_by_root[name][root] except: pass child['action'].append(action) if 'children' in child: for grandchild in child['children']: grandchild['noop'] = True # get the names of mechanism parameters (range_vars) range_vars = {} for mech in mech_names: h.mt = h.MechanismStandard(mech) range_vars[mech] = [] suffix = '_' + mech lensuffix = len(suffix) for i in xrange(int(h.mt.count())): h('mt.name(mname, %d)' % i) mname = h.mname if mname[-lensuffix :] == suffix: mname = mname[: -lensuffix] range_vars[mech].append(mname) if not range_vars[mech]: del range_vars[mech] #print 'range_vars:', range_vars def mechs_present(secs): result = []
def psection(sec): from neuron import h, _has_rxd try: if _has_rxd['crxd']: from neuron import crxd as rxd from neuron.crxd import region, species from neuron.crxd import rxd as rxd_module else: from neuron import rxd from neuron.rxd import region, species from neuron.rxd import rxd as rxd_module have_rxd = True except: have_rxd = False results = {} mname = h.ref('') # point processes pps = {} mt = h.MechanismType(1) for i in range(int(mt.count())): mt.select(i) mypps = set() pp = mt.pp_begin(sec=sec) while pp is not None: mypps.add(pp) pp = mt.pp_next() if mypps: mt.selected(mname) pps[mname[0]] = mypps results['point_processes'] = pps center_seg_dir = dir(sec(0.5)) mechs_present = [] # membrane mechanisms mt = h.MechanismType(0) for i in range(int(mt.count())): mt.select(i) mt.selected(mname) name = mname[0] if name in center_seg_dir: mechs_present.append(name) results['density_mechs'] = {} results['ions'] = {} for mech in mechs_present: my_results = {} ms = h.MechanismStandard(mech, 0) for j in range(int(ms.count())): n = int(ms.name(mname, j)) name = mname[0] pvals = [] # TODO: technically this is assuming everything that ends with _ion # is an ion. Check this. if mech.endswith('_ion'): pvals = [getattr(seg, name) for seg in sec] else: mechname = name #+ '_' + mech for seg in sec: if n > 1: pvals.append( [getattr(seg, mechname)[i] for i in range(n)]) else: pvals.append(getattr(seg, mechname)) my_results[name[:-(len(mech) + 1)] if name.endswith('_' + mech) else name] = pvals # TODO: should be a better way of testing if an ion if mech.endswith('_ion'): results['ions'][mech[:-4]] = my_results else: results['density_mechs'][mech] = my_results morphology = { 'L': sec.L, 'diam': [seg.diam for seg in sec], 'pts3d': [(sec.x3d(i), sec.y3d(i), sec.z3d(i), sec.diam3d(i)) for i in range(sec.n3d())], 'parent': sec.parentseg(), 'trueparent': sec.trueparentseg() } results['morphology'] = morphology results['nseg'] = sec.nseg results['Ra'] = sec.Ra results['cm'] = [seg.cm for seg in sec] if have_rxd: regions = { r() for r in region._all_regions if r() is not None and sec in r().secs } results['regions'] = regions my_species = [] for sp in species._all_species: sp = sp() if sp is not None: sp_regions = sp._regions if not hasattr(sp_regions, '__len__'): sp_regions = [sp_regions] if any(r in sp_regions for r in regions): my_species.append(sp) results['species'] = set(my_species) results['name'] = sec.hname() results['hoc_internal_name'] = sec.hoc_internal_name() results['cell'] = sec.cell() #all_active_reactions = [r() for r in rxd_module._all_reactions if r() is not None] return results