## 3 Methodology
### Attention Gate and SDM Branch  
Attention gates are added between the encoder and its corresponding decoder layers to improve features in important regions and suppress responses in the irrelevant back  
Figure 4: The flowchart illustrating the process of computing multiple self-attention using the shifted window strategy in the Swin-Transformer architecture. Figure 5: Flowchart of the feature extraction block. Figure 3: The Swin-Transformer block in the network architecture is composed of two consecutive Swin-Transformer layers. ground. As shown in Figure 6, the attention gate receives two input features: \(x^{l}\) and \(g\). These inputs undergo two \(1\times 1\) convolution operations followed by batch normalization. Afterward, the resulting features are summed element-wise, and this sum is passed through a \(ReLU\) activation layer. To generate the attention map, a final \(1\times 1\) convolution layer is applied, followed by a \(Sigmoid\) operation. The output of the attention gate is the element-wise multiplication of the input features and the attention map. The specific formula is as follows:  
\[att=\sigma_{2}(\psi(\sigma_{1}(W_{x}\cdot x^{l}_{i}+W_{g}\cdot g_{i})))\]  
\[\hat{x}^{l}_{i}=att\otimes x^{l}_{i}\]  
Among them, \(W_{x}\), \(W_{g}\), and \(\psi\) represent three different \(1\times 1\times 1\) convolution operators, \(\sigma_{1}\) and \(\sigma_{2}\) represent \(ReLU\) and Sigmoid activation functions, \(x^{l}_{i}\) is the feature output from the layer 1 of the encoder, and \(g_{i}\) is The features from the \(upsampling\) process of the \(l+1\) layer of the decoder, \(att\) is the attention vector generated by the attention-gating mechanism. \(\otimes\) represents the matrix element-wise multiplication operation, and \(\hat{x}^{l}_{i}\) is the output result of the attention-gating mechanism. In our multitask network, we define task 1 as a segmentation task and task 2 as an SDM regression task. In existing work, pixel-level classification for segmentation has been extensively studied, while the SDM regression is a traditional task that captures active geometric contours and distance information [57], recently when combined with CNN rejuvenate [58], which is specifically defined as follows:  
\[\mathcal{T}(x)= \begin{cases}-\inf_{y\in\partial S}\|x-y\|_{2},&x\in S_{in}\\ 0,&x\in\partial S\\ +\inf_{y\in\partial S}\|x-y\|_{2},&x\in S_{out}\end{cases} \]  
where \(x\) and \(y\) are two different pixels in the same segmentation mask, \(\partial S\) is a zero-level set, which also represents the outline of the target object. \(S_{in}\) and \(S_{out}\) denote the inner and outer regions of the segmentation target. We then define \(\mathcal{T}(x)\) as the transformation from a segmentation map to an SDM. In this experiment, a segmentation mask is first converted into three different binarized channels by \(Onehot\) operation, representing the background, liver, and tumors. Then, the corresponding SDMs are calculated for the liver and tumor channels using the above formula. The proposed network is trained using a mixed loss function, which includes cross-entropy loss (CE loss), DSC loss, and SDM loss. CE loss is defined as follows:  
\[L_{CE}(p,\hat{p})=-\frac{1}{N}\sum_{i=1}^{N}[p_{i}\log\hat{p}_{i}+(1-p_{i}) \log(1-\hat{p}_{i})]\]  
Among them, N represents the number of speed-ups for each sample, \(p\),\(\hat{p}\) represent ground truth and prediction, respectively, and \(p_{i}\),\(\hat{p}_{i}\) represent the probability values at position  
Figure 6: Schematic diagram of the attention gate mechanism. \(i\) from ground truth and prediction, respectively. The specific definition of DSC loss is as follows:  
\[L_{DSC}=1-\frac{2|G\cap P|}{|G|+|P|}\]  
In this case, \(G\) and \(P\) represent the voxel sets for the ground truth and prediction, respectively, and \(|.|\) denotes the voxel count calculation. The definition of the Sdm loss is as follows:  
\[L_{Sdm}=\left\|S-\mathcal{T}(M)\right\|^{2}\]  
Among them, S and M, respectively, represent the predicted SDM and the corresponding mask. \(\mathcal{T}(.