Datasets:
Commit ·
fe50be6
1
Parent(s): b4bc3cb
[doc] chore: update doc
Browse files- MedVision.py +10 -2
- README.md +365 -1
- doc/changelog.md +1 -0
MedVision.py
CHANGED
|
@@ -31,12 +31,20 @@ RAMDOM_SEED = 1024
|
|
| 31 |
SPLIT_TRAIN_RATIO = 0.7
|
| 32 |
|
| 33 |
_CITATION = """\
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"""
|
| 37 |
|
| 38 |
_DESCRIPTION = """\
|
| 39 |
This is the official release of the MedVision dataset.
|
|
|
|
| 40 |
"""
|
| 41 |
|
| 42 |
_HOME_PAGE = "https://huggingface.co/datasets/YongchengYAO/MedVision"
|
|
|
|
| 31 |
SPLIT_TRAIN_RATIO = 0.7
|
| 32 |
|
| 33 |
_CITATION = """\
|
| 34 |
+
@misc{yao2025medvisiondatasetbenchmarkquantitative,
|
| 35 |
+
title={MedVision: Dataset and Benchmark for Quantitative Medical Image Analysis},
|
| 36 |
+
author={Yongcheng Yao and Yongshuo Zong and Raman Dutt and Yongxin Yang and Sotirios A Tsaftaris and Timothy Hospedales},
|
| 37 |
+
year={2025},
|
| 38 |
+
eprint={2511.18676},
|
| 39 |
+
archivePrefix={arXiv},
|
| 40 |
+
primaryClass={cs.CV},
|
| 41 |
+
url={https://arxiv.org/abs/2511.18676},
|
| 42 |
+
}
|
| 43 |
"""
|
| 44 |
|
| 45 |
_DESCRIPTION = """\
|
| 46 |
This is the official release of the MedVision dataset.
|
| 47 |
+
Project: https://medvision-vlm.github.io
|
| 48 |
"""
|
| 49 |
|
| 50 |
_HOME_PAGE = "https://huggingface.co/datasets/YongchengYAO/MedVision"
|
README.md
CHANGED
|
@@ -114,7 +114,7 @@ For essential updates, check the [change log](https://huggingface.co/datasets/Yo
|
|
| 114 |
|
| 115 |
<br/>
|
| 116 |
|
| 117 |
-
#
|
| 118 |
To add new datasets, check this [blog](https://huggingface.co/blog/Yongch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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
# Advanced Usage
|
| 167 |
|
| 168 |
The dataset codebase `medvision_ds` can be used to scale the dataset, including adding new annotation types and datasets.
|
|
|
|
| 114 |
|
| 115 |
<br/>
|
| 116 |
|
| 117 |
+
# New Datasets Guide
|
| 118 |
To add new datasets, check this [blog](https://huggingface.co/blog/YongchengYAO/medvision-dataset) for an introduction of MedVision dataset.
|
| 119 |
|
| 120 |
# Requirement
|
|
|
|
| 163 |
|
| 164 |
<br/>
|
| 165 |
|
| 166 |
+
# 📖 Essential Dataset Concept
|
| 167 |
+
|
| 168 |
+
We cover some essential concepts that help we use the MedVision dataset with ease.
|
| 169 |
+
|
| 170 |
+
## Concepts: Dataset & Data Configuration
|
| 171 |
+
|
| 172 |
+
- `MedVision`: the collection of public imaging data and our annotations
|
| 173 |
+
- `dataset`: name of the public datasets, such `BraTS24`, `MSD`, `OAIZIB-CM`
|
| 174 |
+
- `data-config`: name of predefined subsets
|
| 175 |
+
- naming convention: `{dataset}_{annotation-type}_{task-ID}_{slice}_{split}`
|
| 176 |
+
- `dataset`: [details](https://huggingface.co/datasets/YongchengYAO/MedVision#datasets)
|
| 177 |
+
- `annotation-type`:
|
| 178 |
+
- `BoxSize`: detection annotations (bounding box)
|
| 179 |
+
- `TumorLesionSize`: tumor/lesion size annotations
|
| 180 |
+
- `BiometricsFromLandmarks`: angle/distance annotations
|
| 181 |
+
- `task-ID`: `Task[xx]` (Note, this is a local ID in the dataset, not a glocal ID in MedVision.)
|
| 182 |
+
- For datasets with multiple image-mask pairs, we defined tasks in `medvision_ds/datasets/*/preprocess_*.py`
|
| 183 |
+
- source: [medvision_ds](https://huggingface.co/datasets/YongchengYAO/MedVision/tree/main/src)
|
| 184 |
+
- e.g., detection tasks for the `BraTS24` dataset is defined in the `benchmark_plan` in `medvision_ds/datasets/BraTS24/preprocess_detection.py`
|
| 185 |
+
- `slice`: [`Sagittal`, `Coronal`, `Axial`]
|
| 186 |
+
- `split`: [`Train`, `Test`]
|
| 187 |
+
|
| 188 |
+
## What's returned from MedVision Dataset?
|
| 189 |
+
|
| 190 |
+
We only share the annotations (https://huggingface.co/datasets/YongchengYAO/MedVision/tree/main/Datasets). The data loading script [`MedVision.py`](https://huggingface.co/datasets/YongchengYAO/MedVision/blob/main/MedVision.py) will handle raw image downloading and processing. The returned fields in each sample is defined as followed.
|
| 191 |
+
|
| 192 |
+
⚠️ In `MedVision.py`, the class `MedVision(GeneratorBasedBuilder)` defines the feature dict and the method `_generate_examples()` builds the dataset.
|
| 193 |
+
|
| 194 |
+
<details>
|
| 195 |
+
<summary>Code block in `MedVision(GeneratorBasedBuilder)` (Click to expand)</summary>
|
| 196 |
+
|
| 197 |
+
``` python
|
| 198 |
+
"""
|
| 199 |
+
MedVision dataset.
|
| 200 |
+
|
| 201 |
+
NOTE: To update the features returned by the load_dataset() method, the followings should be updated:
|
| 202 |
+
- the feature dict in this class
|
| 203 |
+
- the dict yielded by the _generate_examples() method
|
| 204 |
+
"""
|
| 205 |
+
|
| 206 |
+
# The feature dict for the task:
|
| 207 |
+
# - Mask-Size
|
| 208 |
+
features_dict_MaskSize = {
|
| 209 |
+
"dataset_name": Value("string"),
|
| 210 |
+
"taskID": Value("string"),
|
| 211 |
+
"taskType": Value("string"),
|
| 212 |
+
"image_file": Value("string"),
|
| 213 |
+
"mask_file": Value("string"),
|
| 214 |
+
"slice_dim": Value("uint8"),
|
| 215 |
+
"slice_idx": Value("uint16"),
|
| 216 |
+
"label": Value("uint16"),
|
| 217 |
+
"image_size_2d": Sequence(Value("uint16"), length=2),
|
| 218 |
+
"pixel_size": Sequence(Value("float16"), length=2),
|
| 219 |
+
"image_size_3d": Sequence(Value("uint16"), length=3),
|
| 220 |
+
"voxel_size": Sequence(Value("float16"), length=3),
|
| 221 |
+
"pixel_count": Value("uint32"),
|
| 222 |
+
"ROI_area": Value("float16"),
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
# The feature dict for the task:
|
| 226 |
+
# - Box-Size
|
| 227 |
+
features_dict_BoxSize = {
|
| 228 |
+
"dataset_name": Value("string"),
|
| 229 |
+
"taskID": Value("string"),
|
| 230 |
+
"taskType": Value("string"),
|
| 231 |
+
"image_file": Value("string"),
|
| 232 |
+
"mask_file": Value("string"),
|
| 233 |
+
"slice_dim": Value("uint8"),
|
| 234 |
+
"slice_idx": Value("uint16"),
|
| 235 |
+
"label": Value("uint16"),
|
| 236 |
+
"image_size_2d": Sequence(Value("uint16"), length=2),
|
| 237 |
+
"pixel_size": Sequence(Value("float16"), length=2),
|
| 238 |
+
"image_size_3d": Sequence(Value("uint16"), length=3),
|
| 239 |
+
"voxel_size": Sequence(Value("float16"), length=3),
|
| 240 |
+
"bounding_boxes": Sequence(
|
| 241 |
+
{
|
| 242 |
+
"min_coords": Sequence(Value("uint16"), length=2),
|
| 243 |
+
"max_coords": Sequence(Value("uint16"), length=2),
|
| 244 |
+
"center_coords": Sequence(Value("uint16"), length=2),
|
| 245 |
+
"dimensions": Sequence(Value("uint16"), length=2),
|
| 246 |
+
"sizes": Sequence(Value("float16"), length=2),
|
| 247 |
+
},
|
| 248 |
+
),
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
features_dict_BiometricsFromLandmarks = {
|
| 252 |
+
"dataset_name": Value("string"),
|
| 253 |
+
"taskID": Value("string"),
|
| 254 |
+
"taskType": Value("string"),
|
| 255 |
+
"image_file": Value("string"),
|
| 256 |
+
"landmark_file": Value("string"),
|
| 257 |
+
"slice_dim": Value("uint8"),
|
| 258 |
+
"slice_idx": Value("uint16"),
|
| 259 |
+
"image_size_2d": Sequence(Value("uint16"), length=2),
|
| 260 |
+
"pixel_size": Sequence(Value("float16"), length=2),
|
| 261 |
+
"image_size_3d": Sequence(Value("uint16"), length=3),
|
| 262 |
+
"voxel_size": Sequence(Value("float16"), length=3),
|
| 263 |
+
"biometric_profile": {
|
| 264 |
+
"metric_type": Value("string"),
|
| 265 |
+
"metric_map_name": Value("string"),
|
| 266 |
+
"metric_key": Value("string"),
|
| 267 |
+
"metric_value": Value("float16"),
|
| 268 |
+
"metric_unit": Value("string"),
|
| 269 |
+
"slice_dim": Value("uint8"),
|
| 270 |
+
},
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
features_dict_TumorLesionSize = {
|
| 274 |
+
"dataset_name": Value("string"),
|
| 275 |
+
"taskID": Value("string"),
|
| 276 |
+
"taskType": Value("string"),
|
| 277 |
+
"image_file": Value("string"),
|
| 278 |
+
"landmark_file": Value("string"),
|
| 279 |
+
"mask_file": Value("string"),
|
| 280 |
+
"slice_dim": Value("uint8"),
|
| 281 |
+
"slice_idx": Value("uint16"),
|
| 282 |
+
"label": Value("uint16"),
|
| 283 |
+
"image_size_2d": Sequence(Value("uint16"), length=2),
|
| 284 |
+
"pixel_size": Sequence(Value("float16"), length=2),
|
| 285 |
+
"image_size_3d": Sequence(Value("uint16"), length=3),
|
| 286 |
+
"voxel_size": Sequence(Value("float16"), length=3),
|
| 287 |
+
"biometric_profile": Sequence(
|
| 288 |
+
{
|
| 289 |
+
"metric_type": Value("string"),
|
| 290 |
+
"metric_map_name": Value("string"),
|
| 291 |
+
"metric_key_major_axis": Value("string"),
|
| 292 |
+
"metric_value_major_axis": Value("float16"),
|
| 293 |
+
"metric_key_minor_axis": Value("string"),
|
| 294 |
+
"metric_value_minor_axis": Value("float16"),
|
| 295 |
+
"metric_unit": Value("string"),
|
| 296 |
+
},
|
| 297 |
+
),
|
| 298 |
+
}
|
| 299 |
+
```
|
| 300 |
+
</details>
|
| 301 |
+
|
| 302 |
+
<details>
|
| 303 |
+
<summary>Code block in `_generate_examples` (Click to expand)</summary>
|
| 304 |
+
|
| 305 |
+
```python
|
| 306 |
+
# Task type: Mask-Size
|
| 307 |
+
if taskType == "Mask-Size":
|
| 308 |
+
flatten_slice_profiles = (
|
| 309 |
+
MedVision_BenchmarkPlannerSegmentation.flatten_slice_profiles_2d
|
| 310 |
+
)
|
| 311 |
+
if imageSliceType.lower() == "sagittal":
|
| 312 |
+
slice_dim = 0
|
| 313 |
+
elif imageSliceType.lower() == "coronal":
|
| 314 |
+
slice_dim = 1
|
| 315 |
+
elif imageSliceType.lower() == "axial":
|
| 316 |
+
slice_dim = 2
|
| 317 |
+
slice_profile_flattened = flatten_slice_profiles(biometricData, slice_dim)
|
| 318 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 319 |
+
# Skip cases with a mask size smaller than 200 pixels
|
| 320 |
+
if case["pixel_count"] < 200:
|
| 321 |
+
continue
|
| 322 |
+
else:
|
| 323 |
+
yield idx, {
|
| 324 |
+
"dataset_name": dataset_name,
|
| 325 |
+
"taskID": taskID,
|
| 326 |
+
"taskType": taskType,
|
| 327 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 328 |
+
"mask_file": os.path.join(dataset_dir, case["mask_file"]),
|
| 329 |
+
"slice_dim": case["slice_dim"],
|
| 330 |
+
"slice_idx": case["slice_idx"],
|
| 331 |
+
"label": case["label"],
|
| 332 |
+
"image_size_2d": case["image_size_2d"],
|
| 333 |
+
"pixel_size": case["pixel_size"],
|
| 334 |
+
"image_size_3d": case["image_size_3d"],
|
| 335 |
+
"voxel_size": case["voxel_size"],
|
| 336 |
+
"pixel_count": case["pixel_count"],
|
| 337 |
+
"ROI_area": case["ROI_area"],
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
# Task type: Box-Size
|
| 341 |
+
if taskType == "Box-Size":
|
| 342 |
+
if imageType.lower() == "2d":
|
| 343 |
+
flatten_slice_profiles = (
|
| 344 |
+
MedVision_BenchmarkPlannerDetection.flatten_slice_profiles_2d
|
| 345 |
+
)
|
| 346 |
+
if imageSliceType.lower() == "sagittal":
|
| 347 |
+
slice_dim = 0
|
| 348 |
+
elif imageSliceType.lower() == "coronal":
|
| 349 |
+
slice_dim = 1
|
| 350 |
+
elif imageSliceType.lower() == "axial":
|
| 351 |
+
slice_dim = 2
|
| 352 |
+
slice_profile_flattened = flatten_slice_profiles(
|
| 353 |
+
biometricData, slice_dim
|
| 354 |
+
)
|
| 355 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 356 |
+
# Skip cases with multiple bounding boxes in the same slice
|
| 357 |
+
if len(case["bounding_boxes"]) > 1:
|
| 358 |
+
continue
|
| 359 |
+
# Skip cases with a bounding box size smaller than 10 pixels in any dimension
|
| 360 |
+
elif (
|
| 361 |
+
case["bounding_boxes"][0]["dimensions"][0] < 10
|
| 362 |
+
or case["bounding_boxes"][0]["dimensions"][1] < 10
|
| 363 |
+
):
|
| 364 |
+
continue
|
| 365 |
+
else:
|
| 366 |
+
yield idx, {
|
| 367 |
+
"dataset_name": dataset_name,
|
| 368 |
+
"taskID": taskID,
|
| 369 |
+
"taskType": taskType,
|
| 370 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 371 |
+
"mask_file": os.path.join(dataset_dir, case["mask_file"]),
|
| 372 |
+
"slice_dim": case["slice_dim"],
|
| 373 |
+
"slice_idx": case["slice_idx"],
|
| 374 |
+
"label": case["label"],
|
| 375 |
+
"image_size_2d": case["image_size_2d"],
|
| 376 |
+
"pixel_size": case["pixel_size"],
|
| 377 |
+
"image_size_3d": case["image_size_3d"],
|
| 378 |
+
"voxel_size": case["voxel_size"],
|
| 379 |
+
"bounding_boxes": case["bounding_boxes"],
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
# Task type: Biometrics-From-Landmarks
|
| 383 |
+
if taskType == "Biometrics-From-Landmarks":
|
| 384 |
+
if imageType.lower() == "2d":
|
| 385 |
+
flatten_slice_profiles = (
|
| 386 |
+
MedVision_BenchmarkPlannerBiometry.flatten_slice_profiles_2d
|
| 387 |
+
)
|
| 388 |
+
if imageSliceType.lower() == "sagittal":
|
| 389 |
+
slice_dim = 0
|
| 390 |
+
elif imageSliceType.lower() == "coronal":
|
| 391 |
+
slice_dim = 1
|
| 392 |
+
elif imageSliceType.lower() == "axial":
|
| 393 |
+
slice_dim = 2
|
| 394 |
+
slice_profile_flattened = flatten_slice_profiles(
|
| 395 |
+
biometricData, slice_dim
|
| 396 |
+
)
|
| 397 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 398 |
+
yield idx, {
|
| 399 |
+
"dataset_name": dataset_name,
|
| 400 |
+
"taskID": taskID,
|
| 401 |
+
"taskType": taskType,
|
| 402 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 403 |
+
"landmark_file": os.path.join(
|
| 404 |
+
dataset_dir, case["landmark_file"]
|
| 405 |
+
),
|
| 406 |
+
"slice_dim": case["slice_dim"],
|
| 407 |
+
"slice_idx": case["slice_idx"],
|
| 408 |
+
"image_size_2d": case["image_size_2d"],
|
| 409 |
+
"pixel_size": case["pixel_size"],
|
| 410 |
+
"image_size_3d": case["image_size_3d"],
|
| 411 |
+
"voxel_size": case["voxel_size"],
|
| 412 |
+
"biometric_profile": case["biometric_profile"],
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
# Task type: Biometrics-From-Landmarks-Distance
|
| 416 |
+
if taskType == "Biometrics-From-Landmarks-Distance":
|
| 417 |
+
if imageType.lower() == "2d":
|
| 418 |
+
flatten_slice_profiles = (
|
| 419 |
+
MedVision_BenchmarkPlannerBiometry.flatten_slice_profiles_2d
|
| 420 |
+
)
|
| 421 |
+
if imageSliceType.lower() == "sagittal":
|
| 422 |
+
slice_dim = 0
|
| 423 |
+
elif imageSliceType.lower() == "coronal":
|
| 424 |
+
slice_dim = 1
|
| 425 |
+
elif imageSliceType.lower() == "axial":
|
| 426 |
+
slice_dim = 2
|
| 427 |
+
slice_profile_flattened = flatten_slice_profiles(
|
| 428 |
+
biometricData, slice_dim
|
| 429 |
+
)
|
| 430 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 431 |
+
if case["biometric_profile"]["metric_type"] == "distance":
|
| 432 |
+
yield idx, {
|
| 433 |
+
"dataset_name": dataset_name,
|
| 434 |
+
"taskID": taskID,
|
| 435 |
+
"taskType": taskType,
|
| 436 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 437 |
+
"landmark_file": os.path.join(
|
| 438 |
+
dataset_dir, case["landmark_file"]
|
| 439 |
+
),
|
| 440 |
+
"slice_dim": case["slice_dim"],
|
| 441 |
+
"slice_idx": case["slice_idx"],
|
| 442 |
+
"image_size_2d": case["image_size_2d"],
|
| 443 |
+
"pixel_size": case["pixel_size"],
|
| 444 |
+
"image_size_3d": case["image_size_3d"],
|
| 445 |
+
"voxel_size": case["voxel_size"],
|
| 446 |
+
"biometric_profile": case["biometric_profile"],
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
# Task type: Biometrics-From-Landmarks-Angle
|
| 450 |
+
if taskType == "Biometrics-From-Landmarks-Angle":
|
| 451 |
+
if imageType.lower() == "2d":
|
| 452 |
+
flatten_slice_profiles = (
|
| 453 |
+
MedVision_BenchmarkPlannerBiometry.flatten_slice_profiles_2d
|
| 454 |
+
)
|
| 455 |
+
if imageSliceType.lower() == "sagittal":
|
| 456 |
+
slice_dim = 0
|
| 457 |
+
elif imageSliceType.lower() == "coronal":
|
| 458 |
+
slice_dim = 1
|
| 459 |
+
elif imageSliceType.lower() == "axial":
|
| 460 |
+
slice_dim = 2
|
| 461 |
+
slice_profile_flattened = flatten_slice_profiles(
|
| 462 |
+
biometricData, slice_dim
|
| 463 |
+
)
|
| 464 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 465 |
+
if case["biometric_profile"]["metric_type"] == "angle":
|
| 466 |
+
yield idx, {
|
| 467 |
+
"dataset_name": dataset_name,
|
| 468 |
+
"taskID": taskID,
|
| 469 |
+
"taskType": taskType,
|
| 470 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 471 |
+
"landmark_file": os.path.join(
|
| 472 |
+
dataset_dir, case["landmark_file"]
|
| 473 |
+
),
|
| 474 |
+
"slice_dim": case["slice_dim"],
|
| 475 |
+
"slice_idx": case["slice_idx"],
|
| 476 |
+
"image_size_2d": case["image_size_2d"],
|
| 477 |
+
"pixel_size": case["pixel_size"],
|
| 478 |
+
"image_size_3d": case["image_size_3d"],
|
| 479 |
+
"voxel_size": case["voxel_size"],
|
| 480 |
+
"biometric_profile": case["biometric_profile"],
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
# Task type: Tumor-Lesion-Size
|
| 484 |
+
if taskType == "Tumor-Lesion-Size":
|
| 485 |
+
if imageType.lower() == "2d":
|
| 486 |
+
# Get the target label for the task
|
| 487 |
+
target_label = benchmark_plan["tasks"][int(taskID) - 1]["target_label"]
|
| 488 |
+
|
| 489 |
+
flatten_slice_profiles = (
|
| 490 |
+
MedVision_BenchmarkPlannerBiometry_fromSeg.flatten_slice_profiles_2d
|
| 491 |
+
)
|
| 492 |
+
if imageSliceType.lower() == "sagittal":
|
| 493 |
+
slice_dim = 0
|
| 494 |
+
elif imageSliceType.lower() == "coronal":
|
| 495 |
+
slice_dim = 1
|
| 496 |
+
elif imageSliceType.lower() == "axial":
|
| 497 |
+
slice_dim = 2
|
| 498 |
+
slice_profile_flattened = flatten_slice_profiles(
|
| 499 |
+
biometricData, slice_dim
|
| 500 |
+
)
|
| 501 |
+
for idx, case in enumerate(slice_profile_flattened):
|
| 502 |
+
# Skip cases with multiple fitted ellipses in the same slice
|
| 503 |
+
if len(case["biometric_profile"]) > 1:
|
| 504 |
+
continue
|
| 505 |
+
else:
|
| 506 |
+
yield idx, {
|
| 507 |
+
"dataset_name": dataset_name,
|
| 508 |
+
"taskID": taskID,
|
| 509 |
+
"taskType": taskType,
|
| 510 |
+
"image_file": os.path.join(dataset_dir, case["image_file"]),
|
| 511 |
+
"mask_file": os.path.join(dataset_dir, case["mask_file"]),
|
| 512 |
+
"landmark_file": os.path.join(
|
| 513 |
+
dataset_dir, case["landmark_file"]
|
| 514 |
+
),
|
| 515 |
+
"slice_dim": case["slice_dim"],
|
| 516 |
+
"slice_idx": case["slice_idx"],
|
| 517 |
+
"label": target_label,
|
| 518 |
+
"image_size_2d": case["image_size_2d"],
|
| 519 |
+
"pixel_size": case["pixel_size"],
|
| 520 |
+
"image_size_3d": case["image_size_3d"],
|
| 521 |
+
"voxel_size": case["voxel_size"],
|
| 522 |
+
"biometric_profile": case["biometric_profile"],
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
```
|
| 526 |
+
</details>
|
| 527 |
+
|
| 528 |
+
<br/>
|
| 529 |
+
|
| 530 |
# Advanced Usage
|
| 531 |
|
| 532 |
The dataset codebase `medvision_ds` can be used to scale the dataset, including adding new annotation types and datasets.
|
doc/changelog.md
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
|
| 3 |
This is a summary of essential changes.
|
| 4 |
|
|
|
|
| 5 |
- [Jan, 2026] [chore] fix typo in label name of AMOS22: arota --> aorta @ [25b03408a120f14ee1d620841a79c3ca5fda8f54](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/25b03408a120f14ee1d620841a79c3ca5fda8f54)
|
| 6 |
- [Dec, 2025] [feat] Add filelock mechanism to dataset cache to prevent race conditions @ [5d2731ad873611e7011053f89cfedd4109142c32](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/5d2731ad873611e7011053f89cfedd4109142c32)
|
| 7 |
- [Oct, 2025] update: set default data source of BCV15 and BraTS24 to corresponding HF dataset @ [111e3602b1f8633d17b28de4e89a44aae0430fc0](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/111e3602b1f8633d17b28de4e89a44aae0430fc0)
|
|
|
|
| 2 |
|
| 3 |
This is a summary of essential changes.
|
| 4 |
|
| 5 |
+
- [Jan, 2026] [feat] add 'dataset_name' to each sample @ [15c83e077dd05f3f7358366d23636f62fa824fe1](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/15c83e077dd05f3f7358366d23636f62fa824fe1) and [b4bc3cb31521b3e95d20bf55b6701b234b7101db](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/b4bc3cb31521b3e95d20bf55b6701b234b7101db)
|
| 6 |
- [Jan, 2026] [chore] fix typo in label name of AMOS22: arota --> aorta @ [25b03408a120f14ee1d620841a79c3ca5fda8f54](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/25b03408a120f14ee1d620841a79c3ca5fda8f54)
|
| 7 |
- [Dec, 2025] [feat] Add filelock mechanism to dataset cache to prevent race conditions @ [5d2731ad873611e7011053f89cfedd4109142c32](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/5d2731ad873611e7011053f89cfedd4109142c32)
|
| 8 |
- [Oct, 2025] update: set default data source of BCV15 and BraTS24 to corresponding HF dataset @ [111e3602b1f8633d17b28de4e89a44aae0430fc0](https://huggingface.co/datasets/YongchengYAO/MedVision/commit/111e3602b1f8633d17b28de4e89a44aae0430fc0)
|