# Neuroimaging Data Processing/Normalization
## Concept of Coregistration

Generally, coregistration refers to the spatial alignment of a series of images, either from intra-subject or inter-subject image volumes and is utilized in several steps of preprocessing. Coregistration most often refers to the alignment of functional and structural images from the same subject to map functional information into anatomical space. Normalization refers to the coregistration of the subjects (mostly anatomical) image to a standard template to overcome the issue of brain shape variability from different subjects. (Besides, Realignment coregisters intra-subject time-series image volumes to against head motion of subjects.)
A typical workflow is to coregister an average EPI image to the subjects structural image through affine transformation (i.e. linear, preserving proportions) and warping the structural image to a template using nonlinear transformation. The resulting transformation information from the second step can be applied to the coregistered EPI from the first step to obtain functional information in standard space.

### Preprocessing of anatomical images

The anatomical images used in these procedures have to be preprocessed as well. This can include removing slow frequency drifts (see Data Quality and Temporal Filtering), Field map correction, Surface extraction and Tissue Segmentation. Depending on the software these steps can be implemented as a part of the coregistration procedure.

## Structural-functional coregistration

If the aim is to study how functional activations of a subject overlay to individual's own anatomy, functional and structural images of the same brain should be aligned together. However, the difference between the functional and structural images from the same brain is not trivial. By contrast to the high-resolution structural images with clear region boundary contours, functional images are normally blurry and suffered from geometric and intensity distortions. The basic idea regarding coregistration herein is similar to the realignment, i.e. defining a cost function with the goal to minimize the differences on image parameters among images. However, because of distortions on functional images, the rigid-body transformation with six parameters may be not enough to correct. Depending on the complexity of distortions, either a nine-parameter transformation with another three additional parameters accounting for scaling differences on x-, y- or z- axes or even more sophisticated algorithms could be used to quantify the cost function. Meanwhile, as a result of the different contrasts between functional and structural images, the mutual information is more suitable to act as cost function than the sum of squared differences.

## Spatial normalization

Human brains are variable in their size and shape. Such structural variability of brains imposes obstacles on intersubject brain function studies in how to determine regional correspondence from brain to brain despite of their divergence. The attempts are mainly focusing on setting up a reference frame in a three-dimensional Cartesian coordinate space as a common space for different brains to align to. The ultimate goal of spatial normalization is the spatial transformation of brains into a common space, making them comparable to each other.

### Templates

A template refers to a representative image with anatomical features in a coordinate space, which then provides a target to individual images aligned to. The very first attempt to model a reference brain atlas was proposed by Jean Talairach in 1967. A set of anatomical landmarks were defined as anterior commissure (AC), posterior commissure (PC), the midline sagital plane and the exterior boundaries of the brain at each edge respectively. On the basis of these anchors in brain, a three-dimensional coordinate space was built up. To be more specific, anterior commissure (AC) is set up as origin and the direction from AC to PC is the Y axis; the longitudinal (interhemispheric or midsagittal) fissure conferencing to Y axis is Z axis; the last X axis is perpendicular to the YZ plane. Talairach coordinates provide a possibility to normalize any brain to this template by a well-defined procedure. However, such Talairach space template is not perfect, and the limitations regarding to the lack of MRI scan base and unrepresentative of population call for further developments. Currently the most commonly used templates are proposed by Montreal Neurological Institute (MNI), known as the MNI templates. Here 241 normal MRI scans were taken as a basis to manually define various landmarks, in order to identify a line very similar to the AC-PC line, and the edges of the brain. Each brain was scaled to match the landmarks to equivalent positions on the Talairach atlas. Then 305 normal MRI scans (all right handed, 239 M, 66 F, age 23.4 +/- 4.1) were matched to the average of the Talairach matched 241 brains using an automated 9 parameter linear algorithm and an average of 305 brains was created, the MNI305. The MNI305 was the first MNI template. The current standard MNI template is the ICBM152, which is the average of 152 normal MRI scans that have been matched to the MNI305 using a 9 parameter affine transform.

### Spatial normalization methods
#### Landmark-based

For a landmark-based normalization, a cuboid in AC-PC space is defined, which requires specification of additional landmarks specifying the borders of the cerebrum. Then the bounding box is sub-divided by several sub-planes into 12 sub-cuboids. In a final Talairach transformation step, each of the 12 sub-cuboids is compensated to match the corresponding standard Talairach template by mathematical stretching, squeezing and warping the sub-cuboids. According to such piecewise linear transformation, the difference between the each brain and the Talairach template obtains minimum.

#### Volume-based

Volume-based normalization aims to maximize the overlapping voxels in the intersection region of the template and individual target image on the basis of normalized correlation coefficient (NCC). Suppose the template image as X, and the target image represented as X', the overlapped region between individual target image X' and template X can be denoted as:
$X_{0}=\{{X_{0}:X_{0}\in X\cap T(X')}\}$..........(1)
$T$: a rigid body transformation
The overlapped voxels between template and target image are:
$F(X_{0})$: intensity set of overlapped voxels in template
$G(X_{0})$: intensity set of overlapped voxels in target image
The normalized correlation coefficient (NCC) between overlapped sets are:
$NCC(F,G)={\frac {1}{N_{0}^{2}}}{\frac {\sum _{x_{0}\in X_{0}}(f(x_{0})-{\overline {f}})(g(x_{0})-{\overline {g}})}{\sigma _{f}\sigma _{g}}}$..........(2)
${\overline {f}}$: mean intensity of voxels in $F(X_{0})$
${\overline {g}}$: mean intensity of voxels in $G(X_{0})$
$\sigma _{f}={\frac {1}{N_{0}}}{\sqrt {\sum _{x_{0}\in X_{0}}(f(x_{0})-{\overline {f}})^{2}}}$..........(3)
$\sigma _{g}={\frac {1}{N_{0}}}{\sqrt {\sum _{x_{0}\in X_{0}}(g(x_{0})-{\overline {g}})^{2}}}$..........(4)
Finally, try to maximize the normalized correlation coefficient in equation (2) to achieve the spatial normalization.

#### Surface-based

Instead of using a full brain volume to perform the normalization, surface-based methods consider the cortical surface alone. The methods normally involve two steps, 1). extraction of the cortical surface from the anatomical image (see Surface extraction); 2). registration to a surface atlas.

## Quality control

It's very necessary to check the performance of normalization with the aim to detect outliers in a series of normalized images. To summarize, the methods fall into three general categories.
* Check the overlap between the template and the normalized image by coregistration strategy
* Inspect the averaging image of all normalized brains. A good normalization result expects a blurry version of a brain. If there is a brain image showing extraordinary, then it implies some problems during the normalization procedure.
* View the series of normalized images as a movie (e.g. in FSLView), jump out images are identified as outliers for a normalization.

### Implementations
#### SPM

SPM provides COREGISTER module to implement a coregistration

#### AFNI

align_epi_anat.py script computes the alignment between two datasets, typically an EPI and an anatomical structural dataset, and applies the resulting transformation to one or the other to bring them into alignment. The transformation is calculated to align the anatomical to the epi data, but the resulting transformation can be used either way that is specified. Basic input is anatomical and epi dataset, which epi volume should be the base of alignment, direction of alignment (0/mean/median/max/volume#) and which direction of alignement is required (anat2epi/epi2anat), e.g.:
In afni_proc.py the align block is not set by default but can be included by do_block align. By default this means anat2epi registration, which can be changed with the following option:
@auto_tlrc is script to transform an antomical dataset to match a template in Talairach space.
Note that this script also performs skullstripping unless instructed otherwise (-no_ss). It can actually also be applied to epi data and not only to anatomical.
In afni_proc.py normalization can be achieved by including do_block tlrc which by default uses TT_N27+tlrc as a base and affine registration (can be changed by -tlrc_NL_warp)
additionally tells afni_proc.py to apply that transformation to the EPI data at the volreg step (this is then implemented as part of 3dAllineate). So the output of the volreg block will be in Talairach space.

## References

1. Comparison of coregistration software http://brainimaging.waisman.wisc.edu/~oakes/teaching/coreg_software_comparison.html
Huettel, S. A., Song, A.W., & McCarthy, G. (2008). Functional Magnetic Resonance Imaging (2nd edition). Sinauer Associates, Inc: Sunderland, Massachusetts, USA.
* ↑ https://en.wikipedia.org/wiki/Jean_Talairach#Limitations
* ↑ http://www.nil.wustl.edu/labs/kevin/man/answers/mnispace.html
* ↑ http://afni.nimh.nih.gov/pub/dist/doc/program_help/align_epi_anat.py.html
* ↑ http://afni.nimh.nih.gov/pub/dist/doc/program_help/3dAllineate.html