### Navigation

- index
- modules |
- modules |
- previous |
- NEURON 7.3 documentation »
- neuron »
- Basic Reaction-Diffusion »

# neuron.rxd.geometry3d

class `neuron.rxd.geometry3d.``ScalarField`(xlo, xhi, ylo, yhi, zlo, zhi, dx, dtype=None)

  A scalar field.

  `dx`

    Discretization size of the grid.

  `values`

    State values.

  `xs`

    The x coordinates of the centers of the voxels.

  `ys`

    The y coordinates of the centers of the voxels.

  `zs`

    The z coordinates of the centers of the voxels.

  `__getitem__`(*args)

    Indexing in to the values of the mesh. This is a syntactic shorthand for values[indices].

    Examples

    To return the value from mesh whose position is mesh.xs[0], mesh.ys[1], mesh.zs[2]:

        >>> a = mesh.__getitem__(0, 1, 2)

    Equivalently, one can use the syntactic shorthand []:

        >>> a = mesh[0, 1, 2]

    Slices are also supported:

        >>> a = mesh[0 : 2, :, 1]

`neuron.rxd.geometry3d.``surface`(source, dx=0.25, internal_membranes=False, n_soma_step=100)

  Generates a triangularized mesh of the surface of a neuron.

  Parameters : | source : `list()`, `nrn.SectionList`, or `nrn.Import3D` The geometry to mesh. dx : double, optional Underlying mesh used to generate the triangles. internal_membranes : [`True` | `False`], optional Set to True to not remove internal membranes. n_soma_step : integer, optional Number of pieces to slice a soma outline into.
  Returns : | result : `TriangularMesh` The mesh.

  Examples

  A simple meshing of the entire NEURON morphology.

      >>> tri_mesh = geometry3d.surface(h.allsec())

  Importing from Neurolucida with a coarser grid.

      >>> h.load_file('stdlib.hoc')
      1.0
      >>> h.load_file('import3d.hoc')
      1.0
      >>> cell = h.Import3d_Neurolucida3()
      >>> cell.input(filename_dot_asc)
      >>> tri_mesh = geometry3d.surface(cell, dx=0.5)

  Removal of the internal membranes is not necessary if the only goal is to plot the surface; here we use `mayavi.mlab`.

      >>> tri_mesh = geometry3d.surface([sec1, sec2, sec3],
      ...                               internal_membranes=True)
      >>> mlab.triangular_mesh(tri_mesh.x, tri_mesh.y, tri_mesh.z,
      ...                      tri_mesh.faces, color=(1, 0, 0))
      >>> mlab.show()

  Note

  The use of Import3D objects is recommended over lists of sections because the former preserves the soma outline information while the later does not. Up to one soma outline is currently supported.

class `neuron.rxd.geometry3d.``TriangularMesh`(data)

  A triangular mesh, typically of a surface.

  `area`

    The sum of the areas of all the triangles.

  `faces`

    A list of the triangles, described as lists of the indices of three points.

  `x`

    The x coordinates of the vertices.

  `y`

    The y coordinates of the vertices.

  `z`

    The z coordinates of the vertices.

`neuron.rxd.geometry3d.``voxelize`(source, dx=0.25, xlo=None, xhi=None, ylo=None, yhi=None, zlo=None, zhi=None, n_soma_step=100)

  Generates a cartesian mesh of the volume of a neuron.

  Parameters : | source : `list()`, `nrn.SectionList`, or `nrn.Import3D` The geometry to mesh. dx : double, optional Mesh step size. xlo : double, optional Minimum x value. If omitted or None, uses minimum x value in the geometry. xhi : double, optional Maximum x value. If omitted or None, uses maximum x value in the geometry. ylo : double, optional Minimum y value. If omitted or None, uses minimum y value in the geometry. yhi : double, optional Maximum y value. If omitted or None, uses maximum y value in the geometry. zlo : double, optional Minimum z value. If omitted or None, uses minimum z value in the geometry. zhi : double, optional Maximum z value. If omitted or None, uses maximum z value in the geometry. n_soma_step : integer, optional Number of pieces to slice a soma outline into.
  Returns : | result : `ScalarField` The mesh. Values are scalars, but may be used as True inside the geometry and False outside.

  Examples

  Basic usage:

      >>> mesh = geometry3d.voxelize(h.allsec())

  Full example, using `pyplot`:

      >>> s1, s2, s3 = [h.Section() for i in xrange(3)]
      >>> for sec in [s2, s3]: ignore_return = sec.connect(s1)
      ...
      >>> for sec in h.allsec():
      ...     sec.diam = 1
      ...     sec.L = 5
      ...
      >>> mesh = geometry3d.voxelize(h.allsec(), dx=.1)
      >>> for i in xrange(10):
      ...     ignore_return = pyplot.subplot(2, 5, i + 1)
      ...     ignore_return = pyplot.imshow(mesh.values[:, :, i])
      ...     ignore_return = pyplot.xticks([])
      ...     ignore_return = pyplot.yticks([])
      ...
      >>> pyplot.show()

  (Source code, png, hires.png, pdf)

  Note

  The use of Import3D objects is recommended over lists of sections because the former preserves the soma outline information while the later does not. Up to one soma outline is currently supported.

### Navigation

- index
- modules |
- modules |
- previous |
- NEURON 7.3 documentation »
- neuron »
- Basic Reaction-Diffusion »