hh.sePublications
Change search
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf
Trajectory-Ordered Objectives for Self-Supervised Representation Learning of Temporal Healthcare Data Using Transformers: Model Development and Evaluation Study
Halmstad University, School of Information Technology.ORCID iD: 0000-0002-1999-8435
Halmstad University, School of Information Technology. Halmstad Municipality, Halmstad, Sweden.ORCID iD: 0000-0003-2006-6229
Lund University, Lund, Sweden.ORCID iD: 0000-0003-1883-2000
Lund University, Lund, Sweden.ORCID iD: 0000-0002-2581-484X
Show others and affiliations
2025 (English)In: JMIR Medical Informatics, E-ISSN 2291-9694, Vol. 13, article id e68138Article in journal (Refereed) Published
Abstract [en]

Background: The growing availability of electronic health records (EHRs) presents an opportunity to enhance patient care by uncovering hidden health risks and improving informed decisions through advanced deep learning methods. However, modeling EHR sequential data, that is, patient trajectories, is challenging due to the evolving relationships between diagnoses and treatments over time. Significant progress has been achieved using transformers and self-supervised learning. While BERT-inspired models using masked language modeling (MLM) capture EHR context, they often struggle with the complex temporal dynamics of disease progression and interventions.

Objective: This study aims to improve the modeling of EHR sequences by addressing the limitations of traditional transformer-based approaches in capturing complex temporal dependencies.

Methods: We introduce Trajectory Order Objective BERT (Bidirectional Encoder Representations from Transformers; TOO-BERT), a transformer-based model that advances the MLM pretraining approach by integrating a novel TOO to better learn the complex sequential dependencies between medical events. TOO-Bert enhanced the learned context by MLM by pretraining the model to distinguish ordered sequences of medical codes from permuted ones in a patient trajectory. The TOO is enhanced by a conditional selection process that focus on medical codes or visits that frequently occur together, to further improve contextual understanding and strengthen temporal awareness. We evaluate TOO-BERT on 2 extensive EHR datasets, MIMIC-IV hospitalization records and the Malmo Diet and Cancer Cohort (MDC)-comprising approximately 10 and 8 million medical codes, respectively. TOO-BERT is compared against conventional machine learning methods, a transformer trained from scratch, and a transformer pretrained on MLM in predicting heart failure (HF), Alzheimer disease (AD), and prolonged length of stay (PLS).

Results: TOO-BERT outperformed conventional machine learning methods and transformer-based approaches in HF, AD, and PLS prediction across both datasets. In the MDC dataset, TOO-BERT improved HF and AD prediction, increasing area under the receiver operating characteristic curve (AUC) scores from 67.7 and 69.5 with the MLM-pretrained Transformer to 73.9 and 71.9, respectively. In the MIMIC-IV dataset, TOO-BERT enhanced HF and PLS prediction, raising AUC scores from 86.2 and 60.2 with the MLM-pretrained Transformer to 89.8 and 60.4, respectively. Notably, TOO-BERT demonstrated strong performance in HF prediction even with limited fine-tuning data, achieving AUC scores of 0.877 and 0.823, compared to 0.839 and 0.799 for the MLM-pretrained Transformer, when fine-tuned on only 50% (442/884) and 20% (176/884) of the training data, respectively.

Conclusions: These findings demonstrate the effectiveness of integrating temporal ordering objectives into MLM-pretrained models, enabling deeper insights into the complex temporal relationships inherent in EHR data. Attention analysis further highlights TOO-BERT's capability to capture and represent sophisticated structural patterns within patient trajectories, offering a more nuanced understanding of disease progression.

 ©Ali Amirahmadi, Farzaneh Etminani, Jonas Björk, Olle Melander, Mattias Ohlsson.

Place, publisher, year, edition, pages
Toronto: JMIR Publications, 2025. Vol. 13, article id e68138
Keywords [en]
BERT, alzheimer disease, deep learning, disease prediction, effectiveness, electronic health record, heart failure, language mode, masked language mode, patient trajectories, prolonged health of stay, representation learning, temporal, transformer
National Category
Information Systems
Research subject
Health Innovation, IDC
Identifiers
URN: urn:nbn:se:hh:diva-56834DOI: 10.2196/68138ISI: 001519087300002PubMedID: 40465350Scopus ID: 2-s2.0-105008277733OAI: oai:DiVA.org:hh-56834DiVA, id: diva2:1982370
Funder
Swedish Research Council, 2019-00198Knowledge Foundation, 20200208 01 HAvailable from: 2025-07-08 Created: 2025-07-08 Last updated: 2026-02-19Bibliographically approved
In thesis
1. Learning More from Less: Accurate and Trustworthy Foundation Models for Patient Trajectories
Open this publication in new window or tab >>Learning More from Less: Accurate and Trustworthy Foundation Models for Patient Trajectories
2026 (English)Doctoral thesis, comprehensive summary (Other academic)
Abstract [en]

Electronic health records (EHRs) contain longitudinal traces of patients’ interactions with the healthcare system. These patient trajectories—sequences of diagnoses, medications, and other events over time—offer opportunities to predict adverse outcomes early to intervene. In practice, however, EHR data are heterogeneous, temporally complex, and often available only in limited-sized cohorts with scarce labels. This thesis, Learning More from Less: Accurate and Trustworthy Foundation Models for Patient Trajectories, investigates how to build foundation-style models for such data.

The work is guided by the question: How can we improve prediction and provide trustworthy explanations for adverse health outcomes by modeling longitudinal EHR trajectories? It follows two tracks: (i) robust EHR-specific representation learning, and (ii) trustworthy modeling. 

First, the thesis enriches self-supervised pretraining for structured EHR. A trajectory-order objective (TOO-BERT) teaches models to distinguish true temporal order from plausible permutations, while a source-masked objective model cross-sources dependencies. These objectives exploit the structure already present in trajectories, yielding stronger representations and improved prediction of incident outcomes.

Second, the thesis targets robust adaptation under label scarcity. Adaptive Noise-Augmented Attention (ANAA) perturbs and smoothly augments attention scores during fine-tuning, broadening overly sharp attention patterns and improving performance.

Third, the thesis develops explanation methods tailored to multimodal transformers EHR telemetry models. A manifold-aware baseline for Integrated Gradients keeps attribution paths in high-density regions of the representation space, improving faithfulness. Group-Sparse IG further adjusts the path schedule to produce sparse, token-level explanations that are more concise. Building on these methods, the thesis also proposes an approach to aggregate individual-level attributions into population-level insights for greater actionability, and applies it to identify key drivers of longevity and early mortality in the Malmö Diet and Cancer cohort

Finally, the thesis explores uncertainty estimation in small, sequence-based datasets through a Gaussian process model with a decoupled global alignment kernel for peptide permeability prediction. This demonstrates how structured sequence kernels can provide better accuracy and calibrated uncertainty when data are limited.

Overall, the thesis shows that in complex, data-scarce EHR settings, ``learning more from less'' requires making the pretraining, fine-tuning, and explanation stages explicitly reflect the structure of patient trajectories, leading to more accurate and trustworthy models for clinical risk prediction.

Place, publisher, year, edition, pages
Halmstad: Halmstad University Press, 2026. p. 46
Series
Halmstad University Dissertations ; 141
National Category
Electrical Engineering, Electronic Engineering, Information Engineering
Identifiers
urn:nbn:se:hh:diva-58472 (URN)978-91-90123-03-4 (ISBN)978-91-90123-04-1 (ISBN)
Public defence
2026-03-26, S3030, Kristian IV:s väg 3, Halmstad, 13:00 (English)
Opponent
Supervisors
Funder
Swedish Research Council, 2019-00198Knowledge Foundation, 20200208 01 H
Available from: 2026-02-26 Created: 2026-02-19 Last updated: 2026-02-26Bibliographically approved

Open Access in DiVA

No full text in DiVA

Other links

Publisher's full textPubMedScopus

Authority records

Amirahmadi, AliEtminani, FarzanehOhlsson, Mattias

Search in DiVA

By author/editor
Amirahmadi, AliEtminani, FarzanehBjörk, JonasMelander, OlleOhlsson, Mattias
By organisation
School of Information Technology
In the same journal
JMIR Medical Informatics
Information Systems

Search outside of DiVA

GoogleGoogle Scholar

doi
pubmed
urn-nbn

Altmetric score

doi
pubmed
urn-nbn
Total: 116 hits
CiteExportLink to record
Permanent link

Direct link
Cite
Citation style
  • apa
  • ieee
  • modern-language-association-8th-edition
  • vancouver
  • Other style
More styles
Language
  • de-DE
  • en-GB
  • en-US
  • fi-FI
  • nn-NO
  • nn-NB
  • sv-SE
  • Other locale
More languages
Output format
  • html
  • text
  • asciidoc
  • rtf