PANDA: Patch-based unsupervised deep learning for brain anomaly detection via age prediction in fetal MRI.
The 2 matches
- [1] § Materials and Methods › Training details ↔ train.py, lines 72–130 · score 0.69 · weight decay, epochs, GPU, checkpoint, optimizer, Loss
- [2] § Materials and Methods › Training details ↔ train.py, lines 72–130 · score 0.59 · weight decay, GPU, optimizer, loss, training, batch
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 · 130 lines · 4.9 KB · MIT · 2 matches
- from sfcn import SFCN
- from monai.networks.nets import ResNet, ResNetBottleneck
- import torch
- from fdataset import FetalBrainDataset
- from pathlib import Path
- import random
- import warnings
- import torch.nn as nn
- from math import sqrt
- from torch.nn import functional as F
- import numpy as np
- import os
- from torch.utils.data import Dataset, Subset
- import nibabel as nib
- from matplotlib import pyplot as plt
- from datetime import datetime
- from tqdm import tqdm
- import pandas as pd
- def create_id_to_age_lookup(file_path, id_column='ID', age_column='Age'):
- df = pd.read_excel(file_path, engine='openpyxl')
- id_age_dict = df.set_index(id_column)[age_column].to_dict()
- result_dict = {}
- for id_key, age_value in id_age_dict.items():
- input_str = str(age_value)
- if "+" in input_str:
- parts = input_str.split("+")
- result = int(parts[0]) * 7 + int(parts[1])
- else:
- result = int(input_str) * 7
- result_dict[id_key] = result
- return result_dict
- file = '/path/to/age'
- id_age_map = create_id_to_age_lookup(file)
- def loss_f2(age, recon_age):
- return torch.abs(age - recon_age).mean()
- def train(model, train_loader, optimizer, device):
- model.train()
- total_loss = 0
- for batch in train_loader:
- brain, filenames = batch
- brain = brain.to(device)
- optimizer.zero_grad()
- ages = [id_age_map.get(fname.split('_')[0], float('nan')) for fname in filenames]
- age = torch.tensor(ages, dtype=torch.float32).to(device)
- predicted_age = model(brain)[0].squeeze()
- loss = loss_f2(age, predicted_age)
- loss.backward()
- optimizer.step()
- total_loss += loss.item()
- len_loss = len(train_loader)
- return total_loss / len_loss
- def val(model, val_loader, device):
- model.eval()
- total_loss = 0
- with torch.no_grad():
- for batch in val_loader:
- brain, filenames = batch
- brain = brain.to(device)
- ages = [id_age_map.get('fb' + fname.split('_')[0], float('nan')) for fname in filenames]
- age = torch.tensor(ages, dtype=torch.float32).to(device)
- predicted_age = model(brain)[0].squeeze()
- loss = loss_f2(age, predicted_age)
- total_loss += loss.item()
- len_loss = len(val_loader)
- return total_loss / len_loss
- if __name__ == "__main__":
- gpu_index = 0
- device = torch.device(f'cuda:{gpu_index}')
- model = SFCN(select_patch=True).to(device)
- lr = 0.0001
- max_epochs = 1000
- optimizer = torch.optim.Adam(model.parameters(), lr=lr, amsgrad=True, weight_decay=0.00001)
- train_datapath = "/data/birth/lmx/work/Class_projects/course5/work/fetal/Data/new_age_data/train"
- train_dataset = FetalBrainDataset(train_datapath, split = 'test')
- print(f"Original train_dataset size: {len(train_dataset)}")
- train_dataloader = torch.utils.data.DataLoader(train_dataset,batch_size=32,shuffle=True,drop_last=True,num_workers=6)
- val_datapath = "/data/birth/lmx/work/Class_projects/course5/work/fetal/Data/new_age_data/val"
- val_dataset = FetalBrainDataset(val_datapath, split = 'test')
- print(f"Original val_dataset size: {len(val_dataset)}")
- val_dataloader = torch.utils.data.DataLoader(val_dataset,batch_size=32,shuffle=False,drop_last=True,num_workers=6)
- progress_bar = tqdm(range(1, max_epochs + 1), desc="Training Progress")
- train_losses = []
- val_losses = []
- best_val_loss = float('inf')
- for epoch in progress_bar:
- train_loss = train(model, train_dataloader, optimizer, device)
- train_losses.append(train_loss)
- val_loss = val(model, val_dataloader, device)
- val_losses.append(val_loss)
- print(f"Epoch [{epoch}/{1000}]")
- print(f"Loss : Train: {train_loss:.8f}, Val: {val_loss:.8f}")
- output_folder = "/your/output/folder"
- if val_loss < best_val_loss:
- best_val_loss = val_loss
- checkpoint_path = os.path.join('/your/output/folder', 'best_model.pt')
- os.makedirs(os.path.dirname(checkpoint_path), exist_ok=True)
- torch.save({
- 'epoch': epoch,
- 'model_state_dict': model.state_dict(),
- 'optimizer_state_dict': optimizer.state_dict(),
- 'best_val_loss': best_val_loss}, checkpoint_path)
- if epoch % 25 == 0:
- current_time = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
- epochs = range(4, len(train_losses) + 1)
- plt.figure(figsize=(10, 5))
- plt.plot(epochs, train_losses[3:], color='green', label='Train Loss Age')
- plt.plot(epochs, val_losses[3:], color='orange', label='Val Loss Age')
- plt.title('Age Loss')
- plt.xlabel('Epoch')
- plt.ylabel('Loss')
- plt.legend()
- plt.grid(True)
- plt.tight_layout()
- age_loss_path = os.path.join(output_folder, f"age_loss_{current_time}.png")
- plt.savefig(age_loss_path, bbox_inches='tight', pad_inches=0)
- plt.close()
train.py at commit 84b13d6, under MIT · at the source
Overview
- Department of Radiology, West China Second University Hospital, Sichuan University, Chengdu, Sichuan Province, China
- School of Biomedical Engineering, Tsinghua Medicine, Tsinghua University, Beijing, China
- Key Laboratory of Birth Defects and Related Diseases of Women and Children, Ministry of Education, Chengdu, Sichuan Province, China
- Department of Radiology, Chengdu Seventh People’s Hospital (Affiliated Cancer Hospital of Chengdu Medical College), Chengdu, China
- Department of Radiology, Sichuan Provincial Women’s and Children’s Hospital, The Affiliated Women’s and Children’s Hospital of Chengdu Medical College, Chengdu, China
- Chengdu Women’s and Children’s Central Hospital, School of Medicine, University of Electronic Science and Technology of China, Chengdu, China
Abstract
Fetal brains frequently exhibit anomalies arising from a broad spectrum of etiologies, such as genetic, infectious, hemorrhagic, or hypoxic-ischemic insults, many of which are associated with serious clinical morbidities. Unsupervised anomaly detection, which learns exclusively from normal cases to identify significant deviations from normative patterns without prior knowledge of specific anomaly types, offers a promising approach for automatic diagnosis of such conditions. In particular, recent studies have demonstrated that the absolute age difference (AAD) between predicted gestational age (PGA) of deep learning models from MRI images and biological gestational age (BGA) shows potential for detecting fetal brain anomalies, albeit with limited performance. To enhance anomaly detection capabilities, this study introduces a three-dimensional (3D) Patch-based brain ANomaly Detection framework via Age prediction (PANDA), utilizing the maximum AAD across all patches (MaxAAD) as a biomarker for identifying fetal brain anomalies. Experiments were conducted on MRI data from a large clinical cohort of 1,316 fetuses comprising 711 normal cases and 605 abnormal cases, including 343 with ventriculomegaly (VM), 50 with germinal matrix-intraventricular hemorrhage (GMH-IVH), and 212 with subependymal cysts (SEC). PANDA achieved the best diagnostic performance with an area under the receiver operating characteristic curve (AUROC) of 0.762 and an area under the precision-recall curve (AUPR) of 0.790. Subgroup analysis across the three disease categories further revealed consistently superior performance.
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 2 matches between paragraphs and lines of code.
yingqihao2022/PANDA
40e00a386b65d617b056bc332bb112c78fb059d2, 27 April 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
7 files
- fdataset.py, Python, 61 lines
- inference.py, Python, 44 lines
- preprocess.py, Python, 112 lines
- sfcn.py, Python, 80 lines
- train.py, Python, 130 lines
- LICENSE, License, 21 lines
- README.md, Text, 71 lines
birthlab/PANDA
84b13d6320bf3c62817e8fb09f5ac802e1a4b166, 18 June 2026Availability: 1 check, the latest on 27 September 2026: the link answers
- 27 September 2026: the link answers
7 files
- fdataset.py, Python, 61 lines
- inference.py, Python, 44 lines
- preprocess.py, Python, 112 lines
- sfcn.py, Python, 80 lines
- train.py, Python, 130 lines, 2 matches
- LICENSE, License, 21 lines
- README.md, Text, 91 lines
The paper's code and data availability statement is in the Data section.
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;
- 10 scripts, each with its path and the digest of its content;
- 2 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
No dataset and no data link were found in the paper.
Data and Code Availability
Data generated or analyzed during the study are not publicly available, but are available from the corresponding author by request. The source codes of PANDA are implemented using Pytorch, which are available at: https://
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, 13 authors, 5 keywords, 6 funders, 50 references.
Cite
This paper
Hao, Y., Liu, M., Zhu, J., Yang, H., Li, H., Kang, M., Song, Y., Lai, H., Zhou, X., Ning, G., Liao, Y., Qu, H., & Tian, Q. (2026). PANDA: Patch-based unsupervised deep learning for brain anomaly detection via age prediction in fetal MRI. Imaging neuroscience (Cambridge, Mass.), 4, IMAG.a.1293. https://
BibTeX
@article{hao2026panda,
author = {Hao, Yingqi and Liu, Mingxuan and Zhu, Juncheng and Yang, Hongjia and Li, Haoxiang and Kang, Min and Song, Yan and Lai, Hua and Zhou, Xiaoling and Ning, Gang and Liao, Yi and Qu, Haibo and Tian, Qiyuan},
title = {{PANDA: Patch-based unsupervised deep learning for brain anomaly detection via age prediction in fetal MRI}},
journal = {Imaging neuroscience (Cambridge, Mass.)},
year = {2026},
month = jul,
volume = {4},
pages = {IMAG.a.1293},
publisher = {MIT Press},
issn = {2837-6056},
doi = {10.1162/
url = {https://
pmid = {42453641},
pmcid = {PMC13366612}
}
RIS
TY - JOUR
AU - Hao, Yingqi
AU - Liu, Mingxuan
AU - Zhu, Juncheng
AU - Yang, Hongjia
AU - Li, Haoxiang
AU - Kang, Min
AU - Song, Yan
AU - Lai, Hua
AU - Zhou, Xiaoling
AU - Ning, Gang
AU - Liao, Yi
AU - Qu, Haibo
AU - Tian, Qiyuan
TI - PANDA: Patch-based unsupervised deep learning for brain anomaly detection via age prediction in fetal MRI
T2 - Imaging neuroscience (Cambridge, Mass.)
J2 - Imaging Neurosci (Camb)
PY - 2026
DA - 2026/
VL - 4
SP - IMAG.a.1293
SN - 2837-6056
PB - MIT Press
DO - 10.1162/
UR - https://
LA - en
ER -
CSL-JSON
{
"id": "10.1162/
"type": "article-journal",
"title": "PANDA: Patch-based unsupervised deep learning for brain anomaly detection via age prediction in fetal MRI",
"container-title": "Imaging neuroscience (Cambridge, Mass.)",
"author": [
{
"family": "Hao",
"given": "Yingqi"
},
{
"family": "Liu",
"given": "Mingxuan"
},
{
"family": "Zhu",
"given": "Juncheng"
},
{
"family": "Yang",
"given": "Hongjia"
},
{
"family": "Li",
"given": "Haoxiang"
},
{
"family": "Kang",
"given": "Min"
},
{
"family": "Song",
"given": "Yan"
},
{
"family": "Lai",
"given": "Hua"
},
{
"family": "Zhou",
"given": "Xiaoling"
},
{
"family": "Ning",
"given": "Gang"
},
{
"family": "Liao",
"given": "Yi"
},
{
"family": "Qu",
"given": "Haibo"
},
{
"family": "Tian",
"given": "Qiyuan"
}
],
"container-title-short":
"volume": "4",
"page": "IMAG.a.1293",
"DOI": "10.1162/
"PMID": "42453641",
"PMCID": "PMC13366612",
"ISSN": "2837-6056",
"publisher": "MIT Press",
"URL": "https://
"language": "en",
"issued": {
"date-parts": [
[
2026,
7,
13
]
]
}
}
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.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: MONAI, NiBabel, PyTorch, 3 other tools, 2 references
- [2] doi:10.1186/s40708-026-00316-y [code]
- Generalizable and explainable deep learning for brain MRI: a multi-cohort evaluation of 3D architectures for age and sex prediction.Journal: Brain informaticsIn common: MONAI, PyTorch, pandas, 2 other tools, structural MRI / diffusion, 1 reference
- [3] 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: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion - [4] doi:10.1371/journal.pcbi.1014555 [code]
- Body surface potential driven personalisation of electrophysiological digital twins in hypertrophic cardiomyopathy.Journal: PLoS computational biologyIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [5] doi:10.3389/fnins.2026.1870124 [code]
- An end-to-end pipeline for automated fetal brain segmentation and biometry from 3D SSFP MRI.Journal: Frontiers in neuroscienceIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [6] doi:10.1038/s41467-026-73996-z [code]
- Genetic architecture of white matter microstructure captured by unsupervised deep representation learning of fractional anisotropy maps.Journal: Nature communicationsIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [7] doi:10.1186/s13244-026-02296-3 [code]
- A pre-trained foundation model framework for multiplanar MRI classification of extramural vascular invasion and mesorectal fascia invasion in rectal cancer.Journal: Insights into imagingIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [8] doi:10.1158/2767-9764.crc-25-0710 [code]
- MRI Deep Learning for Differentiating Glioblastoma, IDH Wild-type from Central Nervous System Diffuse Large B-cell Lymphoma.Journal: Cancer research communicationsIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [9] doi:10.1038/s41467-026-71555-0 [code]
- A deep representation learning model to predict response to vagus nerve stimulation.Journal: Nature communicationsIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
- [10] doi:10.3389/frai.2026.1771088 [code]
- Few-shot deployment of pretrained MRI transformers in brain imaging tasks.Journal: Frontiers in artificial intelligenceIn common: MONAI, NiBabel, PyTorch, 3 other tools, structural MRI / diffusion
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, 10 scripts, and 2 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:ac75a4ca16548a84…
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.
