The goal of fafbseg is to provide support for analysis of segmented EM data. This includes support for working with neuroglancer mesh data for the full adult female brain (FAFB) dataset. In particular there is support for the FlyWire and Google brain automatic segmentations of FAFB data.
fafbseg is integrated with the NeuroAnatomy Toolbox suite (aka natverse) especially elmr and catmaid.
We recommend installing fafbseg from GitHub using the natmanager package:
# install natmanager if required
if (!requireNamespace("natmanager")) install.packages("natmanager")
natmanager::install(pkgs="fafbseg")
You can use the package to generate URLs pointing to a defined location in a neuroglancer dataset. This includes arbitrary locations in the FAFB dataset specified interactively or using CATMAID URLs. For example, we could find the location referenced in this tweet:
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>Zoom into @dddavi whole fly brain EM dataset using public @catmaid server hosted by @virtualflybrain. From whole brain view to synaptic detail. Click to explore this location within the the mushroom body parallel fibre system yourself! https://t.co/JxsBGe3RbJ @flyconnectome pic.twitter.com/NfDiXgJOPX
— Greg Jefferis (@gsxej) July 24, 2018
library(fafbseg)
# First, optionally set a package option with an example neuroglancer URL for your dataset.
# This URL will define the image layers that are visible. You need to use an
# URL for which you have access. The package ships with a default using segmentation
# fafb_v14:fafb_v14_16nm_v00c_split3xfill2 which is probably what you need.
options(fafbseg.sampleurl="https://<neuroglancerlurl>")
# Now open location specified by CATMAID URL
u='https://fafb.catmaid.virtualflybrain.org/?pid=2&zp=131280&yp=170014.98879622458&xp=426584.81386896875&tool=navigator&sid0=2&s0=-1'
open_fafb_ngl(u)
# or display raw coordinates that you can paste into active Neuroglancer session
open_fafb_ngl(u, coords.only = TRUE)
You can use the same approach for https://flywire.ai URLs with the additional
option of transforming the coordinates to get closer to the correct location in
the FlyWire assembly of the FAFB data (which is typically a few hundred nm off).
See flywire2fafb()
for details.
# opens a new browser tab
with_segmentation('flywire31',
open_fafb_ngl(u, sample = 'FAFB14', reference = "FlyWire"))
# writes coordinates to clipboard so that you can paste them into an existings
# flywire neuroglancer browser tab
with_segmentation('flywire31',
clipr::write_clip(
open_fafb_ngl(u, coords.only = TRUE,
sample = 'FAFB14', reference = "FlyWire")))
You can also go in the opposite direction to convert a neuroglancer location into a CATMAID URL. The neuroglancer location can come either from a URL or the JSON scene specification obtained by clicking on the {} icon.
# round trip using the CATMAID URL we used earlier
ngu = open_fafb_ngl(u, open = FALSE)
# now open using elmr package - installed like so if necessary:
# natmanager::install(pkgs="natverse/elmr")
elmr::open_fafb(ngl_decode_scene(ngu))
The package now includes a simple Shiny application that translates between the two URL schemes. You can use an online version of the app at
https://jefferislab.shinyapps.io/CATMAID-Neuroglancer-Converter/
or download from GitHub and run locally the latest version of the app:
if (!require("shiny")) install.packages("shiny")
shiny::runGitHub("natverse/fafbseg", subdir = "inst/app/")
Currently the application does not convert FlyWire<->FAFB coordinates, but this
would be a relatively simple addition using flywire2fafb()
.
Currently the package provides functionality to read neuroglancer meshes into R and then compare such meshes with traced neuron objects e.g. from CATMAID. For this you will need to authenticate with an appropriate API. Alternatively see the article Capturing neuroglancer meshes from a browser scene.
You can read in meshes for the FlyWire segmentation of FAFB by doing (roughly)
choose_segmentation(release = 'flywire31')
open_fafb_ngl(c(109459, 41305, 5424)*c(4,4,40))
va6pn=read_cloudvolume_meshes("720575940633169983")
# compare with VFB CATMAID
library(elmr)
va6pn.skel=read.neurons.catmaid("name:VA6.*PN")
# let's take a look at those
plot3d(va6pn, col='grey', lwd=0.5, type='wire')
# only plot first neuron on RHS
plot3d(va6pn.skel[1], lwd=3, col='red')
# can also transform the FAFB14 skeleton from VFB to FlyWire coordinates
va6pn.skel.fw <- xform_brain(va6pn.skel[1], reference = 'FlyWire', sample='FAFB14')
nclear3d()
plot3d(va6pn, col='grey', lwd=0.5, type='wire')
# only plot first neuron on RHS
plot3d(va6pn.skel.fw, lwd=3, col='red')
You can read in meshes for the Google brain segmentation of FAFB by doing (roughly)
choose_segmentation(release = '20190805')
open_fafb_ngl(c(109459, 41305, 5424)*c(4,4,40))
va6pn=read_brainmaps_meshes("710435991")
The fafbseg package enables access to a number of published and many pre-publication resources. We hope that this will accelerate your science but we strongly request that you ensure that you acknowledge both the authors of this package and the original data sources to ensure that we and they can justify this free sharing of code and data.
- For the FAFB dataset, Zheng et al Cell 2018
- For the FFN1 autosegmentation, Li et al bioRxiv 2019
- For the FlyWire autosegmentation, [Dorkenwald et al Nat Meth 2022](https:// https://doi.org/10.1038/s41592-021-01330-0) and https://flywire.ai
- For the Buhmann synaptic connection autosegmentation, Buhmann et al Nat Meth 2021
- if using the
cleft_score
metric please also cite Heinrich et al 2018
- if using the
- For the neurotransmitter prediction, Eckstein et al. 2020 bioRxiv
FlyWire coordinate transforms and synapse predictions make use of infrastructure contributed by Davi Bock, Gregory Jefferis, Philipp Schlegel and Eric Perlman, supported by NIH BRAIN Initiative (grant 1RF1MH120679-01); additional work including assembling ground truth data was also supported by Wellcome trust (203261/Z/16/Z).
For the fabseg package itself, please include a reference to the github page in your methods section as well as a citation to Bates et al eLife 2020 along with the statement:
Ongoing development of the natverse including the fafbseg package is supported by the NIH BRAIN Initiative (grant 1RF1MH120679-01) and the Medical Research Council (MC_U105188491).
Thank you!