Federated learning framework for medical image analysis with perspective-aware contrastive and mixture of experts.
The 20 matches
- [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] § 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] § 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] § 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] § 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] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 13–44 · score 0.69 · residual connection, attention heads, layer normalization, embeddings, model
- [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] § Evaluation › Comparison and controlled evaluation ↔ src/federated/fedavg.py, lines 1–14 · score 0.61 · Dice coefficient, FedAvg, F1 score, confidence, accuracy, metrics
- [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] § 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] § Methodology › Local training ↔ src/federated/fedavg.py, lines 63–108 · score 0.55 · Dice Coefficient, F1 score, predictions, confidence, Precision, Recall
- [12] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 15–69 · score 0.55 · residual connection, layer normalization, head
- [13] § Methodology › Multi-head self-attention ↔ src/models/attention.py, lines 13–44 · score 0.55 · residual connection, layer normalization, head
- [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] § Methodology › Global contrastive learning ↔ src/federated/fedavg.py, lines 16–41 · score 0.55 · FedAvg, local model, global model, aggregating, federated, clients
- [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] § Methodology › Dataset description ↔ src/data/preprocess.py, lines 1–16 · score 0.54 · NIfTI, BraTS2020, modalities, MRI, segmentation
- [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] § 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] § 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
- """
- fedavg.py
- Core algorithms:
- - Weight aggregation
- - FedAvg update rule
- - Model evaluation with metrics (Accuracy, Precision, Recall, F1-score, Confidence, Dice Coefficient)
- """
- import torch
- import torch.nn.functional as F
- import numpy as np
- from sklearn.metrics import precision_score, recall_score, f1_score
- import copy
- # -----------------------------
- # Federated Averaging (FedAvg)
- # -----------------------------
- def fed_avg(models):
- """
- Perform Federated Averaging on a list of local models.
- Args:
- models (list): List of PyTorch model instances (local models from clients).
- Returns:
- dict: State dict of the global model after aggregation.
- """
- global_dict = models[0].state_dict()
- # Initialize all weights to zero
- for key in global_dict.keys():
- global_dict[key] = torch.zeros_like(global_dict[key]).float()
- # Sum up all model weights
- for model in models:
- local_dict = model.state_dict()
- for key in global_dict.keys():
- global_dict[key] += local_dict[key].float() / len(models)
- return global_dict
- # -----------------------------
- # Negative Sample Generation
- # -----------------------------
- def get_negative_samples(batch_size, dataset):
- """
- Generate negative samples from the dataset.
- Args:
- batch_size (int): Number of negative samples.
- dataset (Dataset): PyTorch dataset object.
- Returns:
- torch.Tensor: Batch of negative samples (images only).
- """
- indices = torch.randint(0, len(dataset), (batch_size,))
- negative_samples = torch.stack([dataset[i][0] for i in indices])
- return negative_samples
- # -----------------------------
- # Metric Computation
- # -----------------------------
- def compute_metrics(z_i, z_j, z_j_neg, threshold=0.99):
- """
- Compute Accuracy, Precision, Recall, F1-score, Confidence, and Dice Coefficient
- for positive and negative pairs using cosine similarity.
- Args:
- z_i (torch.Tensor): Anchor features.
- z_j (torch.Tensor): Positive features.
- z_j_neg (torch.Tensor): Negative features.
- threshold (float): Cosine similarity threshold for positive prediction.
- Returns:
- Tuple: accuracy, precision, recall, f1, confidence, dice_coeff, total_samples
- """
- z_i = F.normalize(z_i, dim=1)
- z_j = F.normalize(z_j, dim=1)
- z_j_neg = F.normalize(z_j_neg, dim=1)
- # Compute cosine similarities
- similarities_pos = torch.sum(z_i * z_j, dim=1)
- similarities_neg = torch.sum(z_i * z_j_neg, dim=1)
- # Predictions
- predictions_pos = (similarities_pos > threshold).int().cpu().numpy()
- predictions_neg = (similarities_neg > threshold).int().cpu().numpy()
- # Ground truth
- targets_pos = np.ones_like(predictions_pos)
- targets_neg = np.zeros_like(predictions_neg)
- # Concatenate
- predictions = np.concatenate((predictions_pos, predictions_neg))
- targets = np.concatenate((targets_pos, targets_neg))
- # Metrics
- accuracy = np.mean(predictions == targets)
- precision = precision_score(targets, predictions, zero_division=0)
- recall = recall_score(targets, predictions, zero_division=0)
- f1 = f1_score(targets, predictions, zero_division=0)
- confidence = similarities_pos.mean().item()
- dice_coeff = (2 * np.sum(predictions * targets)) / (np.sum(predictions) + np.sum(targets) + 1e-8)
- return accuracy, precision, recall, f1, confidence, dice_coeff, len(targets)
- # -----------------------------
- # Model Evaluation
- # -----------------------------
- def evaluate_model(model, dataloader, criterion, device, threshold=0.99):
- """
- Evaluate a model on a dataloader and compute validation metrics.
- Args:
- model (torch.nn.Module): PyTorch model.
- dataloader (DataLoader): Validation dataloader.
- criterion (callable): Loss function.
- device (torch.device): Computation device (CPU/GPU).
- threshold (float): Cosine similarity threshold for metrics.
- Returns:
- Tuple: avg_loss, avg_accuracy, avg_precision, avg_recall, avg_f1, avg_confidence, avg_dice_coeff
- """
- model.eval()
- total_loss = 0
- total_correct = 0
- total_samples = 0
- all_precision, all_recall, all_f1, all_confidence, all_dice_coeff = [], [], [], [], []
- with torch.no_grad():
- for images, _ in dataloader:
- images = images.to(device)
- negative_images = get_negative_samples(len(images), dataloader.dataset).to(device)
- # Extract features
- z_i = model(images)
- z_j = model(images)
- z_j_neg = model(negative_images)
- # Dummy global values for criterion if needed
- ssv = z_i
- gav = z_j.mean(dim=0, keepdim=True).repeat(z_j.size(0), 1)
- loss = criterion(z_i, z_j, ssv, gav)
- total_loss += loss.item()
- metrics = compute_metrics(z_i, z_j, z_j_neg, threshold)
- accuracy, precision, recall, f1, confidence, dice_coeff, total = metrics
- total_correct += accuracy * total
- total_samples += total
- all_precision.append(precision)
- all_recall.append(recall)
- all_f1.append(f1)
- all_confidence.append(confidence)
- all_dice_coeff.append(dice_coeff)
- # Average metrics
- avg_loss = total_loss / len(dataloader)
- avg_accuracy = total_correct / total_samples
- avg_precision = np.mean(all_precision)
- avg_recall = np.mean(all_recall)
- avg_f1 = np.mean(all_f1)
- avg_confidence = np.mean(all_confidence)
- avg_dice_coeff = np.mean(all_dice_coeff)
- 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}")
- 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
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
51b11003fed10149b546b0b6b219b29949afb8e6, 31 March 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
29 files
- gastric_cancer/
dataloader.py , Python, 89 lines - gastric_cancer/
exploring_dataset.py , Python, 66 lines - gastric_cancer/
fed_avg.py , Python, 128 lines - gastric_cancer/
preprocess.py , Python, 134 lines - gastric_cancer/
training.py , Python, 311 lines - gastric_cancer/
training_result.py , Python, 44 lines - src/
data/ , Python, 68 linesdownload.py - src/
data/ , Python, 100 lines, 1 matchpreprocess.py - src/
data/ , Python, 91 linesutils.py - src/
federated/ , Python, 28 linesaggregation.py - src/
federated/ , Python, 37 linesclient_simulator.py - src/
federated/ , Python, 172 lines, 6 matchesfedavg.py - src/
models/ , Python, 69 lines, 2 matchesattention.py - src/
models/ , Python, 68 lines, 2 matchesattention_contrastive_mo del.py - src/
models/ , Python, 42 linesloss.py - src/
models/ , Python, 59 linesmoe.py - src/
models/ , Python, 58 lines, 2 matchesmpda.py - src/
preprocess/ , Python, 34 linesdataloaders.py - src/
preprocess/ , Python, 51 linesdataset.py - src/
preprocess/ , Python, 49 linessplit_clients.py - src/
training/ , Python, 67 lineslosses.py - src/
training/ , Python, 81 lines, 2 matchesmetrics.py - src/
training/ , Python, 102 linestrain.py - src/
visualization/ , Python, 98 lineshistogram_plots.py - src/
visualization/ , Python, 63 linesplot_modalities.py - src/
visualization/ , Python, 135 linessegmentation_plots.py - src/
visualization/ , Python, 97 linesvisualize_slices.py - LICENSE, License, 21 lines
- README.md, Text, 155 lines
Zenodo 17883548
Availability: 1 check, the latest on 27 September 2026: the link answers (HTTP 200)
- 27 September 2026: the link answers (HTTP 200)
23 files
- src/
data/ , Python, 68 linesdownload.py - src/
data/ , Python, 100 linespreprocess.py - src/
data/ , Python, 91 linesutils.py - src/
federated/ , Python, 28 linesaggregation.py - src/
federated/ , Python, 37 linesclient_simulator.py - src/
federated/ , Python, 172 linesfedavg.py - src/
models/ , Python, 44 lines, 2 matchesattention.py - src/
models/ , Python, 52 lines, 1 matchattention_contrastive_mo del.py - src/
models/ , Python, 37 linesloss.py - src/
models/ , Python, 56 linesmoe.py - src/
models/ , Python, 65 lines, 2 matchesmpda.py - src/
preprocess/ , Python, 34 linesdataloaders.py - src/
preprocess/ , Python, 51 linesdataset.py - src/
preprocess/ , Python, 42 linessplit_clients.py - src/
training/ , Python, 67 lineslosses.py - src/
training/ , Python, 81 linesmetrics.py - src/
training/ , Python, 102 linestrain.py - src/
visualization/ , Python, 98 lineshistogram_plots.py - src/
visualization/ , Python, 63 linesplot_modalities.py - src/
visualization/ , Python, 135 linessegmentation_plots.py - src/
visualization/ , Python, 97 linesvisualize_slices.py - LICENSE, License, 21 lines
- README.md, Text, 155 lines
Code availability
The custom code developed for implementing the proposed FedPAC-ME framework is available in a public GitHub repository at: https://
A permanent, citable version of the code has been archived on Zenodo and assigned a DOI: 10.5281/
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
- figshare:26014469, at figshare; found in the references
- kaggle.com/
datasets/ , at Kaggle; found in the referencesawsaf49
Data availability statement
The original contributions presented in the study are included in the article/
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://
BibTeX
@article{das2026federate
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/
url = {https://
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/
VL - 9
SP - 1807248
SN - 2624-8212
PB - Frontiers Media SA
DO - 10.3389/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.3389/
"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":
"volume": "9",
"page": "1807248",
"DOI": "10.3389/
"PMID": "42369006",
"PMCID": "PMC13294053",
"ISSN": "2624-8212",
"publisher": "Frontiers Media SA",
"URL": "https://
"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 communicationsIn 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 reportsIn 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 oncologyIn 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 imagingIn 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 methodsIn 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 intelligenceIn 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 imagingIn 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 myelinationJournal: 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 communicationsIn 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.
Claim this paper
Correct its record
Say what each link of this record is, remove the ones that are not the paper's, add the ones that are missing. The correction becomes a new version of the record, in its Versions section.
Validate its tracing map
You validate the map as this page shows it: 2 repositories of the authors' code, each at its verified commit and with its license, 48 scripts, and 20 matches between paragraphs and code (see the Code and Map sections). It then receives a DOI on Zenodo, with you (your ORCID iD) and OSCR as its creators; the code itself is not deposited.
The map's fingerprint: sha256:34702f18eb6e7d1f…
Add the badge to its README
The badge links the code to this page. Copy one of these into the README of the paper's code: only you decide where it goes, and nothing is changed for you.
Markdown
[, paste the snippet at the top, then “Commit changes…” and, to review it first, “Create a new branch and start a pull request”. You open the pull request; OSCR asks for no permission.
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.
