Input: Longitudinal MRI (T×5×64×64×64) + Clinical PCA features (~20-40 dims)
│
├── 3D CNN Encoder (4 blocks: 32→64→128→256 channels, GroupNorm, ReLU, MaxPool3d)
│ → AdaptiveAvgPool3d(1) → 256-dim per timepoint
│ + append [time_gap_months, log(tumor_volume)] → 258-dim
│
├── Input Projection (Linear 258→256, needed for nhead=4 divisibility)
│
├── Temporal Transformer Encoder (2 layers, 4 heads, dim_ff=512)
│ ★ CAUSAL MASKING — each timepoint only attends to itself + past
│ ★ Learnable [CLS] token prepended → 256-dim temporal summary
│
├── Clinical MLP (PCA_dim → 128 → ReLU → LayerNorm → Dropout(0.3) → 64 → ReLU)
│ → 64-dim
│
└── Fusion (Concat 256+64=320 → FC(128) → ReLU → Dropout → FC(64) → ReLU)
├── Hazard Head: FC(64→1), linear — for Cox PH loss
└── BCE Head: FC(64→1) + Sigmoid — auxiliary 12-month classification
1 # For each horizon (6mo=180d, 12mo=365d):
2 if PFS_days <= horizon AND Progression_Event == 1 :
3 label = 1 , mask = True # True progression
4 elif PFS_days > horizon :
5 label = 0 , mask = True # Survived past horizon
6 else : # PFS < horizon AND event == 0
7 label = 0 , mask = False # CENSORED — excluded from BCE loss
L = L_cox + 0.1 × L_bce
L_cox = -mean[ h_i - log( Σ_{j: t_j ≥ t_i} exp(h_j) ) ] (only uncensored events)
L_bce = BCE(risk_prob, label_12mo) (only non-censored patients)
1 import torch
2 ckpt = torch . load ( 'glioma_survival_transformer.pt' )
3 print ( ckpt . keys ( ) )
4 # dict_keys(['model_state_dict', 'fold_results', 'best_cindex',
5 # 'config', 'scaler_params', 'pca_components', ...])
6
7 # Reconstruct model
8 model = MultimodalSurvivalTransformer ( clinical_pca_dim = ckpt [ 'pca_components' ] )
9 model . load_state_dict ( ckpt [ 'model_state_dict' ] )
1 @misc{glioma_survival_transformer_2025,
2 title={Multimodal Longitudinal MRI Survival Transformer for Glioma Progression},
3 author={ML Research Pipeline},
4 year={2025},
5 note={Based on MU-Glioma-Post dataset from TCIA},
6 url={https://www.cancerimagingarchive.net/collection/mu-glioma-post/}
7 }