--- pretty_name: PMC-PaIR language: - en license: other license_name: pmc-pair-mixed license_link: https://huggingface.co/datasets/dhtandguy21/PMC-PaIR/blob/main/LICENSE.txt task_categories: - image-feature-extraction - image-classification tags: - medical - medical-imaging - radiology - image-retrieval - case-reports - pubmed-central annotations_creators: - machine-generated size_categories: - 10K **This repository is a mirror of the Zenodo record.** The 19 files of the record are stored here unchanged, and `SHA256SUMS.txt` lists the checksums of the other 18. Two files are added: this card and `image_splits.json`, the benchmark partition, which is otherwise distributed with the code. ## At a glance | Property | Value | |---|---| | Positive image pairs | 86,144 | | Images | 86,893 annotated; files distributed for 86,825 and withheld for 68 | | Source articles | 56,013 open-access case reports in PMC, published 1986–2026 (60.6% in 2020 or later) | | Pair annotations | free-text `modality`, `anatomy` and `diagnosis` descriptors | | Image-level labels | 12 modality, 20 anatomy and 40 diagnosis categories; an image can carry several per field | | Case-pair records | citation contexts, generated citation-intent analyses, and generated questions and answers for 121,831 case pairs | | Benchmark partition | 70,552 training, 8,245 validation and 8,096 test images; no pair or source article spans two partitions | | Language | English | The most frequent labels are CT (46.4% of images), MRI (23.1%) and radiography (15.5%) for modality, thorax/respiratory (14.8%), musculoskeletal (14.0%) and vasculature (13.6%) for anatomy, and mass/lesion (31.4%), infection/abscess (9.6%) and inflammatory/autoimmune (7.6%) for diagnosis. An image belongs to a median of one pair (interquartile range 1–2, maximum 33), and 45.9% of images belong to two or more. ## What a pair looks like One record of `image_pairs.json`: ```json { "pair_id": ["9899453_1_1", "4023003_1_3"], "modality": "MRI", "anatomy": "lumbar spine/paraspinal muscles/epidural space", "diagnosis": "paraspinal abscess with spinal epidural abscess" } ``` The two images come from two case reports of children with a paraspinal muscle infection complicated by a spinal epidural abscess, one of which cites the other. The order of the two identifiers carries no meaning, and each unordered pair occurs once. An image identifier joins, with underscores, the numeric part of the article's PMCID, the case index and the extraction index of the figure: `9899453_1_1` is the first extracted figure of case 1 in article [PMC9899453](https://pmc.ncbi.nlm.nih.gov/articles/PMC9899453/). The case index is 1 in every identifier, because only articles reporting a single case were kept. An image is a complete published figure and may contain several panels. The pairs listed are positive pairs. Pairs that are not listed are unlabeled, not negative. ## Files | File | Size | Contents | |---|---|---| | `image_pairs.json` | 16.9 MB | 86,144 positive pairs with shared modality, anatomy and diagnosis descriptors | | `image_labels.jsonl` | 12.4 MB | modality, anatomy and diagnosis labels of 86,893 images | | `label_taxonomy.json` | 143 kB | label categories and the rules that map descriptors to labels | | `case_pair_citations_eligible.json` | 283.3 MB | citation contexts and generated citation-intent analyses of 121,831 case pairs | | `case_pair_questions_answers_eligible.jsonl` | 535.9 MB | generated questions and answers for the same 121,831 case pairs | | `images_captions_001.zip` to `images_captions_004.zip` | 8.7 GB in total | 86,825 images (`images/.jpg`) and their captions (`captions/.txt`) | | `file_manifest.csv` | 25.5 MB | archive, size and SHA-256 checksum of every image and caption file | | `licenses.csv` | 184.8 MB | per-image license, attribution, provenance and availability | | `withheld.csv` | 31.8 kB | identifiers, reasons and source URLs of the 68 withheld images | | `included_image_ids.txt`, `withheld_image_ids.txt` | 1.1 MB, 844 B | identifiers of the 86,825 distributed and the 68 withheld images | | `pair_availability.csv` | 4.0 MB | for every pair, whether the files of both images are distributed | | `release_summary.json` | 6.0 kB | release counts, license distributions and archive metadata | | `README.txt`, `LICENSE.txt`, `SHA256SUMS.txt` | 7.7 kB, 2.2 kB, 1.6 kB | file descriptions, licensing statement and checksums of the Zenodo record | | `image_splits.json` | 2.3 MB | benchmark partition of every image (added in this repository; see [Benchmark partition](#benchmark-partition)) | Images are JPEG files and captions are UTF-8 text files, packaged as obtained from the source articles, without resizing, recompression or caption edits. ## Loading the data ### Annotation tables The four JSON and JSON Lines files are configured as subsets. Each has a single split named `full`, which holds all records regardless of benchmark partition. ```python from datasets import load_dataset repo = "dhtandguy21/PMC-PaIR" pairs = load_dataset(repo, "pairs", split="full") # 86,144 pairs labels = load_dataset(repo, "image_labels", split="full") # 86,893 images citations = load_dataset(repo, "case_pair_citations", split="full") # 121,831 case pairs qa = load_dataset(repo, "case_pair_questions_answers", split="full") # 121,831 case pairs ``` The CSV files are not configured as subsets. Download them and read them with a CSV reader, for example `pandas.read_csv`. ### Images and captions Download the repository and extract the four archives into a new directory: ```python import zipfile from pathlib import Path from huggingface_hub import snapshot_download root = Path(snapshot_download("dhtandguy21/PMC-PaIR", repo_type="dataset")) files = Path("pmc-pair-files") for archive in sorted(root.glob("images_captions_*.zip")): with zipfile.ZipFile(archive) as z: z.extractall(files) # files/images/.jpg and files/captions/.txt ``` The download is 9.8 GB. To check it, run `sha256sum -c SHA256SUMS.txt` in the downloaded directory. To work with the images as a `datasets` table, join the labels, captions and partition to the extracted files. Continuing from the two snippets above: ```python import json from datasets import Image split = json.loads((root / "image_splits.json").read_text()) available = set((root / "included_image_ids.txt").read_text().split()) images = labels.filter(lambda r: r["image_id"] in available) # drops the 68 withheld images images = images.map(lambda r: { "image": str(files / "images" / f"{r['image_id']}.jpg"), "caption": (files / "captions" / f"{r['image_id']}.txt").read_text(encoding="utf-8"), "split": split[r["image_id"]], }) images = images.cast_column("image", Image()) train_images = images.filter(lambda r: r["split"] == "train") ``` ### Benchmark partition `image_splits.json` maps every image identifier to `train`, `val` or `test`. The two images of a pair are always in the same partition, so a pair takes the partition of either image: ```python pairs = pairs.map(lambda r: {"split": split[r["pair_id"][0]]}) train_pairs = pairs.filter(lambda r: r["split"] == "train") ``` | Partition | Images | Pairs | Article groups | |---|---:|---:|---:| | train | 70,552 | 70,262 | 10,670 | | val | 8,245 | 8,034 | 1,333 | | test | 8,096 | 7,848 | 1,335 | | total | 86,893 | 86,144 | 13,338 | The partition was built on the graph whose nodes are images and whose edges are positive pairs. Connected components that share a source article were merged into article groups, and whole groups were assigned 80:10:10 by number of groups (seed 42). No pair and no source article spans two partitions. The file is identical to `image_splits.json` in the pipeline repository and `data/article_disjoint_split.json` in the retrieval repository (SHA-256 `b0b7be4be1597fa4e557fa4c5a51d0148361c2f253a604cf3df4a95a277c30eb`). ### Text descriptions of pairs The benchmark turns a pair's descriptors into one sentence with the template `"{diagnosis} in the {anatomy} on {modality}."`, for example "paraspinal abscess with spinal epidural abscess in the lumbar spine/paraspinal muscles/epidural space on MRI." ## Data fields **`image_pairs.json`** (subset `pairs`), a JSON array with one object per pair: | Field | Type | Description | |---|---|---| | `pair_id` | list of two strings | identifiers of the two images, one from each source article | | `modality` | string | shared imaging modality, free text | | `anatomy` | string | shared anatomical region, free text; may name several related structures | | `diagnosis` | string | shared type of abnormality, free text; may name several related findings | **`image_labels.jsonl`** (subset `image_labels`), one object per image, including the withheld images: | Field | Type | Description | |---|---|---| | `image_id` | string | image identifier | | `labels.modality` | list of strings | categories such as `ct`, `mri`, `radiography`, `ultrasound`, `nuclear_medicine` | | `labels.anatomy` | list of strings | categories such as `thorax_respiratory`, `musculoskeletal`, `vasculature` | | `labels.diagnosis` | list of strings | categories such as `mass_or_lesion`, `infection_or_abscess`, `aneurysm_or_dissection` | The labels of an image are the union of the categories derived from the descriptors of all pairs that contain it. `label_taxonomy.json` defines every category and the mapping rules. The category `other` is assigned only when no pair gives a more specific category in that field (65 images for modality, 277 for anatomy and 2,250 for diagnosis). `nuclear_medicine` is the only label that is also assigned from an image's own caption. **`case_pair_citations_eligible.json`** (subset `case_pair_citations`), a JSON array with one object per annotated case pair: | Field | Type | Description | |---|---|---| | `citing_case`, `cited_case` | string | PMCIDs of the citing and the cited article, for example `PMC9899453` | | `extracted_citation` | string | citation contexts: the paragraphs and table rows of the citing article that refer to the cited article; empty in 857 records | | `citation_reason` | string | generated citation-intent analysis | **`case_pair_questions_answers_eligible.jsonl`** (subset `case_pair_questions_answers`), one object per case pair: | Field | Type | Description | |---|---|---| | `annotation_id` | string | unique record identifier | | `case_pair_id` | string | the two case identifiers, sorted and joined with `\|`, for example `5563556-1\|8167975-1` | | `case_a_uid`, `case_b_uid` | string | case identifiers in the order used in the prompts, which does not indicate citation direction | | `citing_case`, `cited_case` | string | PMCIDs of the citing and the cited article | | `questions`, `answers` | string | generated questions and answers, as saved from the model output | A case identifier joins the numeric part of the PMCID and the case index with a hyphen, as in `9899453-1`. The two case-pair files can be joined on `citing_case` and `cited_case`, and the numeric part of a PMCID is the first component of the image identifiers of that article. **CSV files.** `pair_availability.csv` has the columns `pair_index` (zero-based position in `image_pairs.json`), `image_id_1`, `image_id_2`, `image_1_available`, `image_2_available` and `both_images_available` (`True` or `False`). `file_manifest.csv` has `image_id`, `archive`, `image_path`, `caption_path`, `image_size_bytes`, `caption_size_bytes`, `image_sha256`, `caption_sha256`, `pmcid`, `figure_xml_id` and `source_article_url`. `withheld.csv` has `image_id`, `status`, `reason` and `source_article_url`. The main columns of `licenses.csv` are `image_id`, `pmcid`, `source_article_url`, `file_redistribution_status`, `image_license`, `caption_license`, `image_license_components`, `caption_license_components`, `image_commercial_use_under_recorded_license`, `caption_commercial_use_under_recorded_license`, `attribution`, `article_authors` and `article_title`; `README.txt` describes its further evidence and review columns. ## How the dataset was created **Source data.** Candidate case pairs are the citation links that [PMC-Patients](https://doi.org/10.1038/s41597-023-02814-8) records between case reports. Cases were drawn from the published PMC-Patients collection (articles published until January 2022) and from a collection regenerated with the PMC-Patients code for articles published until February 2026. Only articles that report exactly one case were kept, because figures of a multi-patient article cannot be attributed reliably to one patient. Figures, captions and full text come from the [PMC Open Access Subset](https://pmc.ncbi.nlm.nih.gov/tools/openftlist/). Diagrams and text-heavy figures were removed with a white-background screen and optical character recognition. Each citation link was confirmed in the reference list of one of the two articles. **Annotation.** Of 159,388 candidate case pairs, 122,365 had full text, figures with captions, a case description and a confirmed citation link, and were annotated with citation-guided hierarchical image-pair annotation (CHIPA). CHIPA makes four language-model calls for each case pair: 1. **Citation-intent analysis.** From the titles and abstracts of both articles and the citation contexts, the model states why one report cites the other. 2. **Question generation.** From both case descriptions and the citation-intent analysis, the model writes comparative questions at three levels: imaging modality and organ system, diagnostic category, and specific findings. 3. **Question answering.** A second call answers each question with Yes, No, Partial or Unclear and a brief reason. 4. **Image-pair proposal.** From the questions, the answers and the captions of both articles, the model returns the caption pairs that describe the same modality and the same type of abnormality in the same anatomical region, with descriptors of what they share. The models are OpenAI language models that read text only. The data descriptor and the pipeline repository list the models, their settings and the prompts. **Post-processing.** Parsing the responses gave 93,113 proposed pairs. Removing proposals with invalid identifiers or unavailable image files, proposals from veterinary case reports and duplicates left 86,144 pairs. Of the 121,831 case pairs that remained after the veterinary filter, 48,331 (39.7%) contributed at least one pair. **Labels.** Rule-based mapping of the pair descriptors to controlled vocabularies gives the image-level labels (see [Data fields](#data-fields)). ## Annotation quality The checks below are reported in the data descriptor. Percentages are followed by exact 95% confidence intervals. | Check | Sample | Outcome | |---|---|---| | Image pairs | 163 pairs, rated independently by a medical physicist and a resident physician, then by consensus | matched 147 (90.2%; 84.5–94.3), borderline 6 (3.7%; 1.4–7.8), not matched 10 (6.1%; 3.0–11.0); Cohen's κ 0.70 before consensus | | Image-level labels | the 320 images of those pairs | correct 299 (93.4%; 90.1–95.9), borderline 1 (0.3%; 0.0–1.7), incorrect 20 (6.3%; 3.9–9.5) | | Citation-intent analyses | 25 case pairs | supported 22 (88.0%; 68.8–97.5), partly supported 2, not supported 1 | | CHIPA against single-step annotation | 50 case pairs; all 29 pairs proposed by either workflow | CHIPA proposed 25 of the 27 correct pairs and no incorrect pair; the single-step baseline proposed 12 correct and 2 incorrect pairs | In the review of pairs, the 10 mismatches concerned modality (4 pairs) or anatomy (6 pairs). Diagnosis matched for 156 pairs (95.7%) and was never rated a mismatch. ## Retrieval benchmark The data descriptor uses the pairs to fine-tune and evaluate BiomedCLIP in two tasks. In image-only retrieval (i2i), a query image is compared with candidate images. In image-plus-text retrieval, written (i+t)2i, the query image is accompanied by the descriptions of its pairs. Each of the 8,096 test images is a query, the other test images are candidates, and the images paired with the query are the relevant results. Images linked to the query only indirectly, through other pairs in its connected component, are excluded from its candidates. | Task | Model | Recall@10 (%) | Hit@10 (%) | MRR | Median rank of first positive | |---|---|---:|---:|---:|---:| | i2i | BiomedCLIP, pretrained | 14.62 | 21.47 | 0.111 | 65 | | i2i | fine-tuned on PMC-PaIR | 20.15 | 28.31 | 0.143 | 37 | | (i+t)2i | BiomedCLIP, pretrained | 20.53 | 29.68 | 0.154 | 34 | | (i+t)2i | fine-tuned on PMC-PaIR | 31.62 | 42.98 | 0.220 | 15 | The fine-tuned weights and their documentation are in [dhtandguy21/PMC-PaIR-BiomedCLIP](https://huggingface.co/dhtandguy21/PMC-PaIR-BiomedCLIP). The [retrieval repository](https://github.com/GuyShmueli/pmc-pair-retrieval) holds the code, the saved per-query results and the comparison intervals. These results use all 8,096 test images. With the distributed files, 5 test images and the pairs that contain them are unavailable; the retrieval code then evaluates 8,088 test queries, and the metrics differ slightly from those above. ## Uses The dataset could support: - training and evaluating medical image retrieval models with the released partition; - representation learning from positive pairs, with or without the pair descriptions; - classification of figures by modality, anatomy and diagnosis category; - training and evaluating models that compare two clinical cases or generate comparative questions, with the questions and answers; - case-level or combined text-and-image tasks, by following the PMCIDs to the source articles in PMC. Because the pairs were derived from text, without reference to any image model, they can be used to compare image models. For results comparable with the benchmark, use `image_splits.json` and exclude from each query's candidates the images linked to it only indirectly. ## Limitations - **Positive pairs only.** Unlisted pairs are unlabeled. With contrastive objectives, images linked to an anchor only indirectly can be excluded from its negatives, as in the benchmark. - **Same modality by design.** The two images of a pair share an imaging modality, so the dataset contains no cross-modality matches, such as a CT and an MRI image of the same kind of lesion. - **Machine-generated annotations.** The pairs, descriptors, citation-intent analyses, questions and answers were generated by language models from text, and the labels by rules. The models did not see the images. [Annotation quality](#annotation-quality) gives the error rates measured on samples. - **Whole figures.** An image is a published figure and may contain several panels. Labels from different pairs may refer to different panels. Many images contain arrows, letters or other marks added by the authors. - **Labels are coarser than pairs.** Two images with the same labels can show unrelated abnormalities. `mass_or_lesion` does not distinguish benign from malignant findings. - **Modalities outside radiology.** The annotation prompt restricts pairing to radiological, nuclear-medicine and ophthalmic imaging, but some pairs share another modality. The labels `microscopy`, `photography`, `electrophysiology` and `endoscopy` are assigned to 1,449, 837, 263 and 219 images. Filter by modality label to restrict the data to radiological images. - **Case reports are not routine practice.** Case reports are often published because a presentation is rare, atypical or diagnostically challenging. - **Withheld files.** Files are withheld for 68 images, and 116 pairs contain at least one of them. Use `included_image_ids.txt` and `pair_availability.csv` to select what is available. - **Overlap with pretraining data.** Models pretrained on PMC figures and captions, including BiomedCLIP, may have seen PMC-PaIR images during pretraining. - **Not for clinical use.** The dataset has not been validated for clinical decision-making. ## Personal and sensitive information The dataset was derived entirely from case reports published in the PMC Open Access Subset and from the PMC-Patients collection extracted from them. No patients were recruited or contacted, no data other than the published articles were used, and no attempt was made to identify individuals. Images are figures as published. Some are clinical or operative photographs: 837 images carry the `photography` label, which also covers fundus and specimen photographs. As `README.txt` states, the review before release covered documented public grants and targeted follow-up; it did not include visual review of every image or a full privacy audit. One image is withheld pending privacy review. To report a rights or privacy concern about an image, open a discussion in the Community tab of this repository or an issue in the [pipeline repository](https://github.com/GuyShmueli/pmc-pair-pipeline/issues). ## Licensing No single license covers the whole dataset, which is why the license field of this card is `other`. `LICENSE.txt` gives the full statement. In summary: - **Images, captions and citation contexts** are third-party works and keep the terms of their sources. They are not relicensed. `licenses.csv` records the license, license components, attribution and credit notices for every image and caption. Citation contexts keep the terms of the citing article. - **The authors' contributions** (pair descriptors, labels, generated citation-intent analyses, questions and answers, metadata compilation, partition definitions and documentation) are released under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), to the extent of the authors' rights. Recorded principal licenses of the 86,825 distributed images, from `release_summary.json`: | License family | Images | Share | |---|---:|---:| | CC BY (2.0, 2.5, 3.0, 4.0 or version not stated) | 57,098 | 65.8% | | CC BY-NC | 19,323 | 22.3% | | CC BY-NC-SA | 10,399 | 12.0% | | Public domain | 5 | <0.1% | Commercial use is recorded as permitted for 57,103 images and as not permitted for 29,722. To select images by license, filter `licenses.csv` on `image_license` or on `image_commercial_use_under_recorded_license`. These values describe the recorded copyright terms; they do not clear privacy or other rights. No distributed image or caption has a component recorded under a no-derivatives license. When reusing images or captions, preserve the recorded attribution and credit notices and observe any noncommercial or share-alike conditions. The license metadata comes from article license information, automated screening of captions and figure metadata for rights notices, and targeted follow-up. It is not a legal certification. The fine-tuned model weights are released separately under the MIT license; see the [model card](https://huggingface.co/dhtandguy21/PMC-PaIR-BiomedCLIP). ## Citation Please cite the dataset. A data descriptor is under review, and its reference will be added here. ```bibtex @dataset{shmueli_pmc_pair_2026, author = {Shmueli, Guy and Hope, Tom}, title = {{PMC-PaIR}: Clinically similar medical image pairs from {PubMed Central} case reports}, year = {2026}, publisher = {Zenodo}, version = {v1}, doi = {10.5281/zenodo.23439169}, url = {https://doi.org/10.5281/zenodo.23439169} } ``` The case pairs come from PMC-Patients: Zhao, Z., Jin, Q., Chen, F., Peng, T. & Yu, S. A large-scale dataset of patient summaries for retrieval-based clinical decision support systems. *Scientific Data* 10, 909 (2023). https://doi.org/10.1038/s41597-023-02814-8 ## Contact For questions and corrections, open a discussion in the Community tab of this repository or an issue in the [pipeline repository](https://github.com/GuyShmueli/pmc-pair-pipeline/issues).