TPA: Temporal Prompt Alignment for Fetal Congenital Heart Defect Classification

Darya Taratynova, Alya Almsouti, Beknur Kalmakhanbet, Numan Saeed, Mohammad YaqubarXiv 2025 · DOI

Introduction

Congenital heart defects (CHD) affect approximately 1% of live births. Early detection via prenatal ultrasound is critical for improving neonatal outcomes. However, ultrasound interpretation is notoriously challenging due to inherent image noise, acoustic shadowing from fetal bones, and high inter-operator variability.

Current AI-based diagnostic tools often suffer from three major limitations: they frequently ignore the temporal dynamics of the beating heart, they are often limited to binary "normal vs. abnormal" classification, and they tend to be overconfident. In a clinical setting, a model that lacks proper calibration—the ability to quantify its own uncertainty—can be dangerous.

The TPA Framework

To address these challenges, we present Temporal Prompt Alignment (TPA). TPA is a novel framework designed to align visual motion signatures in ultrasound videos with clinical text descriptions, leveraging vision-language foundation models to improve both diagnostic accuracy and reliability.

Overview of the TPA framework, including the CVAESM module for uncertainty quantification and the temporal prompt alignment mechanism.

The architecture consists of three core pillars:

  1. Spatiotemporal Encoding: Utilizing a foundation model like FetalCLIP, the system extracts high-level features from video frames. A temporal feature extractor (such as a Graph Neural Network or LSTM) then processes these features to capture the heart's motion over time, which is essential for identifying defects like arrhythmias or abnormal chamber contractions.
  2. Prompt-Aware Contrastive Learning: The model is trained to align video features with natural language prompts (e.g., "Is the fetal heart normal in this 4CH ultrasound view?"). A margin-hinge contrastive loss ensures that normal and abnormal cases are clearly separated in the mathematical feature space.
  3. Conditional Variational Autoencoder Style Modulation (CVAESM): This module specifically addresses the overconfidence problem. By injecting a latent style vector that represents data variability and noise, CVAESM allows the model to produce well-calibrated probability scores, effectively quantifying its own uncertainty for each video.

Experimental Setup and Datasets

The TPA framework was evaluated on two distinct datasets to test its accuracy and generalizability:

  • Private Fetal CHD Dataset: This curated dataset contains 477 high-quality four-chamber view (4CH) echocardiographic videos, annotated by senior clinical consultants across 19 distinct CHD classes, including Ventricular Septal Defect (VSD) and Arrhythmia.
  • EchoNet-Dynamic: To test generalizability beyond fetal hearts, the model was applied to this public dataset of over 10,000 adult echocardiograms to classify systolic dysfunction (heart pumping strength).

Key Results and Discussion

TPA achieved state-of-the-art performance on the CHD dataset with a macro F1 score of 85.40%, significantly outperforming traditional sequence models. Beyond raw accuracy, the model demonstrated superior reliability; the inclusion of the CVAESM module reduced the Expected Calibration Error (ECE) by 5.38%, ensuring that the model's confidence scores align more closely with its actual predictive accuracy.

t-SNE visualization comparing video embeddings from a baseline model vs. TPA, demonstrating significantly improved class separation across different heart defect types.

As shown in the t-SNE visualizations, TPA produces much tighter and more distinct clusters for different heart defects compared to baseline methods. This suggests that the alignment of temporal visual features with clinical text prompts helps the model learn more discriminative representations of cardiac pathology. On the public EchoNet-Dynamic dataset, TPA boosted the macro F1 score by 4.73% over the baseline, confirming that the benefits of temporal prompt alignment extend to adult cardiac imaging.

Conclusion and Future Directions

TPA represents a significant advancement in the automated screening of fetal heart defects. By integrating temporal dynamics with clinical language and robust uncertainty quantification, it offers a more reliable tool for prenatal diagnosis. While the current study focuses on the four-chamber view, future work will explore expanding the model to handle multiple ultrasound planes and refining prompt designs to further leverage clinical expertise.

Summary updated

Abstract

Congenital heart defect (CHD) detection in ultrasound videos is hindered by image noise and probe positioning variability. While automated methods can reduce operator dependence, current machine learning approaches often neglect temporal information, limit themselves to binary classification, and do not account for prediction calibration. We propose Temporal Prompt Alignment (TPA), a method leveraging foundation image-text model and prompt-aware contrastive learning to classify fetal CHD on cardiac ultrasound videos. TPA extracts features from each frame of video subclips using an image encoder, aggregates them with a trainable temporal extractor to capture heart motion, and aligns the video representation with class-specific text prompts via a margin-hinge contrastive loss. To enhance calibration for clinical reliability, we introduce a Conditional Variational Autoencoder Style Modulation (CVAESM) module, which learns a latent style vector to modulate embeddings and quantifies classification uncertainty. Evaluated on a private dataset for CHD detection and on a large public dataset, EchoNet-Dynamic, for systolic dysfunction, TPA achieves state-of-the-art macro F1 scores of 85.40% for CHD diagnosis, while also reducing expected calibration error by 5.38% and adaptive ECE by 6.8%. On EchoNet-Dynamic's three-class task, it boosts macro F1 by 4.73% (from 53.89% to 58.62%). Temporal Prompt Alignment (TPA) is a framework for fetal congenital heart defect (CHD) classification in ultrasound videos that integrates temporal modeling, prompt-aware contrastive learning, and uncertainty quantification.

Empirical ResultsBrowse all benchmarks →

BenchmarkMethodMetricScoreProtocol / Evidence
EchoNet-DynamicTPA (GNN temporal extractor)macro F158.62%Classification · variant=TPA with GNN temporal extractor · class-count=3
Source quote
L415: GNN │ \bfseries 84.84 │ \bfseries 87.69 │ \bfseries 58.62 │ \bfseries 82.11
BibTeX
@misc{taratynova2025tpa,
  author = {Darya Taratynova and Alya Almsouti and Beknur Kalmakhanbet and Numan Saeed and Mohammad Yaqub},
  title = {{TPA: Temporal Prompt Alignment for Fetal Congenital Heart Defect Classification}},
  year = {2025},
  eprint = {2508.15298},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.15298},
}
Figure