Skip to content

Commit 625400f

Browse files
committed
brainreg docs
1 parent 71b6c63 commit 625400f

File tree

6 files changed

+244
-0
lines changed

6 files changed

+244
-0
lines changed

brainreg/downloading-files.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
description: Downloading the files that amap needs for registration
3+
---
4+
5+
# Downloading files
6+
7+
## D**ownload atlas \(optional\)**
8+
9+
When amap runs, the appropriate reference atlas will be downloaded \(if not previously done so\). If you would like to download in advance to save time \(or if you will not have an internet connection\) please use `amap_download`.
10+
11+
Currently, the only supported atlas is the Allen reference mouse brain, originally from [here](http://help.brain-map.org/display/mouseconnectivity/API#API-DownloadAtlas). The atlas will download into `./amap/atlas`.
12+
13+
In the future, other atlases will be available, and you will be able to choose which is downloaded.
14+
15+
If you want to modify the am amap download, use:
16+
17+
* `--atlas-install-path` Supply a path to download the atlas elsewhere. This
18+
19+
should also update the default `registration.conf` file so that the correct
20+
21+
atlas is sourced. Alternatively, use this command to tell amap where an
22+
23+
existing atlas is, to save it being downloaded twice. \(Requires 20GB
24+
25+
disk space\)
26+
27+
* `--atlas download path` The path to download the atlas into.
28+
29+
\(Requires 1.2GB disk space\). Defaults to `/tmp`.
30+

brainreg/getting-started/README.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
description: How to register your data to the template
3+
---
4+
5+
# User guide
6+
7+
## Basic usage
8+
9+
```bash
10+
amap /path/to/raw/data /path/to/output/directory -x 2 -y 2 -z 5
11+
```
12+
13+
{% hint style="info" %}
14+
Full command-line arguments are available with `amap -h`
15+
{% endhint %}
16+
17+
{% hint style="warning" %}
18+
If you have any spaces in your file-path, please enclose it in quotation marks, otherwise amap will interpret it as two inputs, separated by a space.
19+
20+
**i.e. `"/path/to/my data"` not `path/to/my data`.**
21+
{% endhint %}
22+
23+
## Arguments
24+
25+
### Mandatory
26+
27+
* Path to the directory of the images. \(Can also be a text file pointing to the files\)
28+
* Output directory for all intermediate and final results
29+
30+
{% hint style="warning" %}
31+
You must also specify the pixel sizes, see [Specifying pixel size](../../user-guide/usage/specifying-pixel-size.md)
32+
{% endhint %}
33+
34+
### Additional options
35+
36+
* `-d` or `--downsample` Paths to N additional channels to downsample to the same coordinate space.
37+
* `--no-save-downsampled` Don't save the downsampled brain before filtering.
38+
* `--registration-config` To supply your own, custom registration configuration file
39+
* `--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
40+
41+
#### Misc options
42+
43+
* `--n-free-cpus` The number of CPU cores on the machine to leave unused by the program to spare resources.
44+
* `--debug` Debug mode. Will increase verbosity of logging and save all intermediate files for diagnosis of software issues.
45+
46+
### Input data orientation
47+
48+
If your data does not match the NifTI standard orientation \(origin is the most ventral, posterior, left voxel\), then please see [Image orientation](image-orientation.md) to reorient the atlas
49+
50+
### Registration options
51+
52+
To change how the actual registration performs, see [Registration parameters](registration-parameters.md)
53+
54+
### Visualisation options
55+
56+
* `--no-boundaries` Do not precompute the outline images \(if you don't want to use `amap_vis`\)
57+
58+
## Visualisation
59+
60+
To visualise your data, please see [Visualisation](../../user-guide/visualisation.md)
61+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
description: Telling amap which way round your images are
3+
---
4+
5+
# Image orientation
6+
7+
**If the supplied data does not match the NifTI standard orientation \(origin is the most ventral, posterior, left voxel\), then the atlas can be reoriented to match:**
8+
9+
* `--flip-x` Flip the sample brain along the first dimension
10+
* `--flip-y` Flip the sample brain along the second dimension
11+
* `--flip-z` Flip the sample brain along the third dimension
12+
* `--orientation` The orientation of the sample brain `coronal`, `saggital`or `horizontal`
13+
14+
\`\`
15+
16+
**If your data isn't in a standard \(i.e. anatomical orientation\), and needs to be rotated, you can use the `--rotation` flag**
17+
What follows the `--rotation` flag, must be a string in the format `xIyJzK`, where x, y & z are the axes to rotate around, and I, J & K are the number of 90 degree rotations for the respective axes. The direction of the rotation is:
18+
19+
* For a rotation around X, the rotation is from the Y axis to Z
20+
* For a rotation around Y, the rotation is from the X axis to Z
21+
* For a rotation around Z, the rotation is from the X axis to Y
22+
23+
For example:
24+
25+
* `x0y0z3` would rotate around the Z axis 90 degrees clockwise \(i.e. 270 degrees anticlockwise\)
26+
* `x0y0z0` would not rotate the image \(default\)
27+
28+
29+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
description: How to refine the registration to the template image
3+
---
4+
5+
# Registration parameters
6+
7+
To change how the image registration performs, you can change the options that are passed to [NiftyReg](http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg):
8+
9+
### **Affine registration**
10+
11+
* `--affine-n-steps` Registration starts with further downsampled versions of the original data to optimize the global fit of the result and prevent "getting stuck" in local minima of the similarity function. This parameter determines how many downsampling steps are being performed, with each step halving the data size along each dimension. **Default: 6**
12+
* `--affine-use-n-steps` Determines how many of the downsampling steps defined by `-affine-n-steps` will have their registration computed. The combination `--affine-n-steps 3 --affine-use-n-steps 2` will e.g. calculate 3 downsampled steps, each of which is half the size of the previous one but only perform the registration on the 2 smallest resampling steps, skipping the full resolution data. Can be used to save time if running the full resolution doesn't result in noticeable improvements. **Default: 5**
13+
14+
### **Freeform registration**
15+
16+
* `--freeform-n-steps` Registration starts with further downsampled versions of the original data to optimize the global fit of the result and prevent "getting stuck" in local minima of the similarity function. This parameter determines how many downsampling steps are being performed, with each step halving the data size along each dimension. **Default: 6**
17+
* `--freeform-use-n-steps` Determines how many of the downsampling steps defined by `--freeform-n-steps` will have their registration computed. The combination `--freeform-n-steps 3 --freeform-use-n-steps 2` will e.g. calculate 3 downsampled steps, each of which is half the size of the previous one but only perform the registration on the 2 smallest resampling steps, skipping the full resolution data. Can be used to save time if running the full resolution doesn't result in noticeable improvements. **Default: 4**
18+
* `--bending-energy-weight` Sets the bending energy, which is the coefficient of the penalty term, preventing the freeform registration from over-fitting. The range is between 0 and 1 \(exclusive\) with higher values leading to more restriction of the registration. **Default: 0.95**
19+
* `--grid-spacing` Sets the control point grid spacing in x, y & z. Positive values are interpreted as real values in mm, negative values are interpreted as the \(positive\) distances in voxels. Smaller grid spacing allows for more local deformations but increases the risk of over-fitting. **Default: -10**
20+
* `--smoothing-sigma-floating` Adds a Gaussian smoothing to the floating image \(the one being registered\), with the sigma defined by the number. Positive values are interpreted as real values in mm, negative values are interpreted as distance in voxels. **Default: 1.0**
21+
* `--smoothing-sigma-reference` Adds a Gaussian smoothing to the reference \(the one being registered to\) image, with the sigma defined by the number. Positive values are interpreted as real values in mm, negative values are interpreted as distance in voxels. **Default: 1.0**
22+
* `--histogram-n-bins-floating` Number of bins used for the generation of the histograms used for the calculation of Normalized Mutual Information on the floating image. **Default: 128**
23+
* `--histogram-n-bins-reference` Number of bins used for the generation of the histograms used for the calculation of Normalized Mutual Information on the reference image. **Default: 128**
24+

brainreg/installation.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
description: Installing amap
3+
---
4+
5+
# Installation
6+
7+
{% hint style="warning" %}
8+
If you already have cellfinder, then amap has been installed for you.
9+
{% endhint %}
10+
11+
## Introduction
12+
13+
amap is included with cellfinder. Unless you have a particular reason not to, I would install cellfinder as this will install all the packages you may need. See [cellfinder installation](../installation/installation.md).
14+
15+
If you know what you're doing just run:
16+
17+
```bash
18+
pip install amap
19+
```
20+
21+
{% hint style="info" %}
22+
If you're not completely sure what you're doing, read on.
23+
{% endhint %}
24+
25+
## Requirements
26+
27+
To run amap you will need a fairly high-powered computer running Windows or Linux \(see [system requirements](../installation/system-requirements.md) for details\). In particular, to use some of the atlases, you may need at least 32GB of RAM.
28+
29+
## Setting up your machine
30+
31+
### Installing Python
32+
33+
amap is written in Python, and so needs a functional Python installation. Your machine may already have Python installed, but **I recommend installing miniconda**.
34+
35+
**See** [**Using conda**](../installation/using-conda.md) **for details.**
36+
37+
{% hint style="danger" %}
38+
amap should run on any type of Python installation, but if you don't use conda, I may not be able to help you.
39+
{% endhint %}
40+
41+
## Installing amap
42+
43+
{% hint style="info" %}
44+
Remember to activate your conda environment before doing anything
45+
{% endhint %}
46+
47+
```bash
48+
pip install amap
49+
```
50+
51+
## Download atlas and trained classification models \(optional\)
52+
53+
When you run amap, it will download the files it needs \(e.g. the atlas\). If you want to save time later, or you know you won't have an internet connection when you run amap you can download these in advance. See [downloading files](downloading-files.md) for details.
54+

brainreg/introduction.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Introduction
2+
3+
{% hint style="info" %}
4+
amap is included with cellfinder, and exists as a standalone tool if you do not need the cell detection part
5+
{% endhint %}
6+
7+
## About
8+
9+
amap is the part of cellfinder that takes care of image registration and atlas-based segmentation. It 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).
10+
11+
The actual registration is carried out by [NiftyReg](http://cmictig.cs.ucl.ac.uk/wiki/index.php/NiftyReg).
12+
13+
## Details
14+
15+
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.
16+
17+
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.
18+
19+
Full details of the process are in the [original paper](https://www.nature.com/articles/ncomms11879).
20+
21+
![Overview of the registration process](https://raw.githubusercontent.com/SainsburyWellcomeCentre/amap-python/master/resources/reg_process.png)
22+
23+
## Installation
24+
25+
```bash
26+
pip install amap
27+
```
28+
29+
{% hint style="info" %}
30+
For detailed instructions see [Installation](installation.md)
31+
{% endhint %}
32+
33+
## Usage
34+
35+
```bash
36+
amap /path/to/raw/data /path/to/output/directory -x 2 -y 2 -z 5
37+
```
38+
39+
{% hint style="info" %}
40+
For more information see [Getting started](getting-started/)
41+
{% endhint %}
42+
43+
###
44+
45+
46+

0 commit comments

Comments
 (0)