Skip to content

Add PH2 dataset and artifact-view classification task (Jin & Ghassemi, CHIL 2025) - #1607

Merged
github-actions[bot] merged 17 commits into
sunlabuiuc:masterfrom
btaiyolee:master
Nov 27, 2026
Merged

github-actions[bot] merged 17 commits into
sunlabuiuc:masterfrom
btaiyolee:master

Conversation

@btaiyolee

Copy link
Copy Markdown
Contributor

Contributors: Bryson Lee (brysonl3), Aayan Verma (aayanv2), Xin Zhang (xinz13)

Contribution Type: New Dataset and New Task (with example and ablation)

Paper: A Study of Artifacts on Melanoma Classification under Diffusion-Based Perturbations, Jin and Ghassemi, CHIL 2025, https://proceedings.mlr.press/v287/jin25b.html

Description: Adds PH2Dataset, a dataset containing 200 dermoscopy images with lesion masks, and PH2ArtifactClassification, a task whose inputs can be any of the paper's 12 modes (whole, lesion, background, three bounding boxes, high/low-pass filters) where it determines benign or malignant. This task can also optionally draw one programmatically-drawn artifact (gel bubble, ink, patches, ruler, dark corner) on the image that does not overlap with lesion pixels.

This reproduces part of the paper's input-disruption experiment on PH2 where the example trains a ResNet-50 model on each mode and compares AUROC with the paper's Table 2. This does not include the paper's diffusion-generated artifacts and its ISIC/HAM10000 transfer experiments.

Files to Review:

  • pyhealth/datasets/ph2.py and pyhealth/datasets/configs/ph2.yaml - dataset and table config
  • pyhealth/tasks/ph2_artifact_classification.py - the task
  • pyhealth/tasks/dermoscopy_artifact_views.py - the 12 views and 5 artifacts
  • tests/core/test_ph2_dataset.py, tests/core/test_ph2_task.py - synthetic-data tests (26 tests, about 3 s)
  • examples/derm/ph2_artifact_classification_resnet50.py - ablation and results
  • docs/api/datasets/pyhealth.datasets.PH2Dataset.rst, docs/api/tasks/pyhealth.tasks.PH2ArtifactClassification.rst, docs/api/datasets.rst, docs/api/tasks.rst - docs, index entries and manual test cases

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 86.81% (48804 / 56218 lines)

Modified file Coverage Lines
pyhealth/datasets/__init__.py 100.00% 84 / 84
pyhealth/datasets/cardiology.py 98.61% 71 / 72
pyhealth/datasets/cdc_covid.py 92.59% 25 / 27
pyhealth/datasets/hmc.py 97.62% 41 / 42
pyhealth/datasets/mimic3.py 100.00% 21 / 21
pyhealth/datasets/mimic4.py 95.80% 114 / 119
pyhealth/datasets/omop.py 96.88% 31 / 32
pyhealth/datasets/ph2.py 95.60% 87 / 91
pyhealth/interpret/__init__.py 100.00% 4 / 4
pyhealth/interpret/uni_acs.py 82.35% 182 / 221
pyhealth/metrics/survival.py 94.25% 82 / 87
pyhealth/models/__init__.py 100.00% 96 / 96
pyhealth/models/chet.py 92.80% 245 / 264
pyhealth/models/clip_stress.py 91.67% 154 / 168
pyhealth/models/clip_stress_layers.py 98.39% 61 / 62
pyhealth/models/clip_stress_utils.py 86.86% 119 / 137
pyhealth/models/concare.py 77.09% 286 / 371
pyhealth/models/ecg_jepa.py 100.00% 121 / 121
pyhealth/models/joint_seq_image.py 99.29% 278 / 280
pyhealth/models/rasc.py 98.63% 72 / 73
pyhealth/models/stagenet.py 96.10% 197 / 205
pyhealth/models/stagenet_mha.py 94.33% 266 / 282
pyhealth/models/text_embedding.py 95.70% 89 / 93
pyhealth/models/time_series_images.py 100.00% 126 / 126
pyhealth/processors/nested_sequence_processor.py 93.75% 165 / 176
pyhealth/processors/stagenet_processor.py 90.20% 184 / 204
pyhealth/processors/utils.py 96.61% 57 / 59
pyhealth/tasks/__init__.py 98.20% 109 / 111
pyhealth/tasks/cdc_covid_mortality.py 91.55% 65 / 71
pyhealth/tasks/climb_ecg.py 98.59% 70 / 71
pyhealth/tasks/cpsc2018_heartlang.py 97.98% 97 / 99
pyhealth/tasks/dermoscopy_artifact_views.py 100.00% 130 / 130
pyhealth/tasks/length_of_stay_prediction.py 77.30% 109 / 141
pyhealth/tasks/mortality_prediction.py 90.29% 400 / 443
pyhealth/tasks/ph2_artifact_classification.py 100.00% 41 / 41
pyhealth/tasks/physionet2012_inhospital_mortality.py 94.52% 138 / 146
pyhealth/tasks/physionet2012_mortality.py 96.20% 76 / 79
pyhealth/tasks/readmission_prediction.py 94.69% 214 / 226
pyhealth/tasks/sleep_staging_hmc.py 99.06% 105 / 106
pyhealth/tasks/value_set_pair_classification.py 98.95% 188 / 190
pyhealth/tasks/variant_classification.py 89.29% 50 / 56
pyhealth/utils.py 83.70% 77 / 92

Workflow run · fd7b991

@solarsys solarsys added the status: automatic The PR will go through automatic review process. label Nov 26, 2026
@solarsys

Copy link
Copy Markdown
Collaborator

/review

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous review

Reviewed commit 73e828f

@github-actions github-actions Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous review

AI Review

suggestion: need change
decision: need change

Thank you for this contribution. It adds PH2Dataset, a PH2ArtifactClassification task with 12 views and 5 hand-drawn artifacts, a ResNet-50 example that compares results with the paper, docs with manual test cases, and 26 synthetic-data tests. Coverage looks good. The whole repository is at 86.4%, against the 60% bar. ph2.py is at 93.5%, and the two task files are at 100%. The change is self-contained, and the __init__ edits only add exports. It is close to ready.

To get this merged:

  1. Blank Clinical Diagnosis cells in PH2_dataset.txt. _parse_annotations documents that rows with an empty code are skipped, but it only checks pd.isna(code). The .txt reader keeps blank cells as empty strings, so int("") raises a ValueError.
    • Either treat empty or whitespace-only codes as missing, or change the docstring to say they raise.
    • Please add a small test for whichever behaviour you choose.

Optional suggestions:

  • In _read_diagnoses, the files are picked in sorted order (.csv, then .txt, then .xlsx). The docs list .txt first, so you could align the two.
  • In bbox_mask, a tiny lesion near an image corner can leave the box short of the 70% or 90% coverage target, because the box is clipped at the image border. A note in the docstring would be enough.
  • The example's --views default is 6 views, while its docstring and results table describe all 12. A sentence saying the results table used --views with all 12 would remove the confusion.

Reviewed commit 73e828f

@btaiyolee

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed commit fd7b991

Comment thread pyhealth/datasets/ph2.py
"""
rows = []
for line in path.read_text(errors="replace").splitlines():
line = line.strip().replace("||", "|").strip("|")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[medium] Annotation parser drops or shifts blank cells that are not space-padded

_read_pipe_table normalises each line with line.strip().replace("||", "|").strip("|"). For an unpadded blank cell such as |IMD001||0|, the replace removes the empty column, so the row becomes IMD001, 0 and the Clinical Diagnosis column index (2) is past the end of the row. _parse_annotations then sees NaN (line 243) and skips the image silently, with no warning, and when a later column holds 0 to 2 the parser can read that column as the diagnosis. The docstring at line 191 says empty cells are kept so columns stay aligned, which is not true for this case, and the tests only use space-padded fixtures, so they miss it. Fix: split on single '|' and keep every empty cell, handle the archive's '||' separators explicitly after checking the real PH2_dataset.txt layout, add a test with unpadded blank cells, and warn when an annotated row is skipped for a blank diagnosis.

@@ -0,0 +1,502 @@
# Contributor: Aayan Verma (aayanv2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[low] Example is much longer than comparable derm examples

At 502 lines this example is about seven times longer than the existing derm examples (examples/derm/*_resnet18.py, 66 to 78 lines). The synthetic archive generator, the results table and the long module docstring add most of that length. Consider moving the results table and the paper comparison into the docs page and keeping the example to the training and evaluation loop, with the synthetic archive as a separate helper if it is kept at all.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review

suggestion: approve
decision: approve

Thank you for this contribution. It adds PH2Dataset (200 dermoscopy images with lesion masks) and PH2ArtifactClassification. The task supports the paper's 12 input views and five optional hand-drawn artifacts that never touch lesion pixels. It also adds a ResNet-50 example that compares results with the paper's Table 2. It looks ready to merge.

What I checked:

  • The change is self-contained. It adds a new dataset, task and helper module, and only registers exports and docs index entries.
  • The dataset cites its source page and the EMBC 2013 paper in its class docstring and docs page.
  • The docs match the code, and the manual test cases are useful.
  • Coverage meets the bar. ph2.py is at 95.6%, dermoscopy_artifact_views.py at 100% and ph2_artifact_classification.py at 100%. The repository total is 86.8%.
  • I looked at the || to | handling in _read_pipe_table. A blank cell written as |||| becomes ||, which still splits into an empty cell, so columns stay aligned. I don't see a column-shift bug there.

Optional suggestions:

  • Add one test for the pipe-separated parser with a blank cell that has no padding spaces, for example ||IMD001||||0||. It would lock in the behaviour above.
  • The example script is long, at about 500 lines. Moving the results discussion from its docstring into the docs would shorten it.
  • The quoted real-archive results can't be checked from the repo. You could say in the docs that they come from a single run with seed 0.

Reviewed commit fd7b991

@btaiyolee

Copy link
Copy Markdown
Contributor Author

/merge

@github-actions
github-actions Bot merged commit 6ae1600 into sunlabuiuc:master Nov 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: automatic The PR will go through automatic review process.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants