MagViT: Interpretable Multi-Magnification Transformers with Patient-Level Model Selection for Breast Histopathology
Organizations: Department of Computer Science and Engineering, Dhaka International University, Dhaka, Bangladesh · Department of Microbiology, TMSS Medical College, Bogura, Bangladesh
Abstract
Breast cancer is one of the most common types of cancer among women around the world. Rapid detection and early treatment can hinder its progress to more complex stages and can impede its spread to other parts of the body. Histopathological image classification is the most common task in cancer detection due to its robustness in analyzing cellular data. Breast histopathology classification requires handling both multi-scale tissue morphology and clinically relevant generalization beyond the source domain. This paper presents MagViT, an interpretable multi-magnification transformer framework with scale-gated fusion and patient-level model selection. The model uses four BreakHis magnifications (40X, 100X, 200X, 400X) and extracts per-scale representations with a ViT backbone, and combines them via a learnable gate that masks missing scales. Patient-level five-fold cross-validation with a fixed seed has been run and compared with three architectural branches. The most accurate branch is then selected as the final model due to the strongest patient-level accuracy while retaining the simplest fusion pathway. On BreakHis, our architecture achieves a mean image accuracy of 0.9191, a mean patient accuracy of 0.9643, and a mean macro-F1 of 0.9042. External transfer experiments provide preliminary evidence of cross-dataset generalization under controlled adaptation settings on BUSI (image accuracy 0.8306, macro-F1 0.7480, patient accuracy 0.8291) and IDC (image accuracy 0.8577, macro-F1 0.8191, patient accuracy 0.8372). Grad-CAM visualization indicates that the model focuses on diagnostically significant and meaningful regions across magnifications. Relative to prior ViT-centered BreakHis work, this study emphasizes patient-level selection and cross-dataset robustness under a reproducible protocol.
Figures & tables
| Step 1: Create multi-magnification samples as groups from dataset |
| Step 2: Ensure patient-wise disjoint splits across folds |
| Step 3: Initialize MagViT model with shared encoder |
| For each fold: |
| Apply identical augmentation across all magnifications |
| Extract features from available scales |
| Handle missing scales using availability mask |
| Setting | Img. Acc. Mean | Img. Acc. Std | Pat. Acc. Mean | Pat. Acc. Std |
|---|---|---|---|---|
| No augmentation | 0.9015 | 0.0381 | 0.9357 | 0.0539 |
| No color jitter | 0.9103 | 0.0359 | 0.9589 | 0.0467 |
| No class weights | 0.9094 | 0.0354 | 0.9482 | 0.0511 |
| Method | Patient Acc. | Notes |
|---|---|---|
| ResNet-18 (single-scale) | 0.8571 | Standard CNN baseline |
| ResNet-50 (single-scale) | 0.8929 | Deeper CNN variant |
| CNN multi-scale fusion | 0.9286 | Feature-level aggregation |
| AutoML (neural search) | 0.9143 | Architecture search baseline |
| Hybrid CNN ensemble | 0.9357 | Multi-backbone ensemble |
| MagViT (proposed) | 0.9643 | MMFF-ViT |
| Branch | Image Acc. | Patient Acc. | Macro-F1 |
|---|---|---|---|
| Branch 1 | 0.9191 0.0335 | 0.9643 0.0357 | 0.9042 0.0379 |
| Branch 2 | 0.9238 0.0378 | 0.9571 0.0466 | 0.9090 0.0482 |
| Branch 3 | 0.8260 0.0232 | 0.9000 0.0299 | 0.8005 0.0288 |
| Fold | Image Acc. | Patient Acc. | Macro-F1 | Runtime (min) |
|---|---|---|---|---|
| 1 | 0.9243 | 0.9286 | 0.9112 | 39.36 |
| 2 | 0.8959 | 0.8571 | 0.8728 | 40.89 |
| 3 | 0.9659 | 1.0000 | 0.9585 | 40.15 |
| 4 | 0.8813 | 0.8571 | 0.8645 | 40.26 |
| 5 | 0.9629 | 1.0000 | 0.9569 | 38.80 |
| Magnification | Mean Image Acc. | Mean Patient Acc. | Mean Macro-F1 |
|---|---|---|---|
| 40X | 0.9106 | 0.9786 | 0.8972 |
| 100X | 0.9112 | 0.9643 | 0.8998 |
| 200X | 0.9209 | 0.9643 | 0.9067 |
| 400X | 0.8920 | 0.9357 | 0.8795 |
| Dataset | Setting | Image Acc. | Macro-F1 | Patient Acc. | ROC-AUC |
|---|---|---|---|---|---|
| BUSI | Linear probe | 0.7581 | 0.4312 | 0.7436 | 0.6908 |
| BUSI | Few-shot | 0.8306 | 0.7480 | 0.8291 | 0.8610 |
| IDC | Linear probe | 0.8503 | 0.8194 | 0.7907 | 0.9144 |
| IDC | Few-shot | 0.8577 | 0.8191 | 0.8372 | 0.9197 |