How to use the neuron.h.pop_section function in NEURON

To help you get started, we’ve selected a few NEURON examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Neurosim-lab / netpyne / netpyne / network.py View on Github external
for ii in range(numpts):
            if h.arc3d(ii) >= s:
                b = ii
                break
        if b == -1: print("an error occurred in pointFromLoc, SOMETHING IS NOT RIGHT")

        if h.arc3d(b) == s:  # shortcut
            x, y, z = h.x3d(b), h.y3d(b), h.z3d(b)
        else:               # need to interpolate
            a = b-1
            t = (s - h.arc3d(a)) / (h.arc3d(b) - h.arc3d(a))
            x = h.x3d(a) + t * (h.x3d(b) - h.x3d(a))
            y = h.y3d(a) + t * (h.y3d(b) - h.y3d(a))
            z = h.z3d(a) + t * (h.z3d(b) - h.z3d(a))    

        h.pop_section()
        return x, y, z
github mattions / neuronvisio / src / neuronvisio / manager.py View on Github external
def __get_parent(self, sec, tree):
        """Recursive function used to create the tree list of section"""
        sec.push()
        secRef = h.SectionRef()
        if secRef.has_parent():
            parentSeg = secRef.parent()
            parentSec = parentSeg.sec
            tree.append(parentSec)
            tree = self.__get_parent(parentSec, tree)
        h.pop_section()
        return tree
github AllenInstitute / bmtk / bmtk / simulator / bionet / modules / record_netcons.py View on Github external
def _get_syn_location(self, nc, cell):
        if isinstance(cell, BioCell):
            sec_x = nc.postloc()
            sec = h.cas()
            sec_id = self._sec_lookup[cell.gid][sec]  # cell.get_section_id(sec)
            h.pop_section()
            return sec_id, sec_x
        else:
            return -1, -1
github mattions / neuronvisio / src / neuronvisio / visio.py View on Github external
def retrieve_coordinate(self, sec):
        """Retrieve the coordinates of the section"""
        coords = {}
        sec.push()
        coords['x0'] = h.x3d((h.n3d()- h.n3d()))
        coords['x1'] = h.x3d((h.n3d()- 1))
        coords['y0'] = h.y3d((h.n3d()- h.n3d()))
        coords['y1'] = h.y3d((h.n3d()- 1))
        coords['z0'] = h.z3d((h.n3d()- h.n3d()))
        coords['z1'] = h.z3d((h.n3d()- 1))
        h.pop_section()
        return coords
github mattions / neuronvisio / neuronvisio / visio.py View on Github external
def build_sec_scalar(self, sec, var_value):
        
        sec.push()
        npoints = self.n3dpoints_per_sec[sec.name()]
        sec_scalar = np.repeat(var_value, npoints)
        h.pop_section()
        return sec_scalar
github Neurosim-lab / netpyne / netpyne / analysis / network.py View on Github external
if showFig: _showFigure()

    else:  # Plot using Interviews
        # colors: 0 white, 1 black, 2 red, 3 blue, 4 green, 5 orange, 6 brown, 7 violet, 8 yellow, 9 gray
        from neuron import gui
        fig = h.Shape()
        secList = h.SectionList()
        if not ivprops:
            ivprops = {'colorSecs': 1, 'colorSyns':2 ,'style': 'O', 'siz':5}
        
        for cell in [c for c in cellsPost]: 
            for sec in cell.secs.values():
                if 'axon' in sec['hSec'].hname() and not includeAxon: continue
                sec['hSec'].push()
                secList.append()
                h.pop_section()
                if showSyns:
                    for synMech in sec['synMechs']:
                        if synMech['hSyn']:
                            # find pre pop using conn[preGid]
                            # create dict with color for each pre pop; check if exists; increase color counter
                            # colorsPre[prePop] = colorCounter

                            # find synMech using conn['loc'], conn['sec'] and conn['synMech']
                            fig.point_mark(synMech['hSyn'], ivprops['colorSyns'], ivprops['style'], ivprops['siz']) 

        fig.observe(secList)
        fig.color_list(secList, ivprops['colorSecs'])
        fig.flush()
        fig.show(0) # show real diam
            # save figure
        if saveFig:
github Neurosim-lab / netpyne / netpyne / network / subconn.py View on Github external
for ii in range(numpts):
        if h.arc3d(ii) >= s:
            b = ii
            break
    if b == -1: print("an error occurred in pointFromLoc, SOMETHING IS NOT RIGHT")

    if h.arc3d(b) == s:  # shortcut
        x, y, z = h.x3d(b), h.y3d(b), h.z3d(b)
    else:               # need to interpolate
        a = b-1
        t = (s - h.arc3d(a)) / (h.arc3d(b) - h.arc3d(a))
        x = h.x3d(a) + t * (h.x3d(b) - h.x3d(a))
        y = h.y3d(a) + t * (h.y3d(b) - h.y3d(a))
        z = h.z3d(a) + t * (h.z3d(b) - h.z3d(a))    

    h.pop_section()
    return x, y, z
github arbor-sim / arbor / validation / ref / neuron / nrn_validation.py View on Github external
def add_dendrite(self, name, geom, to=None, **kw):
        p = combine(default_model_parameters, kw)

        dend = h.Section(name=name)
        dend.push()
        for x, d in geom:
            h.pt3dadd(x, 0, 0, d)
        h.pop_section()

        dend.Ra = p['Ra']
        dend.cm = p['cm']

        # Add passive membrane properties to dendrite.
        dend.insert('pas')
        dend.g_pas = p['g_pas']
        dend.e_pas = p['e_pas']

        dend.nseg = int(p['ncomp'])

        if to is None:
            if self.soma is not None:
                dend.connect(self.soma(1))
        else:
            dend.connect(self.sections[to](1))
github Neurosim-lab / netpyne / netpyne / conversion / neuronPyHoc.py View on Github external
pointps[pointpName][varName] = point.__getattribute__(varName)
                            # special condition for Izhi model, to set vinit=vr
                            # if varName == 'vr': secDic[secName]['vinit'] = point.__getattribute__(varName) 
                        except:
                            print('Could not read %s variable from point process %s'%(varName,pointpName))

        if pointps: secDic[secName]['pointps'] = pointps

        # store topology (keep at the end since h.SectionRef messes remaining loop)
        secRef = h.SectionRef(sec=sec)
        if secRef.has_parent():
            secDic[secName]['topol']['parentSec'] = getSecName(secRef.parent().sec, dirCellSecNames)
            secDic[secName]['topol']['parentX'] = h.parent_connection()
            secDic[secName]['topol']['childX'] = h.section_orientation()

        h.pop_section()  # to prevent section stack overflow
        
    # store section lists
    secLists = h.List('SectionList')
    if int(secLists.count()): 
        secListDic = {}
        for i in range(int(secLists.count())):  # loop over section lists
            hname = secLists.o(i).hname()
            if hname in dirCellHnames:  # use python variable name
                secListName = dirCellHnames[hname]
            else:
                secListName = hname
            secListDic[secListName] = [getSecName(sec, dirCellSecNames) for sec in secLists.o(i)]
    else:
        secListDic = {}

    # globals
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
''' Get soma position;
        Used to calculate seg coords for LFP calc (one per population cell; assumes same morphology)'''
        n3dsoma = 0
        r3dsoma = np.zeros(3)
        for sec in [sec for secName, sec in self.secs.items() if 'soma' in secName]:
            sec['hSec'].push()
            n3d = int(h.n3d())  # get number of n3d points in each section
            r3d = np.zeros((3, n3d))  # to hold locations of 3D morphology for the current section
            n3dsoma += n3d

            for i in range(n3d):
                r3dsoma[0] += h.x3d(i)
                r3dsoma[1] += h.y3d(i)
                r3dsoma[2] += h.z3d(i)

            h.pop_section() 
        
        r3dsoma /= n3dsoma

        return r3dsoma