# Automated Pneumothorax Segmentation with a Spatial Prior Contrast Adapter
## 3 Materials and Methods
### Network Architecture  
CBAM [24] serves as a lightweight and easily pluggable module that can be seamlessly integrated into different CNN architectures. With negligible additional computational costs, CBAM effectively enhances the representational capacity of CNNs, making it particularly suitable for complex tasks such as medical image analysis, where precise localization and discrimination of features are critical. CBAM operates by sequentially applying two complementary attention mechanisms, that is, channel attention and spatial attention. Subsequently, the spatial attention module is employed to capture the inter-spatial dependencies of features. By applying average pooling operations along the channel axis, followed by a convolutional layer, the spatial attention mechanism produces an attention map that highlights the most salient regions within the feature map. As a result, CBAM significantly improves the network's discriminative capability and generalization performance in classification, detection, and segmentation tasks. Its flexibility and ease of integration make it a valuable component in the design of high-performance deep learning models. The structure and functional pipeline of CBAM are illustrated in Figure 2.  
Specifically, the channel attention module analyzes the importance of different channels, amplifying the weights of key channels while reducing the influence of less relevant ones, allowing the network to effectively capture global information. Meanwhile, the spatial attention module redistributes attention across spatial dimensions, enabling the model to focus more on salient regions where the target is located, thereby increasing the discriminative power of feature representations. The integration of CBAM blocks with a standard U-Net architecture significantly enhances feature extraction by leveraging attention mechanisms [25]. Initially, the input feature map undergoes a series of convolutional layers, each followed by normalization and LeakyReLU activations. These stacked convolutional blocks progressively capture hierarchical features, enabling the network to extract both low-level and high-level representations. Upon completion of the final convolutional block, the CBAM is applied to refine the feature maps. The attention-enhanced feature map, which has been refined through both channel and spatial attention, is then passed through the network, allowing the model to prioritize critical features. This refinement improves the model's ability to focus on significant details, thereby enhancing the overall segmentation performance within the nnUNet framework. The overview architecture of the combination of CBAM with plain nnUNet is shown in Figure 3 based on the original U-Net's 5-stage structure. Figure 1: A sample from the CANDID-PTX dataset. **Left** is the original chest X-ray and **right** is the corresponding pneumothorax manual segmentation. Our model combines these two mechanisms in a sequential and complementary manner. Our model seamlessly integrates channel and spatial attention mechanisms in a sequential and complementary manner, leveraging the CBAM to adaptively enhance feature representations, resulting in a total of 212 individual layers for the given configuration. The encoder contributes 90 layers across 9 stages, with each stage comprising 10 layers (3 layers from a convolutional block, 6 layers from a CBAM block, and 1 final activation layer). The decoder adds 104 layers over 8 stages, each consisting of 13 layers (1 transposed convolution, 10 layers from a convolutional block, and 1 segmentation output convolution layer). Through the sequential application of channel and spatial attention, CBAM enables the network to prioritize task-relevant features while minimizing noise, rendering this 212-layer architecture highly effective for high-resolution image segmentation tasks.