Stitch multiple fragments into single neuron using nearest endpoints

stitch_neurons(x, prefer_soma = TRUE, sort = TRUE, warndist = 1000)

Arguments

x

A neuronlist containing fragments of a single neuron

prefer_soma

When TRUE (the default) the fragment tagged as the soma will be used as the master neuron.

sort

When TRUE (the default) the fragments will be sorted by the number of nodes they contain before stitching.

warndist

If distance is greater than this value, create a warning.

Value

A single neuron object containing all input fragments.

Details

Neurons will be ordered by default such the largest (by node count) neuron with a soma tag is the master neuron - i.e. the one containing the root node. Fragments are joined recursively in this sort order each time simply picking the closest fragment to the current master. Closest is here defined by the distance between nearest endpoints.

See also

Examples

if (FALSE) { dl1_main=simplify_neuron(dl1neuron, n = 1, invert = FALSE) dl1_branches=simplify_neuron(dl1neuron, n = 1, invert = TRUE) dl1_branches1=simplify_neuron(dl1_branches, n = 1, invert = FALSE) dl1_branches2=simplify_neuron(dl1_branches, n = 1, invert = TRUE) dl1_fragment <- list(dl1_main,dl1_branches1,dl1_branches2) dl1_fragment <- as.neuronlist(dl1_fragment) dl1_whole = stitch_neurons(dl1_fragment) }