--- license: unknown tags: - medical-imaging - cystoscopy - bladder-cancer - cancer-detection - histological-grade pretty_name: Unified Cystoscopy Cancer Detection (Dataset F) size_categories: - 10K 355 images, all now coming from sources C and D. Because this makes a good patient-level split much harder, the split is **re-derived from scratch** (Dataset F does **not** inherit Dataset E's split assignment). ## Source Datasets | Code | Source | Type | Images in F | Patients in F | |------|--------|------|------------:|---------------:| | B | Cystoscopy video dataset (stride-8 frames) | Video frames | 4,555 | 27 | | C | CystoDS | Still cystoscopy images | 8,067 | 160 | | D | Kaggle cystoscopy frames | Still cystoscopy frames | 1,754 | 22 | Source-B majority-class frames (malignant + non-ROI) in E are already capped at **60 per (patient, track)**; Dataset F's split search used `cap=None`, i.e. it keeps E's existing 60-cap and never adds frames. Source-B `non_malignant` (PUNLMP) frames are excluded entirely, so all 4,555 source-B images in F are `malignant` or `non_roi`. ### Patient ID normalization (unchanged from E) | Source | Original ID field | Normalized range | Count | |--------|-------------------|-----------------|------:| | B | `patient_id` (0-29) | 1-30 | 27 (3 PUNLMP-only patients dropped) | | C | `pid` | 31-190 | 160 | | D | `case_id` (0-25) | 191-212 | 22 | ## Label Derivation Identical to Dataset E. See E's dataset card for the full per-source mapping. The derived 3-class task label is: | 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) | ## Train / Validation / Test Split Patient-level stratified split using **StratifiedGroupKFold** (`source x dominant-class` stratification) for test, then for train/val, followed by greedy patient-swap refinement that minimises the maximum per-class per-split fill-ratio deviation. Hard constraints: every split contains every class and every source; a source-floor of 4 patients per source in val and test. A grid search over `(seed, per-track cap, source_floor)` selected the configuration with the lowest score (`score = max_fill_dev + penalties`): - **Split ratio**: 70 / 15 / 15 (train / val / test) - **Best config**: `cap=None`, `source_floor=4`, `seed=17` - **Swaps applied**: 12 - **Max fill-ratio deviation**: 0.0047 - **No patient appears in more than one split** (verified) ### Split sizes | Split | Images | Patients | |-------|-------:|---------:| | train | 10,067 | 150 | | validation | 2,157 | 31 | | test | 2,152 | 28 | | **Total** | **14,376** | **209** | ### Class distribution per split | Class | Total | Train | Val | Test | |-------|------:|------:|----:|-----:| | malignant | 6,515 (45.3%) | 4,562 | 975 | 978 | | non_malignant | 355 (2.5%) | 249 | 53 | 53 | | non_roi | 7,506 (52.2%) | 5,256 | 1,129 | 1,121 | ### Fill ratios (count / target, ideal = 1.00) | Class | Train | Val | Test | |-------|------:|----:|-----:| | malignant | 1.00 | 1.00 | 1.00 | | non_malignant | 1.00 | 1.00 | 1.00 | | non_roi | 1.00 | 1.00 | 1.00 | ### Source x split (patients) | Source | Train | Val | Test | |--------|------:|----:|-----:| | B | 19 | 4 | 4 | | C | 117 | 23 | 20 | | D | 14 | 4 | 4 | ### Source x split (images) | Source | Train | Val | Test | |--------|------:|----:|-----:| | B | 3,402 | 447 | 706 | | C | 5,654 | 1,224 | 1,189 | | D | 1,011 | 486 | 257 | ### Non-malignant patient coverage | Split | Patients | Images | |-------|---------:|-------:| | train | 53 | 249 | | validation | 12 | 53 | | test | 12 | 53 | All `non_malignant` images in F come from sources C and D (source-B non_malignant / PUNLMP is excluded). ## 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`, 5 folds). | Fold | Patients | Images | Malignant | Non-mal | Non-ROI | |-----:|---------:|-------:|----------:|--------:|--------:| | 0 | 27 | 2,008 | 912 | 49 | 1,047 | | 1 | 30 | 2,017 | 912 | 50 | 1,055 | | 2 | 33 | 1,988 | 912 | 49 | 1,027 | | 3 | 29 | 2,055 | 913 | 50 | 1,092 | | 4 | 31 | 1,999 | 913 | 51 | 1,035 | The `cv_fold` column is -1 for validation and test patients. ### Note on minority-class (non-malignant) fold balance After PUNLMP exclusion the `non_malignant` class shrinks to 355 images and remains heavily patient-concentrated: only 53 train patients carry non_malignant frames and a few patients dominate the count. Because cross-validation is patient-grouped (a patient never appears in more than one fold), high-volume patients cannot be split across folds, so the per-fold non-malignant count varies modestly (49-51) while the majority classes stay near-perfectly balanced (malignant spread 912-913; non-ROI spread 1,027-1,092). 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 ### By target3 | Malignant | Non-malignant | Non-ROI | |----------:|--------------:|--------:| | 6,515 | 355 | 7,506 | ### By subclass label | Malignant | Non-malignant | Normal | Landmark | Foreign body | |----------:|--------------:|-------:|---------:|-------------:| | 6,515 | 355 | 7,044 | 211 | 251 | ### By cancer label | Total | Cancer | Non-cancer | |------:|-------:|-----------:| | 14,376 | 6,514 | 7,862 | ### By grade label | High-grade | Low-grade | Not applicable | |-----------:|----------:|---------------:| | 2,205 | 4,309 | 7,862 | ### By imaging modality | WLI | NBI | BLC | |----:|----:|----:| | 13,605 | 321 | 450 | ### By source | B | C | D | |---:|---:|---:| | 4,555 | 8,067 | 1,754 | ## 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` | int64 | 5-fold CV assignment (0-4) for train patients; -1 for val/test | ## Loading ```python from datasets import load_dataset ds = load_dataset("milkyroad/F") print(ds) # DatasetDict({ # train: 10,067 images # validation: 2,157 images # test: 2,152 images # }) sample = ds["train"][0] print(sample["target3"]) # 0 (malignant), 1 (non_malignant), or 2 (non_roi) ``` ## Provenance Built from `milkyroad/E` by: 1. Dropping all PUNLMP frames (`source_dataset == 'B'` and `target3 == 'non_malignant'`). 2. Grid-searching `(seed, cap, source_floor)` for the patient-level split that minimises the maximum per-class per-split fill-ratio deviation, with hard coverage constraints. 3. Attaching a 5-fold StratifiedGroupKFold CV assignment (`seed=15`) to the train pool. Selected config: `cap=None`, `source_floor=4`, `seed=17`, 12 swaps, max fill-ratio deviation 0.0047.