## 3 Materials and Methods
### Network Encoder  
Different from the Vision Transformer, which divides input images into H \(\times\) W \(\times\) C-sized patches and converts them into sequences for the self-attention calculation combined with location information, we will first encode the input images in two directions: Swin Transformer and CNN. Figure 2 illustrates the encoder architecture and input-data processing flow of the DualTrans model. For the **Swin Transformer encoder,** compared with the 3D volume data, the Vision Transformer directly divides data into non-overlapping 3D blocks. However, such direct partitioning renders the Transformer unable to model image local context information across spatial and depth dimensions. To solve this problem, we encode the Swin Trans  
Figure 1: Overview of glioma segmentation framework for dual-path encoder networks and multi-view dynamic fusion models. In the encoder architecture, the subsampling path on the left represents the Swin Transformer encoder structure, and the subsampling path on the right represents the CNN encoder structure. Figure 2: Encoder architecture diagram of the DualTrans model. former block, which is composed of the LayerNorm layer, residual connection, multi-head attention module, and nonlinear multilayer perceptron (MLP). Utilizing Shifted Windows multi-head self-attention (W-MSA) versus Shifted Windows multi-head self-attention (SW-MSA) within a Swin Transformer block, the feature map is divided into multiple non-overlapping windows, and multi-head self-attention is only carried out in each window. In this way, the calculation load can be reduced, and the Transformer can better handle visual tasks. However, multi-head self-attention in each independent window will also isolate the information interactions between windows from the space, so SW-MSA is used to strengthen the information transmission between windows. For input \(\rm{X}\in\rm{R}^{H\times W\times D\times C}\) of the given multimodal brain-tumor feature map, we slice it according to the three dimensions of axial, coronal, and sagittal, and then input \(\rm{X}_{input}\in\rm{R}^{(H\times W)\times C}\), \(\rm{X}_{input}\in\rm{R}^{(H\times D)\times C}\), and \(\rm{X}_{input}\in\rm{R}^{(W\times D)\times C}\) into the Swin Transformer block, respectively, as shown in Figure 2 for the specific structure. Then, we merge them to form a 3D feature map. In Figure 1, we uniformly described the 3D feature map. We first create a sequence of tokens of dimension \(\rm{\frac{H}{M}\times\frac{W}{M}\times\frac{D}{M}}\) using the patch partition and, then, map them to the embedding space of dimension C through the linear embedding layer. The Swin Transformer encoder has four stages, with each stage containing a patch-merging layer and \(\rm{2^{N}}\) Swin Transformer blocks. In order to maintain the hierarchical structure of the encoder, in each stage, the patch-merging layer reduces the feature resolution by a factor of two, and then, the grouped patches are merged to obtain 4C feature embedding. In order to maintain the same operation as that in convolution, 4C features are transformed into 2C through the fully connected layer, which is similar to the pooling operation of convolution. Based on this local window self-attention mechanism, the output of layers 1 and 1 in the Swin Transformer encoder layer is calculated as follows:  
\[\rm{\hat{z}l}=W-MSA(LN(\rm{\hat{z}l}-1))+\rm{\hat{z}l} \tag{1}\]  
\[\rm{\hat{z}l}=MLP(LN(\rm{\hat{z}l}))+\rm{\hat{z}l} \tag{2}\]  
\[\rm{\hat{z}l+1}=SW-MSA\Big{(}LN\Big{(}\rm{\hat{z}l}\Big{)}\Big{)}+\rm{\hat{z}l} \tag{3}\]  
\[\rm{\hat{z}l+1}=MLP(LN(\rm{\hat{z}l+1}))+\rm{\hat{z}l+1} \tag{4}\]  
where (1) represents the output of W-MSA, (2) represents the output of SW-MSA, \(\rm{\hat{z}l}\) represents the output features of the MLP module, W-MSA denotes multi-head attention using a regular window, and SW-MSA denotes multi-head attention using a shifted window. Using only the W-MSA module would prevent adjacent windows from interacting, leading to the model losing its ability for global modeling.