navis 1.4.0
  • Install
  • Quickstart
  • Tutorials
  • API
  • Changelog
  • Github
  • Ecosystem
  • Site
    • Page
        • navis.insert_nodes
          • insert_nodes()

    navis.insert_nodes¶

    navis.insert_nodes(x, where, coords=None, validate=True, inplace=False)[source]¶

    Insert new nodes between existing nodes.

    Parameters:
    • x (TreeNeuron) – Neuron to insert new nodes into.

    • where (list of node pairs) – Must be a list of node ID pairs. A new node will be added between the nodes of each pair (see examples).

    • coords (None | list of (x, y, z) coordinates | list of fractions) –

      Can be:
      • None: new nodes will be inserted exactly between the two

        nodes

      • (N, 3) array of coordinates for the newly inserted nodes

      • (N, ) array of fractional distances [0-1]: e.g. 0.25 means that a new node will be inserted a quarter of the way between the two nodes (from the child’s perspective)

    • validate (bool) – If True, will make sure that pairs in where are always in (parent, child) order. If you know this to already be the case, set validate=False to save some time.

    • inplace (bool) – If True, will rewire the neuron inplace. If False, will return a rewired copy of the neuron.

    Return type:

    TreeNeuron

    Examples

    Insert new nodes between some random points

    >>> import navis
    >>> n = navis.example_neurons(1)
    >>> n.n_nodes
    4465
    >>> where = n.nodes[['parent_id', 'node_id']].values[100:200]
    >>> _ = navis.insert_nodes(n, where=where, inplace=True)
    >>> n.n_nodes
    4565
    

    Back to top

    Source

    © Copyright 2018, Philipp Schlegel.
    Created using Sphinx 5.3.0.