Repository navigation
Add PH2 dataset and artifact-view classification task (Jin & Ghassemi, CHIL 2025) - #1607
Conversation
Test CoverageTotal: 86.81% (48804 / 56218 lines)
|
|
/review |
There was a problem hiding this comment.
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:
- Blank Clinical Diagnosis cells in
PH2_dataset.txt._parse_annotationsdocuments that rows with an empty code are skipped, but it only checkspd.isna(code). The.txtreader keeps blank cells as empty strings, soint("")raises aValueError.- 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.txtfirst, 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
--viewsdefault is 6 views, while its docstring and results table describe all 12. A sentence saying the results table used--viewswith all 12 would remove the confusion.
Reviewed commit 73e828f
|
/review |
| """ | ||
| rows = [] | ||
| for line in path.read_text(errors="replace").splitlines(): | ||
| line = line.strip().replace("||", "|").strip("|") |
There was a problem hiding this comment.
[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) | |||
There was a problem hiding this comment.
[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.
There was a problem hiding this comment.
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
|
/merge |
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.pyandpyhealth/datasets/configs/ph2.yaml- dataset and table configpyhealth/tasks/ph2_artifact_classification.py- the taskpyhealth/tasks/dermoscopy_artifact_views.py- the 12 views and 5 artifactstests/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 resultsdocs/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