OSCR

Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts.

Code ↔ Paper

20 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 20 matches
  1. [1] § Methodology › Multi-Perspective Augmentation (MPA) ↔ src/models/mpda.py, lines 14–65 · score 0.81 · adversarial perturbations, Spatially Shifted View, Perturbed Contrastive View, Adversarial View, noise, PCV
  2. [2] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 15–69 · score 0.77 · residual connection, linear projection, attention heads, layer normalization, model
  3. [3] § Methodology › Multi-Perspective Augmentation (MPA) ↔ src/models/mpda.py, lines 14–65 · score 0.77 · Spatially Shifted View, Perturbed Contrastive View, Adversarial View, noise, pixel, simulates
  4. [4] § Methodology › Multi-Perspective Augmentation (MPA) ↔ src/models/mpda.py, lines 12–58 · score 0.75 · Spatially Shifted View, Perturbed Contrastive View, Adversarial View, noise, pixel, PCV
  5. [5] § Methodology › Multi-Perspective Augmentation (MPA) ↔ src/models/mpda.py, lines 12–58 · score 0.73 · Spatially Shifted View, Perturbed Contrastive View, Adversarial View, noise, PCV, SSV
  6. [6] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 13–44 · score 0.69 · residual connection, attention heads, layer normalization, embeddings, model
  7. [7] § Evaluation › Performance metrics and evaluation criteria ↔ src/federated/fedavg.py, lines 63–108 · score 0.67 · ground truth, Dice coefficient, F1 score, predicted, confidence, precision
  8. [8] § Evaluation › Comparison and controlled evaluation ↔ src/federated/fedavg.py, lines 1–14 · score 0.61 · Dice coefficient, FedAvg, F1 score, confidence, accuracy, metrics
  9. [9] § Methodology › Module integration and data flow ↔ src/federated/fedavg.py, lines 16–41 · score 0.58 · model weights, FedAvg, Global Model, Aggregation, Federated
  10. [10] § Methodology › Module integration and data flow ↔ src/models/attention_contrastive_model.py, lines 16–68 · score 0.56 · DenseNet, Attention Contrastive Model, backbone, flattening, global, Module
  11. [11] § Methodology › Local training ↔ src/federated/fedavg.py, lines 63–108 · score 0.55 · Dice Coefficient, F1 score, predictions, confidence, Precision, Recall
  12. [12] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 15–69 · score 0.55 · residual connection, layer normalization, head
  13. [13] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 13–44 · score 0.55 · residual connection, layer normalization, head
  14. [14] § Evaluation › Performance metrics and evaluation criteria ↔ src/training/metrics.py, lines 37–70 · score 0.55 · Dice Coefficient, F1 Score, Confidence, epoch, metrics, Precision
  15. [15] § Methodology › Global contrastive learning ↔ src/federated/fedavg.py, lines 16–41 · score 0.55 · FedAvg, local model, global model, aggregating, federated, clients
  16. [16] § Evaluation › Performance metrics and evaluation criteria ↔ src/training/metrics.py, lines 37–70 · score 0.54 · Dice Coefficient, F1 Score, Confidence, epochs, metrics, Recall
  17. [17] § Methodology › Dataset description ↔ src/data/preprocess.py, lines 1–16 · score 0.54 · NIfTI, BraTS2020, modalities, MRI, segmentation
  18. [18] § Methodology › Module integration and data flow ↔ src/models/attention_contrastive_model.py, lines 14–52 · score 0.54 · DenseNet, Attention Contrastive Model, backbone, flattening, Module
  19. [19] § Evaluation › Performance metrics and evaluation criteria ↔ src/federated/fedavg.py, lines 1–14 · score 0.52 · Dice coefficient, F1 score, confidence, precision, recall, metrics
  20. [20] § Methodology › Local training ↔ src/models/attention_contrastive_model.py, lines 16–68 · score 0.51 · DenseNet, expert routing, MHSA, MoE

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

Python · 172 lines · 5.8 KB · MIT · 6 matches

  1. """
  2. fedavg.py
  3. Core algorithms:
  4. - Weight aggregation
  5. - FedAvg update rule
  6. - Model evaluation with metrics (Accuracy, Precision, Recall, F1-score, Confidence, Dice Coefficient)
  7. """
  8. import torch
  9. import torch.nn.functional as F
  10. import numpy as np
  11. from sklearn.metrics import precision_score, recall_score, f1_score
  12. import copy
  13. # -----------------------------
  14. # Federated Averaging (FedAvg)
  15. # -----------------------------
  16. def fed_avg(models):
  17. """
  18. Perform Federated Averaging on a list of local models.
  19. Args:
  20. models (list): List of PyTorch model instances (local models from clients).
  21. Returns:
  22. dict: State dict of the global model after aggregation.
  23. """
  24. global_dict = models[0].state_dict()
  25. # Initialize all weights to zero
  26. for key in global_dict.keys():
  27. global_dict[key] = torch.zeros_like(global_dict[key]).float()
  28. # Sum up all model weights
  29. for model in models:
  30. local_dict = model.state_dict()
  31. for key in global_dict.keys():
  32. global_dict[key] += local_dict[key].float() / len(models)
  33. return global_dict
  34. # -----------------------------
  35. # Negative Sample Generation
  36. # -----------------------------
  37. def get_negative_samples(batch_size, dataset):
  38. """
  39. Generate negative samples from the dataset.
  40. Args:
  41. batch_size (int): Number of negative samples.
  42. dataset (Dataset): PyTorch dataset object.
  43. Returns:
  44. torch.Tensor: Batch of negative samples (images only).
  45. """
  46. indices = torch.randint(0, len(dataset), (batch_size,))
  47. negative_samples = torch.stack([dataset[i][0] for i in indices])
  48. return negative_samples
  49. # -----------------------------
  50. # Metric Computation
  51. # -----------------------------
  52. def compute_metrics(z_i, z_j, z_j_neg, threshold=0.99):
  53. """
  54. Compute Accuracy, Precision, Recall, F1-score, Confidence, and Dice Coefficient
  55. for positive and negative pairs using cosine similarity.
  56. Args:
  57. z_i (torch.Tensor): Anchor features.
  58. z_j (torch.Tensor): Positive features.
  59. z_j_neg (torch.Tensor): Negative features.
  60. threshold (float): Cosine similarity threshold for positive prediction.
  61. Returns:
  62. Tuple: accuracy, precision, recall, f1, confidence, dice_coeff, total_samples
  63. """
  64. z_i = F.normalize(z_i, dim=1)
  65. z_j = F.normalize(z_j, dim=1)
  66. z_j_neg = F.normalize(z_j_neg, dim=1)
  67. # Compute cosine similarities
  68. similarities_pos = torch.sum(z_i * z_j, dim=1)
  69. similarities_neg = torch.sum(z_i * z_j_neg, dim=1)
  70. # Predictions
  71. predictions_pos = (similarities_pos > threshold).int().cpu().numpy()
  72. predictions_neg = (similarities_neg > threshold).int().cpu().numpy()
  73. # Ground truth
  74. targets_pos = np.ones_like(predictions_pos)
  75. targets_neg = np.zeros_like(predictions_neg)
  76. # Concatenate
  77. predictions = np.concatenate((predictions_pos, predictions_neg))
  78. targets = np.concatenate((targets_pos, targets_neg))
  79. # Metrics
  80. accuracy = np.mean(predictions == targets)
  81. precision = precision_score(targets, predictions, zero_division=0)
  82. recall = recall_score(targets, predictions, zero_division=0)
  83. f1 = f1_score(targets, predictions, zero_division=0)
  84. confidence = similarities_pos.mean().item()
  85. dice_coeff = (2 * np.sum(predictions * targets)) / (np.sum(predictions) + np.sum(targets) + 1e-8)
  86. return accuracy, precision, recall, f1, confidence, dice_coeff, len(targets)
  87. # -----------------------------
  88. # Model Evaluation
  89. # -----------------------------
  90. def evaluate_model(model, dataloader, criterion, device, threshold=0.99):
  91. """
  92. Evaluate a model on a dataloader and compute validation metrics.
  93. Args:
  94. model (torch.nn.Module): PyTorch model.
  95. dataloader (DataLoader): Validation dataloader.
  96. criterion (callable): Loss function.
  97. device (torch.device): Computation device (CPU/GPU).
  98. threshold (float): Cosine similarity threshold for metrics.
  99. Returns:
  100. Tuple: avg_loss, avg_accuracy, avg_precision, avg_recall, avg_f1, avg_confidence, avg_dice_coeff
  101. """
  102. model.eval()
  103. total_loss = 0
  104. total_correct = 0
  105. total_samples = 0
  106. all_precision, all_recall, all_f1, all_confidence, all_dice_coeff = [], [], [], [], []
  107. with torch.no_grad():
  108. for images, _ in dataloader:
  109. images = images.to(device)
  110. negative_images = get_negative_samples(len(images), dataloader.dataset).to(device)
  111. # Extract features
  112. z_i = model(images)
  113. z_j = model(images)
  114. z_j_neg = model(negative_images)
  115. # Dummy global values for criterion if needed
  116. ssv = z_i
  117. gav = z_j.mean(dim=0, keepdim=True).repeat(z_j.size(0), 1)
  118. loss = criterion(z_i, z_j, ssv, gav)
  119. total_loss += loss.item()
  120. metrics = compute_metrics(z_i, z_j, z_j_neg, threshold)
  121. accuracy, precision, recall, f1, confidence, dice_coeff, total = metrics
  122. total_correct += accuracy * total
  123. total_samples += total
  124. all_precision.append(precision)
  125. all_recall.append(recall)
  126. all_f1.append(f1)
  127. all_confidence.append(confidence)
  128. all_dice_coeff.append(dice_coeff)
  129. # Average metrics
  130. avg_loss = total_loss / len(dataloader)
  131. avg_accuracy = total_correct / total_samples
  132. avg_precision = np.mean(all_precision)
  133. avg_recall = np.mean(all_recall)
  134. avg_f1 = np.mean(all_f1)
  135. avg_confidence = np.mean(all_confidence)
  136. avg_dice_coeff = np.mean(all_dice_coeff)
  137. print(f"Validation -> Loss: {avg_loss:.4f}, Accuracy: {avg_accuracy:.4f}, Precision: {avg_precision:.4f}, Recall: {avg_recall:.4f}, F1: {avg_f1:.4f}, Confidence: {avg_confidence:.4f}, Dice: {avg_dice_coeff:.4f}")
  138. return avg_loss, avg_accuracy, avg_precision, avg_recall, avg_f1, avg_confidence, avg_dice_coeff

fedavg.py at commit 51b1100, under MIT · at the source

Overview

Authors: Shradhanjali Das1, K Hemalatha1
  1. School of Computer Science and Engineering, Vellore Institute of Technology, Chennai, Tamil Nadu, India
Journal: Frontiers in artificial intelligence, volume 9, article 1807248
Dates: received 9 February 2026; accepted 14 May 2026; published online 11 June 2026
Type: Research article · Language: English
License: CC BY
Identifiers: DOI 10.3389/frai.2026.1807248 · PMID 42369006 · PMCID PMC13294053 · OpenAlex W7164414128
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: methods / tools (subfield)
Methods: Machine learning
Keywords: federated learning, medical image classification, perspective aware contrastive, mixture of experts, attention mechanism, attention contrastive model, multi perspective augmentation
Topic: Privacy-Preserving Technologies in Data (Artificial Intelligence, Computer Science), according to OpenAlex
Citations: not cited yet (Europe PMC); 49 references in the paper

Abstract

Medical image analysis faces persistent challenges due to the distributed data, limited annotations, and variations in imaging modalities, acquisition protocols, and patient demographics. Centralized deep learning approaches compromise data privacy, while Federated Learning (FL) enables decentralized model training without sharing raw data. However, conventional FL frameworks struggle with non-IID distributions and heterogeneous clinical environments, limiting their generalization and stability. We propose FedPAC-ME, a novel Federated Learning Framework for Medical Image Analysis that integrates Perspective-Aware Contrastive Learning with a Mixture of Experts (MoE) architecture to address heterogeneity and data imbalance. The framework introduces Multi-Perspective Augmentation (MPA) to emulate diverse clinical views, and a Perspective-Aware contrastive Module (PACM) that aligns representations across modalities and clients. Additionally, a Mixture of Experts routing layer dynamically allocates specialized experts to client-specific data distributions, enhancing adaptability and collaboration across sites. A Perspective-Aware Contrastive Loss (PACL) further enforces cross-view consistency during local training while maintaining global coherence across institutions. Extensive experiments on the BraTS2020 multi-institutional brain tumor segmentation dataset demonstrate that FedPAC-ME achieves 98.80% accuracy, surpassing state-of-the-art FL baselines by over 2.5%. These results confirm the framework's effectiveness in improving feature alignment, generalization, and privacy preservation under diverse clinical conditions.

Reproduced under the paper's license (CC BY), from the paper cited above.

Repositories

Its files are read in the Code ↔ Paper reader above, with 20 matches between paragraphs and lines of code.

Shradha1023/FedPAC-ME

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Commit: 51b11003fed10149b546b0b6b219b29949afb8e6, 31 March 2026
Languages: Python (27)
Size: 44 files, 27 scripts
Software Heritage: not archived
Found in: “Code availability”
Holds: README, license file, environment (requirements.txt)
Not found: CITATION.cff, tests, continuous integration, documentation
Tools: PyTorch (14 files), NumPy (11 files), Matplotlib (8 files), scikit-learn (6 files), NiBabel (2 files), pandas (2 files), Pillow (2 files), SciPy (1 file), seaborn (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers
  • 27 September 2026: the link answers
29 files

Zenodo 17883548

License: MIT
State: the link answers, verified on 27 September 2026
Evidence: files inventoried
Size: 1 file
Software Heritage: not checked
Found in: “Code availability”
Not found: README, license file, CITATION.cff, environment file, tests, continuous integration, documentation
Tools: PyTorch (11 files), NumPy (7 files), Matplotlib (6 files), scikit-learn (3 files), NiBabel (2 files), pandas (1 file), SciPy (1 file)
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
  • 27 September 2026: the link answers (HTTP 200)
23 files

Code availability

The custom code developed for implementing the proposed FedPAC-ME framework is available in a public GitHub repository at: https://github.com/Shradha1023/FedPAC-ME.

A permanent, citable version of the code has been archived on Zenodo and assigned a DOI: 10.5281/zenodo.17883548 (https://doi.org/10.5281/zenodo.17883548), in accordance with Scientific Reports editorial policies. The archived version corresponds to the exact code used in this study's experiments. The code is released under the MIT license. No restrictions apply to accessing or using the code. Any dependencies and environment configurations are documented in the repository README.md.

Reproduced under the paper's license (CC BY), from the paper cited above.

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 2 repositories of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 48 scripts, each with its path and the digest of its content;
  • 20 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

Datasets cited

Data availability statement

The original contributions presented in the study are included in the article/supplementary material, further inquiries can be directed to the corresponding author.

Reproduced under the paper's license (CC BY), from the paper cited above.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 27 September 2026: the first record

Recorded: type, language, journal, volume, pages, dates, 2 authors, 7 keywords, 39 references.

Cite

This paper

Das, S., & Hemalatha, K. (2026). Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts. Frontiers in artificial intelligence, 9, 1807248. https://doi.org/10.3389/frai.2026.1807248

BibTeX

@article{das2026federated,
author = {Das, Shradhanjali and Hemalatha, K},
title = {{Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts}},
journal = {Frontiers in artificial intelligence},
year = {2026},
month = jun,
volume = {9},
pages = {1807248},
publisher = {Frontiers Media SA},
issn = {2624-8212},
doi = {10.3389/frai.2026.1807248},
url = {https://doi.org/10.3389/frai.2026.1807248},
pmid = {42369006},
pmcid = {PMC13294053}
}

RIS

TY - JOUR
AU - Das, Shradhanjali
AU - Hemalatha, K
TI - Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts
T2 - Frontiers in artificial intelligence
J2 - Front Artif Intell
PY - 2026
DA - 2026/06/11
VL - 9
SP - 1807248
SN - 2624-8212
PB - Frontiers Media SA
DO - 10.3389/frai.2026.1807248
UR - https://doi.org/10.3389/frai.2026.1807248
LA - en
ER -

CSL-JSON

{
"id": "10.3389/frai.2026.1807248",
"type": "article-journal",
"title": "Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts",
"container-title": "Frontiers in artificial intelligence",
"author": [
{
"family": "Das",
"given": "Shradhanjali"
},
{
"family": "Hemalatha",
"given": "K"
}
],
"container-title-short": "Front Artif Intell",
"volume": "9",
"page": "1807248",
"DOI": "10.3389/frai.2026.1807248",
"PMID": "42369006",
"PMCID": "PMC13294053",
"ISSN": "2624-8212",
"publisher": "Frontiers Media SA",
"URL": "https://doi.org/10.3389/frai.2026.1807248",
"language": "en",
"issued": {
"date-parts": [
[
2026,
6,
11
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.1038/s41467-026-71267-5 [code]
Human-like cognitive generalization for large models via mental representation-guided supervision.
Journal: Nature communications
In common: Pillow, PyTorch, scikit-learn, 4 other tools, kaggle.com/datasets/awsaf49
[2] doi:10.1038/s41598-026-48496-1 [code]
A unified FLAIR hyperintensity segmentation model for various CNS tumor types and acquisition time points.
Journal: Scientific reports
In common: Pillow, NiBabel, seaborn, 5 other tools, methods / tools, 2 references
[3] doi:10.1016/j.phro.2026.101056 [code]
Toward uncertainty-aware manual delineation of brain tumours using eye-tracking and image-derived features.
Journal: Physics and imaging in radiation oncology
In common: Pillow, NiBabel, PyTorch, 6 other tools, 1 reference
[4] doi:10.1186/s12880-026-02481-2 [code]
Deep learning-based neuroanatomical profiling reveals population-specific brain changes in multiple sclerosis: a large-scale Middle Eastern study.
Journal: BMC medical imaging
In common: Pillow, NiBabel, seaborn, 5 other tools, 1 reference
[5] doi:10.1038/s41592-026-03194-8 [code]
Beyond benchmarking: an expert-guided consensus approach to spatially aware clustering.
Journal: Nature methods
In common: Pillow, NiBabel, PyTorch, 6 other tools, methods / tools
[6] doi:10.3389/frai.2026.1841639 [code]
Label tree semantic losses for rich multi-class medical image segmentation.
Journal: Frontiers in artificial intelligence
In common: Pillow, NiBabel, PyTorch, 5 other tools, 1 reference
[7] doi:10.1016/j.patter.2026.101538 [code]
A multi-modal foundation model for brain disease diagnosis and medical imaging.
Journal: Patterns (New York, N.Y.)
In common: Pillow, NiBabel, PyTorch, 5 other tools, 1 reference
[8] doi:10.1186/s13244-026-02365-7 [code]
Super-resolution MRI and 2.5D deep learning for intratumoral-peritumoral radiomics in preoperative prediction of rectal cancer perineural invasion.
Journal: Insights into imaging
In common: Pillow, NiBabel, PyTorch, 6 other tools
[9] doi:10.64898/2026.08.18.26360725 [code]
Temporal pole blurring in hippocampal sclerosis reflects seizure-disrupted myelination
Journal: medRxiv (preprint)
In common: Pillow, NiBabel, PyTorch, 6 other tools
[10] doi:10.1038/s41467-026-76098-y [code]
A single computational objective can produce specialization of streams in visual cortex.
Journal: Nature communications
In common: Pillow, NiBabel, PyTorch, 6 other tools

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.