# A Machine Learning Approach to Support Treatment Identification for Chari I Malformation
## 2 Methods
### Registration
#### 2.2.1 Balanced Multi-Image Demons  
Demons method is a non-parametric, non-rigid image registration that matches an atlas image \(M(p)\) (for which target regions are known) and a test MRI \(F(p)\) (where \(p\) indicates the pixel location). In practice, a deformable model \(s:p\to s(p)\) is pushed in the direction normal to the MRI intensity gradient so that \(M\circ s(p)\) fits the reference image \(F(p)\) in terms of the minimization of their squared error [34; 35]. A regularization term is also added to stabilize the solution and a hidden variable \(c\) (of correspondences) is introduced to improve computational efficiency [36] (accommodating possible errors in the estimation of the transformation \(s\)), finally obtaining the following functional to be minimized with respect to \(s\) and \(c\)  
\[\frac{\left\|F(p)-M\circ c(p)\right\|^{2}}{\sigma_{i}^{2}}+\frac{\left\|c(p)-s (p)\right\|^{2}}{\sigma_{x}^{2}}+\frac{\left\|\
abla s(p)\right\|^{2}}{\sigma _{T}^{2}} \tag{1}\]  
where \(\sigma_{i}\), \(\sigma_{x}\) and \(\sigma_{T}\) are parameters accounting for image noise, spatial uncertainty in the correspondences and regularization, respectively. This problem is solved iteratively, minimizing the sum of the first two terms with respect to \(c\) with \(s\) fixed and then computing a Gaussian smoothing of \(c\) (with standard deviation \(\sigma_{T}\) =1.5 pixels), which corresponds to minimizing the sum of the last two terms with respect to \(s\) with \(c\) fixed. For each iteration, a local linearization of the first step was solved, thus writing \(c=s\circ(\mathds{1}+u)\) (\(\mathds{1}\) being the identify map and \(u\) a small deformation). Moreover, two innovations have been included in [33] with respect to the standard demons approach described above. * Different images from the atlas and the test MRI were matched by a single optimal deformation, found using the following update for the linearized problem mentioned above \[u=\frac{\sum_{i=1}^{N}(F_{i}-M_{i}\circ s)J_{i}^{T}}{\sum_{i=1}^{N}\left\|I_{ i}\right\|^{2}+\Sigma_{i}^{2}}\] (2) where \(\{M_{i}\}\) and \(\{F_{i}\}\) are \(N\) images obtained from the atlas and test image (as detailed below), \(J_{i}\) is the Jacobian matrix of \(M_{i}\) and \(\Sigma_{i}^{2}=\sigma_{i}^{2}/\sigma_{x}^{2}=|F_{i}-M_{i}\circ s|^{2}\). * The iterations were performed in alternation to the atlas and to the test sets of images (\(\{M_{i}\}\) and \(\{F_{i}\}\), respectively). Five images were included in the sets, which are the same as those considered in [30; 33] with the exception of one of them: the following procedure involving a bilateral filter [37]was used instead of the median filter considered in [30; 33] (both filters allow smoothing, preserving edges; preliminary tests showed that bilateral filter provided better performances than median filter). Specifically, Gaussian kernels were used to smooth the noise on neighbors with similar amplitude (with a geometric spread \(\sigma_{d}=5\)) and to weight the smoothing as a function of image intensity difference (photometric spread \(\sigma_{r}=1\)), so that the smoothing was reduced in case of high variations (as when an edge is present). After a first application of the bilateral filter, a second step of image enhancement was applied following the method proposed in [38]. Specifically, the image was decomposed with Daubechies wavelets of order 30, separating low and high frequency components along rows, columns and diagonals. Then, a bilateral filter was applied only to low frequency components (with \(\sigma_{d}=30\) and \(\sigma_{r}=100\)) and the high frequencies details were summed unchanged (see an example application in Figure 2). Thus, finally, the following 5 images were used in our registration algorithm (example shown in Figure 3): original image and then the same MRI processed by adaptive histogram equalization, smoothing procedure just detailed using bilateral filter, entropy and phase symmetry [39]. Figure 3: The five images used for the multi-image demons registration of an example sagittal MRI.