Update README.md
Browse files
README.md
CHANGED
|
@@ -57,17 +57,17 @@ To use the image data, you **must** request access and agree to the data use agr
|
|
| 57 |
Below is a demo script to load and link the knowledge graph with your local image data:
|
| 58 |
|
| 59 |
```python
|
| 60 |
-
from
|
| 61 |
import pandas as pd
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
-
#
|
| 67 |
-
kg_df = pd.read_csv(
|
| 68 |
-
mapping_df = pd.read_csv(
|
| 69 |
|
| 70 |
-
#
|
| 71 |
local_root = "/path/to/your/mimic-cxr-jpg"
|
| 72 |
|
| 73 |
# Map image IDs to full paths
|
|
@@ -76,9 +76,9 @@ iid_to_path = {
|
|
| 76 |
for _, row in mapping_df.iterrows()
|
| 77 |
}
|
| 78 |
|
| 79 |
-
#
|
| 80 |
kg_df["Head_Path"] = kg_df["Head"].map(iid_to_path)
|
| 81 |
kg_df["Tail_Path"] = kg_df["Tail"].map(iid_to_path)
|
| 82 |
|
| 83 |
-
print("Example with image paths:")
|
| 84 |
print(kg_df.head())
|
|
|
|
|
|
| 57 |
Below is a demo script to load and link the knowledge graph with your local image data:
|
| 58 |
|
| 59 |
```python
|
| 60 |
+
from huggingface_hub import hf_hub_download
|
| 61 |
import pandas as pd
|
| 62 |
|
| 63 |
+
kg_path = hf_hub_download(repo_id="xcwangpsu/MedMKG", filename="MedMKG.csv", repo_type="dataset")
|
| 64 |
+
mapping_path = hf_hub_download(repo_id="xcwangpsu/MedMKG", filename="image_mapping.csv", repo_type="dataset")
|
| 65 |
|
| 66 |
+
# Load CSVs
|
| 67 |
+
kg_df = pd.read_csv(kg_path)
|
| 68 |
+
mapping_df = pd.read_csv(mapping_path)
|
| 69 |
|
| 70 |
+
# Local path to downloaded MIMIC-CXR images
|
| 71 |
local_root = "/path/to/your/mimic-cxr-jpg"
|
| 72 |
|
| 73 |
# Map image IDs to full paths
|
|
|
|
| 76 |
for _, row in mapping_df.iterrows()
|
| 77 |
}
|
| 78 |
|
| 79 |
+
# Merge image path info into KG
|
| 80 |
kg_df["Head_Path"] = kg_df["Head"].map(iid_to_path)
|
| 81 |
kg_df["Tail_Path"] = kg_df["Tail"].map(iid_to_path)
|
| 82 |
|
|
|
|
| 83 |
print(kg_df.head())
|
| 84 |
+
|