How to use the neuron.h.z3d 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 get_axon_direction(hobj):
    for sec in hobj.somatic:
        n3d = int(h.n3d())  # get number of n3d points in each section
        soma_end = np.asarray([h.x3d(n3d - 1), h.y3d(n3d - 1), h.z3d(n3d - 1)])
        mid_point = int(n3d / 2)
        soma_mid = np.asarray([h.x3d(mid_point), h.y3d(mid_point), h.z3d(mid_point)])

    for sec in hobj.all:
        section_name = sec.name().split(".")[1][:4]
        if section_name == 'axon':
            n3d = int(h.n3d())  # get number of n3d points in each section
            axon_p3d = np.zeros((n3d, 3))  # to hold locations of 3D morphology for the current section
            for i in range(n3d):
                axon_p3d[i, 0] = h.x3d(i)
                axon_p3d[i, 1] = h.y3d(i)  # shift coordinates such to place soma at the origin.
                axon_p3d[i, 2] = h.z3d(i)

    # Add soma coordinates to the list
    p3d = np.concatenate(([soma_mid], axon_p3d), axis=0)
github AllenInstitute / bmtk / bmtk / simulator / bionet / default_setters / cell_models.py View on Github external
def get_axon_direction(hobj):
    for sec in hobj.somatic:
        n3d = int(h.n3d())  # get number of n3d points in each section
        soma_end = np.asarray([h.x3d(n3d - 1), h.y3d(n3d - 1), h.z3d(n3d - 1)])
        mid_point = int(n3d / 2)
        soma_mid = np.asarray([h.x3d(mid_point), h.y3d(mid_point), h.z3d(mid_point)])

    for sec in hobj.all:
        section_name = sec.name().split(".")[1][:4]
        if section_name == 'axon':
            n3d = int(h.n3d())  # get number of n3d points in each section
            axon_p3d = np.zeros((n3d, 3))  # to hold locations of 3D morphology for the current section
            for i in range(n3d):
                axon_p3d[i, 0] = h.x3d(i)
                axon_p3d[i, 1] = h.y3d(i)  # shift coordinates such to place soma at the origin.
                axon_p3d[i, 2] = h.z3d(i)

    # Add soma coordinates to the list
    p3d = np.concatenate(([soma_mid], axon_p3d), axis=0)

    # Compute PCA
    pca = PCA(n_components=3)
github AllenInstitute / bmtk / bmtk / simulator / bionet / default_setters / cell_models.py View on Github external
def get_axon_direction(hobj):
    for sec in hobj.somatic:
        n3d = int(h.n3d())  # get number of n3d points in each section
        soma_end = np.asarray([h.x3d(n3d - 1), h.y3d(n3d - 1), h.z3d(n3d - 1)])
        mid_point = int(n3d / 2)
        soma_mid = np.asarray([h.x3d(mid_point), h.y3d(mid_point), h.z3d(mid_point)])

    for sec in hobj.all:
        section_name = sec.name().split(".")[1][:4]
        if section_name == 'axon':
            n3d = int(h.n3d())  # get number of n3d points in each section
            axon_p3d = np.zeros((n3d, 3))  # to hold locations of 3D morphology for the current section
            for i in range(n3d):
                axon_p3d[i, 0] = h.x3d(i)
                axon_p3d[i, 1] = h.y3d(i)  # shift coordinates such to place soma at the origin.
                axon_p3d[i, 2] = h.z3d(i)

    # Add soma coordinates to the list
    p3d = np.concatenate(([soma_mid], axon_p3d), axis=0)

    # Compute PCA
    pca = PCA(n_components=3)
    pca.fit(p3d)
    unit_v = pca.components_[0]

    mag_v = np.sqrt(pow(unit_v[0], 2) + pow(unit_v[1], 2) + pow(unit_v[2], 2))
    unit_v[0] = unit_v[0] / mag_v
    unit_v[1] = unit_v[1] / mag_v
    unit_v[2] = unit_v[2] / mag_v

    # Find the direction
    axon_end = axon_p3d[-1] - soma_mid
github Neurosim-lab / netpyne / netpyne / network.py View on Github external
def _posFromLoc(self, sec, x):
        sec.push()
        s = x * sec.L
        numpts = int(h.n3d())
        b = -1
        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 / 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 AllenInstitute / bmtk / bmtk / simulator / bionet / morphology.py View on Github external
def get_soma_pos(self):
        n3dsoma = 0
        r3dsoma = np.zeros(3)
        for sec in self.hobj.soma:
            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, sec=sec)
                r3dsoma[1] += h.y3d(i, sec=sec)
                r3dsoma[2] += h.z3d(i, sec=sec)

        r3dsoma /= n3dsoma
        return r3dsoma
github Neurosim-lab / netpyne / netpyne / network.py View on Github external
numpts = int(h.n3d())
        b = -1
        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