# A Novel Perturbation Consistency Framework in Semi-Supervised Medical Image Segmentation
## 3 Method
### A Novel Methodology for Strong Perturbations  
The proposed hybrid copy-paste perturbation (HCP) method is integrated within the auxiliary-main model framework. The main process operates as follows: An unlabeled image \(X_{\text{un}}\) and a labeled image \(X_{\text{I}}\) from the training set are randomly selected. A portion of the foreground content from \(X_{\text{I}}\) is cropped and pasted onto the corresponding position of \(X_{\text{un}}\) before being fed into the main network \(F_{\text{s}}\) for training. This generates a new hybrid image, \(X_{\text{in}}\), which is then fed into the main network to obtain the predicted segmentation results. The segmentation results are also supervised by the HCP of the predicted unlabeled images from the auxiliary's network and the label map of the labeled images.  
To perform HCP between pairs of images, we first generate an all-zero center mask, \(\alpha\in\{0,1\}\), indicating whether the pixel is from the foreground (0) or background (1) image. The size of the zero-valued region is \(\beta H\times\beta W\times\beta L\), where \(\beta\in(0,1)\). Subsequently, the labeled and unlabeled images are mixed and pasted as Equation (1). This equation represents the mixing of the labeled image \(X_{\text{I}}\) and the unlabeled image \(X_{\text{u}}\) using the mask \(\alpha\).  
\[X_{\text{in}}=X_{\text{I}}\odot\alpha+X_{\text{u}}\odot(1-\alpha). \tag{1}\]  
\[P_{L}=F_{\text{f}}(X_{\text{un}};\theta_{\text{f}}). \tag{2}\]  
The initial pseudo-labels \(P_{L}\) are generated through predictions by the auxiliary model as Equation (2). This equation computes the initial pseudo-labels \(P_{L}\) by passing the unlabeled image \(X_{\text{un}}\) through the auxiliary model \(F_{\text{t}}\) with parameters \(\theta_{\text{f}}\). The formula for the supervised signal is presented in Equation (3). This equation is similar to Equation (1), but while Equation (1) focuses on the processing of images, Equation (3) deals with the processing of the mask.  
\[Y_{\text{in}}=Y_{\text{I}}\odot\alpha+\tilde{Y}_{\text{u}}\odot(1-\alpha). \tag{3}\]  
For the loss function, each input image to the main network consists of elements from both labeled and unlabeled images. In fact, the true mask of a labeled image is typically more accurate than the pseudo-label of an unlabeled image. We use \(\gamma\) to regulate the contribution of unlabeled image pixels to the loss function. The loss function for \(X_{\text{in}}\) is computed as follows:  
\[L_{\text{in}}=L_{\text{seg}}(Q_{\text{in}},Y_{\text{in}})\odot\alpha+\gamma L _{\text{seg}}(Q_{\text{in}},Y_{\text{in}})\odot(1-\alpha). \tag{4}\]  
where \(L_{\text{seg}}\) represents a linear combination of the Dice loss and the cross-entropy loss. The equation for calculating \(Q_{\text{in}}\) is as shown in Equation (5):  
\[Q_{\text{in}}=F_{\text{s}}(X_{\text{in}};\Theta_{\text{s}}). \tag{5}\]  
The pseudo-code for the above algorithm is presented in Algorithm 2.  
```
0:labeled_images,unlabeled_images,num_copies
0:augmented_images
1:Initializeaugmented_images \(=[]\)
2:for eachimage\({}_{l}\) in labeled_imagesdo
3:for\(i=1\) tonum_copiesdo
4: Select a random \(image_{u}\) fromunlabeled_images
5: Copy random patch from \(image_{l}\) to\(image_{u}\) creating \(image_{u}^{\prime}\)
6: Copy corresponding patch from \(image_{u}\) to\(image_{l}\) creating\(image_{l}^{\prime}\)
7: Add\(image_{u}^{\prime}\) and\(image_{l}^{\prime}\) to\(augmented\_images\)
8:endfor
9:endfor
10:returnaugmented_images
```  
**Algorithm 2** Hybrid Copy-paste Perturbation Algorithm