Datasets:
ArXiv:
License:
| license: apache-2.0 | |
| # Dataset Card for MedIAnomaly | |
| ## Dataset Description | |
| **MedIAnomaly** is a benchmark designed to evaluate anomaly detection methods in the medical imaging domain. It provides a standardized evaluation protocol across **seven real-world medical image datasets**, including both **image-level anomaly classification (AnoCls)** and **pixel-level anomaly segmentation (AnoSeg)** tasks. | |
| All datasets follow a **one-class training setting**, where **only normal (non-anomalous) images are available in the training set**, and the **test set includes both normal and abnormal cases**. This reflects real-world scenarios where anomalies are rare and not annotated during training. | |
| The benchmark includes a total of **seven datasets**, spanning across various imaging modalities (X-ray, MRI, fundus, dermatoscopy, histopathology), and ensures unified data format and preprocessing to support fair and reproducible comparison of anomaly detection methods. | |
|  | |
| ## Dataset Source | |
| - **Homepage**: [https://github.com/caiyu6666/MedIAnomaly](https://github.com/caiyu6666/MedIAnomaly) | |
| - **License**: [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0) | |
| - **Paper**: Yu Cai et al. _MedIAnomaly: A Comparative Study of Anomaly Detection in Medical Images_, arXiv 2024. | |
| ## Dataset Structure | |
| | Dataset | Modality | Task | 𝒟<sub>train</sub> | 𝒟<sub>test</sub> (Normal+Abnormal) | | |
| |--------------|-----------------------|-------------------|------------------|----------------------------| | |
| | RSNA | Chest X-ray | AnoCls | 3851 | 1000 + 1000 | | |
| | VinDr-CXR | Chest X-ray | AnoCls | 4000 | 1000 + 1000 | | |
| | Brain Tumor | Brain MRI | AnoCls | 1000 | 600 + 600 | | |
| | LAG | Retinal fundus image | AnoCls | 1500 | 811 + 811 | | |
| | ISIC2018 | Dermatoscopic image | AnoCls | 6705 | 909 + 603 | | |
| | Camelyon16 | Histopathology image | AnoCls | 5088 | 1120 + 1113 | | |
| | BraTS2021 | Brain MRI | AnoCls & AnoSeg | 4211 | 828 + 1948 | | |
| ### Notes on Dataset-Specific Definitions | |
| - **RSNA**: Training images are all normal chest X-rays. Test set contains a balanced mix of normal and pneumonia images. | |
| - **VinDr-CXR**: Training set consists only of normal chest X-rays. Test set includes both normal and abnormal findings. | |
| - **Brain Tumor**: MRI scans. All training samples are healthy brains; test set contains normal and tumor cases. | |
| - **LAG**: Retinal fundus images. Training set includes only normal cases; glaucomatous images appear in test set. | |
| - **ISIC2018**: One-hot multi-label data. Only images with `NV = 1` and all other labels = 0 are considered **normal**. All others (with any other disease present) are considered **abnormal**. | |
| - **Camelyon16**: Histopathological whole-slide patches. Training includes only benign tissue. Abnormal cancerous regions are tested. | |
| - **BraTS2021**: Brain MRI for both classification and segmentation. Training includes only normal images. Test set includes tumor cases with segmentation masks. | |
| ## Example Usage | |
| ### RSNA | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="rsna", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="rsna", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### Vin-CXR | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="vincxr", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="vincxr", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### Brain Tumor | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="braintumor", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="braintumor", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### LAG | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="lag", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="lag", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### Camelyon16 | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="camelyon16", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="camelyon16", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### BraTS2021 | |
| ```python | |
| from datasets import load_dataset | |
| # Train | |
| dataset = load_dataset("randall-lab/medianomaly", name="brats2021", split="train", trust_remote_code=True) | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| image.show() | |
| print(f"Label: {label}") | |
| # Test | |
| dataset = load_dataset("randall-lab/medianomaly", name="brats2021", split="test", trust_remote_code=True) | |
| example = dataset[828] # >= 828 is abnormal images with seg mask | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| anno = example["annotation"] # None if label is 0, seg mask if label is 1 | |
| image.show() | |
| anno.show() | |
| print(f"Label: {label}") | |
| ``` | |
| ### ISIC2018 | |
| ```python | |
| from datasets import load_dataset | |
| dataset = load_dataset("randall-lab/medianomaly", name="isic2018_task3", split="train", trust_remote_code=True) | |
| # dataset = load_dataset("randall-lab/medianomaly", name="isic2018_task3", split="test", trust_remote_code=True) | |
| # View a sample | |
| example = dataset[0] | |
| image = example["image"] | |
| label = example["label"] # "normal" or "abnormal" | |
| labels = example["labels"] # one-hot multi label for different disease [MEL, NV, BCC, AKIEC, BKL, DF, VASC] | |
| # Individual binary class labels (0 or 1) | |
| mel_label = example["MEL"] | |
| nv_label = example["NV"] | |
| bcc_label = example["BCC"] | |
| akiec_label = example["AKIEC"] | |
| bkl_label = example["BKL"] | |
| df_label = example["DF"] | |
| vasc_label = example["VASC"] | |
| image.show() | |
| print(f"Label: {label}") | |
| ``` | |
| If you are using colab, you should update datasets to avoid errors | |
| ``` | |
| pip install -U datasets | |
| ``` | |
| ## Citation | |
| ``` | |
| @article{cai2024medianomaly, | |
| title={MedIAnomaly: A comparative study of anomaly detection in medical images}, | |
| author={Cai, Yu and Zhang, Weiwen and Chen, Hao and Cheng, Kwang-Ting}, | |
| journal={arXiv preprint arXiv:2404.04518}, | |
| year={2024} | |
| } | |
| ``` |