implementation of the algorithm for calculating flow centralities from Schneider-Mizell et al. (2016) (slightly modified). Can be used on nat::neuronlist objects read using neuprintr::neuprint_read_neurons. The example code below gives the recommended arguments when using hemibrain data.

  mode = c("centrifugal", "centripetal", "sum"),
  polypre = TRUE,
  soma = TRUE,
  primary.dendrite = 0.9,
  primary.branchpoint = 0.25,
  split = c("synapses", "distance"),



a nat::neuronlist or nat::neuron object. It is assumed that this neuron has been read in by neuprintr::neuprint_read_neurons or possibly catmaid::read.neurons.catmaid.


type of flow centrality to calculate. There are three flavours: (1) centrifugal, which counts paths from proximal inputs to distal outputs; (2) centripetal, which counts paths from distal inputs to proximal outputs; and (3) the sum of both.


whether to consider the number of presynapses as a multiple of the numbers of connections each makes


logical, whether or not the given neuron has a soma. The soma should be its root. If it does, primary_neurite will be called to make sure the primary neurite is labelled correctly.


whether to try to assign nodes to a 'primary dendrite'. Defaults to considering nodes of 0.9*maximal flow centrality. Assigning to NULL will prevent generating this compartment.


the proportion of the maximum branchpoint score needed for a point to be assigned as the primary branchpoint. Used only when soma = TRUE. See the first argument in primary_neurite for details.


the algorithm will assign two main neurite compartments, which as per SWC format will be indicates as either axon (Label =2) or dendrite (Label = 3) in the returned objects, at neuron$d$Label. This assignment can be based which compartment contains the most postsynapses ("postsynapses") or presynapses ("presynapses"), or the geodesic distance of its first branch point from the primary branch point (i.e. the first branch point from the soma) ("distance"). The compartment closest to this branchpoint is most usually the dendrite (Bates & Schlegel 2020).


Additional arguments passed to methods or eventually to nat::nlapply


the neuron or neuron list object inputted, with centripetal flow centrality information added to neuron$d and a segregation index score. The neuron$d$Label now gives the compartment, where axon is Label = 2, dendrite Label = 3, primary dendrite Label = 4 and primary neurite Label = 7. Soma is Label = 1.


From Schneider-Mizell et al. (2016): "We use flow centrality for four purposes. First, to split an arbor into axon and dendrite at the maximum centrifugal SFC, which is a preliminary step for computing the segregation index, for expressing all kinds of connectivity edges (e.g. axo-axonic, dendro-dendritic) in the wiring diagram, or for rendering the arbor in 3d with differently colored regions. Second, to quantitatively estimate the cable distance between the axon terminals and dendritic arbor by measuring the amount of cable with the maximum centrifugal SFC value. Third, to measure the cable length of the main dendritic shafts using centripetal SFC, which applies only to insect neurons with at least one output syn- apse in their dendritic arbor. And fourth, to weigh the color of each skeleton node in a 3d view, providing a characteristic signature of the arbor that enables subjective evaluation of its identity."


Schneider-Mizell, C. M., Gerhard, S., Longair, M., Kazimiers, T., Li, F., Zwart, M. F., … Cardona, A. (2015). Quantitative neuroanatomy for connectomics in Drosophila. bioRxiv, 026617. doi:10.1101/026617.

See also


# \donttest{ # Choose neurons ## These neurons are some 'tough' examples from the hemibrain:v1.0.1 ### They will split differently depending on the parameters you use. tough = c("5813056323", "579912201", "5813015982", "973765182", "885788485", "915451074", "5813032740", "1006854683", "5813013913", "5813020138", "853726809", "916828438", "5813078494", "420956527", "486116439", "573329873", "5813010494", "5813040095", "514396940", "665747387", "793702856", "451644891", "482002701", "391631218", "390948259", "390948580", "452677169", "511262901", "422311625", "451987038" ) # for documentation purposes only run first 5 examples tough=tough[1:5] # Get neurons neurons = neuprintr::neuprint_read_neurons(tough)
#> Warning: Please supply a `dataset` argument or set a default one at login or using the neuprint_dataset environment variable! See ?neuprint_login for details. For now we will use 'hemibrain:v1.2.1'.
# Now make sure the neurons have a soma marked ## Some hemibrain neurons do not, as the soma was chopped off neurons.checked = hemibrain_skeleton_check(neurons, meshes =
#> Re-rooting 2 neurons without a soma
#> Removing synapses outside the hemibrain neuropil volume for 5 neurons
#> Warning: invalid factor level, NA generated
#> Warning: invalid factor level, NA generated
#> Warning: invalid factor level, NA generated
#> Warning: invalid factor level, NA generated
#> Warning: invalid factor level, NA generated
#> Warning: invalid factor level, NA generated
# Split neuron ## These are the recommended parameters for hemibrain neurons neurons.flow = flow_centrality(neurons.checked, polypre = TRUE, mode = "centrifugal", split = "distance") if (FALSE) { # Plot the split to check it nat::nopen3d() nlscan_split(neurons.flow, WithConnectors = TRUE) }# }