EchoBridge: Long-Tail-Aware ECG--Echocardiography Text Alignment for Echocardiography-Derived Cardiac Findings
Standardized echocardiography conclusions provide meaningful supervision for learning ECG representations of echocardiography-derived cardiac findings. Global ECG--text alignment may entangle modality-specific factors, while long-tailed finding distributions provide sparse positive supervision for low-prevalence conditions. We propose EchoBridge with Complementary Shared--Private Projection (CSPP) and Adaptive Prototype Boundary Calibration (APBC). CSPP maps each modality into shared and auxiliary private projections, reduces directional redundancy via within-modality orthogonality, and bidirectionally aligns normalized shared projections. APBC organizes the shared hypersphere with class-specific prototypes, training-frequency-adaptive angular margins, and spherical Riesz repulsion. We evaluate EchoBridge on EchoNext-Mini and independent PKUPH and SHTMU cohorts under four protocols: prompt-based inference without downstream classifier training, in-domain frozen linear probing, target-domain cross-center frozen linear probing, and source-only cross-center transfer, supplemented by finding-specific analyses. EchoBridge improves classifier-free AUROC, AUPRC, and F1 over the strongest baselines by 7.88, 5.61, and 4.54 points, respectively, and achieves the highest point estimates across all in-domain and target-domain probing budgets and both source-only transfer cohorts. Finding-specific analyses show gains for most conditions, including several low-prevalence valvular findings.
- CSPP: maps ECG and text into shared and private projections, enforces within-modality orthogonality, and bidirectionally aligns normalized shared embeddings.
- APBC: calibrates class prototypes on the shared hypersphere with frequency-adaptive angular margins and spherical Riesz repulsion for long-tailed findings.
| Protocol | Description |
|---|---|
| Prompt-based inference | Classifier-free matching with text prompts |
| In-domain frozen linear probing | Frozen ECG encoder + linear head on EchoNext |
| Target-domain cross-center probing | Frozen encoder, probe on external centers |
| Source-only cross-center transfer | Train on source, evaluate on PKUPH / SHTMU |
EchoBridge/
├── data/
│ ├── dataset.py # ECG--text dataset loaders
│ ├── echonext_labels.json # Prototype / label schema
│ └── README.md # Data layout details
├── engine/
│ ├── encoders.py # ECG backbone (ResNet18)
│ ├── model.py # EchoBridge (CSPP + prototypes)
│ ├── losses.py # Alignment / APBC losses
│ ├── train.py # Pretraining entry
│ └── utils.py
├── linear_probing/
│ ├── train.py # Frozen linear probing
│ └── test.py # Linear probing evaluation
├── zeroshot/
│ ├── prompts.json # Finding prompts
│ └── zeroshot.py # Prompt-based inference
└── outputs/ # Checkpoints and eval reports
- Python >= 3.9
- PyTorch (CUDA recommended)
- transformers
- numpy / tqdm / scikit-learn
Example install:
pip install torch torchvision transformers numpy tqdm scikit-learnThe text encoder defaults to ncbi/MedCPT-Article-Encoder.
Pretrained checkpoints are available on Hugging Face: XiaochengFang/EchoBridge.
| File | Description | Link |
|---|---|---|
best_model.pth |
EchoBridge alignment model (CSPP + APBC) | download |
best_linear_head.pth |
Frozen linear probing head (EchoNext, 100% budget) | download |
Place the downloaded files as:
outputs/EchoNext/align/best_model.pth
outputs/EchoNext/linear_probing/best_linear_head.pth
Or download with Hugging Face CLI:
pip install -U huggingface_hub
huggingface-cli download XiaochengFang/EchoBridge best_model.pth \
--local-dir outputs/EchoNext/align
huggingface-cli download XiaochengFang/EchoBridge best_linear_head.pth \
--local-dir outputs/EchoNext/linear_probingEchoBridge expects paired ECG--echo-text samples plus a label CSV keyed by ECG_Id. Supported storage formats (NPZ / LMDB) and field definitions are documented in data/README.md.
Minimal checklist:
-
train/val/testsplits are ready - Each sample has
filename,ecg,echo - Parsed
ECG_Idmatches the label CSV -
prototype_colsindata/echonext_labels.jsonmatch CSV column names
Train EchoBridge alignment (CSPP + APBC) on EchoNext:
cd EchoBridge
python engine/train.py \
--data_path <ECHO_NEXT_DATA_ROOT> \
--csv_path <ECHO_NEXT_LABEL_CSV> \
--labels_json data/echonext_labels.json \
--text_model ncbi/MedCPT-Article-Encoder \
--proj_hidden 256 \
--proj_out 256 \
--batch_size 64 \
--max_epochs 15 \
--gpu 0 \
--checkpoint_dir outputs/EchoNext/alignBest checkpoint is saved as outputs/EchoNext/align/best_model.pth.
Key loss weights:
| Argument | Default | Role |
|---|---|---|
--lambda_align |
1.0 | Shared-projection bidirectional alignment |
--lambda_prototype |
1.0 | Prototype supervision (APBC) |
--lambda_prototype_cons |
0.5 | ECG/text prototype consistency |
--lambda2 |
0.1 | Shared--private decoupling |
python zeroshot/zeroshot.py \
--npz_path <TEST_NPZ> \
--labels_csv <ECHO_NEXT_LABEL_CSV> \
--checkpoint outputs/EchoNext/align/best_model.pth \
--prompt_json zeroshot/prompts.json \
--labels_json data/echonext_labels.json \
--gpu 0 \
--out_report outputs/EchoNext/zeroshot/zeroshot_eval.txtSet --bootstrap_iterations 0 to disable 95% CI estimation.
Train a linear head on frozen ECG features:
python linear_probing/train.py \
--data_path <ECHO_NEXT_DATA_ROOT> \
--labels_csv <ECHO_NEXT_LABEL_CSV> \
--align_checkpoint outputs/EchoNext/align/best_model.pth \
--subset_ratio 1.0 \
--max_epochs 30 \
--gpu 0 \
--output_dir outputs/EchoNext/linear_probingEvaluate:
python linear_probing/test.py \
--data_path <ECHO_NEXT_DATA_ROOT> \
--labels_csv <ECHO_NEXT_LABEL_CSV> \
--align_checkpoint outputs/EchoNext/align/best_model.pth \
--head_checkpoint outputs/EchoNext/linear_probing/best_linear_head.pth \
--gpu 0 \
--output_file outputs/EchoNext/linear_probing/linear_probing_eval.txtUse --subset_ratio 0.01 / 0.1 / 1.0 for low-shot probing budgets.
If you find this repository useful, please cite:
@article{echobridge2026,
title={EchoBridge: Long-Tail-Aware ECG--Echocardiography Text Alignment for Echocardiography-Derived Cardiac Findings},
author={},
journal={},
year={2026}
}(Paper / camera-ready citation will be updated upon release.)
Code in this repository is provided for research purposes. Please follow the licenses of EchoNext / PKUPH / SHTMU data and of third-party models (e.g., MedCPT).
We thank the EchoNext community and related ECG--text alignment baselines that inspired this codebase.
