# Generation of Synthetic Rat Brain MRI Scans with a 3D Enhanced Alpha Generative Adversarial Network
## 2 Materials and Methods
### Overall Process Workflow
(2019) [26]:  
\[L_{GD}=-E_{z_{e}}[D(G(z_{e}))]-E_{z_{e}}[D(G(z_{r}))] \tag{1}\]  
\[L_{G1}=L_{GD}-E_{z_{e}}[C(z_{e})]+\lambda_{2}||x_{real}-G(z_{e})||_{L1} \tag{2}\]  
\[L_{C}=E_{z_{e}}[C(z_{e})]-E_{z_{e}}[C(z_{r})]+\lambda_{1}L_{GP-C} \tag{3}\]  
\[L_{D}=-L_{GD}-2E_{x_{real}}[D(x_{real})]+\lambda_{1}L_{GP-D} \tag{4}\]  
where \(L_{GD}\) denotes the feedback from the Discriminator, \(D\) denotes the Discriminator, \(G\) denotes the Generator, \(C\) denotes the Code Discriminator, \(z_{e}\) denotes the latent vector of the encoder, \(z_{r}\) denotes the input random vector, \(x_{real}\) denotes a real scan, \(L_{GP-D}\) denotes the gradient penalty of Discriminator, \(L_{GP-C}\) denotes the gradient penalty of Code Discriminator, \(L1\) denotes the L1 loss function, and \(E\) denotes the total distribution. Vertical flipping was the only conventional data augmentation used to train this first model. The Adam optimiser [27] was used with a learning rate of 0.0002, betas of 0.9, 0.999 and eps of \(10^{-8}\). This architecture was called \(\alpha\)-WGAN_ADNI. The new loss functions and normalisation layer used in this work are described below. The first proposed architecture, based on [PERSON] et al. (2020) [28] is shown in Figure 5 in which Spectral Normalisation (SN) [29] was added after each convolution to stabilise training, especially discriminator training, batch normalisation layers were replaced by instance normalisation layers to avoid some artefacts, and the activation function LeakyReLU was used instead of ReLU to speed up the training and improve the results [30]. This architecture was called \(\alpha\)-WGANSigmaRat1. The loss functions used to train this model were the same as those used for the \(\alpha\)-WGAN_ADNI model--except for the generator--for which a new loss function was introduced (5) with \(\lambda_{1}=\lambda_{2}=10\):  
\[L_{G2}=L_{GD}-E_{z_{e}}[C(z_{e})]+\lambda_{1}||x_{real}-G(z_{e})||_{L1}+ \lambda_{2}||x_{real}-G(z_{e})||_{MSE} \tag{5}\]  
For this training process, all previously mentioned conventional data augmentations--zoom, rotation, Gaussian noise, flip, translation and scaling intensity--as well as the Adam optimiser and a random vector size of 500 were used. The last proposed model architecture is shown in Figure 6. The main changes compared to the \(\alpha\)-WGANSigmaRat1 architecture were the removal of SN after each convolution only in the generator and encoder, since in the original work by [PERSON] et al. (2018) [29] the SN was created to stabilise discriminator training. The instance normalisation layers were also removed in the discriminator and in the code discriminator to avoid artefacts and reduce computational costs. In the new loss function (6), the L1 loss function was replaced by the Gradient Difference Loss (GDL) [31], which is described in the latest works on super-resolution [31; 32; 33]:  
\[L_{G3}=L_{GD}-E_{z_{e}}[C(z_{e})]+\lambda_{3}||x_{real}-G(z_{e})||_{GDL}+ \lambda_{2}||x_{real}-G(z_{e})||_{MSE} \tag{6}\]  
The loss functions used to train this model were (3) for the code discriminator, (4) for the discriminator and (6) for the generator/encoder with \(\lambda_{1}=\lambda_{2}=100\) and \(\lambda_{3}=0.01\). The chosen values for \(\lambda_{1}\), \(\lambda_{2}\) and \(\lambda_{3}\) proved to be more stable than other values after some experimental tests. All conventional data augmentations were performed, the size of the input random vector was 500, and a new optimiser was used, AdamW [34] with a learning rate of 0.0002, betasof 0.9, 0.999, eps of 10\({}^{-8}\) and a weight decay of 0.01. The AdamW is known to have a more stable weight decay than the Adam. This architecture was named \(\alpha\)-WGANSigmaRat2. The difference between the synthesis of rat and human MRI brains is the resolution of the input scans. Here, scans with a resolution of 64 \(\times\) 64 \(\times\) 40 were used, but nowadays--with the arrival of better GPUs--it is possible to process scans with higher resolutions, e.g., 256 \(\times\) 256 \(\times\) 256.