hemibrain_reroot: Re-root (a) hemibrain/flywire neuron/neurons

View source: R/hemibrain_reroot.R

hemibrain_rerootR Documentation

Re-root (a) hemibrain/flywire neuron/neurons

Description

Re-root neurons by predicting their soma location. Somas have been manually tagged by the FlyEM project. However, in some cases the roots are wrong, or somas are outside of the volume. The Fly Connectome team at the University of Cambridge has manually tagged better root points for these neurons. Soma locations, updated by this work, as saved as hemibrain_somas in this package. A user can read somas from here, or get a bleeding edge version from the Google Sheet. Alternatively, they can 'estimated' a good root-point. This works by finding the longest path outside of a given neuropil mesh/meshes, as in insect neurons the soma should be located in a cortex outside of the neuropil proper.

Usage

hemibrain_reroot(
  x,
  method = c("manual", "estimated"),
  meshes = NULL,
  googlesheet = FALSE,
  hemibrain_somas = hemibrainr::hemibrain_somas,
  ...
)

Arguments

x

a nat::neuronlist or nat::neuron object

method

whether to use the manually curated soma list or estimate soma location.

meshes

a list/a single object of class mesh3d or hxsurf. Only used for estimation. If NULL then hemibrain_roi_meshes is called.

googlesheet

logical, whether to read soma locations from the Google Sheet if method == "manual".

hemibrain_somas

a data.frame that gives soma locations for hemibrain neurons. See the default, hemibrain_somas. If googelsheet is TRUE this is read fresh from the hemibrain Google team drive overseen by the Drosophila Connectomics group.

...

methods sent to nat::nlapply

flywire_nuclei

a data.frame that gives auto-detected nuclei locations in the Flywire dataset. This is provided by fafbseg::flywire_nuclei(rawcoords = TRUE). This assumes the flywire neuron is in its untransformed, raw coordinates.

try_hairball

logical, if TRUE when a match to flywire_nuclei cannot be foudn soma is estimated using fafbseg:::reroot_hairball.

rootid_backup

logical, if TRUE then if the nucleus_id cannot be used, attempt to use root_id with result rfom fafbseg::flywire_nuclei.

Value

a nat::neuronlist or nat::neuron object

See Also

flow_centrality, hemibrain_somas

Examples


# Choose some known trouble makers
bad.soma = c("5813015982","885788485","5813013913")

# Read in these neurons
neurons.bs = neuprintr::neuprint_read_neurons(bad.soma)

# Re-root
neurons = hemibrain_reroot(neurons.bs, meshes = hemibrain.surf)

## Not run: 
# Let's check that this worked. Old root in red, new in green
nat::nopen3d()
for(i in 1:length(neurons)){
     n = neurons[[i]]
     bs = neurons.bs[[i]]
     clear3d();
     message(n$bodyid)
     plot3d(n,col="brown",lwd=2)
     points3d(nat::xyzmatrix(n$connectors),col="black")
     spheres3d(nat::xyzmatrix(n)[nat::rootpoints(n),],radius=500, alpha=0.5, col = "green")
     spheres3d(nat::xyzmatrix(bs)[nat::rootpoints(bs),],radius=500, alpha=0.5, col = "red")
     p = readline("Done? ")
}

## End(Not run)

natverse/hemibrainr documentation built on Nov. 27, 2024, 9:01 p.m.