natverse / nat

NeuroAnatomy Toolbox: An R package for the (3D) visualisation and analysis of biological image data, especially tracings of single neurons.
https://natverse.org/nat/
62 stars 26 forks source link

Undesired output when stitching with an empty neuronlist #490

Closed dokato closed 2 years ago

dokato commented 2 years ago

I try to stitch a single neuron with some of its partners. I use some filter for my selection, so it happens rarely that the partners list is empty. In such case:

> x <- neuronlist()
> nn = Cell07PNs[[1]]
> stitch_neurons(
     c(as.neuronlist(nn), x)
 )
'neuronlist' containing 1 'neuron' object and 'data.frame' with 0 vars [37.4 kB]

Despite what docs say:

Value: A single neuron object containing all input fragments.

Which is weird as calling c(as.neuronlist(nn), x) returns correct neuronlist with just a single neuron.

jefferis commented 2 years ago

Yes, it looks like that edge case wasn't considered. FWIW stitch_neurons_mst is generally recommended – and that seems to work

> x <- neuronlist()
> nn = Cell07PNs[1]
> stitch_neurons_mst(c(nn, x))
'neuron' with 180 vertices in 1 tree

did you already track down where this goes wrong in stitch_neurons?