# A Novel Perturbation Consistency Framework in Semi-Supervised Medical Image Segmentation
## 3 Method
### A Novel Pixel Sampling Method  
Our findings indicate that in all weak-to-strong consistent regularised segmentation frameworks, the predictions of the weakly perturbed branch consistently act as a supervisory signal for the other branches, which do not participate in the training of the model. Therefore, we explored the potential for integrating this branch into the training process. To achieve this, we incorporated the concept of contrastive learning, allowing this branch to initiate gradient backpropagation and participate in the training process. The contrastive learning component of the model is illustrated in Figure 2.  
Indeed, if the positive and negative pairs correspond to the desired segmentation categories, the contrast loss will learn diverse representations for downstream medical segmentation tasks [31]. However, a key limitation in realistic scenarios is the memory bottleneck [32]. That is, the memory limit will be severely exceeded if all pixel points are sampled. The current mainstream solution is plain sampling (NS), but this approach is too random, typically produces high variance, and fails to recognize pixels that are similar in meaning, thus limiting the stability of CL. To address these two key issues of memory bottleneck and high variance, we propose a simple but effective technique, semantic grouped comparison sampling (SGCS). This method aims to sample the most representative pixels from semantically similar pixel groups while alleviating the high variance constraint. In practice, images of different categories are first divided into grids of the same size. Pixels that are semantically close to  
Figure 2: Contrastive learning framework illustrating how positive and negative pairs are generated during training. The use of semantic grouping for pixel sampling ensures memory efficiency and high variance reduction. Solid arrows represent data flow, while dashed arrows represent supervision signals. each other within the same grid are then sampled with high probability, while minimizing the additional memory footprint. Figure 3 shows the schematic diagram of SGCS. To maintain consistency with the previous representation, we define an arbitrary image in a given medical image dataset as \(x\in X\), where \(X\) represents the set of pixels. For any function \(h:X\times P\rightarrow\mathbb{R}\), the aggregation function \(H(x)\) can be expressed as Equation (6). This formula represents the aggregation result \(H(x)\) for a pixel \(x\) by summing over all parameters \(p\) and then averaging the results. In this way, different characteristics or processing results of the pixel can be synthesized based on the various parameters \(p\). \[H(x)=\frac{1}{|P|}\sum_{p\in P}h(x;p). \tag{6}\]  
As the direct computation of \(H(x)\) may become infeasible due to the large scale of \(P\), a group sampling approach is utilized. The SGCS sampling method initially decomposes the pixels into \(M\) disjoint groups, designated as \(P_{m}\). For each group \(P_{m}\), a center \(C_{m}\) is identified such that each sampling point \(p\) is symmetric with respect to \(C_{m}\). Subsequently, a subset of pixels is sampled within each group to form \(D_{m}\). This allows the aggregation function \(H_{SGCS}\) to be expressed as Equation (7):  
\[\hat{P}_{SGCS}(x;D)=\frac{1}{M}\sum_{m=1}^{M}\frac{1}{|D_{m}|}\sum_{p\in D_{m} }h(x;p). \tag{7}\]  
Let \(M\) be the total number of groups, and let \(D_{m}\) be the subset of pixels obtained by symmetric sampling in group \(P_{m}\). The absolute value of \(D_{m}\) is the number of pixels obtained by sampling in group \(m\). \(h(x;p)\) is a function applied to pixel \(p\) on image \(x\).