Spatially Context-Aware Transformers Facilitate Modeling-Based Anomaly Detection of Subtle Lesions in Brain MRI Images

Johannes Schwarz1Orcid, Lena Will1,2Orcid, Jörg Wellmer1Orcid, Axel Mosig3,4Orcid
1: Ruhr-Epileptology, Department of Neurology, University Hospital Knappschaftskrankenhaus Bochum, Ruhr-University Bochum, Bochum, Germany, 2: Ruhr-Epileptology, Department of Radiology and Neuroradiology, University Hospital Knappschaftskrankenhaus Bochum, Ruhr-University Bochum, Bochum, Germany, 3: Ruhr-University Bochum, Center for Protein Diagnostics, Bochum, Germany, 4: Ruhr-University Bochum, Faculty of Biology and Biotechnology, Bioinformatics Group, Bochum, Germany
Publication date: 2026/10/18
https://doi.org/10.59275/j.melba.2026-a92b
PDF · Code

Abstract

The detection of small and subtle lesions in high-resolution 3D volumes is a highly relevant, yet far from solved task in biomedical imaging. We here address a specific task in detecting certain types of epileptogenic lesions through our novel semi-supervised spatially context aware transformer (SpyCAT ) approach to anomaly detection. SpyCAT is modeling-based in the sense that it builds on specific assumptions that constitute what is normal and what constitutes relevant deviations from normality. We explicitly use these assumptions to justify the inductive bias of our anomaly detection approach. The resulting SpyCAT system is patch-based and uses a transformer architecture to process discrete tokens obtained from a vector-quantized variational autoencoder, which produces counterfactual patches through full 3D convolutions of each patch. We evaluate our approach on the grounds of point-annotations of two subtypes of epileptogenic lesions, using validation measures that build on the Metrics Reloaded framework, showing that SpyCAT can reliably identify and localize the lesion types under consideration, and outperforms state-of-the-art reference methods. Our code is available at https://github.com/johannesSX/SpyCAT

Keywords

magnetic resonance imaging · anomaly detection · semi-supervised learning · spatially contextualized patch transformers · voxel and image-level detection

Bibtex @article{melba:2026:035:schwarz, title = "Spatially Context-Aware Transformers Facilitate Modeling-Based Anomaly Detection of Subtle Lesions in Brain MRI Images", author = "Schwarz, Johannes and Will, Lena and Wellmer, Jörg and Mosig, Axel", journal = "Machine Learning for Biomedical Imaging", volume = "2026", issue = "October 2026 issue", year = "2026", pages = "719--738", issn = "2766-905X", doi = "https://doi.org/10.59275/j.melba.2026-a92b", url = "https://melba-journal.org/2026:035" }
RISTY - JOUR AU - Schwarz, Johannes AU - Will, Lena AU - Wellmer, Jörg AU - Mosig, Axel PY - 2026 TI - Spatially Context-Aware Transformers Facilitate Modeling-Based Anomaly Detection of Subtle Lesions in Brain MRI Images T2 - Machine Learning for Biomedical Imaging VL - 2026 IS - October 2026 issue SP - 719 EP - 738 SN - 2766-905X DO - https://doi.org/10.59275/j.melba.2026-a92b UR - https://melba-journal.org/2026:035 ER -

2026:035 cover