Brain MRI Segmentation with SA-UNet
Keep the slice and mask together
Each MRI slice in the project has a corresponding mask marking the annotated region. Training depends on preserving that alignment. When a data generator rotates or flips a slice, it must apply the same transformation to the mask. A shifted label would teach the network to draw its boundary in the wrong place.
Add spatial attention to U-Net
The encoder compresses the image into feature maps. At the bottleneck, the attention block takes the maximum and mean across channels at every location, then combines them into a learned spatial weight. The decoder upsamples the weighted features and uses skip connections from the encoder to recover finer detail.
Measure the foreground
An MRI slice can contain far more background pixels than annotated foreground. Pixel accuracy alone can hide a poor outline. Dice and intersection over union focus on the overlap between predicted and reference masks. Viewing those masks beside the source slice makes boundary errors easier to locate.