Paper commentary
SAM: Self-supervised Learning of Pixel-wise Anatomical Embeddings in Radiological Images
SAM learns pixel-level anatomical embeddings from unlabeled radiological images
- Problem Supervised landmark and lesion matchers only find structures that were labeled in advance. Each new point of interest needs new labels and new training, which is slow and costly.
- Method SAM assigns each pixel an anatomical embedding by contrasting pixels across two random crops of the same volume. Two levels, global and local, are learned without anatomical labels.
- Results On a chest CT dataset with 19 landmarks, SAM scored 4.3 pixels of mean radial error, compared to 4.6 for DEEDS.
Why matching anatomy across scans is hard
Finding the same anatomical structure in different scans underlies both landmark detection and follow-up lesion tracking. The usual route is supervised detection or segmentation, and that route needs many labels for every structure and sub-structure of interest. Annotation is slow, costly and demands expert knowledge, so labeled sets tend to be narrow in coverage and detail.
A supervised model therefore finds only the points it was trained on, and a new point of interest means new labels and new training.
Radiological images have a stable underlying anatomy, so the same body part looks consistent from one scan to another. The difficulty is that an embedding must be global enough to separate every body part and local enough to separate neighbouring structures with similar texture. It also has to tolerate changes in size, shape, intensity and texture caused by patient differences, deformation, contrast and disease.
A pixel-level contrastive idea with two embedding levels
The key idea is to contrast pixels against each other: two pixels that show the same location in two augmented views should embed close together, and other pixels should embed apart. Because the training signal comes from the volume itself, the method needs no anatomical labels. Positive pairs are pixels that fall in the overlap of two random crops, so both crops refer to the same voxel in the volume.
One embedding would have to carry both global context and fine detail, so SAM builds two levels: a global embedding and a local embedding for each pixel. A 3D ResNet-18 backbone with a feature pyramid network supplies the global embedding from the coarsest level and the local embedding from the finest level. The coarsest feature is cut from the level above it, which makes the two embeddings less dependent on each other.
The backbone starts from ImageNet weights inflated to 3D, and the X-ray variant uses a 2D ResNet-34 instead.
How the training loss is built
For each training step the method crops two patches at random locations and sizes from one unlabeled volume and resizes both to a shared shape. The overlap between the two patches is drawn at random with a ratio between 0.2 and 1. The default setting samples 100 positive pairs for CT, and each positive pair gets its own set of negatives.
The loss for each positive pair is an InfoNCE term, where the anchor embedding is pulled toward its matched embedding and pushed away from the negatives. \[ L = -\sum_{i=1}^{n_{pos}} \log \frac{\exp(f_i \cdot f'_i/\tau)}{\exp(f_i \cdot f'_i/\tau) + \sum_{j=1}^{n_{neg}} \exp(f_i \cdot h_{ij}/\tau)} \] Here \(f_i\) is the anchor, \(f'_i\) its matched embedding, \(h_{ij}\) the negatives, and \(\tau\) is 0.5.
A second term with \(f_i\) and \(f'_i\) swapped makes the loss symmetric, and the same form is applied to both the global and the local embeddings.
Global negatives are chosen by online hard negative selection: the pixels whose global embeddings are most similar to the anchor, excluding the anchor and its match. The method then adds random pixels from other images in the batch, because such pixels are very unlikely to sit at the anchor's anatomical position. The default number of these random global negatives is 1000 for CT.
Local negatives are ranked on the sum of the global and local similarity maps, which is the same combination used at inference. The local map has high resolution, so its hardest candidates are mostly neighbouring pixels, and the method samples the final negatives from a larger candidate pool.

Fig. 2 : The learning process of SAM. We first do random data augmentation to an unlabeled image, then send the two transformed patches to a network to generate a global and a local embedding vector for each pixel (Sec. III-A). One embedding channel of an axial image slice is visualized in the figure with the global embedding zoomed in. Next, we use a global and a local InfoNCE loss [23] to encourage matched pixels (positive pairs) to have similar embeddings, while push unmatched ones (negative pixels) apart (Sec. III-B). The negative pixels are random pixels in the two patches guided by hard and diverse sample selection strategies (Sec. III-C).
Original paper · CC BY 4.0 · Ke Yan, Jinzheng Cai, Dakai Jin, Shun Miao, Dazhou Guo, Adam P. Harrison, Youbao Tang, Jing Xiao, Jingjing Lu, Le Lu · SAM: Self-supervised Learning of Pixel-wise Anatomical Embeddings in Radiological Images · Original paper figure · Extracted the figure area from page 3 of the original PDF.Figure 2 shows this whole loop, from the two augmented patches through the global and local embeddings to the two InfoNCE losses.
Matching a template point at run time
A user labels one point on a template image, and SAM extracts the anchor embeddings at that point from the global and local tensors. Each query image gets its own global and local tensors, and the similarity between the anchors and every query pixel is a cosine similarity computed as a convolution. Both similarity maps are upsampled to the image size, summed, and the peak of the sum is returned as the matched point.
The network is not fine-tuned at this stage, so the run-time step is only embedding extraction and a similarity search.
Landmark results on ChestCT and X-rays
On ChestCT with contrast-enhanced templates, SAM scored 4.3 pixels of mean radial error, compared to 4.6 for DEEDS and 6.0 for SyN. SAM also took 0.23 seconds per volume, including embedding extraction and matching on GPU, while DEEDS took 50.16 seconds. The supervised SCN reference reached 2.6 pixels, so SAM stays above a fully supervised model on this task.
The authors explain the registration gap by saying deformable methods need a robust initial alignment and can struggle with large body or pose differences. With a non-contrast template, SAM's error on contrast-enhanced images stayed close to its same-modality value, which the authors read as robustness to contrast change.
On hand X-rays, one-shot SAM scored 13.1 pixels, compared to 14.1 for HRNet trained on 50 labeled images. On pelvic X-rays, SAM scored 32.2 pixels, compared to 35.1 for HRNet-50 and 35.3 for DAG with five labels. DAG with 50 labeled hand images scored 6.2, which is well below SAM, so SAM does not beat every supervised setting. The paired t-tests were significant against HRNet-5, HRNet-50 and DAG-5 on hand X-rays, but on pelvic X-rays only against HRNet-5.
Lesion matching, registration and initialization
The detection-plus-matching baselines are limited by their detector, whose recall on the query CTs was 87.3%. DLT's errors come mainly from failing to locate small lesions, so SAM's direct matching avoids that intermediate step.
SAM supplies correspondences for registration through the SAME pipeline, which runs SAM-affine, SAM-coarse and SAM-VoxelMorph. These registration results come from the authors' earlier SAME work, so this paper reports them only briefly.
Initializing a 3D U-Net from SAM with 10 labeled liver CTs gives a liver tumor Dice of 0.55, compared to 0.42 for random initialization. With 105 labeled samples the gap almost disappears, 0.64 against 0.62 for liver tumor.
Which design choices carry the gains
Removing the coarse-to-fine structure raises hand X-ray error from 13.1 to 26.1 pixels, so the two-level design matters in this comparison. Using only the local embedding at test time pushes hand X-ray error to 473.4, because the local map can light up distant areas with similar texture.
Dropping the hard negatives raises the hand and pelvic errors from 13.1 and 32.2 to 19.1 and 39.7. Dropping the diverse negatives keeps the average errors close but raises maximum errors, for example from 16.4 to 58.7 on ChestCT CE.
Random crops with scaling are enough for CT, but adding deformation and rotation lowers hand X-ray error from 22.6 to 13.1. Adding flips raises hand error to 64.9 and pelvic error to 326.4, because the anatomical left and right sides matter. The parameter study shows SAM is robust to embedding size and to npos and nneg once nneg is at least 100.
The parameter study on ChestCT and lesion matching is summarized in the figure below.

Fig. 8 : Parameter study on the ChestCT and lesion matching datasets. Lower MRE is better.
Original paper · CC BY 4.0Limitations
The authors attribute the large hand X-ray spread mainly to a few mismatched outliers, together with the large size of the images. Failure cases include severe pathological deformation that differs strongly from the template, shown in the pelvic and hand subplots (j) and (n). On the z-axis, the tube-shaped descending aorta has few discriminative textures, and SAM placed it off along that axis.
The lesion comparison uses the authors' own annotated pairs and a detector-based baseline. Initialization was tested on liver and liver tumor only, and the authors note SAM was not designed for that purpose.
Paper info
- Authors
- Ke Yan, Jinzheng Cai, Dakai Jin, Shun Miao, Dazhou Guo, Adam P. Harrison, Youbao Tang, Jing Xiao, Jingjing Lu, Le Lu
- Venue
- arXiv · Preprint
- First published
- 2020-12-4
- Added
- 2026-11-6
- Updated
- 2023-10-21
- Version
- v3
- arXiv
- 2012.02383
- Category
- cs.CV
- Original paper terms
- CC BY 4.0
- What we show
- Paper info, commentary and permitted figures from the original paper
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Abstract
Radiological images such as computed tomography (CT) and X-rays render anatomy with intrinsic structures. Being able to reliably locate the same anatomical structure across varying images is a fundamental task in medical image analysis. In principle it is possible to use landmark detection or semantic segmentation for this task, but to work well these require large numbers of labeled data for each anatomical structure and sub-structure of interest. A more universal approach would learn the intrinsic structure from unlabeled images. We introduce such an approach, called Self-supervised Anatomical eMbedding (SAM). SAM generates semantic embeddings for each image pixel that describes its anatomical location or body part. To produce such embeddings, we propose a pixel-level contrastive learning framework. A coarse-to-fine strategy ensures both global and local anatomical information are encoded. Negative sample selection strategies are designed to enhance the embedding's discriminability. Using SAM, one can label any point of interest on a template image and then locate the same body part in other images by simple nearest neighbor searching. We demonstrate the effectiveness of SAM in multiple tasks with 2D and 3D image modalities. On a chest CT dataset with 19 landmarks, SAM outperforms widely-used registration algorithms while only taking 0.23 seconds for inference. On two X-ray datasets, SAM, with only one labeled template image, surpasses supervised methods trained on 50 labeled images. We also apply SAM on whole-body follow-up lesion matching in CT and obtain an accuracy of 91%. SAM can also be applied for improving image registration and initializing CNN weights.
Quote from the paper
Ke Yan, Jinzheng Cai, Dakai Jin, Shun Miao, Dazhou Guo, Adam P. Harrison, Youbao Tang, Jing Xiao, Jingjing Lu, Le Lu (2020). SAM: Self-supervised Learning of Pixel-wise Anatomical Embeddings in Radiological Images. arXiv:2012.02383v3. https://arxiv.org/abs/2012.02383v3
BibTeX
@misc{yan2020self,
title = {{SAM: Self-supervised Learning of Pixel-wise Anatomical Embeddings in Radiological Images}},
author = {Ke Yan and Jinzheng Cai and Dakai Jin and Shun Miao and Dazhou Guo and Adam P. Harrison and Youbao Tang and Jing Xiao and Jingjing Lu and Le Lu},
year = {2020},
eprint = {2012.02383},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2012.02383v3}
}