# Generation of Synthetic Rat Brain MRI Scans with a 3D Enhanced Alpha Generative Adversarial Network
## 2 Materials and Methods
### Overall Process Workflow  
This work was developed in Python (version 3.7.7, Python Software Foundation), drawing on two important DL frameworks, PyTorch [24] (version 1.7.1+cu101, Facebook AI Research team) and MONAI [25] (version 0.5.0, Project MONAI). The specifications of the workstations are given in Table 1. The code is available at [[https://github.com/ShadowTwin41/alpha-WGAN-SigmaRat](https://github.com/ShadowTwin41/alpha-WGAN-SigmaRat)]([https://github.com/ShadowTwin41/alpha-WGAN-SigmaRat](https://github.com/ShadowTwin41/alpha-WGAN-SigmaRat)) (accessed on 4 January 2022). The entire training and evaluation process flow is described in Figure 3. Figure 3A, the Image Resources block, represents the acquisition of the MRI scans and the creation of the dataset. Figure 3B, the Development Environment block, describes the development environment with all frameworks, libraries, and other dependencies for training the models. Figure 3C, the Preprocessing block, corresponds to the preprocessing of the dataset--always working with the whole 3D scan--such as resizing to 64 \(\times\) 64 \(\times\) 64 with constant padding of zero values, intensity normalisation between \(-\)1 and 1, and some conventional data augmentation. Figure 3D, the Deep Learning application block, is the final step where the training and evaluation of the models are done and where the best model is selected. Some conventional data augmentations such as zooming, rotating, adding Gaussian noise, flipping, shifting, and scaling the intensity were done, as this can fill some gaps in the dataset. The size of the input random vector is an important consideration, as it should be large enough to represent the dataset but not too large to avoid overfitting. Therefore, the sizes 500/1000 were tested. The creation of the final files is the last step, which is shown in Figure 4. To generate a new scan, a random vector, e.g., a noise vector from a Gaussian distribution, and the final model from the training process are needed. Afterwards, the generated scan is subjected to an automatic post-processing to reverse the preprocessing steps--flipping, cropping to 64 \(\times\) 64 \(\times\) 40, and normalising--resulting in an image with the same properties as the original file. Cropping is necessary because the input data were padded as mentioned above. Flipping was done because the input dataset was inverted. Finally, it is possible to generate a 3D NIfTI file from the dataset using the generated scan and metadata--headers and affines--from an original file--from the \(\text{D}_{\text{r}}\text{2}\text{1}\text{0}\). Eleven models were created, each trained for 200,000 iterations, i.e., 952 epochs, with a batch size of four, but only the two best and the baseline model for comparison are presented in this article. The first model was the baseline based on the [PERSON] et al. (2019) [26] model, where the generator, discriminator, encoder, and code discriminator networks are identical, and the latent space is of size 1000. The use of this architecture is more computationally intensive than some traditional GANs architectures because it involves four networks instead of just two. However, this choice was justified because \begin{table}
\begin{tabular}{l l} \hline \hline
**Operative System** & **Ubuntu 18.04.3 LTS (64 bits)** \\ \hline CPU & Intel Xeon E5-1650 12 Core \\ \hline \multirow{3}{*}{GPU} & GPU – NVIDIA P6000 \\  & Cuda Parallel-Processing Cores 3840 \\  & 24 GB GDDR5X \\  & FY32 Performance 12 TFLOPS \\ \hline Primary Memory & 64 Gb \\ \hline \multirow{2}{*}{Secondary Memory} & 2 Disks of 2 TB \\  & 1 Disk of 512 Gb \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Workstation Specifications. the \(\alpha\)-GAN architecture avoids mode collapse and fuzziness by adding a VAE and a code discriminator to the GAN network [26]. The loss functions used in this training process were (1) and (2) for generator/encoder, (3) for code discriminator, and (4) for discriminator with \(\lambda_{1}=\lambda_{2}=10\)--based on the experiments of [PERSON] et al.