--- language: - en license: cc-by-4.0 multilinguality: monolingual size_categories: 10K= 10: break print(row["pmcid"], row["title"][:80]) ``` ### Working with Sections The dataset provides two ways to access section text: **1. Via the `sections` list** (full detail with original headings): ```python from datasets import load_dataset ds = load_dataset("awinml/pubmed_case_reports", split="train") for row in ds: sections = row["sections"] presentation = [s for s in sections if s["section_type"] == "case_presentation"] if presentation: print(f"PMCID: {row['pmcid']}") print(f"Heading: {presentation[0]['heading']}") print(f"Text: {presentation[0]['text'][:200]}...") break ``` **2. Via direct section columns** (simpler, concatenated across all sections of that type): ```python from datasets import load_dataset ds = load_dataset("awinml/pubmed_case_reports", split="train") for row in ds: if row["case_presentation"]: print(f"PMCID: {row['pmcid']}") print(f"Case presentation: {row['case_presentation'][:200]}...") break ``` **3. Section length analysis with pandas:** ```python from datasets import load_dataset import pandas as pd ds = load_dataset("awinml/pubmed_case_reports", split="train") df = ds.to_pandas() # Which sections are most common? for col in ["background", "case_presentation", "discussion", "conclusion"]: pct = (df[col].str.len() > 0).mean() * 100 print(f"{col}: {pct:.1f}% of articles have this section") # Average discussion length df[df["discussion"] != ""]["discussion"].str.len().describe() ``` ### Converting to Pandas ```python import pandas as pd from datasets import load_dataset ds = load_dataset("awinml/pubmed_case_reports", split="train") df = ds.to_pandas() # Journal distribution print(df["journal"].value_counts().head(10)) # Average body text length by year df["year"] = pd.to_datetime(df["publication_date"]).dt.year print(df.groupby("year")["body_text"].apply(lambda x: x.str.len().mean())) ``` ### Retrieval-Augmented Generation ```python from datasets import load_dataset from sentence_transformers import SentenceTransformer # Load and chunk for RAG ds = load_dataset("awinml/pubmed_case_reports", split="train", streaming=True) # Build a simple in-memory index from body texts corpus = [] pmcids = [] for i, row in enumerate(ds): if i >= 1000: break corpus.append(row["body_text"][:2000]) # first 2000 chars pmcids.append(row["pmcid"]) model = SentenceTransformer("all-MiniLM-L6-v2") embeddings = model.encode(corpus, show_progress_bar=True) ``` ## Limitations & Considerations - **Case reports are inherently anecdotal**: They describe individual patient experiences and should not be treated as population-level evidence. - **Publication bias**: Journals are more likely to publish rare or novel cases, so the dataset may overrepresent unusual presentations. - **Temporal skew**: The collection is weighted toward recent publications (51% from 2021–2025). - **No structured outcome labels**: The dataset does not include standardised diagnostic or treatment outcome labels — this is a raw text corpus. - **License variability**: Articles carry different Creative Commons licenses. Users should verify license compatibility for their specific use case (see the `license` field per row). - **No PHI redaction guarantee**: While the source articles are published in open-access journals, individual case reports may contain identifiable patient information. Users should exercise appropriate caution. ## Citation If you use this dataset, please cite it as: ```bibtex @misc{awinml_pubmed_case_reports_2025, author = {Ashwin Mathur}, title = {PubMed Case Reports: A Dataset of Full-Text Clinical Case Reports from PMC}, year = {2025}, publisher = {Hugging Face}, journal = {Hugging Face Datasets}, howpublished = {\\url{https://huggingface.co/datasets/awinml/pubmed_case_reports}} } ``` ## License The dataset itself is released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Individual articles carry their own licenses as specified in the `license` field and may have additional restrictions. ## Contact For questions or feedback, open an issue on the [dataset repository](https://huggingface.co/datasets/awinml/pubmed_case_reports).