Anatomy-Privileged Distillation with Token Routing for MRI-Based Prediction of Perineural Invasion


Abstract

Perineural invasion (PNI) is associated with poor postoperative outcomes in intrahepatic cholangiocarcinoma, but it is confirmed by surgical pathology. Existing preoperative imaging models often rely on radiologist-defined variables, contrast-enhanced imaging, or manual annotations. We propose an anatomy-privileged teacher–student framework for patient-level PNI prediction from T2-weighted MRI. During training, the teacher uses MRI with tumor and liver masks to learn dense token routing, and the student distills this guidance to retain and aggregate informative tokens under a fixed budget. Anatomical supervision is restricted to training, and the deployed model does not require masks at inference. In 155 patients, the proposed method achieved the highest mean AUROC of 0.750 among matched MRI-only baselines evaluated under the same protocol, with 1.43 GFLOPs and 8.02 ms per case on a Jetson Orin Nano Super Developer Kit.

computer-aided diagnosis, privileged information, transformers, embedded systems

1 Introduction↩︎

Perineural invasion (PNI) is a histopathologic finding associated with tumor spread and adverse outcomes across solid malignancies [1]. In intrahepatic cholangiocarcinoma (ICC), postoperative PNI is associated with worse recurrence-free and overall survival after curative resection [2][4]. Because PNI is confirmed by surgical pathology, preoperative assessment must rely on noninvasive data and is relevant to risk stratification before treatment [5][7].

PNI in cholangiocarcinoma is related to interactions among cancer cells, nerves, and surrounding microenvironment [8], [9]. In ICC, nerve-related features in the tumor microenvironment and PNI-associated molecular characteristics are linked to adverse oncologic outcomes [10], [11]. MRI studies on preoperative ICC PNI prediction have also reported associations with tumor location and peritumoral or margin-related findings [6], [12], [13]. These observations suggest that the relevant imaging signal is not restricted to the lesion interior.

Several preoperative models for ICC PNI prediction have been reported, including clinicoradiologic models, CT radiomics, MRI-based nomograms, and MRI fusion or interpretable machine-learning models [5][7], [12], [13]. Recent 3D MRI deep-learning studies have also explored localized, scale-adaptive, and attention-based architectures for noninvasive PNI prediction [14], [15]. Together, these studies show that imaging contains predictive information for PNI. However, many established approaches rely on radiologist-defined variables, contrast-enhanced imaging, or explicit lesion delineation [5][7], [12]. This creates a gap between information that can improve model development and information that is practical to require at inference.

Learning using privileged information (LUPI) addresses this gap by allowing training-time guidance that is not required at inference [16], [17]. Knowledge distillation transfers information from a teacher with richer inputs to a student with a simpler inference path [18]. In medical imaging, this teacher–student strategy has been used to transfer information from contrast-enhanced inputs to models operating on non-contrast images [19]. More recent medical privileged-distillation studies have used training-time information that is costly or unavailable at inference to improve routine-input models in histopathology and lesion classification [20], [21].

For patient-level PNI prediction from T2-weighted MRI, tumor and liver masks provide privileged spatial cues during training, but requiring such annotations at deployment would limit practicality. Token sparsification methods reduce transformer cost by retaining informative tokens [22], [23]. However, standard token sparsification does not address how anatomical information available only during training should guide token retention. We therefore combine privileged distillation with token sparsification by training a mask-guided teacher to learn dense anatomy-aware routing over a 3D token grid and distilling this routing to an MRI-only student. The student retains the top-\(M\) tokens and reuses the same routing scores for weighted aggregation, with computation bounded by the retained-token budget.

Figure 1: Overview of the proposed framework. During training, the teacher receives MRI together with tumor and liver masks, produces a dense routing distribution over the token grid, and predicts the patient-level label. The student receives MRI only and is trained with supervised learning, routing distillation, and output distillation. At inference, the student retains the top-M tokens and reuses the same routing scores for weighted pooling over the retained tokens.

The main contributions of this work are as follows:

  • We present an anatomy-privileged teacher–student framework that transfers anatomy-aware supervision to an MRI-only classifier without requiring masks at inference.

  • We introduce a shared-score routing design in which the same routing scores are used for both token selection and weighted aggregation of the retained tokens.

  • We evaluate the method against matched MRI-only baselines and analyze the effects of token budget, distillation target, routing design, teacher input, and deployment cost.

2 Proposed Method↩︎

Let \(x \in \mathbb{R}^{1 \times H \times W \times D}\) denote the input MRI volume and let \(y \in \{0,1\}\) denote the patient-level PNI label. During training, privileged tumor and liver masks are available: \[m_{\mathrm{tum}},\, m_{\mathrm{liv}} \in \{0,1\}^{1 \times H \times W \times D}.\] The teacher input is \[x^{T} = [x; m_{\mathrm{tum}}; m_{\mathrm{liv}}],\] where \([\cdot;\cdot]\) denotes channel-wise concatenation, and the student input is \[x^{S} = x.\] For branch \(b \in \{T,S\}\), a tokenizer produces \[E^{b} = \mathcal{T}^{b}(x^{b}) \in \mathbb{R}^{N \times C},\] where \(N\) is the number of spatial tokens and \(C\) is the token dimension. A routing head predicts one score per token: \[s^{b} = \mathcal{G}^{b}(E^{b}) \in \mathbb{R}^{N}.\]

2.1 Anatomy-Privileged Teacher↩︎

The teacher is used only during training and processes all \(N\) tokens. A token mixer contextualizes the token set: \[\widehat{E}^{T} = \mathcal{R}^{T}(E^{T}) \in \mathbb{R}^{N \times C},\] where \(\mathcal{R}^{T}\) denotes the teacher token mixer. The routing scores are normalized into dense aggregation weights: \[\alpha^{T} = \mathrm{softmax}(s^{T}) \in \mathbb{R}^{N}.\] The teacher representation and logit are \[z^{T} = \sum_{i=1}^{N} \alpha_i^{T}\widehat{E}^{T}_{i} \in \mathbb{R}^{C}, \qquad \ell^{T} = h^{T}(z^{T}),\] where \(h^{T}\) is the teacher classifier head.

Figure 2: Shared-score routing in the student. Dense routing scores are predicted from MRI, the top-M tokens are selected for token mixing, and the same retained scores are normalized for weighted pooling.

2.2 MRI-Only Student with Shared-Score Routing↩︎

The student predicts dense routing scores from MRI only, and it processes only the top-\(M\) tokens. Let \[\mathcal{I}_{M} = \operatorname{Sort}\!\big(\mathop{\mathrm{TopK}}(s^{S}, M)\big),\] where \(\mathop{\mathrm{TopK}}\) returns the \(M\) highest-score token indices and \(\operatorname{Sort}\) restores their original spatial order. The retained tokens and their scores are \[E^{S}_{M} = E^{S}_{\mathcal{I}_{M}} \in \mathbb{R}^{M \times C}, \qquad s^{S}_{M} = s^{S}_{\mathcal{I}_{M}} \in \mathbb{R}^{M}.\] Only the retained tokens are passed to the student token mixer: \[\widehat{E}^{S} = \mathcal{R}^{S}(E^{S}_{M}) \in \mathbb{R}^{M \times C},\] where \(\mathcal{R}^{S}\) denotes the student token mixer. The same retained scores are then reused for weighted pooling: \[\alpha^{S} = \mathrm{softmax}(s^{S}_{M}) \in \mathbb{R}^{M},\] \[z^{S} = \sum_{i=1}^{M} \alpha_i^{S}\widehat{E}^{S}_{i} \in \mathbb{R}^{C}, \qquad \ell^{S} = h^{S}(z^{S}),\] where \(h^{S}\) is the student classifier head.

2.3 Routing and Output Distillation↩︎

The teacher is first optimized with weighted binary cross-entropy and then frozen. For each retained-token budget \(M\), the student is trained from scratch with supervised learning, routing distillation, and output distillation.

Let \[p^{T} = \sigma(\ell^{T}), \qquad p^{S} = \sigma(\ell^{S}),\] where \(\sigma(\cdot)\) is the sigmoid function. The supervised loss for the student is \[\mathcal{L}_{\mathrm{sup}} = - w_{+} y \log p^{S} - (1-y)\log(1-p^{S}),\] where \(w_{+}\) is the positive-class weight computed from the training split.

Routing distillation is applied before hard token selection so that the student receives dense supervision over all \(N\) scores: \[\pi^{T} = \mathrm{softmax}(s^{T}/\tau_{r}), \qquad \pi^{S} = \mathrm{softmax}(s^{S}/\tau_{r}),\] \[\mathcal{L}_{\mathrm{route}} = \tau_{r}^{2}\,\mathrm{KL}\!\left(\pi^{T}\,\|\,\pi^{S}\right),\] where \(\tau_{r}\) is the routing temperature.

For patient-level output distillation, the teacher and student logits are softened with temperature \(\tau_{o}\): \[q^{T} = \sigma(\ell^{T}/\tau_{o}), \qquad q^{S} = \sigma(\ell^{S}/\tau_{o}),\] \[\mathcal{L}_{\mathrm{out}} = \tau_{o}^{2} \left[ q^{T}\log\frac{q^{T}}{q^{S}} + (1-q^{T})\log\frac{1-q^{T}}{1-q^{S}} \right],\] where \(\tau_{o}\) is the output temperature.

The final student objective is \[\mathcal{L}_{S} = \mathcal{L}_{\mathrm{sup}} + \lambda_{r}\mathcal{L}_{\mathrm{route}} + \lambda_{o}\mathcal{L}_{\mathrm{out}}.\]

The top-\(M\) operator remains discrete during both training and inference. Consequently, \(\mathcal{L}_{\mathrm{sup}}\) and \(\mathcal{L}_{\mathrm{out}}\) update the retained student path, while \(\mathcal{L}_{\mathrm{route}}\) provides dense supervision to the routing head before pruning.

3 Experimental Results↩︎

3.1 Dataset, Protocol, and Implementation↩︎

The dataset comprised 155 patients collected over 10 years at Samsung Medical Center, including 61 PNI-positive and 94 PNI-negative cases. Only the T2-weighted MRI sequence was used for classification. Tumor and liver masks were obtained from expert annotations and were used as privileged inputs for teacher training. All methods used the same preprocessed 3D input. Volumes were resampled to a common grid, intensity-normalized over the nonzero region, and cropped to a fixed size of \(96 \times 96 \times 48\).

Evaluation used a stratified five-fold cross-validation at the patient level. Reported values are cross-fold means.

The tokenizer consisted of three 3D convolution blocks with channel widths \(\{32,64,128\}\), kernel size \(3\), stride \(2\), and GELU activation, yielding a \(12 \times 12 \times 6\) token grid with \(N=864\) and \(C=128\). A learnable positional embedding was added before token mixing. Both teacher and student used two transformer encoder blocks with four attention heads and feed-forward hidden dimension \(256\). The teacher processed all \(N\) tokens, whereas the student processed only the retained \(M\) tokens. Channel-wise mask dropout was applied to the privileged teacher inputs.

All models were optimized with AdamW [24] for 200 epochs with batch size 4, initial learning rate \(10^{-4}\), weight decay \(10^{-4}\), and cosine decay after 10 warm-up epochs. The distillation temperatures were \(\tau_r{=}2.0\) and \(\tau_o{=}2.0\), and the loss weights were \(\lambda_r{=}1.0\) and \(\lambda_o{=}0.5\). Training was performed using PyTorch 2.10.0 and CUDA 12.8 on an NVIDIA RTX PRO 6000 Blackwell workstation.

Deployment profiling used batch size 1 on a Jetson Orin Nano Super Developer Kit. All profiled models used MRI only at inference. Latency, GFLOPs, and peak memory were measured on preloaded input tensors under FP16 autocast. Each latency value was averaged over 200 forward passes after 50 warm-up iterations.

3.2 Comparison with Baselines↩︎

We compared the proposed student with matched dense volumetric and multiple instance learning (MIL) baselines under the same input setting, fold assignment, and optimization protocol. The dense volumetric baselines were a 3D ResNet [25], a 3D DenseNet [26], and a 3D Swin Transformer implemented with a Swin UNETR-style encoder [27]. The MIL baselines were ABMIL [28], DSMIL [29], and TransMIL [30], adapted to the same token grid as the proposed model.

Table 1: Patient-level comparison under the same input and evaluation protocol.
Method AUROC GFLOPs
(MB)
(ms)
Dense 3D backbones
ResNet-18 [25] 0.711 106.38 379.74 169.61
DenseNet-121 [26] 0.726 18.26 104.00 42.89
Swin Transformer [27] 0.719 4.66 412.80 63.12
MIL baselines
ABMIL [28] 0.704 1.43 27.91 3.08
DSMIL [29] 0.673 1.55 28.17 3.41
TransMIL [30] 0.717 4.22 30.68 5.67
Ours (\(M{=}64\)) 0.750 1.43 25.00 8.02

4.0pt

Table 1 shows that the proposed model achieved the strongest discrimination among the compared classifiers while remaining much closer to the MIL baselines than to the dense backbones in computational cost. Relative to the dense baselines, the advantage is not limited to AUROC. The proposed model also shifts inference to a substantially lighter operating regime. Relative to the MIL baselines, it improves AUROC without increasing GFLOPs or peak memory, although the lightest MIL model remains faster in wall-clock latency.

3.3 Ablation Studies↩︎

Table 2: Effect of token budget in the student. \(M{=}N\) denotes the dense student.
AUROC AUPRC GFLOPs
\(N\) (dense) 0.719 0.604 4.2159
128 0.733 0.714 1.5570
96 0.743 0.706 1.4917
64 (default) 0.750 0.712 1.4306
48 0.740 0.671 1.4017
32 0.723 0.643 1.3737
16 0.714 0.647 1.3469

6.0pt

Table 2 examines the effect of the token budget in the student. The budget study shows that token selection is not only a computation-saving mechanism. Moderate budgets outperform the dense student, indicating that routing can also act as feature selection by suppressing less relevant tokens before token mixing. Performance degrades when the budget becomes too small, suggesting a loss of useful context. We therefore use \(M{=}64\) as the default operating point because it provides the best AUROC while remaining close to the best AUPRC with lower compute than larger budgets.

Table 3: Ablation at \(M{=}64\). In the distillation-target and aggregation-design blocks, the teacher input is fixed to MRI + tumor + liver masks. R and O denote routing distillation and output distillation, respectively.
Setting KD Shared AUROC AUPRC
Distillation target
No KD 0.712 0.638
Output KD O 0.724 0.643
Routing KD R 0.749 0.678
Dual KD R+O 0.750 0.712
Aggregation design
Separate pooling R+O 0.722 0.657
Shared-score routing R+O 0.750 0.712
Privileged teacher input
MRI only R+O 0.726 0.692
MRI + tumor masks R+O 0.746 0.708
MRI + tumor + liver masks R+O 0.750 0.712

4.1pt

Table 3 decomposes the contribution of the distillation target, the aggregation design, and the privileged teacher input at \(M{=}64\). In the distillation block, routing distillation is the primary driver of AUROC improvement, whereas output distillation alone has only a limited effect. When combined with routing distillation, however, output distillation yields an additional gain in AUPRC. This pattern is consistent with routing distillation providing the dominant spatial supervision, while output distillation refines the patient-level decision once the routing pattern is established. In the aggregation block, shared-score routing outperforms a separate pooling head under the same dual-distillation setting. This suggests that keeping token selection and token aggregation tied to the same routing signal is more effective than learning the two roles independently. In the teacher-input block, the largest gain comes from adding the tumor mask, while the liver mask provides a smaller additional improvement. This indicates that explicit lesion localization is the main source of privileged teacher guidance, with organ-level context providing complementary information.

3.4 Qualitative Analysis↩︎

Figure 3: Qualitative routing comparison at M{=}64 for representative (a) PNI-positive and (b) PNI-negative patients. From left to right: MRI, masks, teacher routing, student routing without distillation, student routing with distillation, and top-M retained tokens. Distillation suppresses diffuse background responses and concentrates routing on lesion-related and adjacent regions.

Figure 3 provides a visual counterpart to the ablation results. Without routing distillation, the student produces more diffuse responses and allocates part of the token budget to background regions. After distillation, routing becomes more concentrated around lesion-related and adjacent regions, and the retained tokens align more closely with the teacher. This behavior is consistent with the gain observed from routing distillation in Table 3.

4 Conclusion↩︎

This work presented an anatomy-privileged teacher–student framework for patient-level PNI prediction from T2-weighted MRI. The method uses tumor and liver masks during teacher training to distill anatomy-aware routing into an MRI-only student. By linking token selection and weighted aggregation to a shared routing signal, the student enables fixed-budget inference while preserving discriminative spatial context. Under a unified evaluation protocol, the proposed model achieved the highest mean AUROC among the matched MRI-only baselines while maintaining a low deployment cost on embedded hardware. The study remains limited by the relatively small single-center cohort, moderate class imbalance, and absence of external validation. These findings suggest that anatomy-privileged routing distillation is a promising and efficient strategy for mask-free MRI-based PNI prediction.

Acknowledgment↩︎

This work was supported by the IITP grant (IITP-2023-RS-2023-00256081) funded by MSIT, Korea, and the ANCHOR program (2026-ANCHOR-01-110) funded by the Ministry of Education and the Seoul Metropolitan Government, Republic of Korea.

References↩︎

[1]
C. Liebig, G. Ayala, J. A. Wilks, D. H. Berger, and D. Albo, “Perineural invasion in cancer: A review of the literature,” Cancer: Interdisciplinary International Journal of the American Cancer Society, vol. 115, no. 15, pp. 3379–3391, 2009.
[2]
K. Shirai et al., “Perineural invasion is a prognostic factor in intrahepatic cholangiocarcinoma,” World journal of surgery, vol. 32, no. 11, pp. 2395–2402, 2008.
[3]
Z. Zhang, Y. Zhou, K. Hu, D. Wang, Z. Wang, and Y. Huang, “Perineural invasion as a prognostic factor for intrahepatic cholangiocarcinoma after curative resection and a potential indication for postoperative chemotherapy: A retrospective cohort study,” Bmc Cancer, vol. 20, no. 1, p. 270, 2020.
[4]
T. Wei et al., “Prognostic impact of perineural invasion in intrahepatic cholangiocarcinoma: Multicentre study,” British Journal of Surgery, vol. 109, no. 7, pp. 610–616, 2022.
[5]
Z. Liu et al., “Noninvasive prediction of perineural invasion in intrahepatic cholangiocarcinoma by clinicoradiological features and computed tomography radiomics based on interpretable machine learning: A multicenter cohort study,” International Journal of Surgery, vol. 110, no. 2, pp. 1039–1051, 2024.
[6]
D. Liu et al., “A nomogram based on magnetic resonance imaging to predict perineural invasion in mass intrahepatic cholangiocarcinoma: A two-centre, retrospective study,” Clinical Radiology, vol. 88, p. 106985, 2025.
[7]
Z. Qi et al., “An MRI-based fusion model for preoperative prediction of perineural invasion status in patients with intrahepatic cholangiocarcinoma,” World Journal of Surgical Oncology, vol. 23, no. 1, p. 164, 2025.
[8]
F.-Z. Shen et al., “Current research in perineural invasion of cholangiocarcinoma,” Journal of Experimental & Clinical Cancer Research, vol. 29, no. 1, p. 24, 2010.
[9]
S. Faulkner, P. Jobling, B. March, C. C. Jiang, and H. Hondermarck, “Tumor neurobiology and the war of nerves in cancer,” Cancer discovery, vol. 9, no. 6, pp. 702–710, 2019.
[10]
J. Bednarsch et al., “The presence of small nerve fibers in the tumor microenvironment as predictive biomarker of oncological outcome following partial hepatectomy for intrahepatic cholangiocarcinoma,” Cancers, vol. 13, no. 15, p. 3661, 2021.
[11]
X.-L. Meng et al., “The clinical implications and molecular features of intrahepatic cholangiocarcinoma with perineural invasion,” Hepatology international, vol. 17, no. 1, pp. 63–76, 2023.
[12]
S. Zhang et al., “Noninvasive preoperative prediction of perineural invasion in intrahepatic cholangiocarcinoma based on dynamic contrast-enhanced MRI,” BMC Medical Imaging, 2026.
[13]
X. Zhou et al., “Preoperative prediction of perineural invasion in intrahepatic cholangiocarcinoma with interpretable machine learning based on MRI,” European Journal of Surgical Oncology, p. 111450, 2026.
[14]
Y. Han et al., “LoSA-net: A localized and scale-adaptive network for boundary-sensitive prediction of perineural invasion in 3D MRI,” in 2026 IEEE 23rd international symposium on biomedical imaging (ISBI), 2026, pp. 1–5.
[15]
Y. Han et al., “MMA-former: Multi-window mixture-of-head attention transformer for adaptive PNI prediction in 3D MRI,” in 2026 IEEE 23rd international symposium on biomedical imaging (ISBI), 2026, pp. 1–5.
[16]
V. Vapnik and A. Vashist, “A new learning paradigm: Learning using privileged information,” Neural networks, vol. 22, no. 5–6, pp. 544–557, 2009.
[17]
D. Lopez-Paz, L. Bottou, B. Schölkopf, and V. Vapnik, “Unifying distillation and privileged information,” in International conference on learning representations, 2016.
[18]
G. Hinton, O. Vinyals, and J. Dean, NIPS 2014 Deep Learning Workshop“Distilling the knowledge in a neural network.” 2015, doi: 10.48550/arXiv.1503.02531.
[19]
J. Zhao and S. Li, “When evidence modeling meets knowledge distillation: Towards reliable contrast-enhanced knowledge distillation for non-contrast medical image segmentation,” Medical Image Analysis, vol. 105, p. 103677, 2025.
[20]
L. Farndale, R. Insall, and K. Yuan, “Trident: Triple deep network training for privileged knowledge distillation in histopathology,” Medical Image Analysis, vol. 102, p. 103479, 2025.
[21]
Q. Han et al., “Clinical priors-inspired privileged knowledge distillation for reliable pancreatic lesion classification,” Medical Image Analysis, p. 104041, 2026.
[22]
Y. Rao, W. Zhao, B. Liu, J. Lu, J. Zhou, and C.-J. Hsieh, “Dynamicvit: Efficient vision transformers with dynamic token sparsification,” Advances in neural information processing systems, vol. 34, pp. 13937–13949, 2021.
[23]
Y. Liang, C. Ge, Z. Tong, Y. Song, J. Wang, and P. Xie, “Not all patches are what you need: Expediting vision transformers via token reorganizations,” in International conference on learning representations, 2022.
[24]
I. Loshchilov and F. Hutter, “Decoupled weight decay regularization,” in International conference on learning representations, 2019.
[25]
K. He, X. Zhang, S. Ren, and J. Sun, “Deep residual learning for image recognition,” in Proceedings of the IEEE conference on computer vision and pattern recognition, 2016, pp. 770–778.
[26]
G. Huang, Z. Liu, L. Van Der Maaten, and K. Q. Weinberger, “Densely connected convolutional networks,” in Proceedings of the IEEE conference on computer vision and pattern recognition, 2017, pp. 4700–4708.
[27]
A. Hatamizadeh, V. Nath, Y. Tang, D. Yang, H. R. Roth, and D. Xu, “Swin unetr: Swin transformers for semantic segmentation of brain tumors in mri images,” in International MICCAI brainlesion workshop, 2021, pp. 272–284.
[28]
M. Ilse, J. Tomczak, and M. Welling, “Attention-based deep multiple instance learning,” in International conference on machine learning, 2018, pp. 2127–2136.
[29]
B. Li, Y. Li, and K. W. Eliceiri, “Dual-stream multiple instance learning network for whole slide image classification with self-supervised contrastive learning,” in Proceedings of the IEEE/CVF conference on computer vision and pattern recognition, 2021, pp. 14318–14328.
[30]
Z. Shao et al., “Transmil: Transformer based correlated multiple instance learning for whole slide image classification,” Advances in neural information processing systems, vol. 34, pp. 2136–2147, 2021.