Using Traub's parallel gap junction in Python

General issues of interest both for network and
individual cell parallelization.

Moderator: hines

Post Reply
pascal
Posts: 89
Joined: Thu Apr 26, 2012 11:51 am

Using Traub's parallel gap junction in Python

Post by pascal »

I am trying to implement Traub's parallel gap junction code (see https://senselab.med.yale.edu/ModelDB/S ... hoc#tabs-2) in Python. So far I have the following for par_gap_create and par_gap_create1 (implemented as methods within a "Net" class):

Code: Select all

    def par_gap_create(self,gid_one,cellone_section,gid_two,celltwo_section,gmax):
        '''create gap junction between two cells, that works with parallel simulations'''
        if(pc.gid_exists(gid_one)):
            self.par_gap_create1(gid_one, cellone_section, self.gap_src_gid + 1, self.gap_src_gid, gmax)
        if(pc.gid_exists(gid_two)):
            self.par_gap_create1(gid_two, celltwo_section, self.gap_src_gid, self.gap_src_gid + 1, gmax)
            
        self.gap_src_gid += 2
        
    def par_gap_create1(self,gid,cellsection,target_src_gid,source_src_gid,gmax):
        '''create individual gap junction'''
        cell=pc.gid2cell(gid)
        if(cellsection==0): #let cellsection==0 specify that the gap junction be located on the soma; can add other sections in future
            gapj = h.gGapPar(cell.soma(0.5))
            self.par_gaps.append(gapj)
            pc.target_var(gapj._ref_vgap, target_src_gid)
            pc.source_var(cell.soma(0.5)._ref_v, source_src_gid)
            gapj.g=gmax
        if(cellsection != 0):
            pass
When I try to run my program, I keep getting an error on the line pc.source_var(cell.soma(0.5)._ref_v, source_src_gid). The error is "Pointer to v is not in the currently accessed section." But as far as I can tell, using cell.soma(0.5)._ref_v is standard when using Python. Also, the same syntax is used in this forum post: viewtopic.php?f=31&t=2738&p=10998&hilit ... hon#p10998. So I'm not really sure what is going on here. Thanks for the help.

pascal
Posts: 89
Joined: Thu Apr 26, 2012 11:51 am

Re: Using Traub's parallel gap junction in Python

Post by pascal »

All right, I figured out the fix from this post: viewtopic.php?f=2&t=3160

I had to replace the line

Code: Select all

pc.source_var(cell.soma(0.5)._ref_v, source_src_gid)
with

Code: Select all

pc.source_var(cell.soma(0.5)._ref_v, source_src_gid,sec=cell.soma)
According to the link above, sec=cell.soma is required because "NEURON needs to know what thread/etc contains the pointer, and this information is not accessible via the raw pointer." I do not understand how sec=cell.soma conveys any information about threads. From my naive perspective, it seems that cell.soma(0.5)._ref_v makes sec=cell.soma redundant.

Could anyone explain what is going on under the hood here? Thanks.

hines
Site Admin
Posts: 1600
Joined: Wed May 18, 2005 3:32 pm

Re: Using Traub's parallel gap junction in Python

Post by hines »

Every section contains information about what thread it is in. Unfortunately although the section is known when the pointer is evaluated from the statement
cell.soma(.5)._ref_v, it is difficult to retrieve that information from the pointer itself (one would have to iterate over all threads and all voltages in those threads
to find a pointer match.)

Post Reply