Datasets:
Update README.md
Browse filesfix typos and polish TAIX-Ray dataset README
README.md
CHANGED
|
@@ -127,36 +127,47 @@ dataset_info:
|
|
| 127 |
dataset_size: 1226435862593.624
|
| 128 |
---
|
| 129 |
|
|
|
|
| 130 |
# TAIX-Ray Dataset
|
| 131 |
|
| 132 |
-
TAIX-Ray is a comprehensive dataset of
|
| 133 |
-
Trained radiologists provided structured reports at the time of acquisition, assessing key findings such as cardiomegaly, pulmonary congestion, pleural effusion, pulmonary opacities, and atelectasis on an ordinal scale.
|
| 134 |
|
|
|
|
| 135 |
|
| 136 |
<br>
|
| 137 |
|
| 138 |
-
## Code & Details
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
## How to Use
|
| 142 |
|
| 143 |
### Prerequisites
|
|
|
|
| 144 |
Ensure you have the following dependencies installed:
|
| 145 |
|
| 146 |
```bash
|
| 147 |
pip install datasets matplotlib huggingface_hub pandas tqdm
|
| 148 |
```
|
| 149 |
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
| **Name** | **Size** | **Image Size** |
|
| 154 |
-
|--------
|
| 155 |
-
| default
|
| 156 |
-
| original
|
| 157 |
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
-
### Option A: Use within the Hugging Face Framework
|
| 160 |
If you want to use the dataset directly within the Hugging Face `datasets` library, you can load and visualize it as follows:
|
| 161 |
|
| 162 |
```python
|
|
@@ -167,26 +178,29 @@ from matplotlib import pyplot as plt
|
|
| 167 |
dataset = load_dataset("TLAIM/TAIX-Ray", name="default")
|
| 168 |
|
| 169 |
# Access the training split (Fold 0)
|
| 170 |
-
ds_train = dataset[
|
| 171 |
|
| 172 |
# Retrieve a single sample from the training set
|
| 173 |
item = ds_train[0]
|
| 174 |
|
| 175 |
# Extract and display the image
|
| 176 |
-
image = item[
|
| 177 |
-
plt.imshow(image, cmap=
|
| 178 |
-
plt.savefig(
|
| 179 |
plt.show() # Display the image
|
| 180 |
|
| 181 |
# Print metadata (excluding the image itself)
|
| 182 |
for key in item.keys():
|
| 183 |
-
if key !=
|
| 184 |
print(f"{key}: {item[key]}")
|
| 185 |
```
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
| 188 |
|
| 189 |
If you prefer to download the dataset to a specific folder, use the following script. This will create the following folder structure:
|
|
|
|
| 190 |
```
|
| 191 |
.
|
| 192 |
├── data/
|
|
@@ -194,13 +208,12 @@ If you prefer to download the dataset to a specific folder, use the following sc
|
|
| 194 |
│ ├── d8546c6108aad271211da996eb7e9eeabaf44d39cf0226a4301c3cbe12d84151.png
|
| 195 |
│ └── ...
|
| 196 |
└── metadata/
|
| 197 |
-
├──
|
| 198 |
-
└── split.csv
|
| 199 |
```
|
| 200 |
|
| 201 |
```python
|
| 202 |
from datasets import load_dataset
|
| 203 |
-
from huggingface_hub import hf_hub_download
|
| 204 |
from pathlib import Path
|
| 205 |
import pandas as pd
|
| 206 |
from tqdm import tqdm
|
|
@@ -208,19 +221,19 @@ from tqdm import tqdm
|
|
| 208 |
# Define output paths
|
| 209 |
output_root = Path("./TAIX-Ray")
|
| 210 |
|
| 211 |
-
# Create folders
|
| 212 |
data_dir = output_root / "data"
|
| 213 |
metadata_dir = output_root / "metadata"
|
| 214 |
data_dir.mkdir(parents=True, exist_ok=True)
|
| 215 |
metadata_dir.mkdir(parents=True, exist_ok=True)
|
| 216 |
|
| 217 |
# Load dataset in streaming mode
|
| 218 |
-
dataset =
|
| 219 |
|
| 220 |
# Process dataset
|
| 221 |
metadata = []
|
| 222 |
for split, split_dataset in dataset.items():
|
| 223 |
-
print("-------- Start Download:
|
| 224 |
for item in tqdm(split_dataset, desc="Downloading"): # Stream data one-by-one
|
| 225 |
uid = item["UID"]
|
| 226 |
img = item.pop("Image") # PIL Image object
|
|
@@ -229,16 +242,19 @@ for split, split_dataset in dataset.items():
|
|
| 229 |
img.save(data_dir / f"{uid}.png", format="PNG")
|
| 230 |
|
| 231 |
# Store metadata
|
| 232 |
-
metadata.append(item)
|
| 233 |
|
| 234 |
# Convert metadata to DataFrame
|
| 235 |
metadata_df = pd.DataFrame(metadata)
|
| 236 |
|
| 237 |
-
# Save annotations to CSV
|
| 238 |
-
metadata_df.drop(columns=["Split", "Fold"]).to_csv(
|
| 239 |
-
|
|
|
|
| 240 |
|
| 241 |
print("Dataset streamed and saved successfully!")
|
| 242 |
```
|
| 243 |
|
| 244 |
|
|
|
|
|
|
|
|
|
| 127 |
dataset_size: 1226435862593.624
|
| 128 |
---
|
| 129 |
|
| 130 |
+
|
| 131 |
# TAIX-Ray Dataset
|
| 132 |
|
| 133 |
+
TAIX-Ray is a comprehensive dataset of approximately 200k bedside chest radiographs from around 50k intensive care patients at University Hospital Aachen, Germany, collected between 2010 and 2024.
|
|
|
|
| 134 |
|
| 135 |
+
Trained radiologists provided structured reports at the time of acquisition, assessing key findings such as cardiomegaly, pulmonary congestion, pleural effusion, pulmonary opacities, and atelectasis on an ordinal scale.
|
| 136 |
|
| 137 |
<br>
|
| 138 |
|
| 139 |
+
## Code & Details
|
| 140 |
+
|
| 141 |
+
The code for data loading, preprocessing, and baseline experiments is available at:
|
| 142 |
+
[https://github.com/mueller-franzes/TAIX-Ray](https://github.com/mueller-franzes/TAIX-Ray)
|
| 143 |
+
|
| 144 |
+
---
|
| 145 |
|
| 146 |
## How to Use
|
| 147 |
|
| 148 |
### Prerequisites
|
| 149 |
+
|
| 150 |
Ensure you have the following dependencies installed:
|
| 151 |
|
| 152 |
```bash
|
| 153 |
pip install datasets matplotlib huggingface_hub pandas tqdm
|
| 154 |
```
|
| 155 |
|
| 156 |
+
---
|
| 157 |
+
|
| 158 |
+
## Configurations
|
| 159 |
+
|
| 160 |
+
This dataset is available in two configurations:
|
| 161 |
|
| 162 |
| **Name** | **Size** | **Image Size** |
|
| 163 |
+
| -------- | -------- | -------------- |
|
| 164 |
+
| default | 62GB | 512px |
|
| 165 |
+
| original | 1.2TB | variable |
|
| 166 |
|
| 167 |
+
---
|
| 168 |
+
|
| 169 |
+
## Option A: Use within the Hugging Face Framework
|
| 170 |
|
|
|
|
| 171 |
If you want to use the dataset directly within the Hugging Face `datasets` library, you can load and visualize it as follows:
|
| 172 |
|
| 173 |
```python
|
|
|
|
| 178 |
dataset = load_dataset("TLAIM/TAIX-Ray", name="default")
|
| 179 |
|
| 180 |
# Access the training split (Fold 0)
|
| 181 |
+
ds_train = dataset["train"]
|
| 182 |
|
| 183 |
# Retrieve a single sample from the training set
|
| 184 |
item = ds_train[0]
|
| 185 |
|
| 186 |
# Extract and display the image
|
| 187 |
+
image = item["Image"]
|
| 188 |
+
plt.imshow(image, cmap="gray")
|
| 189 |
+
plt.savefig("image.png") # Save the image to a file
|
| 190 |
plt.show() # Display the image
|
| 191 |
|
| 192 |
# Print metadata (excluding the image itself)
|
| 193 |
for key in item.keys():
|
| 194 |
+
if key != "Image":
|
| 195 |
print(f"{key}: {item[key]}")
|
| 196 |
```
|
| 197 |
|
| 198 |
+
---
|
| 199 |
+
|
| 200 |
+
## Option B: Downloading the Dataset
|
| 201 |
|
| 202 |
If you prefer to download the dataset to a specific folder, use the following script. This will create the following folder structure:
|
| 203 |
+
|
| 204 |
```
|
| 205 |
.
|
| 206 |
├── data/
|
|
|
|
| 208 |
│ ├── d8546c6108aad271211da996eb7e9eeabaf44d39cf0226a4301c3cbe12d84151.png
|
| 209 |
│ └── ...
|
| 210 |
└── metadata/
|
| 211 |
+
├── annotation.csv
|
| 212 |
+
└── split.csv
|
| 213 |
```
|
| 214 |
|
| 215 |
```python
|
| 216 |
from datasets import load_dataset
|
|
|
|
| 217 |
from pathlib import Path
|
| 218 |
import pandas as pd
|
| 219 |
from tqdm import tqdm
|
|
|
|
| 221 |
# Define output paths
|
| 222 |
output_root = Path("./TAIX-Ray")
|
| 223 |
|
| 224 |
+
# Create folders
|
| 225 |
data_dir = output_root / "data"
|
| 226 |
metadata_dir = output_root / "metadata"
|
| 227 |
data_dir.mkdir(parents=True, exist_ok=True)
|
| 228 |
metadata_dir.mkdir(parents=True, exist_ok=True)
|
| 229 |
|
| 230 |
# Load dataset in streaming mode
|
| 231 |
+
dataset = load_dataset("TLAIM/TAIX-Ray", name="default", streaming=True)
|
| 232 |
|
| 233 |
# Process dataset
|
| 234 |
metadata = []
|
| 235 |
for split, split_dataset in dataset.items():
|
| 236 |
+
print("-------- Start Download:", split, "--------")
|
| 237 |
for item in tqdm(split_dataset, desc="Downloading"): # Stream data one-by-one
|
| 238 |
uid = item["UID"]
|
| 239 |
img = item.pop("Image") # PIL Image object
|
|
|
|
| 242 |
img.save(data_dir / f"{uid}.png", format="PNG")
|
| 243 |
|
| 244 |
# Store metadata
|
| 245 |
+
metadata.append(item)
|
| 246 |
|
| 247 |
# Convert metadata to DataFrame
|
| 248 |
metadata_df = pd.DataFrame(metadata)
|
| 249 |
|
| 250 |
+
# Save annotations to CSV file
|
| 251 |
+
metadata_df.drop(columns=["Split", "Fold"]).to_csv(
|
| 252 |
+
metadata_dir / "annotation.csv", index=False
|
| 253 |
+
)
|
| 254 |
|
| 255 |
print("Dataset streamed and saved successfully!")
|
| 256 |
```
|
| 257 |
|
| 258 |
|
| 259 |
+
|
| 260 |
+
|