Skip to content

Commit

Permalink
Merge brainreg-napari into brainreg (#145)
Browse files Browse the repository at this point in the history
* initial commit

* adds gui

* removes deprecated folder

* Update README.md

* Update README.md

* adds brainreg to requirements

* renames gui label from register to brainreg

* renames register to brainreg-register

* adds brainglobe repo to setup.py

* Delete requirements.txt

* makes output destination selectable in GUI

* Update entry point

* removes sort_input_file option

* Update setup.py

* updates project urls in setup.cfg

* Update support link

* fixes output path to directory

* re adds sort_input_file as hardcoded variable

* adds atlas options as dropdown

* adds showing the results of registration

* removed a global declaration

* minor refactoring

* deleted commented code

* fixes logging output

* only loads relevant output data

* outputs scaled overlay of boundaries and atlas

* imports and groups segment plugin with register

* lowers requirements from python >=3.7 to >=3.6 and removes project url from setup.py

* removes superfluous pixel args from logging

* Update readme, setup.py & general reformatting (#16)

* update gitignore

* Update setup.py

* update readme

* format with black

* remove docs

* remove unused import

* delete tests for now

* format imports

* Release (#18)

* Update setup.py

* add bump2version config

* Bump version: 0.0.1 → 0.0.2-rc0

* remove reqs from manifest

* disable tests on GH actions for now

* fixes reset_defaults by ignoring atlas dropdown

* adds additional channels functionality

* Update OS compatibility & update use of napari API

* Bump (#23)

* Bump version: 0.0.2-rc1 → 0.0.2-rc2

* Bump version: 0.0.2-rc2 → 0.0.2-rc3

* Bump version: 0.0.2-rc3 → 0.0.3-rc0

* Add tooltips (#25)

* change default parameter names

* Add tooltips

* Bump version: 0.0.3-rc0 → 0.0.4-rc0

* Update README.md

* Update broken image URL

* Add categories and preview page workflow for the napari hub (#27)

* adds EDAM Bioimaging labels

* adds Action for napari hub preview service

* Update citation

* Update README.md

* Convert to npe2

* Add pyqt library setup

* Fix manifest

* Add basic smoke test

* Add link to contributing guide

* Add pre-commit

* Fix manifest

* Add sample data

* Add example script

* Fix pre-commit and manifest

* Use g-node.org for sample data

* Clean up example

Make noqa more specific

* Set plugin values from metadata

* Add a test for sample data

* Add pooch to requirements

Move pooch req comment

* Test loading sample data through napari

* Set sensible contrast limits

* pre-commit fixes

* Add Python 3.10 support, drop 3.7 support

* Add an integration test

Type block

* Fix getting additional layers

* Factor out add_image_layers function

* Remove arguments from run()

* Refactor blocking/non-blocking behaviour

* Store metadata in napari layers

* Use re-usable action for running tests

* Give better name to add_image_layers

* Add error if trying to load non-existent registration

* Return layers from add_registered_image_layers

* Bump version: 0.0.4-rc0 → 0.0.5-rc0

* Input orientation check (#44)

* Add many features:

- debug mode
- interactive way of checking input orientation
- brain geometry
- save annotations with original orientation

* add comments and docstring.

* Crop the reference atlas when using interactive orientation check with half brains.

* Fix a bug where run throw an error.

* Fix typo in docstrings

* format

* Add info to use if data not loaded before checking orientation

* Update docstrings

Co-authored-by: Jules Scholler <[email protected]>

* Update readme

* format readme

* Add codecov badge

* Added citation file (#45)

* Added citation file

* Changes according to PR comments

* Updated Citation file 

Updated citation file to have the preferred citation coming from the article/book when available

Co-authored-by: Simão sá <[email protected]>

* Update packaging (#46)

* update pre-commit config

* update args for new brainreg version

* lint

* update manifest

* Bump version: 0.0.5-rc0 → 0.0.5-rc1

* update testing

* update packaging

* update requirements

* update manifest

* move entry point to pyproject.toml

* update hub preview version

* update release for use with setuptools_scm

* migrate from BG to neuroinformatics actions

* add setuptools_scm to dev requirements

* reduce number of tested version

* update python versions tested

* update release

* [Napari HUB cli] Metadata enhancement suggestions (#47)

* Copy "Display Name" from secondary to primary file

Display Name was found in a secondary file and copied in the primary one:
* (found here)  "pyproject.toml"
* (copied here) "brainreg_napari/napari.yaml"

* Copy "Summary Sentence" from secondary to primary file

Summary Sentence was found in a secondary file and copied in the primary one:
* (found here)  "pyproject.toml"
* (copied here) ".napari/config.yml"

* Use standard pre-commit config (#51)

* Add standard pre-commit config

* Automated pre-commit fixes

* Testing clean (#50)

* Use composite test action

Fix use-xvfb argument

* Clean tox.ini

* Don't fail fast

* Remove old setup steps

* Clean up dev dependencies

Add pyqt5 back as a dev dep

* Try passing display env

Put back passenv in tox

* Use selected atlas to check orientation

* Add orientation check tests

* [pre-commit.ci] pre-commit autoupdate (#57)

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.240 → v0.0.272](astral-sh/ruff-pre-commit@v0.0.240...v0.0.272)
- [github.com/psf/black: 23.1.0 → 23.3.0](psf/black@23.1.0...23.3.0)
- [github.com/pre-commit/mirrors-mypy: v0.991 → v1.3.0](pre-commit/mirrors-mypy@v0.991...v1.3.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Update links (#56)

* Update README.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Update dependency (imlib -> brainglobe-utils) (#58)

* [pre-commit.ci] pre-commit autoupdate (#59)

updates:
- [github.com/charliermarsh/ruff-pre-commit: v0.0.272 → v0.0.275](astral-sh/ruff-pre-commit@v0.0.272...v0.0.275)
- [github.com/pre-commit/mirrors-mypy: v1.3.0 → v1.4.1](pre-commit/mirrors-mypy@v1.3.0...v1.4.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#60)

updates:
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.276](astral-sh/ruff-pre-commit@v0.0.275...v0.0.276)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#61)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.276 → v0.0.277](astral-sh/ruff-pre-commit@v0.0.276...v0.0.277)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#62)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.277 → v0.0.278](astral-sh/ruff-pre-commit@v0.0.277...v0.0.278)
- [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#63)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.278...v0.0.280)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#65)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.280 → v0.0.281](astral-sh/ruff-pre-commit@v0.0.280...v0.0.281)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#66)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](astral-sh/ruff-pre-commit@v0.0.281...v0.0.282)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#67)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.282 → v0.0.284](astral-sh/ruff-pre-commit@v0.0.282...v0.0.284)
- [github.com/pre-commit/mirrors-mypy: v1.4.1 → v1.5.0](pre-commit/mirrors-mypy@v1.4.1...v1.5.0)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#68)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.284 → v0.0.285](astral-sh/ruff-pre-commit@v0.0.284...v0.0.285)
- [github.com/pre-commit/mirrors-mypy: v1.5.0 → v1.5.1](pre-commit/mirrors-mypy@v1.5.0...v1.5.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#70)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.285 → v0.0.286](astral-sh/ruff-pre-commit@v0.0.285...v0.0.286)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Update .pre-commit-config.yaml (#71)

* [pre-commit.ci] pre-commit autoupdate (#72)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.286 → v0.0.287](astral-sh/ruff-pre-commit@v0.0.286...v0.0.287)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* [pre-commit.ci] pre-commit autoupdate (#74)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.287 → v0.0.292](astral-sh/ruff-pre-commit@v0.0.287...v0.0.292)
- [github.com/psf/black: 23.7.0 → 23.9.1](psf/black@23.7.0...23.9.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* Test on Python 3.11 (#49)

* Use composite test action

Fix use-xvfb argument

* Clean tox.ini

* Don't fail fast

* Remove old setup steps

* Clean up dev dependencies

Add pyqt5 back as a dev dep

* Try passing display env

Put back passenv in tox

* Test on Python 3.11

* Update Python versions

---------

Co-authored-by: Adam Tyson <[email protected]>

* Delete .github/workflows/plugin_preview.yml (#75)

* Write safe concat function

* Use safe concat of dataframes

* Fix logic of safe concat method

* pre-commit pass

* Add unit test to aplease codecov overlords

* Restructure as brainreg/core, adjust imports accordingly

* Make package installable again

* Fix test import

* Rework package structure to be compatible with brainreg-core

* Update example code with new structure

* Rename napari plugin to drop the -napari suffix

* Exclude the to-be-reconciled READMEs from the manifest

---------

Co-authored-by: stephen <[email protected]>
Co-authored-by: Adam Tyson <[email protected]>
Co-authored-by: Adam Tyson <[email protected]>
Co-authored-by: Justin Kiggins <[email protected]>
Co-authored-by: David Stansby <[email protected]>
Co-authored-by: Patrick Roddy <[email protected]>
Co-authored-by: Alessandro Felder <[email protected]>
Co-authored-by: Jules Scholler <[email protected]>
Co-authored-by: Simão Bolota <[email protected]>
Co-authored-by: Simão sá <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
12 people authored Oct 27, 2023
1 parent ab18739 commit 5add675
Show file tree
Hide file tree
Showing 70 changed files with 1,401 additions and 227 deletions.
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
ignore = E203, E231, W503, E722
max-line-length = 79
exclude = __init__.py,build,.eggs
10 changes: 7 additions & 3 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,22 @@ jobs:
python-version: "3.10"
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.8"

steps:
- name: Cache atlases
uses: actions/cache@v3
with:
path: ~/.brainglobe
key: atlases
- uses: neuroinformatics-unit/actions/test@v2

- name: Setup QT libraries
uses: tlambert03/setup-qt-libs@v1

- name: Run tests
uses: neuroinformatics-unit/actions/test@v2
with:
python-version: ${{ matrix.python-version }}
use-xvfb: true

test-with-conda:
needs: [linting, manifest]
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*.conf.custom

# Byte-compiled / optimized / DLL files
__pycache__/
**/__pycache__/
*.py[cod]
*$py.class

Expand Down Expand Up @@ -122,3 +122,4 @@ tests/data/test_output


*.DS_Store
pip-wheel-metadata/
7 changes: 7 additions & 0 deletions .napari/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
labels:
ontology: EDAM-BIOIMAGING:alpha06
terms:
- Image registration
- Affine registration
- Multi-channel
summary: Multi-atlas whole-brain microscopy registration
177 changes: 177 additions & 0 deletions BR-CORE-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
[![Python Version](https://img.shields.io/pypi/pyversions/brainreg.svg)](https://pypi.org/project/brainreg)
[![PyPI](https://img.shields.io/pypi/v/brainreg.svg)](https://pypi.org/project/brainreg)
[![Wheel](https://img.shields.io/pypi/wheel/brainreg.svg)](https://pypi.org/project/brainreg)
[![Development Status](https://img.shields.io/pypi/status/brainreg.svg)](https://github.com/brainglobe/brainreg)
[![Tests](https://img.shields.io/github/workflow/status/brainglobe/brainreg/tests)](
https://github.com/brainglobe/brainreg/actions)
[![codecov](https://codecov.io/gh/brainglobe/brainreg/branch/master/graph/badge.svg?token=FbPgwBIGnd)](https://codecov.io/gh/brainglobe/brainreg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)

# brainreg

brainreg is an update to
[amap](https://github.com/SainsburyWellcomeCentre/amap_python) (itself a port
of the [original Java software](https://www.nature.com/articles/ncomms11879))
to include multiple registration backends, and to support the many atlases
provided by [bg-atlasapi](https://github.com/brainglobe/bg-atlasapi).

Documentation can be found [here](https://brainglobe.info/documentation/brainreg/index.html).

For segmentation of bulk structures in 3D space
(e.g. injection sites, Neuropixels probes), please see
[brainreg-segment](https://github.com/brainglobe/brainreg-segment).

**N.B. There is also a [napari plugin](https://github.com/brainglobe/brainreg-napari) if you'd rather use brainreg with a graphical user interface. Currently this interface is slightly limited compared to the command line tool**

This software is at a very early stage, and was written with our data in mind.
Over time we hope to support other data types/formats. If you have any issues, please get in touch [on the forum](https://forum.image.sc/tag/brainglobe) or by
[raising an issue](https://github.com/brainglobe/brainreg/issues).

## Details

The aim of brainreg is to register the template brain
(e.g. from the [Allen Reference Atlas](https://mouse.brain-map.org/static/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](https://www.nature.com/articles/ncomms11879).
![reg_process](https://user-images.githubusercontent.com/13147259/143553945-a046e918-7614-4211-814c-fc840bb0159d.png)

**Overview of the registration process**

## Installation

```bash
pip install brainreg[napari]
```

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

```bash
pip install brainreg
```

**N.B. If you are using macOS, please run `conda install -c conda-forge niftyreg` to ensure all dependencies are installed.**

## Usage

### Basic usage

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

## Arguments

### Mandatory

* Path to the directory of the images. (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, see [Specifying voxel size](https://brainglobe.info/documentation/general/image-definition.html#voxel-sizes)**

### 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.

### Atlas

By default, brainreg will use the 25um version of the [Allen Mouse Brain Atlas](https://mouse.brain-map.org/). 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.:

```bash
--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._

### Registration backend

To change the registration algorithm used, use the `--backend` flag. The default is `niftyreg` as that is currently the only option.

### Input data orientation

If your data does not match the [brainglobe](https://github.com/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 [bg-space](https://github.com/brainglobe/bg-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:

```bash
--orientation asl
```

### Registration options

To change how the actual registration performs, see [Registration parameters](https://brainglobe.info/documentation/brainreg/user-guide/parameters.html)

Full command-line arguments are available with `brainreg -h`, but please
[get in touch](mailto:[email protected]?subject=brainreg) if you have any questions.

### Visualisation

brainreg comes with a plugin ([brainglobe-napari-io](https://github.com/brainglobe/brainglobe-napari-io)) for [napari](https://github.com/napari/napari) to view your data

##### 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.

_N.B. If you use a high resolution atlas (such as `allen_mouse_10um`), then the files can take a little while to load._

![sample_space](https://raw.githubusercontent.com/brainglobe/napari-brainreg/master/resources/sample_space.gif)

##### Atlas space

`napari-brainreg` also comes with an additional plugin, for visualising your data
in atlas space.

This is typically only used in other software, but you can enable it yourself:

* Open napari
* Navigate to `Plugins` -> `Plugin Call Order`
* In the `Plugin Sorter` window, select `napari_get_reader` from the `select hook...` dropdown box
* Drag `brainreg_standard` (the atlas space viewer plugin) above `brainreg` (the normal plugin) to ensure that the atlas space plugin is used preferentially.

### Contributing

Contributions to brainreg are more than welcome. Please see the [developers guide](https://brainglobe.info/developers/index.html).

### 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&eacute;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](https://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>
**Don't forget to cite the developers of the atlas that you used (e.g. the Allen Brain Atlas)!**
75 changes: 75 additions & 0 deletions BR-NAPARI-README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[![Python Version](https://img.shields.io/pypi/pyversions/brainreg-napari.svg)](https://pypi.org/project/brainreg-napari)
[![PyPI](https://img.shields.io/pypi/v/brainreg-napari.svg)](https://pypi.org/project/brainreg-napari)
[![Wheel](https://img.shields.io/pypi/wheel/brainreg-napari.svg)](https://pypi.org/project/brainreg-napari)
[![Development Status](https://img.shields.io/pypi/status/brainreg-napari.svg)](https://github.com/brainglobe/brainreg-napari)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
[![codecov](https://codecov.io/gh/brainglobe/brainreg-napari/branch/master/graph/badge.svg?token=HEBXJPLD2S)](https://codecov.io/gh/brainglobe/brainreg-napari)

# brainreg-napari

Napari plugin to run [brainreg](https://github.com/brainglobe/brainreg),
developed by [Stephen Lenzi](https://github.com/stephenlenzi).

## Installation

```bash
pip install brainreg-napari
```

## Usage

Documentation and tutorials for the plugin can be found [here](https://brainglobe.info/documentation/brainreg/index.html).

For segmentation of bulk structures in 3D space
(e.g. injection sites, Neuropixels probes), please see
[brainreg-segment](https://github.com/brainglobe/brainreg-segment).

This software is at a very early stage, and was written with our data in mind.
Over time we hope to support other data types/formats. If you have any issues, please get in touch [on the forum](https://forum.image.sc/tag/brainglobe) or by
[raising an issue](https://github.com/brainglobe/brainreg/issues).

## Details

brainreg is an update to
[amap](https://github.com/SainsburyWellcomeCentre/amap-python) (itself a port
of the [original Java software](https://www.nature.com/articles/ncomms11879))
to include multiple registration backends, and to support the many atlases
provided by [bg-atlasapi](https://github.com/brainglobe/bg-atlasapi).

The aim of brainreg is to register the template brain
(e.g. from the [Allen Reference Atlas](https://mouse.brain-map.org/static/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](https://www.nature.com/articles/ncomms11879).
![reg_process](https://user-images.githubusercontent.com/13147259/143553945-a046e918-7614-4211-814c-fc840bb0159d.png)
**Overview of the registration process**

## Contributing

Contributions to brainreg-napari are more than welcome. Please see the [developers guide](https://brainglobe.info/developers/index.html).

### 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&eacute;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](https://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>
**Don't forget to cite the developers of the atlas that you used (e.g. the Allen Brain Atlas)!**
Loading

0 comments on commit 5add675

Please sign in to comment.