Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

97 Commits

Folders and files

Repository files navigation

Trajectory Modeling for Disease Progression Prediction

Code for the M.Sc. thesis Clinical parameter trajectory modeling for disease progression prediction (Tammy Wertheimer, Tel Aviv University; advisor Prof. Ron Shamir).

The recent course of a clinical parameter (for example lactate over the last three days) is represented by scores for three trajectory types: Stable, Linear progression and Non-linear progression. The scores are estimated from many spline trajectories sampled by Bayesian MCMC or by bootstrap, and are used as features for predicting disease progression in five ICU tasks on MIMIC-III, eICU and HiRID.

Trajectory types

Each sampled trajectory is evaluated on a uniform grid and classified by its interval slopes (src/traj_features/backends/bayes/classify.py; the bootstrap backend uses the same rules):

Type Rule Code
Stable at least a fraction α of the slopes ≤ τ_inc and |mean slope| ≤ τ_flat nonprogression
Linear progression at least a fraction α of the slopes > τ_inc linear
Non-linear progression mean of the upper half of the sorted slopes minus mean of the lower half > γ_gap nonlinear

α = 0.8. The thresholds are set per task and clinical parameter (thesis Table 2.2) and appear in the code as τ_flat = flat_thr, τ_inc = decline_thr and γ_gap = nonlinear_gap. For parameters whose decrease indicates progression (platelets, systolic BP) the signs are reversed (flags_from_traj instead of pos_flags_from_traj).

The type score T̂(c) is the fraction of the sampled trajectories classified as type c; the scores need not sum to one. Output columns keep older names: stable, gradual for Linear progression and rapid for Non-linear progression (for example prob_gradual_increase, or lactate_rapid_boot for bootstrap).

Timeline

A prediction is made at an anchor time a (the integer time_day of a row; time_hour for circulatory failure). The trajectory features use the measurements of the index day [a, a+1) and of the W days before it. The gap δ and the prediction window Δ are counted from a+1, so the outcome is evaluated in [a+δ+1, a+δ+Δ+1] (thesis Section 2.4.2).

Pipeline

Step Code
1. Cohorts, outcomes and features scripts/{mimic,eicu,hirid}_preprocessing/
2. Trajectory type scores (MCMC, bootstrap) src/traj_features/, scripts/trajectory/ (cluster: scripts/slurm/, docker/)
3. Prediction: LR, RF, HGB and XGBoost, 10×5 grouped cross-validation src/analysis/, scripts/analysis/<dataset>/
4. Boxplots, tables and significance tests scripts/analysis/poster/, scripts/analysis/tables/, scripts/rerun/
5. Thesis figures scripts/figures/, scripts/analysis/eicu/ (sensitivity), scripts/benchmarks/
Task Datasets Clinical parameters
Septic shock (sepsis) MIMIC-III, eICU lactate, WBC, platelets
Acute-on-chronic liver failure (liver) MIMIC-III, eICU bilirubin
AKI stage 3 (aki) MIMIC-III, eICU creatinine
Ventilator discontinuation (ventilator) MIMIC-III, eICU P/F ratio
Circulatory failure (circulatory_failure) MIMIC-III, eICU, HiRID lactate, heart rate, systolic BP

Commands, data paths and the settings of the thesis runs: docs/pipeline.md. How the thesis results were produced: docs/thesis_results.md.

Installation

pip install -e .[all]        # or .[bayes], .[bootstrap], .[evaluation]

The analyses also need xgboost, the preprocessing duckdb, and parquet files pyarrow. The PhysioNet data (MIMIC-III, eICU, HiRID) requires credentialed access and is not part of this repository; nothing derived from it at patient level may be committed.

Usage

from traj_features.backends.bootstrap import BootstrapTraj, BootstrapConfig
from traj_features.backends.bayes.classify import pos_flags_from_traj

# df: one row per measurement, columns patientid, time (days), time_window (anchor day), lab_value
types = ("stable", "linear_progression", "nonlinear_progression")
model = BootstrapTraj(BootstrapConfig(
    window_years=3.0,          # lookback window W, in the time unit of the data
    n_bootstrap=200,
    flat_thr=10.0, decline_thr=30.0, nonlinear_gap=20.0,   # tau_flat, tau_inc, gamma_gap
    class_func=pos_flags_from_traj,
    traj_types=types,
    label_map={"nonprogression": types[0], "linear": types[1], "nonlinear": types[2]},
    pids="patientid", values="lab_value", time_col="time", windowing_col="time_window",
))
scores = model.embed(df)       # one row per (patient, anchor): trajtype_<type>_prob columns

BayesianTraj / BayesConfig in traj_features.backends.bayes work the same way.

Tests

pytest tests/test_smoke_backends.py -m "not slow"   # all tests: -m "not slow or slow"

scripts/ckd_*.py belong to a separate All of Us CKD analysis, and docs/thesis/ holds early drafts of the methods text; neither is part of the thesis pipeline.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages