## 2 Materials and Methods
### Synthetic CT Generation  
The synthetic CT generation process was performed using 30 patients as training, 9 as validation, and 14 as a test set. Patients belonging to the training and validation groups were treated from August 2021 to March 2023, while test cases were collected consecutively, considering the patients treated from April 2023 to June 2023. The network training was performed in a 2D modality, pairing CT axial images with the corresponding CBCT images acquired on the first day of therapy. The first day of therapy was chosen because it was the one where the patient's anatomy was closest to the one acquired during treatment simulation. Image pairing was obtained by applying a rigid roto-translation focused on the spatial correspondence of the bony anatomy using external software (Varian Velocity, version 3, Varian Medical System, Palo Alto, CA, USA). The fused images were spatially resampled to make the CBCT spatial resolution equal to the CT one. For each training case, the quality of the alignment between CBCT and CT images was assessed by a radiation oncologist with more than five years of experience in the field. Registered images were then exported in Digital Imaging and Communications in Medicine (DICOM) format, normalised in terms of pixel intensities, and converted to Portable Network Graphics (PNG) format to make them compliant for network architecture. An image selection process was manually carried out on the 2D axial CBCT-CT paired images, with the aim of including in the training set only images meeting the following criteria:  
* High anatomical correspondence in terms of bony anatomy. * Shape correspondence related to the patient's body is displayed in the two images. * High agreement in terms of location and volume of air pockets. * No presence of image artifacts in CBCT due to the presence of large air bubbles. * No presence of cut images due to a reduced field of view (FOV), a condition typical of apical CBCT slices. The trained neural network was a conditional Generative Adversarial Network (cGAN) based on pix2 pix architecture, as similarly carried out in similar experiences dealing with this topic [16; 17]. The GAN architecture consists of two neural networks, the discriminator and the generator, which are trained in mutual competition. The aim of the discriminator is todifferentiate between the fake images created by the generator and the real ones provided by the user and belonging to the validation set. The generator continuously improves the image quality with the goal of making the discriminator in trouble, reducing the difference between the created images and the real ones. The training can be considered completed when the discriminator is not able to differentiate between real and fake samples. The generator architecture was a 2D U-Net with the introduction of skip-connections among different network layers, while the discriminator was a 30 \(\times\) 30 matrix organised following a PatchGAN architecture, aiming to divide the images into sub-regions of 70 \(\times\) 70 pixels and calculating the probability of each patch being a real image [20]. Each element of the discriminator matrix contains the probability of each single sub-region being fake (probability equal to zero) or real (probability equal to one). The cost function used during the GAN optimisation was labelled as L\({}_{\text{TOT}}\) and equal to the following:  
\[\text{L}_{\text{TOT}}=\text{L}_{\text{GAN}}+\lambda\text{L}_{\text{L1}}\]  
where L\({}_{\text{GAN}}\) is the adversarial loss function; L\({}_{\text{1}}\) is the norm loss; and \(\lambda\) is the lambda weighting factor of the L\({}_{\text{1}}\) loss. A hyperparameter tuning phase was performed to identify the optimal parameters for network training: three learning rate values (0.02, 0.002, and 0.0002) were combined with two lambda weighting factors (100 and 2000) in a grid search strategy.