Datasets:
File size: 3,866 Bytes
a089d69 219b4b4 a089d69 219b4b4 a089d69 219b4b4 a089d69 219b4b4 a089d69 219b4b4 5ccc8f5 219b4b4 5ccc8f5 a089d69 219b4b4 | 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 | ---
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_id`s.
## Loading
```python
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
```python
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`.
|