Skip to content

Note

Click here to download the full example code

Insect Brain DB#

Fetch neurons and brain meshes from the Insect Brain Database.

The insect brain database (https://insectbraindb.org) is an online repository for neuron morphologies, brain regions and experimental data across various insect species. At the time of writing Insect Brain DB features close to 400 neuronal cell types from well over 30 insect species. Check out Heinze et al. (2021) for details!

While the website features a comprehensive search and some nifty analyses, it can be useful to download these data to run your own analyses or compare to other data sets. For that purpose, NAVis provides an interface to Insect Brain DB that wraps parts of their API:

Network access

This tutorial downloads data from the Insect Brain Database over the network, so it needs an internet connection. No account or token is required.


Import navis

import navis

# Import the actual Insect Brain DB interface
import navis.interfaces.insectbrain_db as ibdb

This tutorial walks through three kinds of data you can pull from the Insect Brain Database:

  • Species metadata


    List the available species and pull metadata for one of them.

    Fetching meta data

  • Neuropil meshes


    Download brain region meshes for a species.

    Fetching meshes

  • Neuron skeletons


    Search for cell types and fetch their reconstructions.

    Fetch neurons

Fetching meta data#

First, fetch a list of available species:

species = ibdb.get_available_species()
species.head()
Traceback (most recent call last):
  File "/home/runner/work/navis/navis/docs/examples/4_remote/tutorial_remote_03_insect_db.py", line 65, in <module>
    species = ibdb.get_available_species()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/navis/navis/navis/interfaces/insectbrain_db.py", line 346, in get_available_species
    return _sort_columns(pd.DataFrame.from_records(session.get(url)))
                                                   ^^^^^^^^^^^^^^^^
  File "/home/runner/work/navis/navis/navis/interfaces/insectbrain_db.py", line 140, in get
    r.raise_for_status()
  File "/opt/hostedtoolcache/Python/3.11.17/x64/lib/python3.11/site-packages/requests/models.py", line 1167, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://www.insectbraindb.org/api/v2/species

Fetch info for a given species (you can use the scientific or common name, or an ID):

spec_info = ibdb.get_species_info('Schistocerca gregaria')
spec_info

Fetching meshes#

Fetch neuropil meshes for the Locust brain:

# `combine=True` would produce a single combined mesh but here we want a list of individual neuropils
locust_brain = ibdb.get_brain_meshes('Desert Locust', combine=False)
locust_brain[:2]

Plot neuropils

navis.plot3d(locust_brain, volume_legend=True)
# This is for the tutorial thumbnail:
import matplotlib.pyplot as plt
fig, ax = navis.plot2d(locust_brain, method='2d')
ax.set_axis_off()
ax.grid(False)
plt.tight_layout()

Fetch neurons#

First we need to know what neurons are available. Just like on the website you can set all kinds of different search parameters. Here we will stick with our Locust:

locust_neurons = ibdb.search_neurons(species='Desert Locust')
locust_neurons.head()

Now fetch skeletons ("reconstructions") for some of the above neurons.

Not all neurons have skeletons

Only some entries come with a reconstruction - check the reconstruction_creator column to see which ones do.

# You can use IDs or names, or a combination thereof to fetch skeletons
sk = ibdb.get_skeletons('CL1a-R2')
sk

Plot the neuron - note that most neurons appear to have radii information

navis.plot3d(sk, radius=True)

Check out the API reference for further details.

Total running time of the script: ( 0 minutes 0.116 seconds)

Download Python source code: tutorial_remote_03_insect_db.py

Download Jupyter notebook: tutorial_remote_03_insect_db.ipynb

Gallery generated by mkdocs-gallery