Skip to content

MedMod in-hospital mortality (4/4): runner scripts and Colab notebook - #1640

Open
Rainie-Hu wants to merge 8 commits into
sunlabuiuc:masterfrom
Rainie-Hu:medmod-ihm-runners
Open

Rainie-Hu wants to merge 8 commits into
sunlabuiuc:masterfrom
Rainie-Hu:medmod-ihm-runners

Conversation

@Rainie-Hu

@Rainie-Hu Rainie-Hu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Contributors: Yuqing Hu (GT username yhu672, yhu672@gatech.edu) and Hanh Trang Do (GT username hdo61, hdo61@gatech.edu), Georgia Tech CSE 6250

Contribution Type: Full Pipeline, part 4 of 4 (#1609): the scripts and Colab notebook behind the real-data results

**Part 4 of 4 of #1609. Depends on #1637 and #1639. Until they merge, this diff also shows parts 1 and 3. After they merge, this branch will be rebased so it shows only part 4. The split: 1. dataset, task and processor (#1637); 2. models (#1638); 3. image tools, synthetic data, MedSigLIP, examples and results (#1639); 4. this PR.

Paper: Elsharief, S., et al. (2025). MedMod: Multimodal Benchmark for Medical Prediction Tasks with Electronic Health Records and Chest X-Ray Scans. CHIL 2025, PMLR 287. https://proceedings.mlr.press/v287/elsharief25a.html (code: https://github.com/nyuad-cai/MedMod)

What it adds:

  • examples/medmod_runners/: the scripts that produced the real-data results in examples/mimic4_medmod_ihm_results.md. They train the same models with the same settings as the two example scripts. They also compute bootstrap confidence intervals, write a JSON report for every run and save checkpoints, so that a run continues after a disconnect. Its README.md explains the data layout and how to prepare the data.
  • examples/mimic4_medmod_ihm_colab_runs.ipynb: the Google Colab notebook that runs all of them, with its outputs.
  • The notes in the examples and the results page saying the runners come in a follow-up PR are removed.

Links to other components: the runners use only our own components from #1637–#1639. They do not import or change existing PyHealth components.

Files to review (part 4 only):

  • examples/medmod_runners/ - early_fusion_run.py, convirt_pretrain.py, convirt_probe.py (the real-data runs), samples.py, pretrain_samples.py, slim_events.py (data preparation), provenance.py, colab_bundle.py, and its README.md
  • examples/mimic4_medmod_ihm_colab_runs.ipynb - the Colab notebook, with its outputs
  • examples/mimic4_medmod_ihm_early_fusion.py, examples/mimic4_medmod_convirt.py, examples/mimic4_medmod_ihm_results.md - the "runners come in a follow-up PR" notes removed

Testing: on this branch, all 142 tests pass offline, and every runner script's --help works. python tools/check_pr_rules.py passes.

Data: the runners need credentialed PhysioNet access to MIMIC-IV v1.0 and MIMIC-CXR-JPG 2.0.0. They print only aggregates, such as counts, losses and scores. The notebook shows only aggregate scores and counts. No MIMIC data, identifiers or trained weights are in this PR.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Test Coverage

Total: 88.87% (62610 / 70451 lines)

Modified file Coverage Lines
pyhealth/datasets/__init__.py 100.00% 95 / 95
pyhealth/datasets/medmod/__init__.py 100.00% 0 / 0
pyhealth/datasets/medmod/discretizer.py 97.01% 162 / 167
pyhealth/datasets/medmod/downloads.py 97.78% 44 / 45
pyhealth/datasets/medmod/extraction.py 92.61% 326 / 352
pyhealth/datasets/medmod/image_presets.py 82.22% 37 / 45
pyhealth/datasets/medmod/medsiglip.py 92.06% 116 / 126
pyhealth/datasets/medmod/pretraining.py 97.94% 95 / 97
pyhealth/datasets/medmod/resize_cxr.py 88.64% 78 / 88
pyhealth/datasets/medmod/synthetic.py 94.85% 129 / 136
pyhealth/datasets/medmod_mimic4.py 100.00% 79 / 79
pyhealth/processors/medmod_ehr_processor.py 97.50% 39 / 40
pyhealth/tasks/__init__.py 98.66% 147 / 149
pyhealth/tasks/medmod_mortality_mimic4.py 98.44% 63 / 64

Workflow run · 06c83be

@Rainie-Hu Rainie-Hu changed the title Part 4 of 4 of sunlabuiuc/PyHealth#1609 MedMod in-hospital mortality (4/4): runner scripts and Colab notebook Nov 27, 2026
@dhtrg
dhtrg force-pushed the medmod-ihm-runners branch from 4ff7dd3 to 844e8c8 Compare November 27, 2026 22:35
dhtrg and others added 3 commits November 30, 2026 17:01
Part 1 of 4 of sunlabuiuc#1609.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
The task page now says the image transform belongs to the model's image
loader; the task returns image_path only. A custom itemid_map adds a digest
of its file to dataset_name, so each map gets its own PyHealth cache, with a
test that builds two maps on one cache_dir.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
The dataset drops events outside its item map before caching, so a
task whose item map has other ids would silently miss their events.
set_task now raises a ValueError naming them, with a test. This is the
second half of the AI review's item-map comment.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
@dhtrg
dhtrg force-pushed the medmod-ihm-runners branch 2 times, most recently from 93f4809 to 5559553 Compare November 30, 2026 23:10
dhtrg added a commit to Rainie-Hu/PyHealth that referenced this pull request Nov 30, 2026
Same code as sunlabuiuc#1637-sunlabuiuc#1640 after their reviews. sunlabuiuc#1638 is merged as 1aaeaea.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
dhtrg and others added 5 commits November 30, 2026 18:52
Starting and stopping PyHealth's local Dask cluster took about 5 s per event-table build on 28 fake rows. The dataset tests now run the same Dask graph in the test process, and the custom item map test checks its cache key and row filter without a second build. The slowest step is now the module's one shared build (about 1.7 s); every test takes under 0.5 s.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
…ples

Part 3 of 4 of sunlabuiuc#1609. Builds on parts 1 and 2.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
resize_cxr leaves a .tmp_*.jpg file behind if it is killed while saving. list_images now skips it, as existing_basenames already does.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
Part 4 of 4 of sunlabuiuc#1609. Builds on part 3.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>
Without --tag, a run with a second seed found the first seed's report and stopped at once. The default tags of early_fusion_run, convirt_pretrain and convirt_probe now end in _seed<seed>. The notebook passes its own tags, so its runs are unchanged.

Co-authored-by: rainiehu <57816421+Rainie-Hu@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants