okunator commited on
Commit
534682b
·
verified ·
1 Parent(s): 6e01275

Add validated PanNuke folds, dataset card and annotation examples

Browse files
Files changed (6) hide show
  1. README.md +181 -0
  2. examples.png +3 -0
  3. fold_1.parquet +3 -0
  4. fold_2.parquet +3 -0
  5. fold_3.parquet +3 -0
  6. manifest.json +137 -0
README.md ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-nc-sa-4.0
3
+ task_categories:
4
+ - image-segmentation
5
+ tags:
6
+ - histology
7
+ - nuclei
8
+ - instance-segmentation
9
+ configs:
10
+ - config_name: default
11
+ data_files:
12
+ - split: fold1
13
+ path: fold_1.parquet
14
+ - split: fold2
15
+ path: fold_2.parquet
16
+ - split: fold3
17
+ path: fold_3.parquet
18
+ ---
19
+
20
+ # PanNuke in Parquet format
21
+
22
+ [PanNuke](https://warwick.ac.uk/fac/cross_fac/tia/data/pannuke/) contains
23
+ 256 × 256 histology images with labels for individual nuclei and their cell types.
24
+ This version stores all 7,901 images in Parquet files, keeping the original three
25
+ folds and cell-type mapping. It is a repackaging, not an official author release.
26
+
27
+ ## Files and fields
28
+
29
+ There is one Parquet file per fold and one row per image. The `image`, `inst`
30
+ and `type` fields contain PNG bytes.
31
+
32
+ | Field | Contents |
33
+ | --- | --- |
34
+ | `id` | Unique sample name: `fold1_00000`, for example |
35
+ | `image` | RGB uint8 image encoded as PNG; pixel values are 0–255 |
36
+ | `inst` | uint16 instance mask encoded as PNG; 0 is background |
37
+ | `type` | uint8 cell-type mask encoded as PNG; labels are listed below |
38
+ | `fold` | Original fold number, 1, 2 or 3 |
39
+ | `tissue` | Original tissue category from `types.npy` |
40
+
41
+ ## Cell types
42
+
43
+ The `type` mask uses these labels:
44
+
45
+ | Value | Class |
46
+ | --- | --- |
47
+ | 0 | background |
48
+ | 1 | neoplastic |
49
+ | 2 | inflammatory |
50
+ | 3 | connective |
51
+ | 4 | dead |
52
+ | 5 | epithelial |
53
+
54
+ Instance IDs start at 1 in each image; 0 is background. IDs are unique within
55
+ an image and have no meaning across images.
56
+
57
+ ## Original folds
58
+
59
+ Keep the original folds for comparisons with published PanNuke results. The
60
+ authors specify these three arrangements:
61
+
62
+ | Arrangement | Training | Validation | Testing |
63
+ | --- | --- | --- | --- |
64
+ | 1 | Fold 1 | Fold 2 | Fold 3 |
65
+ | 2 | Fold 2 | Fold 1 | Fold 3 |
66
+ | 3 | Fold 3 | Fold 2 | Fold 1 |
67
+
68
+ ## Read a sample
69
+
70
+ Download a fold Parquet file, then decode one sample:
71
+
72
+ ```python
73
+ from io import BytesIO
74
+
75
+ import numpy as np
76
+ import polars as pl
77
+ from PIL import Image
78
+
79
+
80
+ def read_png(data: bytes) -> np.ndarray:
81
+ """Read an image or label mask from PNG bytes."""
82
+ with Image.open(BytesIO(data)) as image:
83
+ return np.array(image)
84
+
85
+
86
+ row = pl.read_parquet("fold_1.parquet", n_rows=1).row(0, named=True)
87
+ image = read_png(row["image"])
88
+ instances = read_png(row["inst"])
89
+ cell_types = read_png(row["type"])
90
+ ```
91
+
92
+ The decoded shapes are `(256, 256, 3)` for the RGB image and `(256, 256)` for
93
+ both masks. Each positive instance number identifies one nucleus; `type` gives
94
+ its cell category at the same pixels. The Hub configuration exposes `fold1`,
95
+ `fold2` and `fold3` as separate splits.
96
+
97
+ ## Plot patches and annotations
98
+
99
+ The following example shows three patches from fold 1:
100
+
101
+ ```python
102
+ import matplotlib.pyplot as plt
103
+ from matplotlib.patches import Patch
104
+ from skimage.segmentation import find_boundaries
105
+
106
+ sample_ids = ["fold1_00017", "fold1_00738", "fold1_02422"]
107
+ samples = (
108
+ pl.scan_parquet("fold_1.parquet")
109
+ .filter(pl.col("id").is_in(sample_ids))
110
+ .collect()
111
+ )
112
+ names = ["Neoplastic", "Inflammatory", "Connective", "Dead", "Epithelial"]
113
+ colors = np.array([
114
+ [230, 75, 53], [54, 140, 204], [0, 160, 135],
115
+ [243, 155, 60], [144, 102, 190],
116
+ ]) / 255
117
+
118
+ fig, axes = plt.subplots(3, 2, figsize=(5.5, 8))
119
+ for row_axes, sample in zip(axes, samples.iter_rows(named=True)):
120
+ image = read_png(sample["image"])
121
+ instances = read_png(sample["inst"])
122
+ cell_types = read_png(sample["type"])
123
+ foreground = instances > 0
124
+ overlay = image / 255
125
+ overlay[foreground] = (
126
+ 0.65 * overlay[foreground] + 0.35 * colors[cell_types[foreground] - 1]
127
+ )
128
+ edges = find_boundaries(instances, mode="inner") & foreground
129
+ overlay[edges] = colors[cell_types[edges] - 1]
130
+ for ax, pixels in zip(row_axes, (image, overlay)):
131
+ ax.imshow(pixels)
132
+ ax.set_axis_off()
133
+ row_axes[0].set_title(sample["tissue"], fontsize=9)
134
+
135
+ axes[0, 1].set_title("Nucleus annotations", fontsize=9)
136
+ fig.legend(
137
+ handles=[Patch(facecolor=c, label=n) for c, n in zip(colors, names)],
138
+ loc="lower center", ncol=5, frameon=False, fontsize=7,
139
+ )
140
+ fig.tight_layout(rect=(0, 0.04, 1, 1))
141
+ plt.show()
142
+ ```
143
+
144
+ ![Three PanNuke patches with cell-type annotation overlays](examples.png)
145
+
146
+ Breast, colon and skin patches from fold 1. Left: original images. Right:
147
+ annotated nuclei, coloured by cell type.
148
+
149
+ ## Conversion notes
150
+
151
+ Images keep their original pixel values and size. Instance IDs are renumbered
152
+ within each image. A small number of pixels belong to multiple nucleus class
153
+ channels in the source data; these are assigned to the lower-numbered class.
154
+ Background is any pixel without a nucleus. Every original nucleus is retained.
155
+
156
+ All saved images and masks are checked against the source after conversion.
157
+ `manifest.json` records sample counts, conversion details and file hashes.
158
+
159
+ ## License and attribution
160
+
161
+ PanNuke is provided for research and noncommercial use under
162
+ [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).
163
+ This repackaging retains that license. Attribute the original authors, cite both
164
+ papers below, link to the original data and license, and identify the format and
165
+ label-conversion changes when redistributing it.
166
+
167
+ - Gamper et al. (2019). *PanNuke: an open pan-cancer histology dataset for nuclei
168
+ instance segmentation and classification.*
169
+ [Paper](https://doi.org/10.1007/978-3-030-23937-4_2).
170
+ - Gamper et al. (2020). *PanNuke Dataset Extension, Insights and Baselines.*
171
+ [Paper](https://arxiv.org/abs/2003.10778).
172
+
173
+ ## Validated sample counts
174
+
175
+ | Fold | Samples |
176
+ | --- | --- |
177
+ | 1 | 2656 |
178
+ | 2 | 2523 |
179
+ | 3 | 2722 |
180
+
181
+ Total: 7901 samples.
examples.png ADDED

Git LFS Details

  • SHA256: 18f33a5750fdbc62fa29a292418b0370cf1d16dcf005acf6aa7faeb3ec0bfe82
  • Pointer size: 131 Bytes
  • Size of remote file: 418 kB
fold_1.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9e40907a07c59768c674d142ea80b4dd867b29bc70dcb0f8bef4e9c446b9a79
3
+ size 329319785
fold_2.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:413de87c2c3e130f28086c8b5e03075583e8e90fd6ba3a4e254315ce86e1de6b
3
+ size 309704351
fold_3.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98327000b6203ac08c7a80288024653049ab764b203b1dd133fee9c467440001
3
+ size 338978966
manifest.json ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "created_utc": "2026-10-18T08:27:08.417852+00:00",
3
+ "source": "https://warwick.ac.uk/fac/cross_fac/tia/data/pannuke",
4
+ "license": "cc-by-nc-sa-4.0",
5
+ "classes": {
6
+ "0": "background",
7
+ "1": "neoplastic",
8
+ "2": "inflammatory",
9
+ "3": "connective",
10
+ "4": "dead",
11
+ "5": "epithelial"
12
+ },
13
+ "overlap_policy": "lowest nucleus class number wins; background is pixels without nuclei",
14
+ "conversion_script_sha256": "6bcf46f2afd8dfb8f0de7e99d685cb564131cd73dd411e2089007ba9f886cdb8",
15
+ "folds": [
16
+ {
17
+ "fold": 1,
18
+ "samples": 2656,
19
+ "nuclei_by_class": {
20
+ "neoplastic": 26201,
21
+ "inflammatory": 10820,
22
+ "connective": 16388,
23
+ "dead": 967,
24
+ "epithelial": 8842
25
+ },
26
+ "samples_by_tissue": {
27
+ "Breast": 827,
28
+ "Colon": 478,
29
+ "Lung": 80,
30
+ "Kidney": 37,
31
+ "Prostate": 77,
32
+ "Bladder": 21,
33
+ "Stomach": 50,
34
+ "Ovarian": 54,
35
+ "Esophagus": 155,
36
+ "Pancreatic": 78,
37
+ "Uterus": 17,
38
+ "Thyroid": 80,
39
+ "Skin": 59,
40
+ "Cervix": 155,
41
+ "Adrenal_gland": 134,
42
+ "Bile-duct": 159,
43
+ "Testis": 60,
44
+ "HeadNeck": 70,
45
+ "Liver": 65
46
+ },
47
+ "overlap_pixels": 1216,
48
+ "samples_with_overlap": 194,
49
+ "source_background_mismatch_pixels": 2359296,
50
+ "source_url": "https://warwick.ac.uk/fac/cross_fac/tia/data/pannuke/fold_1.zip",
51
+ "archive_sha256": "6e19ad380300e8ce9480f9ab6a14cc91fa4b6a511609b40e3d70bdf9c881ed0b",
52
+ "parquet_sha256": "b9e40907a07c59768c674d142ea80b4dd867b29bc70dcb0f8bef4e9c446b9a79",
53
+ "parquet": "fold_1.parquet",
54
+ "validation": "all saved RGB pixels and resolved class/instance masks match source; no nuclei lost"
55
+ },
56
+ {
57
+ "fold": 2,
58
+ "samples": 2523,
59
+ "nuclei_by_class": {
60
+ "neoplastic": 22731,
61
+ "inflammatory": 10631,
62
+ "connective": 16756,
63
+ "dead": 884,
64
+ "epithelial": 8870
65
+ },
66
+ "samples_by_tissue": {
67
+ "Breast": 749,
68
+ "Colon": 468,
69
+ "Lung": 53,
70
+ "Kidney": 56,
71
+ "Prostate": 37,
72
+ "Bladder": 61,
73
+ "Stomach": 48,
74
+ "Ovarian": 40,
75
+ "Esophagus": 128,
76
+ "Pancreatic": 89,
77
+ "Uterus": 6,
78
+ "Thyroid": 84,
79
+ "Skin": 87,
80
+ "Cervix": 52,
81
+ "Adrenal_gland": 148,
82
+ "Bile-duct": 103,
83
+ "Testis": 79,
84
+ "HeadNeck": 169,
85
+ "Liver": 66
86
+ },
87
+ "overlap_pixels": 1572,
88
+ "samples_with_overlap": 190,
89
+ "source_background_mismatch_pixels": 3801371,
90
+ "source_url": "https://warwick.ac.uk/fac/cross_fac/tia/data/pannuke/fold_2.zip",
91
+ "archive_sha256": "5bc540cc509f64b5f5a274d6e5a245527dbd3e6d3155d43555115c5d54709b07",
92
+ "parquet_sha256": "413de87c2c3e130f28086c8b5e03075583e8e90fd6ba3a4e254315ce86e1de6b",
93
+ "parquet": "fold_2.parquet",
94
+ "validation": "all saved RGB pixels and resolved class/instance masks match source; no nuclei lost"
95
+ },
96
+ {
97
+ "fold": 3,
98
+ "samples": 2722,
99
+ "nuclei_by_class": {
100
+ "neoplastic": 28471,
101
+ "inflammatory": 10825,
102
+ "connective": 17441,
103
+ "dead": 1057,
104
+ "epithelial": 8860
105
+ },
106
+ "samples_by_tissue": {
107
+ "Breast": 775,
108
+ "Colon": 494,
109
+ "Lung": 51,
110
+ "Kidney": 41,
111
+ "Prostate": 68,
112
+ "Bladder": 64,
113
+ "Stomach": 48,
114
+ "Ovarian": 52,
115
+ "Esophagus": 141,
116
+ "Uterus": 163,
117
+ "Thyroid": 62,
118
+ "Skin": 41,
119
+ "Cervix": 86,
120
+ "Adrenal_gland": 155,
121
+ "Pancreatic": 28,
122
+ "Bile-duct": 158,
123
+ "Testis": 57,
124
+ "HeadNeck": 145,
125
+ "Liver": 93
126
+ },
127
+ "overlap_pixels": 1530,
128
+ "samples_with_overlap": 191,
129
+ "source_background_mismatch_pixels": 4325424,
130
+ "source_url": "https://warwick.ac.uk/fac/cross_fac/tia/data/pannuke/fold_3.zip",
131
+ "archive_sha256": "c14d372981c42f611ebc80afad01702b89cad8c1b3089daa31931cf5a4b1a39d",
132
+ "parquet_sha256": "98327000b6203ac08c7a80288024653049ab764b203b1dd133fee9c467440001",
133
+ "parquet": "fold_3.parquet",
134
+ "validation": "all saved RGB pixels and resolved class/instance masks match source; no nuclei lost"
135
+ }
136
+ ]
137
+ }