hemibrain_skeleton_check: Pre-process hemibrain skeletons

View source: R/hemibrain_reroot.R

hemibrain_skeleton_checkR Documentation

Pre-process hemibrain skeletons

Description

Call hemibrain_reroot on neurons read from the hemibrain neuprintr project, that have no marked soma, and remove_bad_synapses on all neurons. Does not prune synapses from soma positions / along the primary neurite, but does remove synapses outside of the hemibrain volume.

Usage

hemibrain_skeleton_check(
  x,
  meshes = hemibrainr::hemibrain.surf,
  min.nodes.from.soma = 100,
  min.nodes.from.pnt = 5,
  OmitFailures = FALSE,
  ...
)

Arguments

x

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.

meshes

a list/a single object of class mesh3d or hxsurf. Defaults to hemibrain.surf. See examples for alternatives.

min.nodes.from.soma

the minimum number of nodes (geodesic distance) a synapse can be from the soma. Synapses closes than this will be removed. For comparable results across neurons, recommended to use nat::resample on your neurons before using.

min.nodes.from.pnt

the minimum number of nodes (geodesic distance) a synapse can be from a point along the primary neurite. Synapses closes than this will be removed.

OmitFailures

Whether to omit neurons for which FUN gives an error. The default value (NA) will result in nlapply stopping with an error message the moment there is an error.

...

methods sent to nat::nlapply

Value

a nat::neuronlist or nat::neuron object

See Also

hemibrain_reroot

Examples


# Choose some known trouble makers
ids = 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"
)

# just use a subset for documentation purposes
ids=ids[1:3]

# Read in these neurons
neurons = neuprintr::neuprint_read_neurons(ids)
## Not run: 
# Get all the roi meshes
hemibrain.rois = hemibrain_roi_meshes()
## Using this as the argument for 'meshes' will also
## give you the ROI for each point and synapse in a neuron's skeleton!!

# Re-root
neurons.checked = hemibrain_skeleton_check(neurons, meshes = hemibrain.rois)

## End(Not run)

# Alternatively, we can do this faster using a single surface model for the
# whole hemibrain

neurons.checked = hemibrain_skeleton_check(neurons, meshes = hemibrain.surf)

## Not run: 
# Let's check that this worked
nat::nopen3d()
for(n in neurons.checked){
     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)
     p = readline("Done? ")
}

## End(Not run)

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