navis-org / navis-flybrains

Transforms for navis that enable mapping between different Drosophila template brains.
GNU General Public License v3.0
7 stars 2 forks source link
brain bridging drosophila mirroring navis registrations templates transforms vnc

DOI

navis-flybrains

Transforms to map between different Drosophila template brains. Intended to be used with navis.

This library is analogous to Greg Jefferis' nat.templatebrains, nat.jrcbrains and nat.flybrains for R.

flybrains ships with:

There are plenty additional transforms that need to be downloaded separately (see below).

Installation

You can install flybrains from PyPI:

pip3 install flybrains

To install the dev version from Github:

pip3 install git+https://github.com/navis-org/navis-flybrains.git

External dependencies

In order to use the Jefferis lab or VFB transforms, you will need to have CMTK installed.

For the FANC to JRCVNC2018F transform, you will need to download elastix and make sure that the path to the binaries is in your PATH variable.

Usage

It's highly recommended that after install, you download the (optional) bridging transforms to map between template brains/nerve cords.

IMPORTANT: the URL for the JRC2018F <-> JRC2018M transform (JRC2018U_JRC2018M.h5) was incorrect in flybrains version 0.2.6. If you downloaded it using that version of flybrains you need to manually remove the file, update flybrains and download again using a newer version.

:exclamation: If you already have downloaded these registrations via nat.jrcbrains and/or nat.flybrains you can skip this: flybrains should be able to find the registrations downloaded via R and register them for you (see also code at the bottom).

>>> import flybrains

# This downloads (or updates) various CMTK bridging and mirror transforms
# generated or collated by the Jefferis lab - see docstring for details
>>> flybrains.download_jefferislab_transforms()

# This downloads H5 bridging transforms between JRC brain templates
# (Saalfeld lab, Janelia Research Campus) - see docstring for details
>>> flybrains.download_jrc_transforms()

# This downloads H5 bridging transforms between JRC VNC templates
# (Saalfeld lab, Janelia Research Campus) - see docstring for details
>>> flybrains.download_jrc_vnc_transforms()

# This downloads (or updates) various CMTK bridging and mirror transforms
# generated or collated by VirtualFlyBrain.org - see docstring for details
>>> flybrains.download_vfb_transforms()

# Register the transforms - this is only necessary if you just downloaded them
# Alternatively just restart your Python session and import flybrains
>>> flybrains.register_transforms()

In the future, simply importing flybrains is sufficient to make the transforms available to navis:

>>> import navis
>>> import flybrains
>>> import numpy as np
>>> points = np.array([[429536, 205240,  38400]])
>>> navis.xform_brain(points, source='FAFB', target='JRC2018F')
array([[241.53969657, 100.99399233,  35.96977733]])

Please see the transform tutorial for navis to learn how to transform more complex data.

To check which transforms are available (either downloaded or via R) you can run this:

>>> # Generate a report - note the mix of transforms downloaded via Python and R
>>> flybrains.report()
Flybrains Status Report
=======================
Data Home: /Users/philipps/flybrain-data

CMTK registrations (Jefferis lab/VFB): 41 of 45
H5 registrations (JRC/Saalfeld lab): 3 of 8

nat regdirs
-----------
~/Library/Application Support/rpkg-nat.templatebrains/regfolders: 41 CMTK | 0 H5 transforms
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/nat.flybrains/extdata/bridgingregistrations: 5 CMTK | 0 H5 transforms
/Library/Frameworks/R.framework/Versions/3.6/Resources/library/nat.flybrains/extdata/mirroringregistrations: 5 CMTK | 0 H5 transforms
~/Library/Application Support/R/nat.jrcbrains: 0 CMTK | 5 H5 transforms

Meta data and surface meshes for the template brains/VNCs are readily accessible:

>>> flybrains.FAFB14
Template brain
--------------
Name: Full Adult Fly Brain
Short Name: FAFB14
Type: None
Sex:  female
Dimensions: 165372 x 80745 x 6730 voxels
Voxel size:
  x = 4 nanometers
  y = 4 nanometers
  z = 40 nanometers
Bounding box (nanometers):
  x = 192200, y = 75853, z = 2007,
  x = 853686, y = 398832, z = 271205,
Description: SSTEM volume comprising an entire female Drosophila brain was imaged at
 4x4x40nm by Zheng et al. (2018) and is availabe for download at
https://temca2data.org/. The meta data and associated mesh represent
version 14 (FAFB14) of this data set.
DOI: 10.1016/j.cell.2018.06.019

Most templates come with a mesh e.g. for plotting via navis:

>>> flybrains.FAFB14.mesh
<trimesh.Trimesh(vertices.shape=(25047, 3), faces.shape=(50416, 3))>
>>> # You can pass the template object directly to navis' plotting functions
>>> navis.plot3d(flybrains.FAFB14)

Changes

Acknowledgements

navis-flybrains is critically based on nat.flybrains and nat.jrcbrains by Greg Jefferis et al. for both inspiration regarding the implementation as well as template brain meta data.

Citing

If you use navis-flybrains in for your research please make sure to cite us (see Zenodo DOI badge at the top of this page), navis and importantly the people who generated the meshes & registrations distributed with flybrains!

As reference for the Jefferis lab registrations please use:

The natverse, a versatile toolbox for combining and analysing neuroanatomical data.
A.S. Bates, J.D. Manton, S.R. Jagannathan, M. Costa, P. Schlegel, T. Rohlfing, G.S. Jefferis
eLife (2020); doi: https://doi:10.7554/eLife.53350

As (partial) reference for the Saalfeld lab registrations please see:

An unbiased template of the Drosophila brain and ventral nerve cord.
John A Bogovic, Hideo Otsuna, Larissa Heinrich, Masayoshi Ito, Jennifer Jeter, Geoffrey Meissner, Aljoscha Nern, Jennifer Colonell, Oz Malkesman, Kei Ito, Stephan Saalfeld
PLOS One (2018); doi: https://doi.org/10.1371/journal.pone.0236495

As reference for the VFB CMTK transforms please use:

A Systematic Nomenclature for the Drosophila Ventral Nerve Cord.
Robert Court, Shigehiro Namiki, J. Douglas Armstrong, Jana Börner, Gwyneth Card, Marta Costa, Michael Dickinson, Carsten Duch, Wyatt Korff, Richard Mann, David Merritt, Rod K. Murphey, Andrew M. Seeds, Troy Shirangi, Julie H. Simpson, James W. Truman, John C. Tuthill, Darren W. Williams, David Shepherd
Neuron (2020); doi: https://doi.org/10.1016/j.neuron.2020.08.005.

As reference for the FANC<->JRCVNC2018F transform by Jasper Phelps please use:

Reconstruction of motor control circuits in adult Drosophila using automated transmission electron microscopy.
Phelps JS, Hildebrand DGC, Graham BJ, Kuan AT, Thomas LA, Nguyen TM, Buhmann J, Azevedo AW, Sustar A, Agrawal S, Liu M, Shanny BL, Funke J, Tuthill JC, Lee WA
Cell (2021); doi: 10.1016/j.cell.2020.12.013

For references on individual template brains, please see their docstrings:

>>> help(flybrains.IBN)

When in doubt, feel free to open an issue to ask for advice.