## 2 Materials and Methods
### Analysis of the XCT Images Implementing a Machine Learning (ML) Segmentation
\begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Accelerating** & **Current (\(\mu\)A)** & **Number of** & **Exposure Time per** & **Number of** & **Scan Duration (h)** & **Voxel Size** \\
**Voltage (kV)** & **Current (\(\mu\)A)** & **Projection** & **Projection (ms)** & **Averaged** & **(\(\mu\)m)** \\ \hline
120 & 120 & 3142 & 1000 & 2 & 2 & 6.8 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: XCT acquisition parameters used for the implant characterizations. brightness and contrast augmentations (+/ - 10%) in random order and intensity, moderate random Gaussian noise (0-8 in 8-bit grayscale range: 0-255), and random Gaussian blur (random sigma: 0-1). This approach has been proven by [PERSON] et al. [18] to considerably improve the segmentation accuracy of different phases in XCT scans with overlapping gray levels. To further improve the segmentation accuracy, the training of the UNets was undertaken in two stages with a different UNet in each stage. The first UNet was trained to segment the various phases while treating the bone and osteoid phases as a single phase (i.e., 5 phases: metal, pores, metallic grains, bone/osteoid combined, and background). The second UNet was responsible for segmenting only the challenging bone and osteoid phases while considering the rest phases as background (i.e., 3 phases: bone, osteoid, and background). Effectively, the regions in the training/validation image pairs belonging to the metal, pores, and metallic grains phases were nulled (i.e., converted to \"black\" background) before training the second UNet. Samples of the training/validation/testing data used for the two UNets are illustrated in Figure 7.  
The UNet architectures (shown in Figure 8) were designed and trained with Sony's Neural Network libraries [19] on a workstation equipped with a GeForce RTX 3090 graphics card (Nvidia, Santa Clara, CA, USA), an Intel i7 CPU (Intel, Santa Clara, CA, USA), and 32 GB of memory. The ADAM optimizer [20] was selected as the training algorithm (parameters: initial learning rate/alpha = 10\({}^{-4}\), beta1 = 0.9, beta2 = 0.999, updated every iteration), with an input batch size of 8, and random shuffling for the training dataset on each epoch. The learning rate was updated exponentially on every epoch with a learning rate multiplier LRM = 0.95, and we trained for a total of 300 epochs with Categorical Entropy Loss. The decisive (learnable/trainable) parameters within the UNet architectures were adopted from the epoch that minimized the validation error. Based on the reserved testing image, we report a global accuracy Dice score of 85%. Figure 6: Bone and osteoid tissue sharing the exact same XCT gray levels at different locations within the same dataset due to beam hardening. Our forwarding strategy was the following:  
We sliced the NLM-conditioned XCT datasets/stacks in 2D images along all three planes (i.e., xy, xz, and yz planes), and for each plane, we applied four rotations (0\({}^{\circ}\), 90\({}^{\circ}\), 180\({}^{\circ}\), and 270\({}^{\circ}\)). Thus, this resulted in 12 different sets of images (12 different views). Each set was forwarded through the first (trained) UNet, resulting in 12 \(\times\) 5 (5 possible phases for the first UNet) probability map sets. These probability map sets were rotated back to 0\({}^{\circ}\) and assembled back into 3D stacks according to the plane direction that was initially sliced, resulting in 12 \(\times\) 5 probability map 3D stacks. Finally, the probability stacks were summed together according to their respective phase probability group, resulting in 5 probability stacks for the 5 phases. The final classification (i.e., assigned class/label: metal, pores, metallic grains, bone/osteoid combined, or background) was assigned based on the highest phase probability across all 5 probability stacks for each voxel. Based on this segmentation (i.e., from the first UNet), the gray levels of regions (voxels) in the XCT datasets that were segmented/classified as metal, pores, and metallic grains were nulled to appear as background.