# Midsagittal line alignment

This section presents a detailed description of the Midsagittal Line Alignment algorithm which is used for the automatic detection of the midsagittal line in 2D and midsagittal plane in 3D brain images.

The midsagittal line alignment is important because the ideal coordinate system attached to the head, in which the inter-hemispheric fissure is conveniently displayed, differs from the coordinate system of the image because of the usual tilt of the patient's head. It means that the midsagittal fissure is generally not displayed in the center of the image lattice where it should be. This might prevent from further visual inspection or analysis of the image, because the homologous anatomical structures or functional areas in both hemispheres are not displayed in the same axial or coronal slice in the 3D image. See Figure 1.

The algorithm searches for the midsagittal plane in 3D images or for midsagittal line in 2D images.

### Background

Midsagittal plane is the plane with respect to which the image exhibits maximum symmetry. Therefore, the algorithm defines the midsagittal plane as the one that maximizes the similarity between the image and it's symmetric. The Cross-Correlation cost function is used as a similarity measure.

Symmetry is measured by flipping the image horizontally and then registering the flipped image against original. The plane that shows maximal symmetry, and thus approaches the cost function global minimum is a midsagittal plane. The algorithm uses a multi-resolution approach to evaluate the cost function. To find a global minimum of the cross-correlation cost function, the algorithm uses the Powell method.

#### Outline of the method:

1. The minimum resolution of the image is determined.
2. The image is flipped horizontally and the flipped image is saved.
3. Both images are, then, resampled and interpolated to create high resolution isotropic voxels. The algorithm uses Trilinear interpolation to subsample the images.
4. The center of mass (COM) for both images is computed and one translation step is performed to align the COMs.
5. The iterative method is used to register original image against flipped. Refer to "Iterative method used to register original image against flipped".

#### Iterative method used to register original image against flipped

1. The first estimation of the midsagittal plane is made based on low density and low resolution. Both images -the original and flipped - are subsampled and interpolated to a low resolution (8 times).
2. The coarse angle step (45 degrees with 15 degrees step) is used in each dimension when registering the original low resolution image against the flipped image. For each angle configuration, a six degrees of freedom (6-DOF) local optimization is also performed to find the optimal midsagittal aligning. The parameters of the transformation are then systematically varied, where the cost function is evaluated for each setting. The parameters corresponding to the smallest value(s) of the cost function are, then, used as the initial transformation for the next level in the optimization.
3. For each parameter setting corresponding to the top 20% of the cost function minima, the algorithm performs rotations over the fine grid (which is by default 15 degrees with 6 degrees step) and evaluates the cost function.
4. Three best minima with corresponding transformation parameters are stored in a vector of minima and then used as initial parameters for the next optimization level.
5. The images are resampled and interpolated to a higher resolution (4 times). The transformation corresponding to the smallest value(s) of the cost function is determined and used as the initial transformation for the next level in the optimization.
6. Similar processing as the previous two levels except the images are, first, sub-sampled and interpolated to 2 times.
7. Finally, 1mm resolution images are used. The algorithm returns the value of the rotation angle that was applied to register the original to flipped image.
8. The algorithm transforms the original image back by half of the registration rotation. This finds the estimated midsagittal plane.
9. The estimated plane is aligned with the center of the image lattice.
• Calculate the Center of Mass;
• Subsample and interpolate the images;
• Find the global minima and use it in evaluation of the cost function;

Refer to "Optimized Automatic Registration 3D".

#### Image types

2D and 3D grayscale and color brain images

#### Running the Midsagittal Line Alignment algorithm

To run the algorithm,

1. Open an image of interest;
2. Call Algorithms>Brain Tools>Midsaggital line alignment.

The algorithm begins to run and several windows appear with the status as shown in Figure 3. When the algorithm finishes running, the aligned image appears in a new image frame as shown in Figure 2-B.