Papers › Contrast Everything: A Hierarchical Contrastive Framework for Medical Time-Series

Contrast Everything: A Hierarchical Contrastive Framework for Medical Time-Series

21 Oct 2023NeurIPS 2023 11arXiv:2310.14017archive 2025-07-28

Yihe Wang, Yu Han, Haishuai Wang, Xiang Zhang

Contrastive representation learning is crucial in medical time series analysis as it alleviates dependency on labor-intensive, domain-specific, and scarce expert annotations. However, existing contrastive learning methods primarily focus on one single data level, which fails to fully exploit the intricate nature of medical time series. To address this issue, we present COMET, an innovative hierarchical framework that leverages data consistencies at all inherent levels in medical time series. Our meticulously designed model systematically captures data consistency from four potential levels: observation, sample, trial, and patient levels. By developing contrastive loss at multiple levels, we can learn effective representations that preserve comprehensive data consistency, maximizing information utilization in a self-supervised manner. We conduct experiments in the challenging patient-independent setting. We compare COMET against six baselines using three diverse datasets, which include ECG signals for myocardial infarction and EEG signals for Alzheimer's and Parkinson's diseases. The results demonstrate that COMET consistently outperforms all baselines, particularly in setup with 10% and 1% labeled data fractions across all datasets. These results underscore the significant impact of our framework in advancing contrastive representation learning techniques for medical time series. The source code is available at https://github.com/DL4mHealth/COMET.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2310.14017")

Code

Syntology Ran 35 of 42 code samples harvested from 5 repositories linked to this paper; 7 have no recorded run. Of those that ran: 2 ran · violated contract; 4 ran · our draft was wrong; 2 ran · fixture could not drive it; 27 ran with no contract checked.

By repository: official repository: 21 samples from 1 repository, 18 ran; found in paper text by Syntology: 20 samples from 4 repositories, 16 ran; 1 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

dl4mhealth/comet officialmentioned in papermentioned on GitHubpytorchMIT report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

42 samples harvested; 35 ran; 0 honoured the contract we drafted; 7 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · violated contract
4ran · our draft was wrong
2ran · fixture could not drive it
27ran
7unverified

Licence: 2 of the 42 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 5 repositories linked to this paper, official or community; each sample names its own and says which. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

MyBatchSampler dl4mhealth/comet/comet.py official repository ran MIT (permissive) · efe1ff11e7f6a9b7 · report
TSEncoder dl4mhealth/comet/comet.py official repository ran fingerprinted MIT (permissive) · 535006b4dc141e1a · report
batch_shuffle_feature_label dl4mhealth/comet/comet.py official repository ran MIT (permissive) · 827011853812f006 · report
contrastive_loss dl4mhealth/comet/comet.py official repository ran MIT (permissive) · 016be840858ae4f4 · report
fit_svm DL4mHealth/COMET/tasks/_eval_protocols.py official repository ran MIT (permissive) · c62d56549152cab0 · report
generate_binomial_mask dl4mhealth/comet/comet.py official repository ran · violated contract fingerprinted MIT (permissive) · 7077c48726f289f1 · report
generate_continuous_mask dl4mhealth/comet/comet.py official repository ran · violated contract fingerprinted MIT (permissive) · 9cd8a0cb1b50b24b · report
id_contrastive_loss dl4mhealth/comet/comet.py official repository ran MIT (permissive) · bba058f7876cca50 · report
load_ad DL4mHealth/COMET/dataloading/ad_preprocessing.py official repository ran MIT (permissive) · abb87f4aadacbffd · report
load_ptb DL4mHealth/COMET/dataloading/ptb_preprocessing.py official repository ran MIT (permissive) · 32ecaa526bdb3d05 · report
load_tdbrain DL4mHealth/COMET/dataloading/tdbrain_preprocessing.py official repository ran MIT (permissive) · b5885c72d25d5f24 · report
observation_contrastive_loss dl4mhealth/comet/comet.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · 127e5186b374c0c6 · report
patient_contrastive_loss dl4mhealth/comet/comet.py official repository ran MIT (permissive) · c721d4c3f9feca7a · report
sample_contrastive_loss dl4mhealth/comet/comet.py official repository ran · our draft was wrong fingerprinted MIT (permissive) · a068a662fad3b92a · report
shuffle_feature_label dl4mhealth/comet/comet.py official repository ran MIT (permissive) · 84ad5a6296c54002 · report
shuffle_feature_label DL4mHealth/COMET/utils.py official repository ran MIT (permissive) · 925a0da719ba3129 · report
trial_contrastive_loss dl4mhealth/comet/comet.py official repository ran MIT (permissive) · 9f939df27acbf98d · report
trial_shuffle_feature_label dl4mhealth/comet/comet.py official repository ran fingerprinted MIT (permissive) · 1acb85286d268c68 · report
COMET dl4mhealth/comet/comet.py official repository unverified MIT (permissive) · ae8e2b7de075b9f3 · report
fit_knn DL4mHealth/COMET/tasks/_eval_protocols.py official repository unverified MIT (permissive) · befe203f4fa96ee5 · report
fit_lr DL4mHealth/COMET/tasks/_eval_protocols.py official repository unverified MIT (permissive) · 2309c20a08ac1773 · report
Attention emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran · metamorphic tier: deterministic MIT (permissive) · 617e0645b9972b67 · report
ConvBlock yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran · metamorphic tier: invariant fingerprinted MIT (permissive) · 0e30f1c230eef5dc · report
DilatedConvEncoder yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran · metamorphic tier: invariant fingerprinted MIT (permissive) · c59b7deb5be0dbfa · report
FeedForward emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran · metamorphic tier: deterministic MIT (permissive) · 234836bb032d8d76 · report
Residual emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · 8907e91277107509 · report
Seq_Transformer emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran MIT (permissive) · 92c655e3fea1cdc0 · report
TC emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran · metamorphic tier: deterministic MIT (permissive) · e8e0063a34a8e06f · report
TSEncoder yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran MIT (permissive) · 24fd56663218d25d · report
Transformer emadeldeen24/TS-TCC/models/TC.py found in paper text by Syntology ran · metamorphic tier: deterministic MIT (permissive) · 2b59ed1d60ed9658 · report
cnn_network_contrastive danikiyasseh/CLOCS/prepare_network.py found in paper text by Syntology ran licence not identified · pointer only · 146273205666e8bd · report
mixup_batch wickstrom/mixupcontrastivelearning/src/mcl/trainer.py found in paper text by Syntology ran fingerprinted MIT (permissive) · ab3068c33cd47e9d · report
resolve_device wickstrom/mixupcontrastivelearning/src/mcl/trainer.py found in paper text by Syntology ran MIT (permissive) · e5bafae5d8f3c7d7 · report
split_with_nan yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran · our draft was wrong fingerprinted MIT (permissive) · 271f7134c2ce540e · report
take_per_row yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran · fixture could not drive it MIT (permissive) · e8c3e310ce1ef8a3 · report
to_numpy3d wickstrom/mixupcontrastivelearning/src/mcl/data.py found in paper text by Syntology ran MIT (permissive) · 8eec0828aa4f64f6 · report
torch_pad_nan yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology ran · fixture could not drive it fingerprinted MIT (permissive) · 3e925bf8ba27d5fe · report
TS2Vec yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology unverified MIT (permissive) · 64cc44e198273c4e · report
centerize_vary_length_series yuezhihan/ts2vec/ts2vec.py found in paper text by Syntology unverified MIT (permissive) · a0b6f98fa3e2d24e · report
load_dataset wickstrom/mixupcontrastivelearning/src/mcl/data.py found in paper text by Syntology unverified MIT (permissive) · 48272503a70e16a5 · report
train wickstrom/mixupcontrastivelearning/src/mcl/trainer.py found in paper text by Syntology unverified MIT (permissive) · f5c0c05f7535c06b · report
pad_nan_to_target identical code first harvested elsewhere ran · our draft was wrong fingerprinted licence of this copy not recorded · 5254eb44ce12370e · report

Tasks

Contrastive LearningEEGRepresentation LearningTime SeriesTime Series Analysis

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Contrastive LearningFocus

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections