- CAMUF: Calibrated Adaptive Multi-source Uncertainty Fusion
- 1. Overview
- 2. CAMUF Architecture
- 3. Dataset
- 4. Segmentation Model
- 5. Multi-source Uncertainty Estimation
- 6. Uncertainty Calibration
- 7. CAMUF Feature Extraction
- 8. Learned Uncertainty Fusion
- 9. Repository Structure
- 10. Installation
- 11. Running Inference
- 12. Reproducibility and Verification
- 13. Research Contribution
- 14. Limitations
- 15. Future Work
- 16. Data, Model Availability and License
- 17. Citation
CAMUF: Calibrated Adaptive Multi-source Uncertainty Fusion
Uncertainty-Aware Brain Tumor Segmentation Using Multimodal MRI
CAMUF is a research framework designed to improve the interpretability of uncertainty in deep learning-based medical image segmentation.
It combines Monte Carlo Dropout, Enhanced Test-Time Augmentation (TTA), and Deep Ensembles with uncertainty calibration and a learned feature-fusion network to estimate pixelwise segmentation-error risk.
Unlike conventional segmentation systems that produce only a predicted mask, CAMUF provides additional information about regions where the segmentation may be unreliable.
Research use only. Not intended for clinical diagnosis, treatment planning, or autonomous medical decision-making.
1. Overview
Deep learning models have demonstrated promising performance in medical image segmentation. However, even models with high segmentation accuracy can make errors around tumor boundaries, ambiguous anatomical structures, and low-contrast regions.
A segmentation prediction alone does not communicate how reliable different regions of the output may be.
CAMUF investigates whether combining multiple uncertainty-estimation methods can provide more informative error-risk estimates than relying on a single uncertainty source.
Main capabilities
- Binary whole-tumor segmentation using four MRI modalities.
- Monte Carlo Dropout uncertainty estimation.
- Enhanced Test-Time Augmentation uncertainty estimation.
- Deep Ensemble prediction and uncertainty estimation.
- Calibration of individual uncertainty sources.
- Extraction of 13 complementary uncertainty and image features.
- Learned uncertainty fusion using a multilayer perceptron (MLP).
- Pixelwise segmentation-error risk visualization.
The framework currently supports preprocessed 128 Γ 128 multimodal MRI slices.
2. CAMUF Architecture
The framework consists of four main stages:
- Multimodal MRI segmentation.
- Multi-source uncertainty estimation.
- Uncertainty calibration and feature extraction.
- Learned uncertainty fusion.
Processing pipeline
Multimodal Brain MRI
(4 Γ 128 Γ 128)
|
v
Multimodal U-Net
|
+---------+---------+
| | |
v v v
MC Dropout Enhanced Deep Ensemble
TTA
| | |
v v v
Uncertainty Estimation
| | |
+---------+---------+
|
v
Uncertainty Calibration
|
v
13 CAMUF Feature Channels
|
v
StandardScaler
|
v
CAMUF MLP
|
v
Pixelwise Error-Risk Map
The final system produces a binary tumor segmentation and an associated pixelwise error-risk map.
The reference segmentation is obtained from the mean Deep Ensemble prediction, thresholded at 0.5.
3. Dataset
The framework was developed using the BraTS 2023 Adult Glioma dataset.
The dataset contains multimodal brain MRI scans and expert-provided tumor segmentation annotations.
MRI modalities
| Channel | Modality | Description |
|---|---|---|
| 0 | T2-FLAIR | Fluid-attenuated inversion recovery |
| 1 | T1 | T1-weighted MRI |
| 2 | T1ce | Contrast-enhanced T1-weighted MRI |
| 3 | T2 | T2-weighted MRI |
Segmentation target
The current implementation performs binary whole-tumor segmentation.
All non-background tumor labels are combined into one foreground class.
0: Background1: Whole-tumor foreground
The framework does not currently predict separate tumor subregions.
Input requirements
The original 128 Γ 128 implementation expects a NumPy array with shape:
(4, 128, 128)
The four channels must follow the modality order specified above.
Input images must be preprocessed consistently with the original training pipeline. The development preprocessing included nonzero-brain-pixel intensity normalization and spatial resizing.
Important: The standalone release currently accepts preprocessed .npy images. It does not yet implement a complete raw NIfTI preprocessing pipeline.
BraTS dataset files are not included in this repository. Users must obtain access through authorized distribution channels and comply with the applicable dataset terms.
4. Segmentation Model
Multimodal U-Net
The segmentation backbone is a convolutional U-Net implemented in PyTorch.
The model accepts four MRI channels and predicts one binary segmentation logit per pixel.
| Parameter | Configuration |
|---|---|
| Architecture | U-Net |
| Input channels | 4 |
| Output channels | 1 |
| Input resolution | 128 Γ 128 |
| Dropout probability | 0.2 |
| Output activation | Sigmoid |
| Segmentation threshold | 0.5 |
The implementation includes convolutional blocks with batch normalization and dropout.
A trained baseline checkpoint is used for MC Dropout and Enhanced TTA inference.
Three additional independently trained checkpoints are used for Deep Ensemble inference.
5. Multi-source Uncertainty Estimation
CAMUF integrates three uncertainty-estimation approaches.
5.1 Monte Carlo Dropout
Monte Carlo Dropout approximates predictive variability by performing multiple stochastic forward passes through a trained neural network.
During inference:
- Dropout layers remain active.
- Batch normalization layers remain in evaluation mode.
- The model performs 30 stochastic forward passes.
The predictive mean is calculated as:
[ \bar{p}(x)=\frac{1}{T}\sum_{t=1}^{T}p_t(x) ]
Predictive variance is:
[ U_{\mathrm{MC}}(x)=\frac{1}{T}\sum_{t=1}^{T}(p_t(x)-\bar{p}(x))^2 ]
where (T=30).
5.2 Enhanced Test-Time Augmentation
Enhanced TTA evaluates the segmentation model under several transformations of the input MRI.
The current implementation uses six predictions:
| Transformation | Description |
|---|---|
| Original | Unmodified input |
| Horizontal flip | Spatial flip with inverse transformation |
| Bright | Intensity multiplied by 1.05 |
| Dark | Intensity multiplied by 0.95 |
| Gaussian noise 1 | Independent perturbation with Ο = 0.03 |
| Gaussian noise 2 | Independent perturbation with Ο = 0.03 |
The mean of the transformed predictions provides the TTA segmentation estimate.
The variance across predictions is used as the TTA uncertainty estimate.
Because Gaussian noise is sampled randomly, Enhanced TTA can produce slightly different outputs between inference runs.
5.3 Deep Ensemble
Deep Ensemble combines predictions from three independently trained U-Net checkpoints.
The ensemble uses checkpoints corresponding to random seeds:
- 42
- 123
- 456
The ensemble prediction is:
[ \bar{p}{E}(x)=\frac{1}{M}\sum{m=1}^{M}p_m(x) ]
The ensemble uncertainty is calculated as the population variance of the individual model probabilities:
[ U_E(x)=\frac{1}{M}\sum_{m=1}^{M}(p_m(x)-\bar{p}_E(x))^2 ]
where (M=3).
The ensemble mean prediction is used as the reference segmentation for CAMUF.
6. Uncertainty Calibration
Raw uncertainty values produced by different methods may have different numerical distributions.
For example, the predictive variance of MC Dropout is not necessarily directly comparable to the variance produced by TTA or Deep Ensemble.
CAMUF applies saved uncertainty calibrators before combining the uncertainty sources.
The calibration stage transforms each uncertainty estimate into an estimated probability of segmentation error, based on the calibration model fitted during development.
The implementation supports saved isotonic-regression and logistic-regression calibrators.
The three calibrated uncertainty maps are:
- Calibrated MC Dropout error estimate.
- Calibrated Enhanced TTA error estimate.
- Calibrated Deep Ensemble error estimate.
Calibration is performed before CAMUF feature extraction.
These outputs should be interpreted as model-based error estimates. Clinical calibration and reliability across external datasets have not been established by the provided inference examples.
7. CAMUF Feature Extraction
The learned fusion model uses 13 features calculated for each image pixel.
| No. | Feature |
|---|---|
| 1 | Calibrated MC Dropout error probability |
| 2 | Calibrated TTA error probability |
| 3 | Calibrated Deep Ensemble error probability |
| 4 | Reference segmentation probability |
| 5 | Reference binary entropy |
| 6 | Reference confidence margin |
| 7 | Prediction disagreement |
| 8 | Calibrated uncertainty disagreement |
| 9 | Boundary proximity |
| 10 | Local mean MC Dropout calibrated probability |
| 11 | Local mean TTA calibrated probability |
| 12 | Local mean Deep Ensemble calibrated probability |
| 13 | FLAIR gradient magnitude |
These features capture complementary aspects of uncertainty.
Predictive uncertainty features represent uncertainty estimated by individual methods.
Prediction disagreement measures variation between the segmentation probabilities produced by the three methods.
Boundary proximity provides spatial information about the predicted tumor boundary.
Local uncertainty features capture neighborhood-level uncertainty patterns using a 5 Γ 5 window.
FLAIR gradient magnitude provides information about local image-intensity transitions.
All features are assembled in the same order used during CAMUF training.
8. Learned Uncertainty Fusion
CAMUF uses a trained multilayer perceptron to combine the 13 input features.
CAMUF MLP architecture
Input: 13 Features
|
v
Linear (13 β 32)
Batch Normalization
ReLU
Dropout (0.2)
|
v
Linear (32 β 16)
Batch Normalization
ReLU
Dropout (0.2)
|
v
Linear (16 β 1)
|
v
Sigmoid
|
v
Pixelwise Error-Risk Score
Before inference, features are transformed using the saved StandardScaler.
The CAMUF output is a value between 0 and 1 for each pixel.
Higher values indicate that the model estimates a greater likelihood of segmentation error at that location.
The output is not a replacement for a ground-truth segmentation and should not be treated as a clinically validated probability.
9. Repository Structure
.
βββ README.md
βββ requirements.txt
βββ camuf/
β βββ __init__.py
β βββ unet.py
β βββ model_loader.py
β βββ uncertainty.py
β βββ calibration.py
β βββ features.py
β βββ fusion.py
β βββ pipeline.py
β
βββ checkpoints/
β βββ original_128/
β βββ unet_multimodal_best.pth
β βββ unet_multimodal_seed_42.pth
β βββ unet_multimodal_seed_123.pth
β βββ unet_multimodal_seed_456.pth
β βββ camuf_mlp_best.pth
β βββ camuf_mlp_scaler.joblib
β βββ mc_dropout_calibrator.joblib
β βββ tta_calibrator.joblib
β βββ deep_ensemble_calibrator.joblib
β βββ camuf_logistic_regression.joblib
β
βββ examples/
βββ run_inference.py
βββ test_camuf_inference.py
βββ compare_camuf_outputs.py
The release includes the trained segmentation checkpoints, uncertainty calibrators, CAMUF fusion model and reusable inference modules.
Research notebooks and generated cache files are excluded from the initial public-release layout pending review.
10. Installation
Clone the repository
git clone https://huggingface.co/YOUR_USERNAME/YOUR_REPOSITORY
cd YOUR_REPOSITORY
Replace the placeholder repository address with the actual Hugging Face model repository after publication.
Create a Python environment
python -m venv .venv
source .venv/bin/activate
For Windows, activate the environment using:
.venv\Scripts\activate
Install dependencies
pip install -r requirements.txt
The original development environment used PyTorch 2.5.1 with CUDA 12.1.
CUDA-specific PyTorch installation may require a platform-dependent installation command.
The pinned dependency versions describe the development environment; a clean installation in a separate environment has not yet been verified.
11. Running Inference
The standalone inference pipeline accepts a preprocessed four-channel MRI slice.
Example
Run from the cloned repository root:
python -m examples.run_inference \
--image /path/to/preprocessed_slice.npy \
--checkpoints checkpoints/original_128 \
--output examples/outputs/camuf_inference.png
Note: The inference example is being adapted from the original project layout to the standalone Hugging Face repository layout. Verify the imports and checkpoint paths before using this command in a fresh clone.
Generated outputs
The inference pipeline produces:
- Deep Ensemble segmentation probability map.
- Binary whole-tumor segmentation mask.
- MC Dropout uncertainty map.
- Enhanced TTA uncertainty map.
- Deep Ensemble uncertainty map.
- Calibrated uncertainty maps.
- CAMUF pixelwise error-risk map.
The example script saves a visualization containing the FLAIR MRI, binary segmentation and CAMUF error-risk map.
Python API
import numpy as np
from camuf.pipeline import CAMUFPipeline
pipeline = CAMUFPipeline(
checkpoint_dir="checkpoints/original_128"
)
image = np.load(
"path/to/preprocessed_slice.npy",
allow_pickle=False
)
results = pipeline.predict(
image,
mc_samples=30
)
segmentation = results["segmentation_mask"]
segmentation_probability = results["segmentation_probability"]
error_risk = results["camuf_error_risk"]
uncertainty_maps = results["uncertainty_maps"]
The input must have shape (4, 128, 128).
12. Reproducibility and Verification
The standalone 128 Γ 128 implementation has been tested against the original CAMUF research pipeline using a selected BraTS MRI slice.
Implementation verification
| Test | Result |
|---|---|
| U-Net checkpoint loading | Passed |
| Deep Ensemble mean prediction | Exact agreement with saved cache |
| Deep Ensemble uncertainty | Exact agreement with saved cache |
| Three uncertainty calibrators | Exact agreement with original implementations |
| CAMUF 13-feature extraction | Exact numerical agreement |
| MC Dropout inference | Passed |
| Enhanced TTA inference | Passed |
| Standalone CAMUF inference | Passed |
Cached versus standalone CAMUF comparison
For the selected test slice:
| Metric | Value |
|---|---|
| Cached CAMUF mean risk | 0.004719 |
| Standalone CAMUF mean risk | 0.004658 |
| Mean absolute difference | 0.000306 |
| Maximum absolute difference | 0.137880 |
| 95th percentile absolute difference | 0.0000515 |
| Pixels with difference greater than 0.05 | 23 out of 16,384 |
The spatial patterns of the risk maps were visually similar.
Differences are expected because MC Dropout and Enhanced TTA contain stochastic operations. The comparison does not establish full statistical equivalence across patients or datasets.
These results are implementation verification results for one selected slice, not estimates of overall clinical or model performance.
13. Research Contribution
The primary research contribution of CAMUF is the integration of complementary uncertainty sources through a calibrated, feature-based learned fusion framework.
The framework investigates three ideas:
Multi-source uncertainty: Different uncertainty-estimation methods may capture different sources of predictive variability.
Calibration before fusion: Individual uncertainty estimates are transformed before they are combined.
Learned spatially informed fusion: The fusion network combines calibrated uncertainty, prediction disagreement, boundary proximity and image-gradient information to estimate pixelwise segmentation-error risk.
CAMUF is intended to support research into segmentation reliability, error detection and uncertainty-aware medical image analysis.
14. Limitations
This release has several important limitations:
- The current implementation performs binary whole-tumor segmentation rather than multi-class tumor subregion segmentation.
- Input images must already be preprocessed to the expected resolution and channel order.
- The original 128 Γ 128 preprocessing configuration must be reproduced for valid comparisons.
- MC Dropout and Enhanced TTA produce stochastic outputs.
- The model has been developed using BraTS data, and external-domain generalization has not been established by the provided examples.
- The error-risk output may be miscalibrated on new datasets or patient populations.
- The inference examples do not establish clinical utility or safety.
- The framework has not been validated for autonomous diagnosis or treatment planning.
Intended use
Research, education, methodological comparisons and further development of uncertainty-aware segmentation.
Out-of-scope use
Clinical diagnosis, automated treatment decisions, or replacing expert interpretation of medical images.
15. Future Work
Potential extensions include:
- Full-resolution 240 Γ 240 CAMUF evaluation and packaging.
- Multi-class brain tumor subregion segmentation.
- External dataset validation.
- Improved calibration and reliability assessment.
- Riskβcoverage analysis.
- Error-detection AUROC and AUPRC evaluation.
- Comparison with additional uncertainty-estimation methods.
- Investigation of computational efficiency and inference latency.
- Integration with interactive medical imaging visualization tools.
These are future research directions and should not be interpreted as completed features.
16. Data, Model Availability and License
The original research uses BraTS 2023 Adult Glioma MRI data.
The dataset is not redistributed in this repository.
Checkpoint redistribution, public availability and license selection remain subject to the applicable dataset terms, university policies and collaborator approval.
No open-source license is asserted until the necessary permissions have been confirmed.
Only load model checkpoints and serialized joblib artifacts from trusted sources.
17. Citation
Citation information will be added when an approved technical report, preprint or publication becomes available.
If you use this framework for research, please acknowledge the CAMUF project and the original BraTS dataset and challenge organizers.
CAMUF β Calibrated Adaptive Multi-source Uncertainty Fusion
Research framework for uncertainty-aware multimodal brain tumor segmentation.