File size: 7,401 Bytes
f0bc58b 40173a3 f0bc58b |
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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
---
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}
}
``` |