This repository implements SACP (Spatially-Aware Conformal Prediction), a novel framework that extends conformal prediction to incorporate varying spatial importance in medical image segmentation. While traditional conformal prediction assumes uniform uncertainty across prediction regions, SACP specifically addresses the challenges in pancreatic ductal adenocarcinoma (PDAC) segmentation where different spatial regions - particularly near critical vascular structures - demand distinct levels of certainty.
The following files are required for each case:
- Ground truth segmentation files (
GT*.nii.gz
) - Vessel segmentation files (
VESSELS*.nii.gz
) - Probability maps (
ORGAN_tumour*_probabilities.npz
) - Vessel distance maps (
DISTANCE*.npy
) - Tumor distance maps (
DISTANCETUMOUR*.npy
)
-
conf.py
: Core conformal prediction implementation -
crop.py
: Data preprocessing for computational efficiency -
eval.py
: Evaluation metrics for single threshold -
figure2.py
andfigure3.py
: Visualization scripts -
get_tumour_distances.py
: Generate tumor distance maps -
get_vessel_distances.py
: Generate vessel distance maps -
run_conf.py
: Batch processing for multiple thresholds -
run_eval.py
: Batch evaluation for multiple thresholds
-
numpy>=1.20.0
-
nibabel>=3.2.0
-
scipy>=1.7.0
-
tqdm>=4.60.0
-
pathlib>=1.0.0
-
black
-
pylint
-
pytest
# Optional: Crop data for computational efficiency
python crop.py
# Generate vessel distance maps
python get_vessel_distances.py
# Generate tumor distance maps
python get_tumour_distances.py
- Option A: Multiple Thresholds
- Run conformal prediction for thresholds between 0.05 and 0.95 (0.05 intervals):
python run_conf.py
- Option B: Single Threshold
- Set desired threshold in
conf.py
and run:
- Set desired threshold in
python conf.py
Generate evaluation report on the test set:
- For multiple thresholds:
python run_eval.py
- For single threshold:
python eval.py
If you use this code in your research, please cite: TODO