D / README.md
milkyroad's picture
Update README for flattened single-split structure
219b4b4 verified
|
Raw
History Blame Contribute Delete
3.87 kB
metadata
language:
  - en
license: unknown
task_categories:
  - image-classification
tags:
  - medical
  - cystoscopy
  - bladder-cancer
size_categories:
  - 1K<n<10K
configs:
  - config_name: default
    data_files:
      - split: train
        path: data/train-*.parquet

Kaggle Cystoscopy Frames

Cystoscopic still frames (1 754 PNG, ~236 MB) sourced from a Kaggle dataset, organized by tissue type (HGC / LGC / NST / NTL) and imaging modality (WLI / NBI). Flattened into a single train split with one row per image; images are embedded in the Parquet shards as HF Image features.

Why no splits

This dataset ships one train split only. The original CSV splits leaked patients (19 of 21 train cases also appeared in val/test). Use the case_id column to build your own patient/case-grouped splits to prevent leakage.

Columns

Column Type Description
image Image Decoded PIL image (embedded bytes).
filename string Normalized disk name case_{cid:03d}_pt_{pt:03d}_frame_{frame:04d}_{tissue}.png.
case_id int Case identifier — use this for group-aware splitting.
imaging_type string WLI or NBI.
tissue_type string HGC / LGC / NST / NTL.
original_split string The leaky CSV sub_dataset value — kept for auditability only.

Tissue types

Tissue Count
LGC 647
NST 504
HGC 469
NTL 134

22 unique case_ids.

Loading

from datasets import load_dataset
ds = load_dataset("milkyroad/D", split="train")
print(ds[0]["image"])      # PIL.Image
print(ds[0]["tissue_type"])

Group-aware split example

import random
from collections import defaultdict

ds = load_dataset("milkyroad/D", split="train")
cases = sorted({r["case_id"] for r in ds})
random.Random(42).shuffle(cases)
n_test, n_val = 2, 2
test_cases = set(cases[:n_test])
val_cases = set(cases[n_test:n_test + n_val])

train = ds.filter(lambda r: r["case_id"] not in test_cases and r["case_id"] not in val_cases)
val   = ds.filter(lambda r: r["case_id"] in val_cases)
test  = ds.filter(lambda r: r["case_id"] in test_cases)

Filename normalization

The original Kaggle dataset contained 8 different filename patterns. All have been normalized to a single consistent format:

case_{cid:03d}_pt_{pt:03d}_frame_{frame:04d}_{tissue}.png
Pattern Original format Count Example
1 case_NNN_pt_NNN_frame_NNNN 1266 case_002_pt_003_frame_0009.png
2 case_NNN_pt_NNN_HLT__frame_NNNN 7 case_012_pt_001_HLT__frame_0025.png
3 case_NNN_pt_NNN_HLT_frame_NNNN 30 case_025_pt_004_HLT_frame_0000.png
4 cys_case_N_ptN_frame_NNNN 28 cys_case_1_pt1_frame_2311.png
5 cys_case_N_ptN_NNNN 262 cys_case_5_pt1_0055.png
6 cys_case_N_ptN_NNNN (copy) 4 cys_case_10_pt1_1644 (copy).png
7 cys_case_N_NNNN (no pt) 41 cys_case_7_0384.png
8 case_N_cys_ptN_NNNN 116 case_6_cys_pt1_0165.png

Normalization details:

  • HLT annotation stripped — 37 files had HLT (hyperplasia) embedded in the filename; already classified as NST in metadata, so the annotation was removed.
  • Pattern 7 (no pt) — 41 files had no patient number; assigned pt_000.
  • "(copy)" suffix — 4 files had macOS Finder duplicate suffixes; stripped (no non-copy counterparts existed; images are unique).
  • Tissue type in filename — 9 collision pairs existed where the same case/pt/frame had both cancer and non-cancer images; including {tissue} disambiguates them.

Notes

  • Original splits leak patients. The CSV's sub_dataset column places 19 of 21 train cases also in val/test. original_split is preserved only for auditability; build your own case-level splits via case_id.