knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) rgl::setupKnitr() havelmr=require('elmr', quietly = TRUE) options(nat.plotengine = 'plotly')
This articles gives a quick overview of mapping points between FAFB14 (as used by the "walled garden" and Virtual Fly Brain and FlyWire.
library(fafbseg)
Some known points
# identified location in FAFB14 p.fafb.nm <- cbind(477042, 284535, 90680) p.fafb.raw <- p.fafb.nm/c(4,4,40) # corresponding location in FlyWire p.flywire.raw <- cbind(118865, 71338, 2267) p.flywire.nm <- p.flywire.raw * c(4,4,40)
Compare displacements (in nm) for forward or inverse mapping
# check displacement flywire2fafb(p.flywire.nm)-p.fafb.nm # check what happens when you apply the inverse fafb2flywire(p.fafb.nm)-p.flywire.nm
A sample neuron. First map the points
data("AV4b1", package='catmaid') before=xyzmatrix(AV4b1) after=fafb2flywire(before)
Then some stats and a quick histogram
d=sqrt(rowSums((before-after)^2)) summary(d)
hist(d, br=20, main='Displacement /µm')
sample_points_in_surf <- function(x, n){ x=as.mesh3d(x) bb=boundingbox(x) mm=mapply(runif, min=bb[1,], max=bb[2,], n = n) colnames(mm)=c("X","Y","Z") data.frame(mm, inside=pointsinside(mm,x)) }
set.seed(42) sxyz=sample_points_in_surf(FAFB14.surf,25000) sxyz.in=subset(sxyz, inside) sxyz.fw=fafb2flywire(xyzmatrix(sxyz.in)) deltas=sxyz.fw-sxyz.in delta=rowSums(deltas[,c("X","Y")])
jet.colors<-colorRampPalette(c('navy','cyan','yellow','red')) nclear3d(); spheres3d(xyzmatrix(sxyz.in), col=jet.colors(10)[cut(delta, breaks = 10)], rad=2000)
Let's send those points back again
sxyz.fafb2=flywire2fafb(sxyz.fw)
deltas=sxyz.fafb2-xyzmatrix(sxyz.in) delta=rowSums(deltas[,c("X","Y")]) hist(delta, main = "Round Trip Error", xlab='delta /nm')
To map complex objects, use xform_brain()
AV4b1.fw=xform_brain(AV4b1, sample='FAFB14', reference = 'FlyWire')
# find the main branch point of a neuron, a good place to point to mainbranch <- function(x, ...) { if(is.neuronlist(x)) return(nlapply(x, mainbranch, ...)) sx=nat::simplify_neuron(x, ...) xyzmatrix(sx)[sx$BranchPoints,] }
choose_segmentation("flywire") open_fafb_ngl(mainbranch(AV4b1.fw), coords.only = TRUE)
{width=400px} {width=800px}
Note the relevant links:
catmaid.url="https://garden.catmaid.org/tracing/fafb/v14/?pid=1&zp=146720&yp=162452&xp=353219&tool=tracingtool&active_skeleton_id=488055&active_node_id=2693476&sid0=5&s0=1" fwurl="https://ngl.flywire.ai/#!%7B%22layers%22:%5B%7B%22source%22:%22precomputed://gs://microns-seunglab/drosophila_v0/alignment/image_rechunked%22%2C%22type%22:%22image%22%2C%22blend%22:%22default%22%2C%22shaderControls%22:%7B%7D%2C%22name%22:%22Production-image%22%7D%2C%7B%22source%22:%22graphene://https://prodv1.flywire-daf.com/segmentation/1.0/fly_v31%22%2C%22type%22:%22segmentation_with_graph%22%2C%22segments%22:%5B%220%22%2C%22720575940618054533%22%5D%2C%22skeletonRendering%22:%7B%22mode2d%22:%22lines_and_points%22%2C%22mode3d%22:%22lines%22%7D%2C%22graphOperationMarker%22:%5B%7B%22annotations%22:%5B%5D%2C%22tags%22:%5B%5D%7D%2C%7B%22annotations%22:%5B%5D%2C%22tags%22:%5B%5D%7D%5D%2C%22pathFinder%22:%7B%22color%22:%22#ffff00%22%2C%22pathObject%22:%7B%22annotationPath%22:%7B%22annotations%22:%5B%5D%2C%22tags%22:%5B%5D%7D%2C%22hasPath%22:false%7D%7D%2C%22name%22:%22Production-segmentation_with_graph%22%7D%5D%2C%22navigation%22:%7B%22pose%22:%7B%22position%22:%7B%22voxelSize%22:%5B4%2C4%2C40%5D%2C%22voxelCoordinates%22:%5B88371.25%2C40478.75%2C3668%5D%7D%7D%2C%22zoomFactor%22:8%7D%2C%22perspectiveZoom%22:2230.6094%2C%22jsonStateServer%22:%22https://globalv1.flywire-daf.com/nglstate/post%22%2C%22selectedLayer%22:%7B%22layer%22:%22Production-segmentation_with_graph%22%2C%22visible%22:true%7D%2C%22layout%22:%22xy-3d%22%7D"
Load the flywire mesh
av4.fwm=read_cloudvolume_meshes('720575940618054533')
And plot with the CATMAID skeleton
nclear3d() plot3d(AV4b1.fw, col='red', lwd=3) wire3d(av4.fwm[[1]], col='grey', alpha=.2)
It's obvious that both are only partially traced, but they are still the same neuron.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.