File size: 10,009 Bytes
cb845a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748aa39
 
 
 
 
 
 
 
 
 
 
 
 
 
cb845a3
748aa39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
dataset_info:
  features:
  - name: image
    dtype: image
  - name: tumor
    dtype: int32
  - name: patient_id
    dtype: int32
  - name: node_id
    dtype: int32
  - name: centre_id
    dtype: int32
  - name: patch_x
    dtype: int32
  - name: patch_y
    dtype: int32
  splits:
  - name: train
    num_bytes: 574917756.358
    num_examples: 26753
  download_size: 649099009
  dataset_size: 574917756.358
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*
license: cc0-1.0
task_categories:
- image-classification
language:
- en
tags:
- pathology
- tumor
- medical
- classification
- lymph
pretty_name: Mini CAncer MEtastases in LYmph nOdes challeNge
size_categories:
- 10K<n<100K
---
# MiniCAMELYON — Patch-Level Breast Cancer Metastasis Detection

This dataset is derived from the CAMELYON17 challenge (CAncer MEtastases in LYmph nOdes challeNge), organized by the Diagnostic Image Analysis Group (DIAG) and the Department of Pathology of Radboud University Medical Center in Nijmegen, the Netherlands, as the second grand challenge in computational pathology. The original CAMELYON17 cohort comprises 1,000 H&E-stained whole-slide images of sentinel lymph node sections from breast cancer patients, collected at five medical centers in the Netherlands — Radboud UMC (RUMC), Utrecht UMC (UMCU), Rijnstate Hospital (RST), Canisius-Wilhelmina Hospital (CWZ), and LabPON — and split evenly into 500 training and 500 test slides. Slides were deliberately sourced across centers and three different scanner models so that staining and scanning variability is represented in the data.

Here we provide a Hugging Face ready, patch-level subset: a tissue-filtered sample of 512×512 patches extracted at 0.5 µm/px from a partial download of the CAMELYON17 training set, each paired with its binary tumor label. Patches are drawn under per-slide quotas rather than uniformly, which raises the tumor rate far above true prevalence without making the dataset balanced overall as most slides are negative and contribute normal patches only.

> **This is a subset, not the full challenge dataset.** Only nodes 0 and 1 were downloaded, for approximately 121 slides.
## 📦 Dataset Structure

Each entry corresponds to a single patch extracted from one whole-slide image:

* `image` → 512×512 RGB patch, sampled at 0.5 µm/px (≈20× magnification)
* `tumor` → Binary label: `normal` (0) or `tumor` (1)
* `patient_id` → Artificial patient index from the original release (0–99 in the training set)
* `node_id` → Lymph node index within that patient (0–4 originally; only 0 and 1 here)
* `centre_id` → Contributing medical center, `centre_0``centre_4`
* `patch_x`, `patch_y` → Top-left coordinate of the patch in level-0 slide space

## 🏷️ Labels

### Patch label

The `tumor` field is binary, assigned geometrically from the lesion contours:

| Value | Class | Definition |
|---|---|---|
| 0 | Normal | Central region of the patch contains no annotated metastasis and at least 20% tissue |
| 1 | Tumor | Central region of the patch intersects an annotated metastasis |

The "central region" is the middle third of the patch (≈171×171 px of 512×512). Patches where a metastasis is present somewhere in the patch but *not* in the central region are ambiguous and were discarded rather than assigned to either class, following the labeling convention used by WILDS-Camelyon17.

## ⚙️ Preprocessing

Extraction was performed with OpenSlide and Shapely directly from the BigTIFF slides. The steps below are what distinguish this subset from a naive random-crop dump.

**Tissue masking.** A downsampled thumbnail (≈64× downsample) is converted to HSV and thresholded with Otsu on the saturation channel, with a floor at S > 20 and value bounds 40 < V < 235 to reject blown-out glass and dark pen marks or scanner bars. Small connected components are removed by morphological opening/closing. Uniform random sampling over slide dimensions would return overwhelmingly blank glass, since a lymph node section occupies a small fraction of the slide area.

**Lesion geometry with exclusions honored.** Annotations are ASAP XML polygons in level-0 coordinates. Each `<Annotation>` carries a `PartOfGroup` attribute: `metastases` marks tumor, while `normal` marks exclusion regions *inside* metastases. The tumor geometry is the union of the former minus the union of the latter, so tissue carved out of a lesion is not labeled positive. Vertices are ordered by the `Coordinate/@Order` attribute rather than document order, and self-intersecting contours are repaired.

**Class-targeted sampling.** Metastases occupy a tiny fraction of tissue, so uniform sampling yields a positive rate well under 1%. Tumor patches are drawn by rejection sampling inside the lesion geometry; normal patches are drawn uniformly over the tissue mask and rejected if they touch the lesion geometry at all. Per-slide quotas cap each class. Near-duplicate centers are suppressed on a half-patch grid.

**Magnification.** Slides are scanned at 0.23–0.25 µm/px, but not identically across centers. Rather than reading a fixed pyramid level, the target 0.5 µm/px is resolved per slide against its `openslide.mpp-x` property, so physical scale is constant across the dataset even where native resolution differs.

**Alpha compositing.** `read_region` returns RGBA; transparent regions are composited onto **white**, not converted directly to RGB, which would render slide margins black.

**Un-annotated slides.** Only 50 of the 500 CAMELYON17 training slides carry lesion-level annotations (10 per center). Slides without an XML are used as a normal-patch source **only** when `stages.csv` confirms them as `negative`; slides labeled `itc`, `micro` or `macro` without annotation are skipped entirely, since the metastasis location is unknown and every patch would be a potential false negative.

**Not included:** stain normalization, color augmentation, blur or artifact detection. These are left to the consumer, deliberately — inter-center stain variation is the scientifically interesting property of CAMELYON17 and normalizing it away at the dataset level would defeat the point.


## 🚀 Usage

```python
from datasets import load_dataset
import matplotlib.pyplot as plt

ds = load_dataset("chehablab/MiniCAMELYON", split="train")
sample = ds[0]

plt.imshow(sample["image"])
plt.axis("off")
plt.title(
    f"{sample['slide_id']} | ({sample['patch_x']}, {sample['patch_y']}) | "
    f"{ds.features['tumor'].int2str(sample['tumor'])} | "
    f"slide: {ds.features['stage'].int2str(sample['stage'])} | "
    f"{ds.features['centre_id'].int2str(sample['centre_id'])}"
)
plt.show()
```

Patient-level splitting:

```python
import numpy as np

patients = np.array(sorted(set(ds["patient_id"])))
rng = np.random.default_rng(0)
rng.shuffle(patients)
val_patients = set(patients[: int(0.2 * len(patients))].tolist())

val_ds   = ds.filter(lambda x: x["patient_id"] in val_patients)
train_ds = ds.filter(lambda x: x["patient_id"] not in val_patients)
```

## 📚 Citation

If you use this dataset, please acknowledge [Chehab Lab](https://chehablab.com) and cite the original CAMELYON publications:

```bibtex
@article{litjens2018camelyon,
  title   = {1399 {H\&E}-stained sentinel lymph node sections of breast cancer patients: the {CAMELYON} dataset},
  author  = {Litjens, Geert and Bandi, Peter and Ehteshami Bejnordi, Babak and Geessink, Oscar and Balkenhol, Maschenka and Bult, Peter and Halilovic, Altuna and Hermsen, Meyke and van de Loo, Rob and Vogels, Rob and Manson, Quirine F and Stathonikos, Nikolas and Baidoshvili, Alexi and van Diest, Paul and Wauters, Carla and van Dijk, Marcory and van der Laak, Jeroen},
  journal = {GigaScience},
  volume  = {7},
  number  = {6},
  pages   = {giy065},
  year    = {2018},
  doi     = {10.1093/gigascience/giy065}
}

@article{bandi2019detection,
  title   = {From Detection of Individual Metastases to Classification of Lymph Node Status at the Patient Level: The {CAMELYON17} Challenge},
  author  = {Bandi, Peter and Geessink, Oscar and Manson, Quirine and van Dijk, Marcory and Balkenhol, Maschenka and Hermsen, Meyke and Ehteshami Bejnordi, Babak and Lee, Byungjae and Paeng, Kyunghyun and Zhong, Aoxiao and others},
  journal = {IEEE Transactions on Medical Imaging},
  volume  = {38},
  number  = {2},
  pages   = {550--560},
  year    = {2019},
  doi     = {10.1109/TMI.2018.2867350}
}

@article{ehteshami2017diagnostic,
  title   = {Diagnostic Assessment of Deep Learning Algorithms for Detection of Lymph Node Metastases in Women With Breast Cancer},
  author  = {Ehteshami Bejnordi, Babak and Veta, Mitko and van Diest, Paul Johannes and van Ginneken, Bram and Karssemeijer, Nico and Litjens, Geert and van der Laak, Jeroen A W M and others},
  journal = {JAMA},
  volume  = {318},
  number  = {22},
  pages   = {2199--2210},
  year    = {2017},
  doi     = {10.1001/jama.2017.14585}
}
```

Challenge homepage: https://camelyon17.grand-challenge.org/

Original data repository: http://gigadb.org/dataset/100439

Viewer and annotation tooling: https://github.com/computationalpathologygroup/ASAP

---

## 📜 License

The CAMELYON16 and CAMELYON17 data are released under the [Creative Commons CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) public domain dedication, and this derivative dataset inherits the same terms.

No rights are reserved. You may copy, modify, distribute and use the data, including for commercial purposes, without asking permission. Citation is not legally required under CC0 but is expected as a matter of academic practice — please cite the works above.

The original data collection was approved by the ethics committee of Radboud University Medical Center under 2016-2761, with the need for informed consent waived.

[![CC0](https://licensebuttons.net/p/zero/1.0/88x31.png)](https://creativecommons.org/publicdomain/zero/1.0/)

**Chehab Lab @ 2026**