E / README.md
milkyroad's picture
Update README.md
0c320f4 verified
|
Raw
History Blame Contribute Delete
10.5 kB
---
configs:
- config_name: default
data_files:
- split: train
path: data/train-*
- split: validation
path: data/validation-*
- split: test
path: data/test-*
license: unknown
tags:
- medical-imaging
- cystoscopy
- bladder-cancer
- cancer-detection
- histological-grade
pretty_name: Unified Cystoscopy Cancer Detection (Dataset E)
size_categories:
- 10K<n<100K
dataset_info:
features:
- name: image
dtype: image
- name: cancer_label
dtype:
class_label:
names:
'0': non_cancer
'1': cancer
- name: grade_label
dtype:
class_label:
names:
'0': low_grade
'1': high_grade
'2': not_applicable
- name: subclass_label
dtype:
class_label:
names:
'0': malignant
'1': non_malignant
'2': normal
'3': landmark
'4': foreign_body
- name: source_dataset
dtype: string
- name: original_filename
dtype: string
- name: patient_id
dtype: int32
- name: imaging_type
dtype:
class_label:
names:
'0': WLI
'1': NBI
'2': BLC
- name: target3
dtype:
class_label:
names:
'0': malignant
'1': non_malignant
'2': non_roi
- name: track_id
dtype: string
- name: cv_fold
dtype: int32
splits:
- name: train
num_examples: 10436
- name: validation
num_examples: 2244
- name: test
num_examples: 2241
---
# Unified Cystoscopy Cancer Detection (Dataset E)
## Dataset Description
A unified cystoscopy image dataset assembled from three independent sources,
prepared for 3-class deep learning (malignant vs non-malignant vs non-ROI).
Every image carries a **cancer label**, a **grade label**, a **subclass label**,
and a derived **target3** label for the 3-class task.
- **Total images (after capping)**: 14,921
- **Unique patients/cases**: 212
- **Modalities**: White-Light Imaging (WLI), Narrow-Band Imaging (NBI), Blue-Light Cystoscopy (BLC)
- **Splits**: train / validation / test (70 / 15 / 15), patient-level with no leakage
## Source Datasets
| Code | Source | Type | Images (raw) | Images (after cap) | Patients/Cases |
|------|--------|------|-------------:|--------------------:|----------------:|
| B | Cystoscopy video dataset | Video frames (stride 8) | 6,519 | 5,100 | 30 |
| C | CystoDS | Still cystoscopy images | 8,067 | 8,067 | 160 |
| D | Kaggle cystoscopy frames | Still cystoscopy frames | 1,754 | 1,754 | 22 |
### Source B frame capping
Source B video frames are temporally autocorrelated (stride 8 extraction).
To reduce redundancy, majority-class frames (malignant + non-ROI) are capped
at **60 per (patient, track)**. Non-malignant frames are always kept.
This reduces source B from 6,519 to 5,100 images (cap=60, seed=42).
### Patient ID normalization
| Source | Original ID field | Normalized range | Count |
|--------|-------------------|-----------------|------:|
| B | `patient_id` (0-29) | 1-30 | 30 |
| C | `pid` | 31-190 | 160 |
| D | `case_id` (0-25) | 191-212 | 22 |
## Label Derivation
### cancer_label (ClassLabel: `non_cancer`=0, `cancer`=1)
| Source | Field used | Mapping |
|--------|-----------|---------|
| D | `tissue_type` | HGC, LGC -> cancer; NST, NTL -> non_cancer |
| C | `class` | Malignant -> cancer; all others -> non_cancer |
| B | per-frame tumor annotation (`y`) + `histological_type` | y=1 (carcinoma patient) -> cancer; y=0 or PUNLMP -> non_cancer |
### grade_label (ClassLabel: `low_grade`=0, `high_grade`=1, `not_applicable`=2)
| Source | Field used | High-grade (1) | Low-grade (0) | Not applicable (2) |
|--------|-----------|----------------|---------------|---------------------|
| D | `tissue_type` | HGC | LGC | NST, NTL |
| C | `subclass` | HighGradePapillary, CIS | LowGradePapillary | all other classes |
| B | `histological_type` (patient-level) | pT1HG, pTaHG, pT2, pT2HG | pTaLG, pT1LG | PUNLMP, non-tumor frames (y=0) |
### subclass_label (ClassLabel: `malignant`=0, `non_malignant`=1, `normal`=2, `landmark`=3, `foreign_body`=4)
| Source | Native field | Mapping |
|--------|-------------|---------|
| B | `histological_type` + `y` | Carcinoma + y=1 -> malignant; PUNLMP -> non_malignant; y=0 -> normal |
| C | `class` | Malignant -> malignant; Non-malignant -> non_malignant; Normal mucosa -> normal; Anatomical landmarks -> landmark; Foreign bodies -> foreign_body |
| D | `tissue_type` | HGC, LGC -> malignant; NTL -> non_malignant; NST -> normal |
### target3 (ClassLabel: `malignant`=0, `non_malignant`=1, `non_roi`=2)
Derived 3-class label for the deep learning task:
| subclass_label | target3 |
|----------------|---------|
| malignant (0) | malignant (0) |
| non_malignant (1) | non_malignant (1) |
| normal (2) | non_roi (2) |
| landmark (3) | non_roi (2) |
| foreign_body (4) | non_roi (2) |
### imaging_type (ClassLabel: `WLI`=0, `NBI`=1, `BLC`=2)
| Source | Original field | Values -> unified |
|--------|---------------|------------------|
| B | `light_mode` | CLARA + CHROMA -> WLI, white light -> WLI |
| C | `modality` | WLC -> WLI, BLC -> BLC |
| D | `imaging_type` | WLI -> WLI, NBI -> NBI |
## Train / Validation / Test Split
Patient-level stratified split using StratifiedGroupKFold (source x dominant-class
stratification) + post-split patient swapping to minimize fill-ratio deviation.
- **Split ratio**: 70 / 15 / 15 (train / val / test)
- **Seed**: 16
- **Swaps applied**: 14
- **No patient appears in more than one split** (verified)
### Split sizes
| Split | Images | Patients |
|-------|-------:|---------:|
| train | 10,436 | 148 |
| validation | 2,244 | 35 |
| test | 2,241 | 29 |
| **Total** | **14,921** | **212** |
### Class distribution per split
| Class | Total | Train | Val | Test |
|-------|------:|------:|----:|-----:|
| malignant | 6,515 (43.7%) | 4,568 | 982 | 965 |
| non_malignant | 900 (6.0%) | 631 | 135 | 134 |
| non_roi | 7,506 (50.3%) | 5,237 | 1,127 | 1,142 |
### Fill ratios (count / target, ideal = 1.00)
| Class | Train | Val | Test |
|-------|------:|----:|-----:|
| malignant | 1.00 | 1.00 | 0.99 |
| non_malignant | 1.00 | 1.00 | 0.99 |
| non_roi | 1.00 | 1.00 | 1.01 |
### Source x split (patients)
| Source | Train | Val | Test |
|--------|------:|----:|-----:|
| B | 21 | 4 | 5 |
| C | 115 | 25 | 20 |
| D | 12 | 6 | 4 |
### Source x split (images)
| Source | Train | Val | Test |
|--------|------:|----:|-----:|
| B | 3,763 | 760 | 577 |
| C | 5,821 | 1,129 | 1,117 |
| D | 852 | 355 | 547 |
### Non-malignant patient coverage
| Split | Patients | Images |
|-------|---------:|-------:|
| train | 55 | 631 |
| validation | 12 | 135 |
| test | 13 | 134 |
## 5-Fold Cross-Validation (train pool only)
StratifiedGroupKFold on the train split (per-image `target3` stratification,
patient-level grouping, no patient in multiple folds, seed=15).
| Fold | Patients | Images | Malignant | Non-mal | Non-ROI |
|-----:|---------:|-------:|----------:|--------:|--------:|
| 0 | 26 | 2,028 | 914 | 61 | 1,053 |
| 1 | 35 | 2,119 | 913 | 170 | 1,036 |
| 2 | 31 | 2,026 | 915 | 61 | 1,050 |
| 3 | 26 | 2,026 | 913 | 61 | 1,052 |
| 4 | 30 | 2,237 | 913 | 278 | 1,046 |
The `cv_fold` column is -1 for validation and test patients.
### Note on minority-class (non-malignant) fold balance
Non-malignant images are heavily patient-concentrated in this dataset: in the
train pool, two patients alone account for around 70% of all non-malignant images
(274 and 168 images respectively), and only 17 of 148 train patients are
non-malignant dominant. Because cross-validation is patient-grouped (a patient
never appears in more than one fold), these high-volume patients cannot be
split across folds and inevitably land in a single fold each. As a result,
two folds carry an elevated non-malignant proportion (~8% and ~12%) while the
other three sit at ~3%, against a train-pool baseline of ~6%.
This is an inherent limitation of the dataset's patient-level grouping, not of
the splitting algorithm. StratifiedGroupKFold guarantees that every fold's
*training* portion contains non-malignant-dominant patients and keeps the
majority classes (malignant, non-ROI) near-perfectly balanced across folds
(malignant spread: 913-915; non-ROI spread: 1,036-1,053). Practitioners should
report per-fold non-malignant counts alongside metrics and prefer the
macro-averaged F1 across all five folds over any single fold's score when
estimating minority-class performance.
## Dataset Statistics (after capping)
### By target3
| Malignant | Non-malignant | Non-ROI |
|----------:|--------------:|--------:|
| 6,515 | 900 | 7,506 |
### By subclass label
| Malignant | Non-malignant | Normal | Landmark | Foreign body |
|----------:|--------------:|-------:|---------:|-------------:|
| 6,515 | 900 | 7,044 | 211 | 251 |
### By cancer label
| Total | Cancer | Non-cancer |
|------:|-------:|-----------:|
| 14,921 | 6,514 | 8,407 |
### By grade label
| High-grade | Low-grade | Not applicable |
|-----------:|----------:|---------------:|
| 2,205 | 4,309 | 8,407 |
### By imaging modality
| WLI | NBI | BLC |
|----:|----:|----:|
| 14,150 | 321 | 450 |
## Features Schema
| Column | Type | Description |
|--------|------|-------------|
| `image` | Image | Cystoscopy image (decoded as PIL Image on load) |
| `cancer_label` | ClassLabel | `non_cancer` (0) / `cancer` (1) |
| `grade_label` | ClassLabel | `low_grade` (0) / `high_grade` (1) / `not_applicable` (2) |
| `subclass_label` | ClassLabel | `malignant` (0) / `non_malignant` (1) / `normal` (2) / `landmark` (3) / `foreign_body` (4) |
| `source_dataset` | string | `B`, `C`, or `D` -- original source dataset |
| `original_filename` | string | Filename in the original source dataset |
| `patient_id` | int32 | Normalized sequential patient/case ID (1-212) |
| `imaging_type` | ClassLabel | `WLI` (0) / `NBI` (1) / `BLC` (2) |
| `target3` | ClassLabel | `malignant` (0) / `non_malignant` (1) / `non_roi` (2) -- 3-class task label |
| `track_id` | string | Source B video track ID (e.g. `008`); `NA` for sources C and D |
| `cv_fold` | int32 | 5-fold CV assignment (0-4) for train patients; -1 for val/test |
## Loading
```python
from datasets import load_dataset
ds = load_dataset("milkyroad/E")
print(ds)
# DatasetDict({
# train: 10,436 images
# validation: 2,244 images
# test: 2,241 images
# })
# Access a sample
sample = ds["train"][0]
print(sample["target3"]) # 0 (malignant), 1 (non_malignant), or 2 (non_roi)
```