milkyroad commited on
Commit
bbd3b86
·
verified ·
1 Parent(s): 0814bfe

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +271 -0
README.md CHANGED
@@ -1,4 +1,14 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
2
  dataset_info:
3
  features:
4
  - name: image
@@ -71,3 +81,264 @@ configs:
71
  - split: test
72
  path: data/test-*
73
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: unknown
3
+ tags:
4
+ - medical-imaging
5
+ - cystoscopy
6
+ - bladder-cancer
7
+ - cancer-detection
8
+ - histological-grade
9
+ pretty_name: Unified Cystoscopy Cancer Detection (Dataset F)
10
+ size_categories:
11
+ - 10K<n<100K
12
  dataset_info:
13
  features:
14
  - name: image
 
81
  - split: test
82
  path: data/test-*
83
  ---
84
+
85
+ # Unified Cystoscopy Cancer Detection (Dataset F)
86
+
87
+ ## Dataset Description
88
+
89
+ Dataset **F** is derived from [Dataset E](https://huggingface.co/datasets/milkyroad/E)
90
+ by removing every **PUNLMP** frame and re-deriving a patient-level
91
+ train / validation / test split from scratch. It is prepared for 3-class deep
92
+ learning (malignant vs non-malignant vs non-ROI) and keeps the same per-image
93
+ schema as Dataset E (`image`, `cancer_label`, `grade_label`, `subclass_label`,
94
+ `source_dataset`, `original_filename`, `patient_id`, `imaging_type`, `target3`,
95
+ `track_id`, `cv_fold`).
96
+
97
+ - **Total images**: 14,376 (E had 14,921; 545 PUNLMP frames removed)
98
+ - **Unique patients / cases**: 209 (E had 212; the 3 PUNLMP-only source-B patients 6, 8, 29 are dropped)
99
+ - **Modalities**: White-Light Imaging (WLI), Narrow-Band Imaging (NBI), Blue-Light Cystoscopy (BLC)
100
+ - **Splits**: train / validation / test (70 / 15 / 15), patient-level with **no leakage**
101
+ - **5-fold cross-validation** on the train pool (`cv_fold` 0-4; -1 for val/test)
102
+
103
+ ### Relationship to Dataset E
104
+
105
+ | | Dataset E | Dataset F |
106
+ |---|---:|---:|
107
+ | Total images | 14,921 | 14,376 |
108
+ | Patients | 212 | 209 |
109
+ | non_malignant images | 900 | 355 |
110
+ | PUNLMP frames | 545 (source-B non_malignant) | 0 (excluded) |
111
+ | Split derivation | seed 16, 14 swaps | seed 17, 12 swaps (re-searched) |
112
+
113
+ ## PUNLMP Exclusion
114
+
115
+ In Dataset E, **PUNLMP** (Papillary Urothelial Neoplasm of Low Malignant Potential)
116
+ is the `histological_type` of 12 source-B videos (`milkyroad/B`), and every
117
+ source-B `non_malignant` frame in E comes from those PUNLMP videos (E patients
118
+ 6, 8, 29; tracks 028, 029, 032-037, 162-165). Therefore:
119
+
120
+ ```
121
+ PUNLMP frames == (source_dataset == 'B') AND (target3 == 'non_malignant')
122
+ ```
123
+
124
+ Removing them drops the `non_malignant` class from 900 -> 355 images, all now
125
+ coming from sources C and D. Because this makes a good patient-level split much
126
+ harder, the split is **re-derived from scratch** (Dataset F does **not** inherit
127
+ Dataset E's split assignment).
128
+
129
+ ## Source Datasets
130
+
131
+ | Code | Source | Type | Images in F | Patients in F |
132
+ |------|--------|------|------------:|---------------:|
133
+ | B | Cystoscopy video dataset (stride-8 frames) | Video frames | 4,555 | 27 |
134
+ | C | CystoDS | Still cystoscopy images | 8,067 | 160 |
135
+ | D | Kaggle cystoscopy frames | Still cystoscopy frames | 1,754 | 22 |
136
+
137
+ Source-B majority-class frames (malignant + non-ROI) in E are already capped at
138
+ **60 per (patient, track)**; Dataset F's split search used `cap=None`, i.e. it
139
+ keeps E's existing 60-cap and never adds frames. Source-B `non_malignant`
140
+ (PUNLMP) frames are excluded entirely, so all 4,555 source-B images in F are
141
+ `malignant` or `non_roi`.
142
+
143
+ ### Patient ID normalization (unchanged from E)
144
+
145
+ | Source | Original ID field | Normalized range | Count |
146
+ |--------|-------------------|-----------------|------:|
147
+ | B | `patient_id` (0-29) | 1-30 | 27 (3 PUNLMP-only patients dropped) |
148
+ | C | `pid` | 31-190 | 160 |
149
+ | D | `case_id` (0-25) | 191-212 | 22 |
150
+
151
+ ## Label Derivation
152
+
153
+ Identical to Dataset E. See E's dataset card for the full per-source mapping.
154
+ The derived 3-class task label is:
155
+
156
+ | subclass_label | target3 |
157
+ |----------------|---------|
158
+ | malignant (0) | malignant (0) |
159
+ | non_malignant (1) | non_malignant (1) |
160
+ | normal (2) | non_roi (2) |
161
+ | landmark (3) | non_roi (2) |
162
+ | foreign_body (4) | non_roi (2) |
163
+
164
+ ## Train / Validation / Test Split
165
+
166
+ Patient-level stratified split using **StratifiedGroupKFold**
167
+ (`source x dominant-class` stratification) for test, then for train/val, followed
168
+ by greedy patient-swap refinement that minimises the maximum per-class
169
+ per-split fill-ratio deviation. Hard constraints: every split contains every
170
+ class and every source; a source-floor of 4 patients per source in val and test.
171
+
172
+ A grid search over `(seed, per-track cap, source_floor)` selected the
173
+ configuration with the lowest score
174
+ (`score = max_fill_dev + penalties`):
175
+
176
+ - **Split ratio**: 70 / 15 / 15 (train / val / test)
177
+ - **Best config**: `cap=None`, `source_floor=4`, `seed=17`
178
+ - **Swaps applied**: 12
179
+ - **Max fill-ratio deviation**: 0.0047
180
+ - **No patient appears in more than one split** (verified)
181
+
182
+ ### Split sizes
183
+
184
+ | Split | Images | Patients |
185
+ |-------|-------:|---------:|
186
+ | train | 10,067 | 150 |
187
+ | validation | 2,157 | 31 |
188
+ | test | 2,152 | 28 |
189
+ | **Total** | **14,376** | **209** |
190
+
191
+ ### Class distribution per split
192
+
193
+ | Class | Total | Train | Val | Test |
194
+ |-------|------:|------:|----:|-----:|
195
+ | malignant | 6,515 (45.3%) | 4,562 | 975 | 978 |
196
+ | non_malignant | 355 (2.5%) | 249 | 53 | 53 |
197
+ | non_roi | 7,506 (52.2%) | 5,256 | 1,129 | 1,121 |
198
+
199
+ ### Fill ratios (count / target, ideal = 1.00)
200
+
201
+ | Class | Train | Val | Test |
202
+ |-------|------:|----:|-----:|
203
+ | malignant | 1.00 | 1.00 | 1.00 |
204
+ | non_malignant | 1.00 | 1.00 | 1.00 |
205
+ | non_roi | 1.00 | 1.00 | 1.00 |
206
+
207
+ ### Source x split (patients)
208
+
209
+ | Source | Train | Val | Test |
210
+ |--------|------:|----:|-----:|
211
+ | B | 19 | 4 | 4 |
212
+ | C | 117 | 23 | 20 |
213
+ | D | 14 | 4 | 4 |
214
+
215
+ ### Source x split (images)
216
+
217
+ | Source | Train | Val | Test |
218
+ |--------|------:|----:|-----:|
219
+ | B | 3,402 | 447 | 706 |
220
+ | C | 5,654 | 1,224 | 1,189 |
221
+ | D | 1,011 | 486 | 257 |
222
+
223
+ ### Non-malignant patient coverage
224
+
225
+ | Split | Patients | Images |
226
+ |-------|---------:|-------:|
227
+ | train | 53 | 249 |
228
+ | validation | 12 | 53 |
229
+ | test | 12 | 53 |
230
+
231
+ All `non_malignant` images in F come from sources C and D (source-B
232
+ non_malignant / PUNLMP is excluded).
233
+
234
+ ## 5-Fold Cross-Validation (train pool only)
235
+
236
+ StratifiedGroupKFold on the train split (per-image `target3` stratification,
237
+ patient-level grouping, no patient in multiple folds, `seed=15`, 5 folds).
238
+
239
+ | Fold | Patients | Images | Malignant | Non-mal | Non-ROI |
240
+ |-----:|---------:|-------:|----------:|--------:|--------:|
241
+ | 0 | 27 | 2,008 | 912 | 49 | 1,047 |
242
+ | 1 | 30 | 2,017 | 912 | 50 | 1,055 |
243
+ | 2 | 33 | 1,988 | 912 | 49 | 1,027 |
244
+ | 3 | 29 | 2,055 | 913 | 50 | 1,092 |
245
+ | 4 | 31 | 1,999 | 913 | 51 | 1,035 |
246
+
247
+ The `cv_fold` column is -1 for validation and test patients.
248
+
249
+ ### Note on minority-class (non-malignant) fold balance
250
+
251
+ After PUNLMP exclusion the `non_malignant` class shrinks to 355 images and
252
+ remains heavily patient-concentrated: only 53 train patients carry
253
+ non_malignant frames and a few patients dominate the count. Because
254
+ cross-validation is patient-grouped (a patient never appears in more than one
255
+ fold), high-volume patients cannot be split across folds, so the per-fold
256
+ non-malignant count varies modestly (49-51) while the majority classes stay
257
+ near-perfectly balanced (malignant spread 912-913; non-ROI spread 1,027-1,092).
258
+ Practitioners should report per-fold non-malignant counts alongside metrics and
259
+ prefer the macro-averaged F1 across all five folds over any single fold's score
260
+ when estimating minority-class performance.
261
+
262
+ ## Dataset Statistics
263
+
264
+ ### By target3
265
+
266
+ | Malignant | Non-malignant | Non-ROI |
267
+ |----------:|--------------:|--------:|
268
+ | 6,515 | 355 | 7,506 |
269
+
270
+ ### By subclass label
271
+
272
+ | Malignant | Non-malignant | Normal | Landmark | Foreign body |
273
+ |----------:|--------------:|-------:|---------:|-------------:|
274
+ | 6,515 | 355 | 7,044 | 211 | 251 |
275
+
276
+ ### By cancer label
277
+
278
+ | Total | Cancer | Non-cancer |
279
+ |------:|-------:|-----------:|
280
+ | 14,376 | 6,514 | 7,862 |
281
+
282
+ ### By grade label
283
+
284
+ | High-grade | Low-grade | Not applicable |
285
+ |-----------:|----------:|---------------:|
286
+ | 2,205 | 4,309 | 7,862 |
287
+
288
+ ### By imaging modality
289
+
290
+ | WLI | NBI | BLC |
291
+ |----:|----:|----:|
292
+ | 13,605 | 321 | 450 |
293
+
294
+ ### By source
295
+
296
+ | B | C | D |
297
+ |---:|---:|---:|
298
+ | 4,555 | 8,067 | 1,754 |
299
+
300
+ ## Features Schema
301
+
302
+ | Column | Type | Description |
303
+ |--------|------|-------------|
304
+ | `image` | Image | Cystoscopy image (decoded as PIL Image on load) |
305
+ | `cancer_label` | ClassLabel | `non_cancer` (0) / `cancer` (1) |
306
+ | `grade_label` | ClassLabel | `low_grade` (0) / `high_grade` (1) / `not_applicable` (2) |
307
+ | `subclass_label` | ClassLabel | `malignant` (0) / `non_malignant` (1) / `normal` (2) / `landmark` (3) / `foreign_body` (4) |
308
+ | `source_dataset` | string | `B`, `C`, or `D` -- original source dataset |
309
+ | `original_filename` | string | Filename in the original source dataset |
310
+ | `patient_id` | int32 | Normalized sequential patient/case ID (1-212) |
311
+ | `imaging_type` | ClassLabel | `WLI` (0) / `NBI` (1) / `BLC` (2) |
312
+ | `target3` | ClassLabel | `malignant` (0) / `non_malignant` (1) / `non_roi` (2) -- 3-class task label |
313
+ | `track_id` | string | Source-B video track ID (e.g. `008`); `NA` for sources C and D |
314
+ | `cv_fold` | int64 | 5-fold CV assignment (0-4) for train patients; -1 for val/test |
315
+
316
+ ## Loading
317
+
318
+ ```python
319
+ from datasets import load_dataset
320
+
321
+ ds = load_dataset("milkyroad/F")
322
+ print(ds)
323
+ # DatasetDict({
324
+ # train: 10,067 images
325
+ # validation: 2,157 images
326
+ # test: 2,152 images
327
+ # })
328
+
329
+ sample = ds["train"][0]
330
+ print(sample["target3"]) # 0 (malignant), 1 (non_malignant), or 2 (non_roi)
331
+ ```
332
+
333
+ ## Provenance
334
+
335
+ Built from `milkyroad/E` by:
336
+ 1. Dropping all PUNLMP frames (`source_dataset == 'B'` and `target3 == 'non_malignant'`).
337
+ 2. Grid-searching `(seed, cap, source_floor)` for the patient-level split that
338
+ minimises the maximum per-class per-split fill-ratio deviation, with hard
339
+ coverage constraints.
340
+ 3. Attaching a 5-fold StratifiedGroupKFold CV assignment (`seed=15`) to the
341
+ train pool.
342
+
343
+ Selected config: `cap=None`, `source_floor=4`, `seed=17`, 12 swaps,
344
+ max fill-ratio deviation 0.0047.