abdellaouic commited on
Commit
f32828b
·
verified ·
1 Parent(s): dc525ab

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +11 -25
README.md CHANGED
@@ -260,35 +260,21 @@ One dataset instance corresponds to **one report**.
260
 
261
  ### Hugging Face dataset
262
 
263
- To facilitate machine learning workflows and easy filtering, the Hugging Face representation is organized into three distinct configurations. This allows for efficient filtering and relational access without parsing the original nested JSON:
264
-
265
- - document_metadata: For accessing full texts and global identifiers.
266
-
267
- - spans: For extracting specific annotations and entities.
268
-
269
- - relations: For analyzing links and dependencies between spans (if they exist).
270
-
271
- You can easily load and explore these different parts using the datasets library, as shown in the following example:
272
-
273
 
274
  ```python
 
275
  from datasets import load_dataset
276
 
277
- # Load document metadata and access the first report
278
- ds_meta = load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", name="document_metadata")
279
- first_doc = ds_meta["train"][0]
280
- print(f"Report ID: {first_doc['report']}")
281
-
282
- # Load annotations and iterate through the first samples
283
- ds_spans = load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", name="spans")
284
- for span in ds_spans["train"].select(range(5)):
285
- print(f"Type: {span['span_type']} | Text: {span['span_text']}")
286
-
287
- # Load and display a relation between entities (if they exist)
288
- ds_rel = load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", name="relations")
289
- if len(ds_rel["train"]) > 0:
290
- rel = ds_rel["train"][0]
291
- print(f"Relation: {rel['source_text']} -> {rel['target_text']}")
292
  ```
293
  ### Data Fields
294
 
 
260
 
261
  ### Hugging Face dataset
262
 
263
+ This snippet shows how to extract and iterate over medical report information per patient using the datasets library.
 
 
 
 
 
 
 
 
 
264
 
265
  ```python
266
+ import pandas as pd
267
  from datasets import load_dataset
268
 
269
+ dfs = {cfg: load_dataset("HealthDataHub/PARHAF-biomarkers-annotated", cfg, split="train").to_pandas()
270
+ for cfg in ["document_metadata", "spans", "relations"]}
271
+
272
+ for patient_raw in dfs["document_metadata"].itertuples():
273
+ report_id = patient_raw.report
274
+ text = patient_raw.full_text
275
+ report_spans = dfs["spans"][dfs["spans"]["report"] == report_id]
276
+ report_relations = dfs["relations"][dfs["relations"]["report"] == report_id]
277
+ ...
 
 
 
 
 
 
278
  ```
279
  ### Data Fields
280