# 3D Liver and Tumor Segmentation with CNNs Based on Region and Distance Metrics
## 2 Materials and Methods
### Related Work  
* V-Net  
The 3D V-Net architecture, which was the U-Net 3D variant, was put forward to segment the 3D images. The model was proposed to train end-to-end Magnetic Resonance Imaging (MRI) volumes that depicted prostate, which also immediately learned to estimate whole volume segmentation [29]. Another important contribution of this work was the introduction of a new loss layer for segmentation tasks on the basis of the Dice coefficient, which was a commonly used regional overlap measure to  
Figure 1: The liver and tumor segmentation framework. analyze medical images [33]. The schematic representation of the V-Net architecture is provided in Figure 2.  
The input of the 3D V-Net was 3D data. The first half of the network was constituted by the compression path, while the latter half decompressed the signals till they reached the size of their initial input data. The first half of the network was segmented to diverse phases according to distinct resolutions. Each phase contained one to three convolutional layers. The Parametric Rectified Linear  
Figure 2: The schematic representation of the V-Net architecture. Unit (PReLU) was applied in the entire network. The latter half network extracted features and expanded spatial support for feature maps with low resolution. The deconvolution manipulation was performed to enhance the input size following every stage. In addition, this network also connected features collected via the early stages from the compression to the decompression side of the CNN. Thus, the fine-grained details were collected, which improved the eventual contour estimation quality. The regional loss functions, including cross-entropy and Dice loss, were jointly utilized in the V-net, which was denoted as:  
\[Loss_{Reg}=Loss_{seg}+Loss_{Dice} \tag{4}\]  
where \(Loss_{seg}\) was the cross-entropy loss function and the \(Loss_{Dice}\) was the Dice loss function. \(\bullet\) Cross-entropy loss  
The voxel-wise cross-entropy loss was one of the most commonly used loss functions for image segmentation task. This loss will examine each voxel individually and compare the class prediction vector with the ground truth vector. The cross-entropy loss function is denoted as:  
\[Loss_{seg}(p,g)=-\frac{1}{n}\sum_{i=1}^{N}[g_{i}\log p_{i}+(1-g_{i})\log(1-p_{ i})] \tag{5}\]  
where \(p_{i}\) represents the probability that voxel \(i\) belongs to the foreground, and \(g_{i}\) represents the ground truth. \(\bullet\) Dice loss  
A novel objective function on the basis of the Dice coefficient (range, 0-1) was utilized in V-Net [29]. The liver and tumor segmentation is a binary segmentation task, in which the soft-max layer outputs the probability that each voxel belongs to the foreground or background. For the Dice coefficient \(D\) of two binary volumes, it is calculated by the following formula:  
\[D=\frac{2\sum_{i}^{N}p_{i}g_{i}}{\sum_{i}^{N}p_{i}^{2}+\sum_{i}^{N}g_{i}^{2}} \tag{6}\]  
In the formula, the sums run across N voxels in the estimated binary segmentation volume \(p_{i}\in P\), together with the ground truth binary volume \(g_{i}\in G\). The above formula to calculate Dice is also differentiated in terms of the prediction \(j\)-\(th\) voxel, yielding the gradient:  
\[\frac{\partial D}{\partial p_{j}}=2\left[\frac{g_{j}\Big{(}\sum_{i}^{N}p_{i}^{ 2}+\sum_{i}^{N}g_{i}^{2}\Big{)}-2p_{j}\Big{(}\sum_{i}^{N}p_{i}g_{i}\Big{)}}{ \Big{(}\sum_{i}^{N}p_{i}^{2}+\sum_{i}^{N}g_{i}^{2}\Big{)}^{2}}\right] \tag{7}\]  
Using this loss layer, it was no longer necessary to assign the loss weights to different classes of samples during the training phase. Furthermore, the Dice loss function calculation formula can be used for both 2d and 3d data. \(\bullet\) Boundary loss  
In [30], [PERSON] et al. proposed a boundary loss, in which the distance of contour (or shapes) space, rather than regions, was measured. Boundary loss contributes to alleviating issues associated with regional loss in the context of substantially imbalanced segmentation tasks.