示例#1
0
文件: biocell.py 项目: kaeldai/bmtk
    def _set_gap_junc_preselected(self, edge_prop, src_node, syn_weight, gj_ids):
        if edge_prop.nsyns < 1:
            return 1

        sec_x = edge_prop['sec_x']
        sec_id = edge_prop['sec_id']
        section = self._secs_by_id[sec_id]

        #Sets up the section to be connected to the gap junction.
        pc.source_var(section(0.5)._ref_v, gj_ids[1], sec=section)

        #Creates gap junction.
        try:
            gap_junc = h.Gap(0.5, sec=section)
        except:
            raise Exception("You need the gap.mod file to create gap junctions.")

        #Attaches the source section to the gap junction.
        pc.target_var(gap_junc, gap_junc._ref_vgap, gj_ids[0])

        gap_junc.g = syn_weight

        self._connections.append(ConnectionStruct(edge_prop, src_node, gap_junc, gap_junc, False, True))

        self._gap_juncs.append(gap_junc)
        self._edge_type_ids.append(edge_prop.edge_type_id)

        if self._save_conn:
            self._save_connection(src_gid=src_node.gid, src_net=src_node.network, sec_x=sec_x, seg_ix=sec_id,
                                  edge_type_id=edge_prop.edge_type_id)

        return 1
示例#2
0
def init_gap_junctions():

    # initialize source
    for mgid in range(params.Nmitral):
        mpriden = split.mpriden(mgid)
        if mpriden:
            mpriden.push()
            pc.source_var(mpriden(0.99)._ref_v, mgid)
            h.pop_section()
            
    pc.barrier()

    # initialize targets
    for mgid in range(params.Nmitral):
        mpriden = split.mpriden(mgid)
        if mpriden:
            glomid = mgid/nmxg
            for sistermgid in range(glomid * nmxg, mgid)+range(mgid+1, (glomid+1)*nmxg):
                if pc.gid_exists(sistermgid) > 0:
                    gap = h.Gap(mpriden(0.99))
                    if sistermgid != 189:
                        getmodel().gj[(mgid, sistermgid)] = gap
                        glomid = mgid / nmxg
                        pc.target_var(gap, gap._ref_vgap, sistermgid)
    util.elapsed('Gap junctions builden')
示例#3
0
    def _set_gap_junc(self, edge_prop, src_node, syn_weight, gj_ids):
        if edge_prop.nsyns < 1:
            return 1

        tar_seg_ix, tar_seg_prob = self._morph.get_target_segments(edge_prop)
        nsyns = 1

        # choose nsyn elements from seg_ix with probability proportional to segment area
        seg_ix = self.prng.choice(tar_seg_ix, nsyns, p=tar_seg_prob)[0]
        sec = self._secs[seg_ix]  # section where synapases connect
        x = self._morph.seg_prop['x'][
            seg_ix]  # distance along the section where synapse connects, i.e., seg_x

        if edge_prop.nsyns > 1:
            print(
                "Warning: The number of synapses passed in was greater than 1, but only one gap junction will be made."
            )

        #Sets up the section to be connected to the gap junction.
        pc.source_var(sec(0.5)._ref_v, gj_ids[1], sec=sec)

        #Creates gap junction.
        try:
            gap_junc = h.Gap(0.5, sec=sec)
        except:
            raise Exception(
                "You need the gap.mod file to create gap junctions.")

        #Attaches the source section to the gap junction.
        pc.target_var(gap_junc, gap_junc._ref_vgap, gj_ids[0])

        gap_junc.g = syn_weight

        self._connections.append(
            ConnectionStruct(edge_prop, src_node, gap_junc, gap_junc, False,
                             True))

        self._gap_juncs.append(gap_junc)
        self._edge_type_ids.append(edge_prop.edge_type_id)

        if self._save_conn:
            self._save_connection(src_gid=src_node.gid,
                                  src_net=src_node.network,
                                  sec_x=x,
                                  seg_ix=sec_ix,
                                  edge_type_id=edge_prop.edge_type_id)
示例#4
0
 def _make_connection(self, segment, weight, local_to_remote_vargid, remote_to_local_vargid,
                      local_gid, remote_gid):       
     logger.debug("Setting source_var on local cell {} to connect to target_var on remote "
                  "cell {} with vargid {} on process {}"
                 .format(local_gid, remote_gid, local_to_remote_vargid, 
                         state.mpi_rank))
     # Set up the source reference for the local->remote connection 
     state.parallel_context.source_var(segment(0.5)._ref_v, local_to_remote_vargid)              
     # Create the gap_junction and set its weight
     self.gap = h.Gap(0.5, sec=segment)
     self.gap.g = weight
     # Connect the gap junction with the source_var
     logger.debug("Setting target_var on local cell {} to connect to source_var on remote "
                  "cell {} with vargid {} on process {}"
                 .format(local_gid, remote_gid, remote_to_local_vargid, 
                         state.mpi_rank))
     # set up the target reference for the remote->local connection
     state.parallel_context.target_var(self.gap._ref_vgap, remote_to_local_vargid)
示例#5
0
def init():
    data = {}
    for uid in range(nhost):
      data.update({ uid:(getmodel().mitrals.keys()) })
    data = a2a.all2all(data)
    mgids = []
    for _mgids in data.values(): mgids += _mgids
    mgids = set(mgids)

    # initialize source
    
    for mgid in getmodel().mitrals.keys():
        mpriden = split.mpriden(mgid)
        if not mpriden:
          continue
       
        rgj = params.ranstream(mgid, params.stream_gap_junction)

        
        mpriden.push()
        secref = h.SectionRef()
        h.pop_section()
        
        h.mk_gj_src(pc, mgid, secref)

        glomid = mgid2glom(mgid)
        
        sistergids = []

        # no longer all to all, only a chain
        if not (ismtufted(mgid) and (mgid - nmi) % nmt == (nmt - 1)):
            if ismitral(mgid) and mgid % nmxg == (nmxg - 1):
                sistergids += [glomid * nmt + nmi]
            else:
                sistergids += [mgid + 1]
            
        if not (ismitral(mgid) and mgid % nmxg == 0):
            if ismtufted(mgid) and (mgid - nmi) % nmt == 0:
                sistergids += [(glomid + 1) * nmxg - 1]
            else:
                sistergids += [mgid - 1]
            
        sistergids = mgids.intersection(range(glomid * nmxg, glomid * nmxg + nmxg) + range(glomid * nmt + nmi, glomid * nmt + nmt + nmi)).difference([ mgid ])  

        for sistermgid in sistergids:
            gap = h.Gap(mpriden(0.99))

            if ismitral(mgid) and ismitral(sistermgid):
                gap.g = rgj.uniform(gj_min_g1, gj_max_g1)
            elif  ismtufted(mgid) and ismtufted(sistermgid):
                gap.g = rgj.uniform(gj_min_g3, gj_max_g3)
            else:
                gap.g = rgj.uniform(gj_min_g2, gj_max_g2)
                

            getmodel().gj[(mgid, sistermgid)] = gap
            

    pc.barrier()

    # initialize targets
    for key, gap in getmodel().gj.items():
        mgid, sistermgid = key
        pc.target_var(gap, gap._ref_vgap, sistermgid)

    util.elapsed('Gap junctions built')