remove_bad_synapses: Remove incorrectly placed synapses

View source: R/hemibrain_reroot.R

remove_bad_synapsesR Documentation

Remove incorrectly placed synapses

Description

With the hemibrain projects somas and their tracts were not separately and explicitly detected. Some false synapse assignment has happened, adding synapses to soma and primary neurite locations, that should not exist based on an examination of the greyscale EM data. This function removes 'out-of-mesh' synapses, you might want to use all ROIs or the hemibrain mesh to remove these 'bad' synapses. In addition, synapses are removed if they are too near the soma / along the primary neurite.

Usage

remove_bad_synapses(
  x,
  meshes = NULL,
  soma = TRUE,
  min.nodes.from.soma = 100,
  min.nodes.from.pnt = 5,
  primary.branchpoint = 0.25,
  method = c("unsplit", "split"),
  wipe = TRUE,
  ...
)

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.

soma

logical, if TRUE it is assumed that the neuron being given has the soma as its route and an intact primary neurite tract. Synapses will then be pruned from both.

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.

primary.branchpoint

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.

method

whether to estimate the primary neurite tract ('unsplit') or use the results from flow_centrality.

wipe

logical, whether or not to remove previous flags left on synapses by this function.

...

methods sent to nat::nlapply

Value

a nat::neuronlist or nat::neuron object

See Also

hemibrain_reroot

Examples


# Read in a problematic neuron
neuron = neuprint_read_neurons(5813020793)

## Not run: 
library(nat)
plot3d(neuron)
points3d(xyzmatrix(neuron[[1]]$connectors))

## End(Not run)

# remove any synapses outside of this surface (or on the cell body fibre)
neuron.fixed = remove_bad_synapses(neuron, meshes=hemibrain.surf)
## Not run: 
# previously we used all the individual hemibrain meshes. This may produce
# slightly different results but using *hemibrain.surf* is much faster
neuron.fixed = remove_bad_synapses(neuron, meshes=hemibrain_roi_meshes())

## End(Not run)
## Not run: 
library(nat)
# Let's check that this worked
plot3d(neuron.fixed)
points3d(xyzmatrix(neuron.fixed[[1]]$connectors), size = 5, col = "green")


## End(Not run)
## Not run: 
# Now an example with flywire neurons.

## End(Not run)


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