Skip to content

Repository files navigation

Kailuan BP Reproducibility Code

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.

Repository Contents

  • 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.

What Is Not Included

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/, or paper/ directories.

Environment

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.txt

For GPU runs, install a CUDA-compatible PyTorch build separately if your environment does not already provide one.

Configuration

Copy .env.example to .env and set local paths:

cp .env.example .env
source .env

Required variables for main SSL-Fusion reproduction:

  • SSL_DATA_DIR: directory containing SSL-Fusion NPZ features.
  • SSL_LABELS_CSV: labels CSV with record_id, target columns, and split=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 with ssoid, target columns, and split=train/val/test.

Required variables for post-hoc analysis:

  • inputs/final_mar17/_data/ssl_record_level_predictions_raw_global_meta_meta2_mar17.csv
  • inputs/final_mar17/_data/mar17_ssl_calibration_payload.json
  • inputs/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.

Analysis Partition

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.

Main SSL-Fusion Reproduction

Run the main method full-split right-arm SBP reproduction:

source .env
GPU_ID=0 bash run_ssl_fusion_sbp_full.sh

This 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.

Post-Hoc Clinical Analysis

After supplying the private frozen prediction inputs, run:

source .env
bash run_all.sh

This 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 Appendix Ablation

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.sh

Full 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.

Tests

Run:

python -m pytest -q

Tests requiring private frozen inputs are skipped automatically when those inputs are absent.

Privacy And Release Boundary

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.

About

Sanitized reproducibility code for Kailuan BP SSL-Fusion analysis

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages