--- license: cc0-1.0 tags: - histology - panoptic - segmentation - biology - medical --- ## Dataset Description This dataset contains refined **Panoptils manual regions and bootstrapped nuclei labels** for panoptic segmentation model training. This refined version contains in total **1349 images** and corresponding annotations of **TCGA invasive breast cancer cases**. Cases (total 360) with incomplete or insufficient annotations from the original dataset have been excluded to ensure only high-quality annotations. The segmentation masks have been algorithmically post-processed to fill excessive background regions present in the original annotations, resulting in more contiguous tissue regions. Each sample includes byte-encoded **image, nuclei instance segmentation, nuclei semantic segmentation, and tissue semantic segmentation masks** serialized in a **Parquet file** for efficient access. (See 'How to use'-section on how to decode). The original **[Panoptils dataset](https://sites.google.com/view/panoptils/)** (CC0-1.0) is a large-scale, semi-manually annotated collection of breast cancer whole-slide images (WSIs) designed for panoptic segmentation tasks. **From the Panoptils webpage**: "PanopTILs was created by reconciling and expanding two public datasets, BCSS and NuCLS, to enable in-depth analysis of the tumor microenvironment (TME) in whole-slide images (WSI) of H&E stained slides of breast cancer." "The dataset is composed of **1024x1024 regions of interest (ROIs) at 0.25 microns-per-pixel (MPP) resolution**, which corresponds to 40x magnification on many scanners. Annotations of histologic regions (semantic segmentation), as well as nuclear classifications and segmentation (object segmentation), are provided for the same ROI" **References**: - **PanopTILs dataset** Liu S, Amgad M, Rathore MA, Salgado R, Cooper LA. A panoptic segmentation approach for tumor-infiltrating lymphocyte assessment: development of the MuTILs model and PanopTILs dataset. *medRxiv* 2022.01.08.22268814. - **BCSS dataset** Amgad M, Elfandy H, Hussein H, Atteya LA, Elsebaie MA, Abo Elnasr LS, Sakr RA, Salem HS, Ismail AF, Saad AM, Ahmed J. Structured crowdsourcing enables convolutional segmentation of histology images. *Bioinformatics*. 2019 Sep 15;35(18):3461-7. - **NuCLS dataset** Amgad M, Atteya LA, Hussein H, Mohammed KH, Hafiz E, Elsebaie MA, Alhusseiny AM, AlMoslemany MA, Elmatboly AM, Pappalardo PA, Sakr RA. NuCLS: A scalable crowdsourcing approach and dataset for nucleus classification and segmentation in breast cancer. *GigaScience*. 2022 May 17;11. **Dataset Classes (refined)**: ``` nuclei_classes = { "background": 0, "neoplastic": 1, "stromal": 2, "inflammatory": 3, "epithelial": 4, "other": 5, "unknown": 6, } tissue_classes = { "background": 0, "tumor": 1, "stroma": 2, "epithelium": 3, "junk/debris": 4, "blood": 5, "other": 6, } ``` **How to use**: ```python import pandas as pd import numpy as np import io import matplotlib.pyplot as plt from datasets import load_dataset from PIL import Image from skimage.color import label2rgb # for decoding PNG bytes to numpy array def png_bytes_to_array(png_bytes): img = Image.open(io.BytesIO(png_bytes)) return np.array(img) # Load the dataset from Hugging Face Hub ds = load_dataset("histolytics-hub/panoptils_refined", split="train") # convert to pandas df df = ds.with_format("pandas")[:] # Example: decode one row row = df.iloc[1] image = png_bytes_to_array(row["image"]) inst_mask = png_bytes_to_array(row["inst"]) type_mask = png_bytes_to_array(row["type"]) sem_mask = png_bytes_to_array(row["sem"]) fig, axes = plt.subplots(1, 4, figsize=(20, 5)) axes[0].imshow(image) axes[1].imshow(label2rgb(inst_mask, bg_label=0)) axes[2].imshow(label2rgb(type_mask, bg_label=0)) axes[3].imshow(label2rgb(sem_mask, bg_label=0)) for ax in axes: ax.axis("off") plt.tight_layout() plt.show() ``` ![out](panoptils_example.png) **Note:** The original fold splits are not viable in this dataset since many images were excluded during curation. However, you can easily split the data for training and validation using the `slide_name` and `hospital` columns to avoid data leakage. Here is an example using `sklearn`'s `GroupShuffleSplit` to split by slide: ```python from sklearn.model_selection import GroupShuffleSplit gss = GroupShuffleSplit(n_splits=1, test_size=0.2, random_state=42) train_idx, val_idx = next(gss.split(df, groups=df["slide_name"])) df_train = df.iloc[train_idx] df_val = df.iloc[val_idx] ``` You can also use the `hospital` column as the grouping key if you want to split by hospital.