## 3 Materials and Methods
### The Method
#### 3.2.1 The Network and Hyperparameters Choice
To make a fair comparison between all four FCNN, the same hyperparameters were applied during the training and evaluation process. The choice was made using a literature search and several experiments on the training subset. Our method relied on such hyperparameters as augmentations, network parameters (loss function, optimizer, and the learning rate), and a border merging used for automatic liver cropping. During the training process, 3D image augmentations were applied to increase the data amount and variation. The input batch from the training dataset with a probability of 20% was augmented using random contrast adjustment, introducing random Gaussian smoothing and sharpening, and arbitrary affine deformations such as rotation and zooming for not more than 10% [20]. The introduction of such augmentation showed improvement in the segmentation metrics on the training dataset and aimed to overcome the overfitting problem. All hyperparameters, including loss function, optimizer, and learning rate, were defined in the configuration file, and remain constant for both networks to compare them on the validation subset. Figure 4: Experiment setup for defining the nested FCNN network for MRI liver and tumor segmentation. Between available loss functions and optimizers from the MONAI library, a DiceFocal Loss (Equation (3)) has shown one of the best performances on medical image segmentation tasks [47]. \[L_{DiceFocal}=L_{Dice}+L_{Focal} \tag{3}\]  
where \(L_{Dice}\) is a Dice loss (Equation (4)) and \(L_{Focal}\) is Focal loss (Equation (5)). Dice loss was proposed by the authors of V-net paper [18], which was designed to deal with the imbalance of medical image data for binary problems:  
\[L_{Dice}=1-\frac{2\sum_{c=1}^{C}\sum_{i=1}^{N}g_{i}^{c}s_{i}^{c}}{\sum_{c=1}^{ C}\sum_{i=1}^{N}\left(g_{i}^{c}\right)^{2}+\sum_{c=1}^{C}\sum_{i=1}^{N}\left(s_{i} ^{c}\right)^{2}} \tag{4}\]  
where \(g_{i}^{c}\) is the ground truth binary indicator of the class label \(c\) of the voxel \(i\), and \(s_{i}^{c}\) is the probability of corresponding predicted segmentation. Focal loss is the modification of standard cross-entropy loss, with a focus on misclassified examples rather than correctly classified background pixels. \[L_{Focal}=-\frac{1}{N}\sum_{c}^{C}\ \sum_{i=1}^{N}\left(1-s_{i}^{c}\right)^{ \gamma}g_{i}^{c}logs_{i}^{c} \tag{5}\]  
To train the algorithm, the mean value of liver class and tumor class loss function was used by the Adam optimizer (Equation (6))  
\[\alpha=\alpha_{0}*(1-\frac{e}{N_{e}})^{0.9} \tag{6}\]  
where \(\alpha_{0}\) is the initial learning rate, \(N_{e}\) is a number of epochs, and \(e\) is an epoch counter [48]. After a set of experiments on a training subset, a learning rate of \(1\times 10^{-5}\) and an added merging for a cropping bounding box around the liver were chosen. During the training, it was 10 voxels for each direction, and for the inference, \(-20\) voxels was found to be the optimal value. Due to the dataset inhomogeneity in terms of size, intensity and resolution, preprocessing was applied to normalize the input into the network and fit into the memory constraints of the GPU. Before the volumes were introduced to the network, all volumes were moved into the isotropic space using bilinear resampling. To normalize input intensities, we applied zero means and one standard deviation intensity normalization, also known as a Gaussian kernel normalization, which is a common practice for dealing with data source inhomogeneity for MRI datasets used in DL [31]. The GPU memory constrains the input image sizes for DL networks, such that the input size was 320 by 320 by 160 for 3D U-net and SegResNet, 128 by 128 by 128 for V-net, and 128 by 128 by 92 for HighResNet. The post-processing in the final pipeline reduced the noise and achieved three-class segmentation: background, liver parenchyma, and tumors. For the liver parenchyma mask, the biggest connected component [49] was used to illuminate unconnected islands that might be predicted by the method.