[](https://pypi.org/project/amap)
[](https://pypi.org/project/amap)
[](https://pypi.org/project/amap)
[](https://github.com/SainsburyWellcomeCentre/amap-python)
[](
https://travis-ci.com/SainsburyWellcomeCentre/amap-python)
[](https://coveralls.io/github/SainsburyWellcomeCentre/amap-python?branch=master)
[](https://dependabot.com)
[](https://github.com/python/black)
[](https://gitter.im/cellfinder/amap?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[](https://zenodo.org/badge/latestdoi/225904061)
# amap-python
Automated mouse atlas propagation
## About
amap is python software for registration of brain templates to sample whole-brain
microscopy datasets, and subsequent atlas-based segmentation by
[Adam Tyson](https://github.com/adamltyson),
[Charly Rousseau](https://github.com/crousseau) &
[Christian Niedworok](https://github.com/cniedwor)
from the [Margrie Lab at the Sainsbury Wellcome Centre](https://www.sainsburywellcome.org/web/groups/margrie-lab).
This is a Python port of
[aMAP](https://github.com/SainsburyWellcomeCentre/aMAP/wiki) (originally
written in Java), which has been
[validated against human segmentation](https://www.nature.com/articles/ncomms11879).
The actual registration is carried out by [NiftyReg](http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg).
Documentation can be found [here](https://docs.cellfinder.info/amap/introduction).
## Details
The aim of amap 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 paper](https://www.nature.com/articles/ncomms11879).

**Overview of the registration process**
## Installation
```bash
pip install amap
```
## Usage
amap was designed with generality in mind, but is currently used for a single application. If anyone has different uses
(e.g. requires a different atlas, or the data is in a different format), please get in touch
by [email](mailto:adam.tyson@ucl.ac.uk?subject=amap) or by
[raising an issue](https://github.com/SainsburyWellcomeCentre/amap-python/issues/new/choose).
### Basic usage
```bash
amap /path/to/raw/data /path/to/output/directory -x 2 -y 2 -z 5
```
### 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
**Either**
* `-x` or `--x-pixel-um` Pixel spacing of the data in the first dimension,
specified in um.
* `-y` or `--y-pixel-um` Pixel spacing of the data in the second dimension,
specified in um.
* `-z` or `--z-pixel-um` Pixel spacing of the data in the third dimension,
specified in um.
**Or**
* `--metadata` Metadata file containing pixel sizes (any format supported
by [micrometa](https://github.com/adamltyson/micrometa) can be used).
If both pixel sizes and metadata are provided, the command line arguments
will take priority.
#### Additional options
* `-d` or `--downsample` Paths to N additional channels to downsample to the
same coordinate space.
Full command-line arguments are available with `amap -h`, but please
[get in touch](mailto:adam.tyson@ucl.ac.uk?subject=amap) if you have any questions.
## Citing amap.
If you find amap useful, and use it in your research, please cite the [original Nature Communications paper](https://www.nature.com/articles/ncomms11879) along with this repository:
> Adam L. Tyson, Charly V. Rousseau, Christian J. Niedworok and Troy W. Margrie (2019). amap: automatic atlas propagation. [doi:10.5281/zenodo.3582162](https://zenodo.org/record/3582162)
## Visualisation
amap can use the
[cellfinder visualisation function](https://docs.cellfinder.info/user-guide/visualisation)
(built using [napari](https://github.com/napari/napari)).
#### Usage
```bash
cellfinder_view
```
