This repository contains sanitized reproducibility code for the Kailuan blood-pressure prediction study. It covers the main SSL-Fusion finetuning workflow, post-hoc output adjustment, statistical evaluation, regression conformal prediction, interval-based triage simulation, and the ECG-only PatchTST appendix ablation.
Private data, model checkpoints, frozen prediction tables, generated figures, generated reports, training logs, and run outputs are intentionally not included.
ssl_fusion/finetune_core/: main SSL-Fusion finetuning code used for full right-arm SBP reproduction.scripts/: post-hoc clinical analysis, conformal triage, figure/table builders, and plotting utilities.bp_recode_v1/: ECG-only PatchTST appendix ablation code.tests/: lightweight unit/regression tests. Tests that require private inputs are skipped when those inputs are absent.run_ssl_fusion_sbp_full.sh: main-method SSL-Fusion full-split reproduction entry point.run_all.sh: post-hoc analysis and appendix figure entry point.run_gpu_subset_smoke.sh: small PatchTST GPU sanity check.
The following are excluded by design:
- Raw Kailuan data.
- Preprocessed NPZ feature directories.
- Labels CSV files containing participant-level metadata.
- SSL/CLIP pretrained checkpoints and finetuned checkpoints.
- Frozen prediction tables.
- Generated figures, reports, and paper mirrors.
- Training logs and run outputs.
- Any
outputs/,logs/,inputs/,figures/,reports/, orpaper/directories.
The code was run in a Python/PyTorch environment named bp. A minimal package set is listed in requirements.txt; exact CUDA/PyTorch installation should match the target GPU server.
python -m pip install -r requirements.txtFor GPU runs, install a CUDA-compatible PyTorch build separately if your environment does not already provide one.
Copy .env.example to .env and set local paths:
cp .env.example .env
source .envRequired variables for main SSL-Fusion reproduction:
SSL_DATA_DIR: directory containing SSL-Fusion NPZ features.SSL_LABELS_CSV: labels CSV withrecord_id, target columns, andsplit=train/val/test.SSL_PRETRAINED_CKPT: pretrained SSL-Fusion checkpoint.
Required variables for PatchTST appendix runs:
BP_RECODE_NPZ_DIR: directory containing recoded ECG/PPG NPZ files.BP_RECODE_LABELS_CSV: labels CSV withssoid, target columns, andsplit=train/val/test.
Required variables for post-hoc analysis:
inputs/final_mar17/_data/ssl_record_level_predictions_raw_global_meta_meta2_mar17.csvinputs/final_mar17/_data/mar17_ssl_calibration_payload.jsoninputs/final_mar17/_tables/ssl_fusion_summary_mar17.csv- optional PatchTST metric JSON files under
inputs/patchtst_ecg_runs/
These inputs are project-private and must be supplied locally.
The current manuscript analyses use participant-disjoint training (70%), validation (15%), calibration (5%), and test (10%) partitions. The base models and post-hoc affine mappings are fitted without access to the calibration or test partitions. The validation partition is used for checkpoint and hyperparameter selection. Probability recalibration, screening operating points, and conformal quantiles are estimated on the dedicated calibration partition; all reported clinical performance metrics are then computed on the test partition.
The calibration and test partitions are obtained by a deterministic participant-level subdivision of the original held-out cohort. All visits from one participant remain in the same partition.
Run the main method full-split right-arm SBP reproduction:
source .env
GPU_ID=0 bash run_ssl_fusion_sbp_full.shThis runs the archived best SSL-Fusion configuration used to reproduce the main-model checkpoint:
- target:
right_arm_sbp - mode:
fusion(ECG+PPG) - pretraining variant:
full_xmod - epochs:
50 - batch size:
256 - learning rate:
0.00024687005315668066 - loss:
mse*pearson - Pearson alpha:
0.7854198892237618 - patience:
7 - seed:
42
In the original environment, this reproduced the historical result exactly:
- best epoch:
11 - test MAE:
6.6892 - test RMSE:
8.8770 - test Pearson
r:0.8790 - test
R2:0.7701
These numbers are provided only as a reproducibility target. Generated output files are not tracked by git.
After supplying the private frozen prediction inputs, run:
source .env
bash run_all.shThis regenerates the clinical post-hoc package, including:
- dedicated calibration/test partition summaries,
- continuous agreement summaries,
- probability calibration summaries,
- regression conformal interval triage,
- workflow simulation,
- appendix PatchTST figure if its metric JSON inputs are present.
PatchTST is not the paper's main method. It is included only as an ECG-only appendix ablation and environment sanity check.
Small GPU smoke test:
source .env
GPU_ID=0 bash run_gpu_subset_smoke.shFull PatchTST reruns can be launched directly with bp_recode_v1/train_patchtst_ecg_bp.py after setting BP_RECODE_NPZ_DIR and BP_RECODE_LABELS_CSV.
Run:
python -m pytest -qTests requiring private frozen inputs are skipped automatically when those inputs are absent.
This repository contains reproducibility code only. Do not commit:
- participant-level data,
- model checkpoints,
- prediction CSVs,
- generated metrics JSONs,
- training logs,
- paper PDFs or figure outputs.
If a future release needs public data artifacts, create a separate data statement or controlled-access archive rather than adding them to this repository.