--- license: cc-by-nc-4.0 task_categories: - image-classification language: - en tags: - medical - hematology - white-blood-cell - wbc - robustness - class-imbalance - isbi-2026 pretty_name: WBCBench 2026 - Robust White Blood Cell Classification size_categories: - 100K--of-.parquet` Example: `phase2_train-00002-of-00004.parquet` is shard 2 of 4 in the `phase2_train` split. ## Schema Every row contains: | Column | Type | Notes | |---|---|---| | `image` | Image | The JPEG bytes, decoded as PIL by `datasets` | | `image_id` | str | Filename stem (e.g., `"00173214"` or `"01416766"`) | | `label` | str | One of 13 classes: BA, BL, BNE, EO, LY, MMY, MO, MY, PC, PLY, PMY, SNE, VLY | | `wbcbench_split` | str | Which official split: `phase1_train` / `phase2_train` / `phase2_eval` / `phase2_test` | | `severity` | str | `pristine` / `mild` / `moderate` / `extreme` (pristine config: always `pristine`) | | `original_image_id` | str | For degraded rows: the pristine source `image_id`. Empty for pristine rows. | | `patient_hash` | str | Truncated salted SHA-256 of the patient accession ID. Use for patient-level splits/grouping. | ## Quickstart ### Step 1: Install the Python packages (do this once) ```bash pip install -U datasets huggingface_hub pandas pillow ``` > If you skip this step, the code below might fail with `ModuleNotFoundError: No module named 'datasets'` (skip it if you already have these packages installed). ### Step 2: Generate a Hugging Face access token Go to **https://huggingface.co/settings/tokens** → click **"Create new token"** → select token type **"Read"**. A Read token is all you need to download gated datasets you've been granted access to. Copy the token (it starts with `hf_...`) and treat it like a password — don't commit it to git. ### Step 3: Authenticate After your access request is approved, log in once on your machine to cache the token: ```bash hf auth login # paste the token from Step 2 ``` ### Step 4: Load the data ```python from datasets import load_dataset REPO = "Xin-Tian/wbcbench2026" # First call downloads parquet shards to ~/.cache/huggingface/. Subsequent calls reuse the cache. # Full download: about 3.9 GB. You can also load just one split or stream rows (see below). pristine_train = load_dataset(REPO, "pristine", split="phase2_train") degraded_train = load_dataset(REPO, "degraded", split="phase2_train") # Each row has: image (PIL.Image), image_id, label, wbcbench_split, severity, # original_image_id, patient_hash. See the Schema section below. row = pristine_train[0] print(row["image_id"], row["label"], row["image"].size) # -> "00004087" "SNE" (368, 370) ``` ### Load only what you need (save disk / bandwidth) ```python # Single split (about 500 MB for pristine, about 2 GB for degraded train): train = load_dataset(REPO, "pristine", split="phase2_train") # Stream rows without downloading the full shard: ds = load_dataset(REPO, "degraded", split="phase2_train", streaming=True) for row in ds.take(5): print(row["image_id"], row["label"]) # Slice notation (downloads only the requested shard): sample = load_dataset(REPO, "pristine", split="phase2_train[:100]") ``` ### Saving images to disk Write the raw JPEG bytes directly. This gives files byte-identical to the Kaggle source — no decoding, no quality loss: ```python from datasets import load_dataset, Image import os ds = load_dataset(REPO, "pristine", split="phase2_train") ds = ds.cast_column("image", Image(decode=False)) # raw JPEG bytes, no PIL decode os.makedirs("out", exist_ok=True) for row in ds: with open(f"out/{row['image_id']}.jpg", "wb") as f: f.write(row["image"]["bytes"]) ``` In-memory use during training is fine — PIL decoding is mathematically lossless. The byte-write step above matters only when you save images back to disk. ### Shard naming Each split is split into parquet shards (about 500 MB each) named like `phase2_train-00000-of-00004.parquet`: - `00000` = shard index (0-based, zero-padded) - `of-00004` = total number of shards for this split `load_dataset` finds them all automatically via the glob `phase2_train-*.parquet`. ### Linkage example: find the pristine source of a degraded image (fast) For one-off lookups, `.filter()` on a 24K-row split takes about 13 seconds. Build a dict for O(1) lookups: ```python # Build an in-memory index: image_id -> row index pristine_idx = {iid: i for i, iid in enumerate(pristine_train["image_id"])} # Pick any degraded image and find its pristine source d = degraded_train[0] p = pristine_train[pristine_idx[d["original_image_id"]]] print(f"degraded {d['image_id']} ({d['severity']}) <- pristine {p['image_id']} ({p['label']})") print(f" degraded dims: {d['image'].size} pristine dims: {p['image'].size} (should be equal)") ``` ### Load the class legend (abbreviation -> full cell type name) ```python import pandas as pd from huggingface_hub import hf_hub_download legend = pd.read_csv(hf_hub_download(repo_id="Xin-Tian/wbcbench2026", filename="metadata/class_legend.csv", repo_type="dataset")) LEGEND = dict(zip(legend["abbreviation"], legend["cell_type"])) print(LEGEND["SNE"]) # -> "Segmented neutrophil" ``` ## Patient-level separation All splits are **patient-level disjoint**: every patient (identified by `patient_hash`) appears in exactly one of `phase1_train`, `phase2_train`, `phase2_eval`, `phase2_test`. Verified across the release: 493 unique patients, zero patients appear in more than one split. This is essential for honest generalization benchmarks — no patient leakage between train and test. Use `patient_hash` to group examples for cross-validation or to verify your own splits preserve this property. ## Evaluation metric The official WBCBench 2026 ranking metric is **macro-averaged F1 score** across all 13 classes (equal weight per class, regardless of class frequency — important because the dataset is severely class-imbalanced). ## Severity definitions The degraded config applies one of four severity levels to each phase2 entry: - **pristine** - no degradation applied (the image is identical to its pristine source bytes) - **mild** - small Gaussian noise, low blur, mild color jitter - **moderate** - moderate blur or motion blur + noticeable noise - **extreme** - heavy motion blur, strong noise, strong color shift Exact per-image parameters are in `metadata/degradation_params.csv`. The code that produced them is in `scripts/degrade_ops.py`. ## Curation note After the original Kaggle release, the WBCBench 2026 team commissioned a 10-team annotator review. The expert reviewer's final decisions: - **257 cells**: label corrected based on multi-annotator consensus - **10 cells**: removed from the release (multi-cell artifacts or low-quality images) - **74 cells**: reviewed but original label retained The corrections are silently applied in the labels you see here. The original Kaggle CSV is preserved upstream for reproducibility purposes. ## PII statement All clinical PII (patient accession IDs, source paths, scan dates, machine identifiers) has been removed. The `patient_hash` column is a truncated SHA-256 of (private salt + patient accession), so users can group rows by patient without learning the patient's identity. The salt is not published. ## Citation ```bibtex @inproceedings{wbcbench2026, title={WBCBench 2026: A challenge for robust white blood cell classification under class imbalance}, author={Tian, Xin and Ma, Xudong and Yang, Tianqi and Achim, Alin and Papie{\.z}, Bart{\l}omiej W and Watanaboonyongcharoen, Phandee and Anantrasirichai, Nantheera}, booktitle={2026 IEEE 23rd International Symposium on Biomedical Imaging (ISBI)}, pages={1--4}, year={2026}, organization={IEEE} } ```