xcwangpsu commited on
Commit
c7f1233
·
verified ·
1 Parent(s): 81df180

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +9 -9
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 datasets import load_dataset
61
  import pandas as pd
62
 
63
- # Load the Hugging Face dataset
64
- dataset = load_dataset("xcwangpsu/MedMKG")
65
 
66
- # Convert to Pandas DataFrames
67
- kg_df = pd.read_csv(dataset["data_files"]["MedMKG.csv"])
68
- mapping_df = pd.read_csv(dataset["data_files"]["image_mapping.csv"])
69
 
70
- # Your local MIMIC-CXR image directory (user-provided)
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
- # Add resolved paths
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
+