How to use the neuron.h.pt3dadd 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 AllenInstitute / bmtk / bmtk / simulator / bionet / default_setters / cell_models.py View on Github external
def fix_axon_perisomatic_directed(hobj):
    # io.log_info('Fixing Axon like perisomatic')
    all_sec_names = []
    for sec in hobj.all:
        all_sec_names.append(sec.name().split(".")[1][:4])

    if 'axon' not in all_sec_names:
        io.log_exception('There is no axonal recostruction in swc file.')
    else:
        beg1, end1, beg2, end2 = get_axon_direction(hobj)

    for sec in hobj.axon:
        h.delete_section(sec=sec)
    h.execute('create axon[2]', hobj)

    h.pt3dadd(beg1[0], beg1[1], beg1[2], 1, sec=hobj.axon[0])
    h.pt3dadd(end1[0], end1[1], end1[2], 1, sec=hobj.axon[0])
    hobj.all.append(sec=hobj.axon[0])
    h.pt3dadd(beg2[0], beg2[1], beg2[2], 1, sec=hobj.axon[1])
    h.pt3dadd(end2[0], end2[1], end2[2], 1, sec=hobj.axon[1])
    hobj.all.append(sec=hobj.axon[1])

    hobj.axon[0].connect(hobj.soma[0], 0.5, 0)
    hobj.axon[1].connect(hobj.axon[0], 1.0, 0)

    hobj.axon[0].L = 30.0
    hobj.axon[1].L = 30.0

    h.define_shape()

    for sec in hobj.axon:
        # print "sec.L:", sec.L
github AllenInstitute / bmtk / bmtk / simulator / bionet / default_setters / cell_models.py View on Github external
for sec in hobj.all:
        all_sec_names.append(sec.name().split(".")[1][:4])

    if 'axon' not in all_sec_names:
        io.log_exception('There is no axonal recostruction in swc file.')
    else:
        beg1, end1, beg2, end2 = get_axon_direction(hobj)

    for sec in hobj.axon:
        h.delete_section(sec=sec)
    h.execute('create axon[2]', hobj)

    h.pt3dadd(beg1[0], beg1[1], beg1[2], 1, sec=hobj.axon[0])
    h.pt3dadd(end1[0], end1[1], end1[2], 1, sec=hobj.axon[0])
    hobj.all.append(sec=hobj.axon[0])
    h.pt3dadd(beg2[0], beg2[1], beg2[2], 1, sec=hobj.axon[1])
    h.pt3dadd(end2[0], end2[1], end2[2], 1, sec=hobj.axon[1])
    hobj.all.append(sec=hobj.axon[1])

    hobj.axon[0].connect(hobj.soma[0], 0.5, 0)
    hobj.axon[1].connect(hobj.axon[0], 1.0, 0)

    hobj.axon[0].L = 30.0
    hobj.axon[1].L = 30.0

    h.define_shape()

    for sec in hobj.axon:
        # print "sec.L:", sec.L
        if np.abs(30-sec.L) > 0.0001:
            io.log_exception('Axon stub L is less than 30')
github AllenInstitute / bmtk / bmtk / simulator / bionet / default_setters / cell_models.py View on Github external
for sec in hobj.all:
        section_name = sec.name().split(".")[1][:4]
        if section_name == 'axon':
            axon_diams[1] = sec.diam

    for sec in hobj.axon:
        h.delete_section(sec=sec)
    h.execute('create axon[2]', hobj)
    hobj.axon[0].connect(hobj.soma[0], 1.0, 0)
    hobj.axon[1].connect(hobj.axon[0], 1.0, 0)

    h.pt3dadd(beg1[0], beg1[1], beg1[2], axon_diams[0], sec=hobj.axon[0])
    h.pt3dadd(end1[0], end1[1], end1[2], axon_diams[0], sec=hobj.axon[0])
    hobj.all.append(sec=hobj.axon[0])
    h.pt3dadd(beg2[0], beg2[1], beg2[2], axon_diams[1], sec=hobj.axon[1])
    h.pt3dadd(end2[0], end2[1], end2[2], axon_diams[1], sec=hobj.axon[1])
    hobj.all.append(sec=hobj.axon[1])

    hobj.axon[0].L = 30.0
    hobj.axon[1].L = 30.0

    h.define_shape()

    for sec in hobj.axon:
        # io.log_info('sec.L: {}'.format(sec.L))
        if np.abs(30 - sec.L) > 0.0001:
            io.log_exception('Axon stub L is less than 30')
github MetaCell / NetPyNE-UI / netpyne_ui / models / ball_and_stick.py View on Github external
def shape_3D(self):
        """
        Set the default shape of the cell in 3D coordinates.
        Set soma(0) to the origin (0,0,0) and dend extending along
        the X-axis.
        """
        len1 = self.soma.L
        h.pt3dclear(sec=self.soma)
        h.pt3dadd(0, 0, 0, self.soma.diam, sec=self.soma)
        h.pt3dadd(len1, 0, 0, self.soma.diam, sec=self.soma)
        len2 = self.dend.L
        h.pt3dclear(sec=self.dend)
        h.pt3dadd(len1, 0, 0, self.dend.diam, sec=self.dend)
        h.pt3dadd(len1 + len2, 0, 0, self.dend.diam, sec=self.dend)
    #
github Neurosim-lab / netpyne / netpyne / cell / compartCell.py View on Github external
sec = self.secs[sectName]  # pointer to section

            # set geometry params 
            if 'geom' in sectParams:
                for geomParamName,geomParamValue in sectParams['geom'].items():  
                    if not type(geomParamValue) in [list, dict]:  # skip any list or dic params
                        setattr(sec['hSec'], geomParamName, geomParamValue)

                # set 3d geometry
                if 'pt3d' in sectParams['geom']:  
                    h.pt3dclear(sec=sec['hSec'])
                    x = self.tags['x']
                    y = -self.tags['y'] # Neuron y-axis positive = upwards, so assume pia=0 and cortical depth = neg
                    z = self.tags['z']
                    for pt3d in sectParams['geom']['pt3d']:
                        h.pt3dadd(x+pt3d[0], y+pt3d[1], z+pt3d[2], pt3d[3], sec=sec['hSec'])

            # add distributed mechanisms 
            if 'mechs' in sectParams:
                for mechName,mechParams in sectParams['mechs'].items(): 
                    if mechName not in sec['mechs']: 
                        sec['mechs'][mechName] = Dict()
                    sec['hSec'].insert(mechName)
                    for mechParamName,mechParamValue in mechParams.items():  # add params of the mechanism
                        mechParamValueFinal = mechParamValue
                        for iseg,seg in enumerate(sec['hSec']):  # set mech params for each segment
                            if type(mechParamValue) in [list]: 
                                if len(mechParamValue) == 1: 
                                    mechParamValueFinal = mechParamValue[0]
                                else:
                                    mechParamValueFinal = mechParamValue[iseg]
                            if mechParamValueFinal is not None:  # avoid setting None values
github JustasB / BlenderNEURON / blenderneuron / nrn / neuronsection.py View on Github external
# Use 3D points as the L and diam sources
        h.pt3dconst(1,sec=nrn_section)

        # Clear the existing points - and allocate room for the incoming points
        h.pt3dclear(self.point_count, sec=nrn_section)

        # Use vectorization to add the points to section
        coords = np.array(self.coords).reshape((-1, 3))
        diams = np.array(self.radii) * 2.0

        xvec = h.Vector(coords[:,0])
        yvec = h.Vector(coords[:,1])
        zvec = h.Vector(coords[:,2])
        dvec = h.Vector(diams)

        h.pt3dadd(xvec, yvec, zvec, dvec, sec=nrn_section)
github research-team / robot-dream / Nociception / cfiber.py View on Github external
def position(self):
        '''
        Adds 3D position 
        '''
        if self.numofmodel == 11 or self.numofmodel == 12:
            h.pt3dclear()
            h.pt3dadd(0, 0, self.zpozition, self.diam)
            h.pt3dadd(self.L, 0, self.zpozition, self.diam)
            xyz = dict(x=self.L, y=0, z=0)
            self.coordinates.update({self.branch: xyz})
            for i in range(70):
                h.pt3dclear()
                h.pt3dadd(self.L*(i+1), 0, self.zpozition, self.diam)
                h.pt3dadd(self.L*(i+2), 0, self.zpozition, self.diam)
                xyz = dict(x=self.L*(i+2), y=0, z=0)
                self.coordinates.update({self.stimsec[i]: xyz})
            for i in range(70, 120):
                h.pt3dclear()
                h.pt3dadd(self.L*(i+1), i*8, self.zpozition, self.diam)
                h.pt3dadd(self.L*(i+2), (i+1)*8, self.zpozition, self.diam)
                xyz = dict(x=self.L*(i+2), y=(i+1)*8, z=0)
                self.coordinates.update({self.stimsec[i]: xyz})
            for i in range(120, 170):
github Neurosim-lab / netpyne / examples / M1detailed / cells / ITcell.py View on Github external
def add_axon (self):
    # NB: paste-on axon if using SPI morphology (eg for comparing morph effect on dynamics)
    from PTAxonMorph import axonPts
    self.axon.append(h.Section(name="axon[0]"))
    self.all.append(self.axon[0])
    self.axon[0].connect(self.soma[0], 0.0, 0.0)
    # clears 3d points
    h.pt3dclear()
    # define a logical connection point relative to the first 3-d point
    h.pt3dstyle(axonPts[0][0], axonPts[0][1], axonPts[0][2], axonPts[0][3], sec=self.axon[0])
    # add axon points after first logical connection point
    for x, y, z, d in axonPts[1:]: h.pt3dadd(x, y, z, d, sec=self.axon[0])
github MetaCell / NetPyNE-UI / netpyne_ui / models / ball_and_stick.py View on Github external
def shape_3D(self):
        """
        Set the default shape of the cell in 3D coordinates.
        Set soma(0) to the origin (0,0,0) and dend extending along
        the X-axis.
        """
        len1 = self.soma.L
        h.pt3dclear(sec=self.soma)
        h.pt3dadd(0, 0, 0, self.soma.diam, sec=self.soma)
        h.pt3dadd(len1, 0, 0, self.soma.diam, sec=self.soma)
        len2 = self.dend.L
        h.pt3dclear(sec=self.dend)
        h.pt3dadd(len1, 0, 0, self.dend.diam, sec=self.dend)
        h.pt3dadd(len1 + len2, 0, 0, self.dend.diam, sec=self.dend)
    #