# Analysis of Functional NeuroImages

Analysis of Functional NeuroImages (AFNI) is an open-source environment for processing and displaying functional MRI data—a technique for mapping human brain activity.
AFNI is an agglomeration of programs that can be used interactively or flexibly assembled for batch processing using shell script. The term AFNI refers both to the entire suite and to a particular interactive program often used for visualization. AFNI is actively developed by the NIMH Scientific and Statistical Computing Core and its capabilities are continually expanding.
AFNI runs under many Unix-like operating systems that provide X11 and Motif libraries, including IRIX, Solaris, Linux, FreeBSD and OS X. Precompiled binaries are available for some platforms. AFNI is available for research use under the GNU General Public License, the included SVM-light component is non-commercial and non-distributable. AFNI now comprises over 300,000 lines of C source code, and a skilled C programmer can add interactive and batch functions to AFNI with relative ease.

## History and development

AFNI was originally developed at the Medical College of Wisconsin beginning in 1994, largely by Robert W. Cox. Cox brought development to the NIH in 2001 and development continues at the NIMH Scientific and Statistical Computing Core. In a 1995 paper describing the rationale for development of the software, Cox wrote of fMRI data: "The volume of data gathered is very large, and it is essential that easy-to-use tools for visualization and analysis of 3D activation maps be available for neuroscience investigators." Since then, AFNI has become one of the more commonly used analysis tools in fMRI research, alongside SPM and FSL.
Although AFNI initially required extensive shell scripting to execute tasks, pre-made batch scripts and improvements to the graphical user interface (GUI) have since made it possible to generate analyses with less user scripting.

## Features
### Visualization

One of AFNI's initial offerings improved the approach to transforming scans of individual brains onto a shared standardized space. Since each person's individual brain is unique in size and shape, comparing across a number of brains requires warping (rotating, scaling, etc.) individual brains into a standard shape. Unfortunately, functional MRI data at the time of AFNI's development was too low resolution for effective transformations. Instead, researchers use the higher resolution anatomical brain scans, often acquired at the beginning of an imaging session.
AFNI allows researchers to overlay a functional image to the anatomical, providing tools for aligning the two into the same space. Processes engaged to warp an individual anatomical scan to standard space are then applied also to the functional scan, improving the transformation process.
Another feature available in AFNI is the SUMA tool, developed by Ziad Saad. This tool allows users to project the 2D data onto a 3D cortical surface map. In this way researchers can view activation patterns while more easily taking into account physical cortical features like gyri.

### Image Pre-processing

"afni_proc.py" is a pre-made script that will run fMRI data from a single subject through a series of pre-processing steps, starting with the raw data. The default settings will perform the following pre-processing steps and finish with a basic regression analysis:
* Slice timing: Each 3D brain image is composed of multiple 2D images, "slices". Although acquired at approximately the same time, up to several seconds could separate the first slice acquired from the last. Through interpolation, the slices are aligned to the same time point. Generally, any introduced noise from interpolation errors is thought to be outweighed by improvements in signal.
* Motion correction: Head movements can create sources of error in the analysis. Each 3D acquisition in a scan is collected on a 3D grid, with each small cube of grid space, "voxel", representing a single image intensity value. Ideally, voxels will always represent the same part of the brain in each acquisition, rather than vary from one 3D image to the next. To correct small motion artifacts, AFNI's motion correction tool employs a linear least squares algorithm that attempts to align each 3D image acquired to the first image acquired in the scan.
* Smoothing: To account for random noise in the image, a smoothing kernel is applied. While smoothing can increase the signal-to-noise ratio of the image, it reduces image resolution.
* Mask: Removes any non-brain areas, such as skull, from the fMRI image.
* Scale: Scale each voxel so that changes in intensity represent percentage of signal change over the course of the scan. The default sets the mean of each voxel equal to 100.