Skip to content

Add PhysioNet2019Sepsis task, hospital split, and JointSeqImage benchmark - #1823

Open
yuema-git wants to merge 1 commit into
sunlabuiuc:masterfrom
yuema-git:feat/physionet2019-sepsis-task
Open

yuema-git wants to merge 1 commit into
sunlabuiuc:masterfrom
yuema-git:feat/physionet2019-sepsis-task

Conversation

@yuema-git

Copy link
Copy Markdown
Contributor

Closes #1789

Summary

Follow-up to #1790 (PhysioNet2019Dataset) adding the early ICU sepsis prediction task, leak-free pre-onset normalization statistics, cross-hospital splitting, clinical TaskCard metadata, synthetic tests, Sphinx documentation, and a JointSeqImage benchmark example for PhysioNet/CinC Challenge 2019.

What's Added

  • pyhealth/tasks/physionet2019_sepsis.py (exported in pyhealth/tasks/__init__.py):
    • PhysioNet2019Sepsis(BaseTask):
      • Pre-onset truncation strictly before the first SepsisLabel == 1 hour (skipping stays positive at admission or with zero dynamic observations in the pre-onset window) and toggleable Raindrop-style max_stay_hours=60 cohort filter (None retains longer stays using their most recent max_length hours, eliminating the <60h truncation-length shortcut).
      • Layer 2 missingness handling paired with Layer 1 lossless NaN storage in PhysioNet2019Dataset: missing_mode="raw" (default, preserves NaN for JointSeqImage / GRU-D) or missing_mode="vital_ffill" (short-window forward-fill for continuous VITAL_VARIABLES only while keeping intermittent LAB_VARIABLES un-imputed), plus optional include_missing_features=True to output pre-imputation x_mask and GRU-D x_delta.
      • Optional clean_clinical_units=True (shared Polars expression across task extraction and statistics) to harmonize mixed Temp (°F → °C) and FiO2 (% → fraction) units and drop physically impossible vital readings while preserving critical laboratory abnormalities (e.g., high Lactate, low pH).
      • task_card() returning a structured TaskCard documenting cohort criteria, prediction cutoff, clinical variable groups/directions, and site-shift caveats.
    • physionet2019_sepsis_statistics: computes per-variable (mean, std) strictly on pre-onset observations with graceful (0.0, 1.0) fallback for site-specific 100%-missing variables (e.g., EtCO2 in Hospital A).
    • split_by_hospital: deterministic cross-hospital (A ↔ B) patient-level train/val/test split with zero patient overlap.
    • summarize_physionet2019_cohort: summarizes class prevalence, hospital distribution, and septic vs. non-septic pre-onset sequence lengths.
  • tests/core/test_physionet2019_sepsis.py: 8 offline synthetic tests covering cohort rules, <60h toggle, Layer 2 raw vs. vital_ffill and x_mask/x_delta, unit cleaning, pre-onset-only statistics, split_by_hospital, TaskCard, miniature JointSeqImage forward + train_step integration, parameter validation, and test_synthetic_cutoff_prevents_future_leakage (twin-stay cutoff & boundary inclusion test suggested by @anaba5is in Add PhysioNet 2019 Sepsis Dataset and Prediction Task #1789).
  • examples/joint_seq_image_physionet2019_sepsis.py: runnable benchmark supporting --split-mode random|hospital, --missing-mode raw|vital_ffill, --clean-clinical-units, --max-upsample, and --tiny, alongside a length_only_baseline lower bound and documented local reference results.
  • Docs: docs/api/tasks/pyhealth.tasks.PhysioNet2019Sepsis.rst, updated docs/api/tasks.rst, and cross-link from docs/api/datasets/pyhealth.datasets.PhysioNet2019Dataset.rst.

Verification

  • pytest tests/core/test_physionet2019.py tests/core/test_physionet2019_sepsis.py -v: 18 passed (pyhealth/tasks/physionet2019_sepsis.py line coverage: 96%, 250/261).
  • ruff check and python tools/check_pr_rules.py --base upstream/master --head HEAD: All PR contribution rules passed.
  • Real-data end-to-end verification on all 40,336 PhysioNet 2019 stays (Apple Silicon MPS):
    • max_stay_hours=60 cohort: 38,739 stays (1,561 septic / 37,178 non-septic); max_stay_hours=None: 39,843 stays (2,441 septic / 37,402 non-septic, length-only AUROC drops from 0.689 to 0.438 on Hospital B).
    • Compact JointSeqImage (64×64 random-init Swin, 4 epochs, 6k train / 1.5k val / 3,891 test): random raw test AUROC 0.8084 (vs length-only 0.7062), random vital_ffill 0.8045, cross-hospital A → B 0.7741.
    • Full-cohort Layer 2 missingness ablation (GBDT & 2-layer GRU on all 38,739 / 39,843 stays) documented in examples/joint_seq_image_physionet2019_sepsis.py.

AI Assistance Disclosure

AI coding tools were used to assist with drafting code, tests, and documentation; all design decisions, clinical checks, and local benchmark verifications were reviewed and executed by the author.

@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown

Test Coverage

Total: 89.51% (69940 / 78134 lines)

Modified file Coverage Lines
pyhealth/tasks/__init__.py 98.74% 157 / 159
pyhealth/tasks/physionet2019_sepsis.py 95.79% 250 / 261

Workflow run · 56ad809

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.

Add PhysioNet 2019 Sepsis Dataset and Prediction Task

1 participant