# An Efficient Automatic Midsagittal Plane Extraction in Brain MRI
## 2 Materials and Methods  
### Geometry of MSP  
Generally, MRI of the brain consists of 3-D volumetric data in three orientations: axial, coronal, and sagittal orientations. In the proposed algorithm, only the axial orientation was considered as an input to the algorithm. The head coordinate system is defined as the ideal head coordinate system (\(X_{o}\), \(Y_{o}\), \(Z_{o}\)) and the imaging coordinate system (\(X\), \(Y\), \(Z\)), as described by [PERSON] et al. (2018). The origin of the ideal coordinate is the center of the brain with positive \(X_{o}\) pointing to the right. Anterior and superior directions represent positive \(Y_{o}\) and \(Z_{o}\) axes from the center of the brain, respectively. Mathematically, \(X_{o}=0\) is defined to be the MSP with respect to the ideal coordinate system. Practically, the imaging coordinate system (blue) varies from the ideal coordinate system (black) due to translations and three rotations (pitch \(\omega\), roll \(\varphi\), and yaw \(\theta\) with respect to \(X_{o}\), \(Y_{o}\), and \(Z_{o}\) axes, respectively) of the patient head as portrayed in Figure 1. Therefore, the main objective of MSP extraction is to determine the transformation between the two planes, i.e., \(X_{o}=0\) and \(X=0\). MSP in an image coordinate system can be defined as:  
\[aX+bY+cZ+d=0 \tag{1}\]  
where parameters \((a,b,c)\) are not all zero and can be scaled by any non-zero scalar, vector \((a,b,c)\) is the normal vector of the MSP, and \(d/\sqrt{a^{2}+b^{2}+c^{2}}\) is the perpendicular distance of the plane from the origin. The intersection of MSP with each axial slice (slice cut perpendicularly to the \(Z_{o}\)) is always a vertical line in the ideal coordinate system. The \(r\)th axial slice is represented by a plane equation as:  
\[Z=Z_{r}\]  
Figure 1: An ideal coordinate system \(X_{o}Y_{o}Z_{o}\) (black) versus an imaging coordinate system \(XYZ\) (blue). The intersection of Equations (1) and (2) is the vertical line (ideally a line of bilateral symmetry of brain) on the \(r\)th slice and can be written as:  
\[aX+bY+(cZ_{r}+d)=0 \tag{3}\]  
This represents a normal equation of the 2-D line in the \(XY\) plane. By comparing Equation (3) with the standard normal equation of the line, the orientation \(\theta_{r}\) of the line (vertical line) can be computed as:  
\[\theta_{r}=\tan^{-1}\left(\frac{b}{a}\right) \tag{4}\]  
Equation (4) exhibits that the orientation of all the 2-D symmetric lines should be the same, irrespective of the position of slice i.e., \(Z_{r}\). This angle corresponds to the yaw angle of the patient's head. This angle is estimated using the PCA and cross-correlation technique described in the succeeding paragraph. Similarly, the perpendicular distance (translation offset) \(p_{r}\) of the line (Equation (3)) from the point (0, 0, \(Z_{r}\)) can be calculated as:  
\[p_{r}=cZ_{r}+d \tag{5}\]  
Equation (5) demonstrates that the offset \(p_{r}\) of the symmetric line on the \(r\)th slice (\(Z=Z_{r}\)) is linearly related to slice position as a function of plane parameters \(c\) and \(d\). This represents an overdetermined set of linear equations in \(p_{r}\) and \(Z_{r}\). It can be solved by fitting a plane to a set of parallel lines having the orientation \(\theta_{r}\). We use an orthogonal regression [42] using PCA to fit the plane to these lines in 3-D Euclidian space. To completely determine the MSP parameter (\(a\), \(b\), \(c\), \(d\)), we need to assess the transformation between the two planes \(X_{o}=0\) (MSP in the ideal coordinate system) and \(X=0\) (MSP in the image coordinate system). The derivation of this transformation can be found in [18].