Closed jefferis closed 5 years ago
maybe reverse Strahler order
Could also remove anything tagged as not a branch
Here is a first attempt at this. Trials on some DA1 PNs show a reduction in the number of nodes of about 25%, which seems useful though not huge. It may have a greater impact on neurons with very extensive arbours.
prune_terminals <- function(x, maxorder=1, maxlength=2000,...) {
badsegs = strahler_order(x)$segments <= maxorder &
seglengths(x) <= maxlength
goodids = unlist(x$SegList[!badsegs])
prune_vertices(x, goodids, invert = T)
}
> da1s.p=nlapply(da1s, prune_terminals)
> da1s.p.dps=dotprops(da1s.p/1e3, k=5, resample=1)
> da1s.dps=dotprops(da1s/1e3, k=5, resample=1)
> summary(da1s.p.dps)/summary(da1s.dps)
nodes cable.length
27295 0.6759853 0.6759853
57311 0.7644979 0.7644979
57323 0.7818021 0.7818021
57353 0.8527709 0.8527709
57381 0.6872659 0.6872659
61221 0.7637326 0.7637326
755022 0.7949153 0.7949153
2863104 0.7189805 0.7189805
> summary(summary(da1s.p.dps)/summary(da1s.dps))
nodes cable.length
Min. :0.6760 Min. :0.6760
1st Qu.:0.7111 1st Qu.:0.7111
Median :0.7641 Median :0.7641
Mean :0.7550 Mean :0.7550
3rd Qu.:0.7851 3rd Qu.:0.7851
Max. :0.8528 Max. :0.8528
>
mvp2=read.neuron.catmaid(2333007)
mvp2.orig=dotprops(mvp2/1e3, k=5, resample=1)
mvp2.p=dotprops(prune_terminals(mvp2)/1e3, k=5, resample=1)
> nvertices(mvp2.orig)
[1] 29513
> nvertices(mvp2.p)
[1] 10959
So more significant, but it actually takes 30 s to do the whole dotprops and strahler order thing. More than 20s of that is dotprops, with much of the time spent rbinding.
NB have been having a problem where neurons have cycles
> prune_terminals(da1s[[1]])
Error in as.seglist.igraph(masterg <- x, origin = origin, Verbose = Verbose) :
Graph has cycles!
Called from: as.seglist.igraph(masterg <- x, origin = origin, Verbose = Verbose)
Looks like this relates to a bug introduced into nat when trying to speed up resampling of neurons in jefferis/nat@77ca3e51730af1d5102dc5baf625c352f0504462.
We now have a good implementation of this in prune_twigs
:
https://github.com/jefferis/elmr/blob/e34dc5e4dadc93160dba7889031501462bf9b966/R/prune_twigs.R#L1-L20
(good enough that we may move to nat).
So we can update nblast_fafb
to use this by default. @schlegelp would this have any impact on CATBOT?
No. Catbot uses the basic nblast
function and does all the preprocessing itself. It currently uses the pre-processed simp10.dps
overnight dump. If you are changing nblast_fafb
, should I change that behaviour to using the twigs5.dps
to match nblast_fafb
?
I think twigs5 is def better than simp10 although it might take longer.
By combining strahler order and segment length we could probably remove a large number of small terminal branches without any impact on nblast results.