• Stars
    star
    121
  • Rank 293,924 (Top 6 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automated 3D brain registration with support for multiple species and atlases.

Python Version PyPI Wheel Development Status Tests codecov Code style: black

brainreg

brainreg is an update to amap (which is itself a port of the original Java software) to include multiple registration backends, and to support the many atlases provided by brainglobe-atlasapi. It also comes with an optional napari plugin if you'd rather use brainreg with through graphical interface.

Documentation for both the command-line tool and graphical interface can be found here. If you have any issues, please get in touch on the forum, on Zulip, or by raising an issue.

For segmentation of bulk structures in 3D space (e.g. injection sites, Neuropixels probes), please see brainglobe-segmentation.

Details

The aim of brainreg is to register the template brain (e.g. from the Allen Reference Atlas) to the sample image. Once this is complete, any other image in the template space can be aligned with the sample (such as region annotations, for segmentation of the sample image). The template to sample transformation can also be inverted, allowing sample images to be aligned in a common coordinate space.

To do this, the template and sample images are filtered, and then registered in a three step process (reorientation, affine registration, and freeform registration). The resulting transform from template to standard space is then applied to the atlas.

Full details of the process are in the original aMAP paper.

An illustrated overview of the registration process

Installation

To install both the command line tool and the napari plugin, run

pip install brainreg[napari]

in your desired Python environment. To only install the command line tool with no GUI (e.g. to run brainreg on an HPC cluster), just run:

pip install brainreg

Installing on macOS

If you are using macOS, please run

conda install -c conda-forge niftyreg

in your environment before installing, to ensure all dependencies are installed.

Command line usage

Basic usage

brainreg /path/to/raw/data /path/to/output/directory -v 5 2 2 --orientation psl

Full command-line arguments are available with brainreg -h, but please get in touch if you have any questions.

Mandatory arguments

  • Path to the directory of the images. This can also be a text file pointing to the files.
  • Output directory for all intermediate and final results.
  • You must also specify the voxel sizes with the -v flag, see specifying voxel size for details.

Atlas

By default, brainreg will use the 25um version of the Allen Mouse Brain Atlas. To use another atlas (e.g. for another species, or another resolution), you must use the --atlas flag, followed by the string describing the atlas, e.g.:

--atlas allen_mouse_50um

To find out which atlases are available, once brainreg is installed, please run brainglobe list. The name of the resulting atlases is the string to pass with the --atlas flag.

Input data orientation

If your data does not match the BrainGlobe default orientation (the origin voxel is the most anterior, superior, left-most voxel), then you must specify the orientation by using the --orientation flag. What follows must be a string in the brainglobe-space "initials" form, to describe the origin voxel.

If the origin of your data (first, top left voxel) is the most anterior, superior, left part of the brain, then the orientation string would be "asl" (anterior, superior, left), and you would use:

--orientation asl

Registration options

To change how the actual registration performs, see registration parameters

Additional options

  • -a or --additional Paths to N additional channels to downsample to the same coordinate space.
  • --sort-input-file If set to true, the input text file will be sorted using natural sorting. This means that the file paths will be sorted as would be expected by a human and not purely alphabetically.
  • --brain_geometry Can be one of full (default) for full brain registration, hemisphere_l for left hemisphere data-set and hemisphere_r for right hemisphere data-set.

Misc options

  • --n-free-cpus The number of CPU cores on the machine to leave unused by the program to spare resources.
  • --debug Debug mode. Will increase verbosity of logging and save all intermediate files for diagnosis of software issues.
  • --save-original-orientation Option to save the registered atlas with the same orientation as the input data.

Visualising results

If you have installed the optional napari plugin, you can use napari to view your data. The plugin automatically fetches the brainglobe-napari-io which provides this functionality. If you have installed only the command-line tool you can still manually install brainglobe-napari-io and follow the steps below.

Sample space

Open napari and drag your brainreg output directory (the one with the log file) onto the napari window.

Various images should then open, including:

  • Registered image - the image used for registration, downsampled to atlas resolution
  • atlas_name - e.g. allen_mouse_25um the atlas labels, warped to your sample brain
  • Boundaries - the boundaries of the atlas regions

If you downsampled additional channels, these will also be loaded. Most of these images will not be visible by default - click the little eye icon to toggle visibility.

Note: If you use a high resolution atlas (such as allen_mouse_10um), then the files can take a little while to load.

GIF illustration of loading brainreg output into napari for visualisation

Contributing

Contributions to brainreg are more than welcome. Please see the developers guide.

Citing brainreg

If you find brainreg useful, and use it in your research, please let us know and also cite the paper:

Tyson, A. L., Vรฉlez-Fort, M., Rousseau, C. V., Cossell, L., Tsitoura, C., Lenzi, S. C., Obenhaus, H. A., Claudi, F., Branco, T., Margrie, T. W. (2022). Accurate determination of marker location within whole-brain microscopy images. Scientific Reports, 12, 867 doi.org/10.1038/s41598-021-04676-9

Please also cite aMAP (the original pipeline from which this software is based):

Niedworok, C.J., Brown, A.P.Y., Jorge Cardoso, M., Osten, P., Ourselin, S., Modat, M. and Margrie, T.W., (2016). AMAP is a validated pipeline for registration and segmentation of high-resolution mouse brain data. Nature Communications. 7, 1โ€“9. https://doi.org/10.1038/ncomms11879

Lastly, if you can, please cite the BrainGlobe Atlas API that provided the atlas:

Claudi, F., Petrucco, L., Tyson, A. L., Branco, T., Margrie, T. W. and Portugues, R. (2020). BrainGlobe Atlas API: a common interface for neuroanatomical atlases. Journal of Open Source Software, 5(54), 2668, https://doi.org/10.21105/joss.02668

Finally, don't forget to cite the developers of the atlas that you used (e.g. the Allen Brain Atlas)!

More Repositories

1

brainrender

a python based software for visualization of neuroanatomical and morphological data.
Python
540
star
2

cellfinder

Automated 3D cell detection in very large images
Python
179
star
3

brainglobe-atlasapi

A lightweight python module to interact with atlases for systems neuroscience
Python
125
star
4

slicereg

A 2D-3D histological brain slice registration application for mouse, rat, zebrafish brains.
Python
37
star
5

brainglobe-heatmap

Rendering anatomical heatmaps with brainrender and matplotlib
Python
34
star
6

brainglobe-segmentation

Segmentation of anatomical structures in a common coordinate space
Python
28
star
7

cellfinder-napari

Efficient cell detection in large images using cellfinder in napari
Python
24
star
8

cellfinder-core

Standalone cellfinder cell detection algorithm
Python
19
star
9

brainrender-napari

A napari plugin to render BrainGlobe atlases and associated data as layers.
Python
19
star
10

morphapi

A lightweight python package to download neuronal morphologies
Python
17
star
11

brainreg-napari

Automated 3D brain registration in napari with support for multiple species and atlases.
Python
14
star
12

brainglobe-napari-io

Read and write files from the BrainGlobe neuroanatomy suite
Python
13
star
13

brainglobe-registration

Registration to BrainGlobe atlases in napari using Elastix
Python
13
star
14

bg-brainrender-gui

A GUI built on brainrender: visualise brain regions, neurons and labelled cells.
Python
12
star
15

bg-atlasgen

Tools for packaging atlases for use with BrainGlobe
Python
12
star
16

brainglobe-utils

Shared general purpose tools for the BrainGlobe project
Python
11
star
17

brainrender_paper

Code for recreating the figures in the brainrender paper (Claudi et al. 2020)
Python
11
star
18

probeplanner

Helps plan where to put things in brains
Python
10
star
19

BrainGlobe

General information, resources and dicussions for the BrainGlobe project.
10
star
20

brainglobe-meta

(Meta-)package repository for BrainGlobe's Python tools for computational neuroanatomy.
Python
10
star
21

brainglobe.github.io

brainglobe.info website
Python
10
star
22

imio

Loading and saving of image data.
Python
10
star
23

napari-brainreg

Visualise brainreg registration output
Python
10
star
24

cellfinder-visualize

Python
9
star
25

bgviewer

Visualisation and exploration of brain atlases
Python
9
star
26

brainrender-docs

CSS
9
star
27

brainglobe-workflows

Workflows that utilise BrainGlobe tools to perform data analysis and visualisation.
Python
9
star
28

brainglobe-template-builder

Build unbiased anatomical templates from individual images
Python
8
star
29

napari-cellfinder

Python
8
star
30

brainglobe-space

Anatomical space conventions made easy.
Python
8
star
31

bg-gitbook

Mirror of the brainglobe GitBook page
7
star
32

napari-brainreg-standard

Visualise brainreg registration output in standard space
Python
7
star
33

actions

Re-usable GitHub Action scripts
6
star
34

brainglobe-web

brainglobe.info website
HTML
6
star
35

brainglobe-stitch

A napari plugin for stitching large tiled 3D imaging datasets
Python
6
star
36

.github

Common templates for BrainGlobe repositories.
6
star
37

course-dec-2023

Materials for the BrainGlobe & napari course at the Sainsbury Wellcome Centre
JavaScript
6
star
38

slides-roadmap-oct-2023

SCSS
4
star
39

napari-experimental

Python
2
star
40

micrometa

Parsing of whole-brain microscopy metadata
Python
1
star