Replication package for Causal Diffusion Models for Counterfactual Outcome Distributions in Longitudinal Data by Farbod Alinezhad, Jianfei Cao, Gary J. Young, and Brady Post.
- Farbod Alinezhad
- Jianfei Cao
Section 4 trains CDM, CRN, CT, G-Net, RMSN, and Mamba-CDSP. Section 5 runs the
MIMIC semi-synthetic benchmark and the real MIMIC-III application. Each section
writes checkpoints and run-level results to intermediate_output/ and
manuscript tables and figures to output/.
The Section 4 RSA figure is computed from the newly trained gamma-10 checkpoint: the workflow screens candidate trajectories, recomputes the RSA kernel after a treatment-timing perturbation, and renders the saved numerical result. The case and heatmap are not stored as fixed plotting coordinates.
The workflows record separate seeds for data construction and model training. Both default to 100. Resetting the random state before model initialization prevents the fitted model from depending on incidental random-number use while the simulated data are constructed.
Using Bash on Linux, macOS, or Windows Subsystem for Linux, create and activate a Python 3.11 environment before running the package:
python3.11 -m venv .venv
source .venv/bin/activate
bash install.shinstall.sh installs requirements.txt, runs pip check, and imports the core
packages. A CUDA GPU is recommended for the full experiments; Section 4 also
supports a slower CPU run.
Run:
bash "section 4/run.sh"
MIMIC_DATA_DIR=/path/to/mimiciii/1.4 bash "section 5/run.sh"Section 4 can run on a GPU cluster or, more slowly, on CPU. Section 5 must run on a secure machine containing credentialed MIMIC-III data.
For a smoke test of the code path:
DEBUG=1 GAMMAS=0 ABLATION_GAMMAS=0 bash "section 4/run.sh"
RUN_MIMIC_APPLICATION=0 RUN_TABLE5=0 bash "section 5/run.sh"Debug runs skip the paper-reference validator. A complete run
validates the final table values and figure structure, and rejects any model,
cache, or raw metric that appears under output/. The optional
STRICT_FIGURE_HASHES=1 setting additionally requires byte-identical
hash-covered figures from the documented reference renderer. The
checkpoint-derived RSA figure is instead validated against its recomputed
kernel summary.
Exact figure hashes depend on the operating system, font stack, renderer, and hardware. They are therefore optional for ordinary replication runs. The table checks remain active across environments.
Raw MIMIC-III data cannot be distributed in this repository. A replicator must
complete PhysioNet credentialing, download MIMIC-III v1.4 to a secure location,
and set MIMIC_DATA_DIR to the directory containing ADMISSIONS.csv.gz,
ICUSTAYS.csv.gz, PATIENTS.csv.gz, CHARTEVENTS.csv.gz,
INPUTEVENTS_CV.csv.gz, and INPUTEVENTS_MV.csv.gz.
MIMIC_DATA_DIR=/path/to/mimiciii/1.4 bash "section 5/run.sh"section 5/code/resources/ contains the item identifiers and labels used by
the application. It contains no patient records.