B
File size: 3,553 Bytes
d38e133
 
 
 
 
 
 
 
 
 
 
 
 
75bd513
d38e133
 
 
 
358aa39
d38e133
 
 
 
358aa39
 
 
 
d38e133
358aa39
d38e133
358aa39
 
d38e133
358aa39
d38e133
358aa39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d38e133
 
 
 
358aa39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d38e133
 
358aa39
d38e133
358aa39
 
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
---
language:
- en
license: unknown
task_categories:
- object-detection
tags:
- medical
- cystoscopy
- bladder-cancer
- tumor-detection
- video
size_categories:
- 100M<n<1B
configs:
- config_name: default
  data_files:
  - split: train
    path: data/train-*.parquet
---

# Cystoscopy Tumor Detection

Cystoscopic video dataset with per-frame `tumor` bounding-box annotations,
paired with patient-level clinical metadata. Flattened into a single `train`
split with one row per video; videos are embedded in the Parquet shards as HF
`Video` features and bounding boxes are stored inline.

## Why no splits

This dataset ships **one `train` split only**. Use the `patient_id` column to
build your own patient-grouped splits to prevent leakage. 30 unique patients.

## Columns

| Column | Type | Description |
|---|---|---|
| `video` | `Video` | Embedded video bytes (`decode=False` — returns `{bytes, path}`; cast to `Video(decode=True)` to decode frames, requires `torchcodec`). |
| `video_id` | `string` | Filename stem, e.g. `P000_cystoscopy_track_000`. |
| `patient_id` | `int64` | Patient id — use this for group-aware splitting. |
| `boxes` | `struct` | Per-box annotations as parallel lists (see below). `n = len(boxes["frame"])` boxes for this video. |
| `n_boxes` | `int64` | Number of boxes for this video. |
| `histological_type` | `string` | Patient-level histology (e.g. `Urothelial carcinoma pTaLG`). |
| `num_frames` | `int64` | Patient-level total annotated frames. |
| `light_mode` | `string` | Imaging light mode (e.g. `CLARA + CHROMA`). |

### `boxes` struct fields

Each field is a list of length `n_boxes`; index `i` across all fields
describes one box.

| Field | Type | Description |
|---|---|---|
| `track_id` | `int64` | Annotation track within the video. |
| `frame` | `int64` | Frame number the box belongs to. |
| `label` | `string` | Box label (always `tumor`). |
| `xtl`, `ytl`, `xbr`, `ybr` | `float32` | Absolute pixel coordinates (CVAT format). |
| `occluded` | `int64` | Occlusion flag. |
| `outside` | `int64` | Outside flag. |
| `keyframe` | `int64` | Keyframe flag. |
| `z_order` | `int64` | Z-order. |

## Contents

- 173 cystoscopy `.mp4` videos (~4 GB, embedded).
- 69 108 bounding boxes across 444 annotation tracks.
- 30 patients with clinical metadata.

## Loading

```python
from datasets import load_dataset
ds = load_dataset("milkyroad/B", split="train")
# video is not decoded by default (no torchcodec required to load)
print(ds[0]["video"])          # {'bytes': ..., 'path': 'P000_cystoscopy_track_000.mp4'}
print(ds[0]["n_boxes"])        # 233
boxes = ds[0]["boxes"]
print(boxes["frame"][0], boxes["label"][0], boxes["xtl"][0])
```

### Decode video frames

To decode frames, install `torchcodec` and cast the column:

```python
from datasets import Video
ds = ds.cast_column("video", Video(decode=True))
```

## Group-aware split example

```python
import random
ds = load_dataset("milkyroad/B", split="train")
pids = sorted({r["patient_id"] for r in ds})
random.Random(42).shuffle(pids)
n_test, n_val = 3, 3
test_pids = set(pids[:n_test])
val_pids = set(pids[n_test:n_test + n_val])
train = ds.filter(lambda r: r["patient_id"] not in test_pids and r["patient_id"] not in val_pids)
val   = ds.filter(lambda r: r["patient_id"] in val_pids)
test  = ds.filter(lambda r: r["patient_id"] in test_pids)
```

## Notes

- Box coordinates are absolute pixel coordinates in the source video frames (CVAT format).
- Splits should be by **patient** to prevent leakage; `patient_id` is provided for this purpose.