示例#1
0
文件: test_bas.py 项目: pramodk/nrn
def prun(tstop, restore=False):
    pc.set_maxstep(10 * ms)
    h.finitialize(-65 * mV)

    if restore == "SaveState":
        ns = h.SaveState()
        sf = h.File("state%d.bin" % pc.id())
        ns.fread(sf)
        ns.restore(0)  # event queue restored
        sf.close()
    elif restore == "BBSaveState":
        cp_out_to_in()  # prepare for restore.
        bbss = h.BBSaveState()
        bbss.restore_test()
    else:
        pc.psolve(tstop / 2)

        # SaveState save
        ss = h.SaveState()
        ss.save()
        sf = h.File("state%d.bin" % pc.id())
        ss.fwrite(sf)
        sf.close()

        # BBSaveState Save
        cnt = h.List("PythonObject").count()
        for i in range(1):
            bbss = h.BBSaveState()
            bbss.save_test()
            bbss = None
        assert h.List("PythonObject").count() == cnt

    pc.psolve(tstop)
示例#2
0
def test_ste():

    m1 = model()
    # one state ste with two self transitions
    var = m1["s"](0.5)._ref_v
    thresh1 = h.ref(-50)
    thresh2 = h.ref(-10)
    result = []
    ste = h.StateTransitionEvent(1)
    ste.transition(0, 0, var, thresh1, (act, (1, m1, thresh1, result)))
    ste.transition(0, 0, var, thresh2, (act, (2, m1, thresh2, result)))
    fih = h.FInitializeHandler((on_finit, (ste, result)))

    run(5)
    print("final v=%g" % m1["s"](0.5).v)
    chk_result(2, result, m1)

    h.cvode_active(1)
    run(20)
    chk_result(2, result, m1)

    h.cvode_active(1)
    h.cvode.condition_order(2)
    run(5)
    chk_result(2, result, m1)

    h.cvode.condition_order(1)
    h.cvode_active(0)

    # ste associated with point process
    del fih, ste
    ste = h.StateTransitionEvent(2, m1["ic"])
    fih = h.FInitializeHandler((on_finit, (ste, result)))
    run(5)

    # transition with hoc callback
    h("""proc foo() { printf("foo called at t=%g\\n", t) }""")
    thresh3 = h.ref(-30)
    ste.transition(0, 0, var, thresh3, "foo()")
    run(5)

    # transition with hoc callback in hoc object
    h("""
begintemplate FooSTEtest
objref this
proc foo() { printf("foo in %s called at t=%g\\n", this, t) }
endtemplate FooSTEtest
""")
    thresh4 = h.ref(-20)
    obj = h.FooSTEtest()
    ste.transition(0, 0, var, thresh4, "foo()", obj)
    run(5)

    del ste, fih
    assert h.List("StateTransitionEvent").count() == 0
    assert h.List("FInitializeHandler").count() == 0
示例#3
0
    def test_newobj_err(self):
        '''Test deletion of incompletely constructed objects'''
        print()  # Error message not on above line
        h.load_file("stdlib.hoc")  # need hoc String
        h('''
begintemplate Foo
endtemplate Foo

begintemplate NewObj
objref this, ob, foo1, foo2
proc init() {localobj s
  foo1 = new Foo() // Constructed before error, even partial constructions fill this field.
  if ($1 == 0) {
    execerror("generate an error") // All NewObj instances undergoing construction
  } else if ($1 == $2) {
    // This and all NewObj instances prior to this will construct successfully.
    // All after this will be partially constructed.
    // The execerror should cause only the partially constructed NewObj to
    // be destroyed.
    s = new String()
    sprint(s.s, "ob = new NewObj(%d, %d)", $1-1, $2)
    execute1(s.s, this)
  } else {
    ob = new NewObj($1-1, $2)
  }
  foo2 = new Foo() // Only instances prior to execute1 reach here.
}
endtemplate NewObj
''')
        # arg[0] recursion depth
        # arg[0] - arg[1] + 1 should be successfully constructed
        # arg[1] should be partially constructed and destroyed.
        args = (4, 2)
        a = h.NewObj(*args)
        b = h.List("NewObj")
        c = h.List("Foo")
        print("#NewObj and #Foo in existence", b.count(), c.count())
        z = args[0] - args[1] + 1
        assert (b.count() == z)
        assert (c.count() == 2 * z)

        del a
        del b
        del c
        b = h.List("NewObj")
        c = h.List("Foo")
        print("after del a #NewObj and #Foo in existence", b.count(),
              c.count())
        assert (b.count() == 0)
        assert (c.count() == 0)

        return 1
示例#4
0
def test_fastimem():
    cells = [Cell(id, 10) for id in range(2)]
    # h.topology()
    cvode = h.CVode()
    ics = h.List("IClamp")
    syns = h.List("ExpSyn")
    cvode.use_fast_imem(1)
    h.finitialize(-65)
    run(1.0, ics, 1e-13)
    total_syn_g(syns)
    h.cvode_active(1)
    run(1.0, ics, 1e-12)
    cvode.use_fast_imem(0)
    h.cvode_active(0)
示例#5
0
文件: Fig6C.py 项目: torbjone/EEG
def add_spines_on_segments(list_of_segments, seg_to_num_of_syn):
    HCell.delete_spine()
    total_synapses = 0

    Xs_vec = h.Vector()
    secs_sref_list = h.List()

    for seg in list_of_segments:
        sec = seg.sec
        num_of_synapses = seg_to_num_of_syn[seg]
        assert num_of_synapses != 0, "segment on %s has 0 synapses" % sec.hname(
        )
        Lsec = sec.L
        sref = h.SectionRef(sec=sec)

        if Lsec > CLUSTER_LENGTH:  # distributes the spines on CLUSTER_LENGTH um on the section
            min_x = (Lsec - CLUSTER_LENGTH) / float(seg.x)
        else:  # in cases where the section is shorter than CLUSTER_LENGTH
            mix_x = 0

        for ix in range(num_of_synapses):
            secs_sref_list.append(sref)
            x_syn = min_x + ix * CLUSTER_LENGTH / float(num_of_synapses - 1)
            Xs_vec.append(min(x_syn / float(Lsec), 1))

        total_synapses += num_of_synapses

    HCell.add_few_spines(secs_sref_list, Xs_vec, 0.25, 1.35, 2.8,
                         HCell.soma[0].Ra)

    HCell.soma[0].push()
    return total_synapses
示例#6
0
def synapse_vclamp_test(label, syntype, cell, w, v_holding, v_init, indexes,
                        section):

    vv = h.Vector()
    vv.append(0, 0, 0, 0, 0, 0)

    se = h.SEClamp(cell.sections[section](0.5))

    h('objref synlst')
    h.synlst = h.List()
    for i in indexes:
        h.synlst.append(cell.syns.o(i))
    if syntype == syn_type_excitatory:
        v = cell.syntest_exc(h.synlst, se, w, v_holding, v_init)
    else:
        v = cell.syntest_inh(h.synlst, se, w, v_holding, v_init)

    vv = vv.add(v)

    amp = vv.x[0]
    t_10_90 = vv.x[1]
    t_20_80 = vv.x[2]
    t_all = vv.x[3]
    t_50 = vv.x[4]
    t_decay = vv.x[5]

    print("%s synapse: \n" % label)
    print("  Amplitude %f\n" % amp)
    print("  10-90 Rise Time %f\n" % t_10_90)
    print("  20-80 Rise Time %f\n" % t_20_80)
    print("  Decay Time Constant %f\n" % t_decay)
示例#7
0
文件: testcr.py 项目: nrnhines/bfilt
 def __init__(self, n, seed, modelses, datagenhoc):
     self.n = n
     h.load_file(modelses)
     mrflist = h.List("MulRunFitter")
     mrf = mrflist.o(int(mrflist.count()) - 1)
     self.N = mrf.p.pf.generatorlist.o(0).gen.po
     h('objref nb')
     h.nb = mrf.p.pf.generatorlist.o(0).gen.po
     cvodewrap.fs.panel()
     self.trueParm = self.N.getParm()
     self.modelses = modelses
     self.seed = seed
     if n == 0:
         G = noisegen.Gen(self.N)
         G.reseed(seed)
         self.seed = seed
         self.Data = G.datasim()
     else:
         h.load_file(datagenhoc)
         tvec = h.Vector(self.N.Eve.collectionTimes)
         vec = h.ch3ssdata(n, seed, tvec, self.trueParm,
                           self.N.rf.fitnesslist.o(0))
         self.Data = []
         for i in range(len(vec)):
             self.Data.append(numpy.matrix(vec[i]))
     if fitglobals.verbose: h.topology()
     ss = h.Vector()
     cvodewrap.states(ss)
     if fitglobals.verbose: ss.printf()
     self.N.overwrite(self.Data)
     self.H = numpy.matrix(self.Hessian())
示例#8
0
文件: knox.py 项目: wwlytton/AP
def zeroselfs():
    selfconns = [
        nc for nc in h.List('NetCon') if nc.precell() == nc.postcell()
    ]
    for nc in selfconns:
        for x in range(int(nc.wcnt())):
            nc.weight[x] = 0.0
示例#9
0
 def getParmFitness(self):
     # the ParmFitness instance that owns me.
     # there are probably not many so we can work forward from ParmFitness
     pfl = h.List('ParmFitness')
     for pf in pfl:
         for gi in pf.generatorlist:
             if gi.gen.hocobjptr() == self.rf.hocobjptr():
                 return pf
示例#10
0
def checkMemory():
    from .. import sim

    # print memory diagnostic info
    if sim.rank == 0:  # and checkMemory:
        import resource
        print('\nMEMORY -----------------------')
        print('Sections: ')
        print(h.topology())
        print('NetCons: ')
        print(len(h.List("NetCon")))
        print('NetStims:')
        print(len(h.List("NetStim")))
        print('\n Memory usage: %s \n' %
              resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
        # import objgraph
        # objgraph.show_most_common_types()
        print('--------------------------------\n')
def connectgjs(env):
    rank = int(env.pc.id())
    nhosts = int(env.pc.nhost())

    datasetPath = os.path.join(env.datasetPrefix, env.datasetName)

    gapjunctions = env.gapjunctions
    if env.gapjunctionsFile is None:
        gapjunctionsFilePath = None
    else:
        gapjunctionsFilePath = os.path.join(datasetPath, env.gapjunctionsFile)

    if gapjunctions is not None:

        h('objref gjlist')
        h.gjlist = h.List()
        if env.verbose:
            if env.pc.id() == 0:
                print gapjunctions
        datasetPath = os.path.join(env.datasetPrefix, env.datasetName)
        (graph, a) = bcast_graph(env.comm, gapjunctionsFilePath, attributes=True)

        ggid = 2e6
        for name in gapjunctions.keys():
            if env.verbose:
                if env.pc.id() == 0:
                    print "*** Creating gap junctions %s" % name
            prj = graph[name]
            attrmap = a[name]
            weight_attr_idx = attrmap['Weight'] + 1
            dstbranch_attr_idx = attrmap['Destination Branch'] + 1
            dstsec_attr_idx = attrmap['Destination Section'] + 1
            srcbranch_attr_idx = attrmap['Source Branch'] + 1
            srcsec_attr_idx = attrmap['Source Section'] + 1
            for destination in sorted(prj.keys()):
                edges = prj[destination]
                sources = edges[0]
                weights = edges[weight_attr_idx]
                dstbranches = edges[dstbranch_attr_idx]
                dstsecs = edges[dstsec_attr_idx]
                srcbranches = edges[srcbranch_attr_idx]
                srcsecs = edges[srcsec_attr_idx]
                for i in range(0, len(sources)):
                    source = sources[i]
                    srcbranch = srcbranches[i]
                    srcsec = srcsecs[i]
                    dstbranch = dstbranches[i]
                    dstsec = dstsecs[i]
                    weight = weights[i]
                    if env.pc.gid_exists(source):
                        h.mkgap(env.pc, h.gjlist, source, srcbranch, srcsec, ggid, ggid + 1, weight)
                    if env.pc.gid_exists(destination):
                        h.mkgap(env.pc, h.gjlist, destination, dstbranch, dstsec, ggid + 1, ggid, weight)
                    ggid = ggid + 2

            del graph[name]
示例#12
0
def printGetEventQueueinfo():
    '''will print the size of tvec, flagvec and targetlist obtained from h.cvode.event_queue_info'''
    tvec = h.Vector()
    flagvec = h.Vector()
    targetlist = h.List()
    h.cvode.event_queue_info(3, tvec, flagvec, targetlist)
    print 'tvec:', tvec.printf()
    print 'flagvec:', flagvec.printf()
    print 'targetlist count:', targetlist.count()
    return tvec, flagvec, targetlist
示例#13
0
文件: repro.py 项目: nrnhines/bfilt
 def fill(self, channels, seed, n_trajectory):
     self.seed = seed
     self.channels = channels
     xmd = self.fitfun.xdat.c()
     ymd = h.List()
     for i in range(n_trajectory):
         seed2 = i
         ymd.append(self.datagen(self.channels, self.seed, seed2, xmd))
     self.fitfun.set_data(xmd, ymd)
     h.execute("setxy()", self.fitfun)
示例#14
0
def add_spines(num_of_synapses, secs, Xs):
    secs_sref_list = h.List()
    Xs_vec = h.Vector()

    for ix in range(num_of_synapses):  #create Neuron's list of section refs
        sref = h.SectionRef(sec=HCell.apic[secs[ix]])
        secs_sref_list.append(sref)
        Xs_vec.append(Xs[ix])

    HCell.add_few_spines(secs_sref_list, Xs_vec, 0.25, 1.35, 2.8,
                         HCell.soma[0].Ra)
示例#15
0
文件: io.py 项目: johnsonc/bmtk
def read_state(conf):
    state_dir = conf["output"]["state_dir"]

    state = h.SaveState()
    f = h.File('{}/state_rank-{}'.format(state_dir, int(pc.id())))
    # f = h.File(state_dir+'/state_rank-%d' % (int(pc.id())))
    state.fread(f, 0)
    state.restore()
    rlist = h.List('Random')
    for r_tmp in rlist:
        r_tmp.seq(f.scanvar())
    f.close()
示例#16
0
def add_Spines(num_of_spines, syn_trees, syn_secs, syn_segs):
    hocL = h.List()
    for i in range(num_of_spines):
        if syn_trees[i] == APIC:
            cell.apic[syn_secs[i]].push()
        else:
            cell.dend[syn_secs[i]].push()
        hocL.append(h.SectionRef())
        h.pop_section()
    hocVxs = h.Vector(syn_segs)
    cell.add_few_spines(hocL, hocVxs, SPINE_NECK_DIAM, SPINE_NECK_L,
                        SPINE_HEAD_AREA, SPINE_NECK_RA)
示例#17
0
文件: io.py 项目: johnsonc/bmtk
def save_state(conf):
    state = h.SaveState()
    state.save()

    state_dir = conf["output"]["state_dir"]
    f = h.File('{}/state_rank-{}'.format(state_dir, int(pc.id())))
    # f = h.File(state_dir + '/state_rank-%d' % (int(pc.id())))
    state.fwrite(f, 0)
    rlist = h.List('Random')
    for r_tmp in rlist:
        f.printf('%g\n', r_tmp.seq())
    f.close()
示例#18
0
def add_spines_on_segments(HCell, list_of_segments):

    Xs_vec = h.Vector()
    secs_sref_list = h.List()

    for seg in list_of_segments:
        sec = seg.sec
        sref = h.SectionRef(sec=sec)
        secs_sref_list.append(sref)
        Xs_vec.append(min(seg.x, 1))

    HCell.add_few_spines(secs_sref_list, Xs_vec, 0.25, 1.35, 2.8,
                         HCell.soma[0].Ra)
示例#19
0
    def testHClass(self):
        """Test subclass of hoc class."""

        from ._subclass import A1
        a = A1(5)
        assert a.x == 5.0
        assert a.p() == 6.0
        b = A1(4)
        a.s = 'one'
        b.s = 'two'
        assert a.s == 'one'
        assert b.s == 'two'
        assert h.A[0].s == 'one'
        assert a.p() == 7.0
        assert b.p() == 5.0
        a.a = 2
        b.a = 3
        assert a.a == 2
        assert b.a == 3
        assert h.List('A').count() == 2
        a = 1
        b = 1
        assert h.List('A').count() == 0
示例#20
0
def add_spines(num_of_synapses, trees, secs, Xs):
    HCell.delete_spine()
    secs_sref_list = h.List()
    Xs_vec = h.Vector()

    for ix in range(num_of_synapses):  #creates NEURON's list of section refs
        if trees[ix] == 'apic':
            sref = h.SectionRef(sec=HCell.apic[secs[ix]])
        else:
            sref = h.SectionRef(sec=HCell.dend[secs[ix]])
        secs_sref_list.append(sref)

        Xs_vec.append(Xs[ix])

    HCell.add_few_spines(secs_sref_list, Xs_vec, 0.25, 1.35, 2.8,
                         HCell.soma[0].Ra)
示例#21
0
 def run():
   h.finitialize(-65)
   for sgid in sgids:
     if pc.gid_exists(sgid) == 3:
       sec = pc.gid2cell(sgid).soma
       sec(.5).nai = float(sgid)/100. + .001
   tars = h.List("NaTrans")
   for tar in tars:
     tar.napre = .0001 # correct values don't carryover from previous sim
   pc.psolve(tstop)
   for tar in tars:
     x = (tar.sgid/100. + .001) if tar.sgid >= 0.0 else 0.0
     differ = ("differ") if abs(tar.napre - x) > 1e-10 else ""
     if differ != "":
       print("%d %s %g %g %g %s"%(rank, tar.hname(), tar.sgid, tar.napre, x, differ))
     assert(differ == "")
示例#22
0
 def add_data(self, mname, d):
     instances = h.List(mname)
     if instances.count() == 0:
         return
     names = []
     inst = instances.o(0)
     for name in dir(inst):
         if '__' not in name:
             try:
                 if type(getattr(inst, name)) == float:
                     names.append(name)
             except:
                 pass
     for inst in instances:
         for name in names:
             d.append(getattr(inst, name))
def add_spines_on_seg(num_of_synapses,sec,x):
	Lsec = sec.L
	sref = h.SectionRef(sec=sec)
	xL = float(x)*Lsec
	maxX = xL+CLUSTER_LENGTH/2.0
	if xL+10>Lsec:
		maxX = Lsec
	minX = xL-10
	if xL-10<0:
		minX = 0

	local_vec_x = h.Vector()
	list_sref = h.List()
	for ix in range(num_of_synapses):
		list_sref.append(sref)
		local_vec_x.append(np.random.uniform(minX/Lsec,maxX/Lsec))

	HCell.add_few_spines(list_sref,local_vec_x,0.25,1.35,2.8,HCell.soma[0].Ra)
示例#24
0
    def set_voltage_recorders(self):

        # Record voltage for all segments
        self.vreclist = h.List()

        for sec in self.allseclist:
            # address the problem of the high number of segments necessary to compute the accurate AP propagation
            # in the unmyelinated axon case by limiting the number of monitored segments.
            if sec.nseg > self.numberOfSavedSegments:
                for i in range(1, self.numberOfSavedSegments + 1):
                    vrec = h.Vector(int(h.tstop / h.dt + 1))
                    vrec.record(
                        sec(float(i) / self.numberOfSavedSegments)._ref_v)
                    self.vreclist.append(vrec)
            else:
                for seg in sec:
                    vrec = h.Vector(int(h.tstop / h.dt + 1))
                    vrec.record(seg._ref_v)
                    self.vreclist.append(vrec)
示例#25
0
    def testABI(self):
        """Test use of some  Py_LIMITED_API for python3."""

        # Py_nb_bool
        assert True if h else False
        assert False if h.List else True
        l = h.List()
        assert True if h.List else False
        assert False if l else True
        v = h.Vector(1)
        l.append(v)
        assert True if l else False

        # Py_sq_length
        assert len(l) == 1
        # Py_sq_item
        assert l[0] == v
        # Py_sq_ass_item
        v.x[0] = 5
        assert v.x[0] == 5
示例#26
0
def synapse_iclamp_test(label, syntype, cell, w, v_init, indexes):

    h('objref synlst')
    h.synlst = h.List()
    for i in indexes:
        h.synlst.append(cell.syns.o(i))
    if syntype == syn_type_excitatory:
        v = cell.syn_iclamp_exc(h.synlst, w, v_init)
    else:
        v = cell.syn_iclamp_inh(h.synlst, w, v_init)

    v_amp = v.x[0]
    v_peak = v.x[1]
    v_pre = v.x[2]
    t_peak = v.x[3]
    t_pre = v.x[4]

    print("%s synapse: \n" % label)
    print("  V Amplitude %f\n" % v_amp)
    print("  V Peak %f\n" % v_peak)
    print("  V Pre %f\n" % v_pre)

    return v_amp
示例#27
0
def main(config, template_path, output_path, forest_path, populations, io_size,
         chunk_size, value_chunk_size, cache_size, verbose):
    """

    :param config:
    :param template_path:
    :param forest_path:
    :param populations:
    :param io_size:
    :param chunk_size:
    :param value_chunk_size:
    :param cache_size:
    """

    utils.config_logging(verbose)
    logger = utils.get_script_logger(script_name)

    comm = MPI.COMM_WORLD
    rank = comm.rank

    env = Env(comm=MPI.COMM_WORLD,
              config_file=config,
              template_paths=template_path)
    h('objref nil, pc, templatePaths')
    h.load_file("nrngui.hoc")
    h.load_file("./templates/Value.hoc")
    h.xopen("./lib.hoc")
    h.pc = h.ParallelContext()

    if io_size == -1:
        io_size = comm.size
    if rank == 0:
        logger.info('%i ranks have been allocated' % comm.size)

    h.templatePaths = h.List()
    for path in env.templatePaths:
        h.templatePaths.append(h.Value(1, path))

    if output_path is None:
        output_path = forest_path

    if rank == 0:
        if not os.path.isfile(output_path):
            input_file = h5py.File(forest_path, 'r')
            output_file = h5py.File(output_path, 'w')
            input_file.copy('/H5Types', output_file)
            input_file.close()
            output_file.close()
    comm.barrier()

    (pop_ranges, _) = read_population_ranges(forest_path, comm=comm)
    start_time = time.time()
    for population in populations:
        logger.info('Rank %i population: %s' % (rank, population))
        count = 0
        (population_start, _) = pop_ranges[population]
        template_name = env.celltypes[population]['template']
        h.find_template(h.pc, h.templatePaths, template_name)
        template_class = eval('h.%s' % template_name)
        measures_dict = {}
        for gid, morph_dict in NeuroH5TreeGen(forest_path,
                                              population,
                                              io_size=io_size,
                                              comm=comm,
                                              topology=True):
            if gid is not None:
                logger.info('Rank %i gid: %i' % (rank, gid))
                cell = cells.make_neurotree_cell(template_class,
                                                 neurotree_dict=morph_dict,
                                                 gid=gid)
                secnodes_dict = morph_dict['section_topology']['nodes']

                apicalidx = set(cell.apicalidx)
                basalidx = set(cell.basalidx)

                dendrite_area_dict = {k + 1: 0.0 for k in range(0, 4)}
                dendrite_length_dict = {k + 1: 0.0 for k in range(0, 4)}
                for (i, sec) in enumerate(cell.sections):
                    if (i in apicalidx) or (i in basalidx):
                        secnodes = secnodes_dict[i]
                        prev_layer = None
                        for seg in sec.allseg():
                            L = seg.sec.L
                            nseg = seg.sec.nseg
                            seg_l = old_div(L, nseg)
                            seg_area = h.area(seg.x)
                            layer = cells.get_node_attribute(
                                'layer', morph_dict, seg.sec, secnodes, seg.x)
                            layer = layer if layer > 0 else (
                                prev_layer if prev_layer is not None else 1)
                            prev_layer = layer
                            dendrite_length_dict[layer] += seg_l
                            dendrite_area_dict[layer] += seg_area

                measures_dict[gid] = { 'dendrite_area': np.asarray([ dendrite_area_dict[k] for k in sorted(dendrite_area_dict.keys()) ], dtype=np.float32), \
                                       'dendrite_length': np.asarray([ dendrite_length_dict[k] for k in sorted(dendrite_length_dict.keys()) ], dtype=np.float32) }

                del cell
                count += 1
            else:
                logger.info('Rank %i gid is None' % rank)
        append_cell_attributes(output_path,
                               population,
                               measures_dict,
                               namespace='Tree Measurements',
                               comm=comm,
                               io_size=io_size,
                               chunk_size=chunk_size,
                               value_chunk_size=value_chunk_size,
                               cache_size=cache_size)
    MPI.Finalize()
示例#28
0
文件: testcr.py 项目: nrnhines/bfilt
def MulRunFitHandle():
    mrflist = h.List("MulRunFitter")
    mrf = mrflist.o(int(mrflist.count()) - 1)
    return mrf
示例#29
0
    arc = [h.arc3d(i, sec=sec) for i in xrange(n)]
    f = seg.x * sec.L
    return (numpy.interp(f, arc, x), numpy.interp(f, arc, y), numpy.interp(f, arc, z))


pointprocess_locs_by_root = {}
pointprocess_mouseovers_by_root = {}
for name in pointprocess_names:
    pointprocess_locs_by_root[name] = {}
    pointprocess_mouseovers_by_root[name] = {}
    for root in root_sections:
        pointprocess_locs_by_root[name][root] = []
        pointprocess_mouseovers_by_root[name][root] = []
    #pointprocess_locs_by_root[name] = {root: [] for root in root_sections}
    #pointprocess_mouseovers_by_root[name] = {root: [] for root in root_sections}
    ell = h.List(name)
    for i in xrange(int(ell.count())):
        obj = ell.o(i)
        if obj.has_loc():
            seg = obj.get_segment()
            pt = list(pt_from_seg(seg))
            pointprocess_locs_by_root[name][get_root(seg.sec)].append(pt)
            pointprocess_mouseovers_by_root[name][get_root(seg.sec)].append('%s at %s(%g)<br/>(%g, %g, %g)' % (name, seg.sec.name(), seg.x, pt[0], pt[1], pt[2]))

if 'children' in point_processes:
    base = point_processes['children']
    if len(base):
        text = base[0]['text'].split()
        if len(text) == 3 and text[1] == 'Point' and text[2] == 'Processes' and 'children' in base[0]:
            base = base[0]['children']
    for child in base:
示例#30
0
文件: ch3_11p.py 项目: nrnhines/bfilt
from neuron import h
import fitglobals
fitglobals.debugoff()
h.load_file('mulfit.hoc')
h.load_file('eonerunmlf.hoc')
import nrnbfilt
h.load_file('ch3_11p.ses')

h('objref nb')
h.nb = h.List("PythonObject").o(0)