A 3D Slicer scripted module for automated PSMA PET/CT lesion segmentation using Fine-UNETR — a foundation model trained on 2700 PSMA PET/CT scans.
- Automatic CT/PET DICOM series discovery and reading
- SUV conversion from DICOM radiopharmaceutical tags
- CT-to-PET registration and resampling to model training spacing
- Sliding window inference with the Fine-UNETR (UNETR, patch size 8) model
- Segmentation overlay rendered in all Slicer slice views and 3D viewer
- Per-lesion clinical metrics: TTV (mL), SUVmax, SUVmean, centroid coordinates
- Excel export (.xlsx) with Summary and Per-Lesion sheets
- Coronal and sagittal MIP figures (.png) with prediction overlay
- Optional NIfTI export of the binary segmentation mask
Download from https://download.slicer.org (version 5.2 or newer recommended).
- Clone or download this repository:
git clone https://github.com/mansour2002/SlicerPSMASegmentation.git
- In 3D Slicer: Edit → Application Settings → Modules → Additional module paths
- Click Add and select the
SlicerPSMASegmentationfolder - Click OK and restart Slicer
After restart, the module appears under Segmentation → Nuclear Medicine → Fine-UNETR PSMA Segmentation.
On first use, click Install Required Packages in the module panel. This installs:
| Package | Version tested |
|---|---|
| torch | ≥ 2.0 |
| monai | ≥ 1.2 |
| pydicom | ≥ 2.3 |
| SimpleITK | ≥ 2.2 |
| scipy | ≥ 1.9 |
| nibabel | ≥ 4.0 |
| openpyxl | ≥ 3.0 |
| pandas | ≥ 1.5 |
| einops | ≥ 0.6 |
| matplotlib | ≥ 3.5 |
The trained Fine-UNETR checkpoint is not included in this repository due to file size.
Download: Fine-UNETR.ckpt — Zenodo / Google Drive / HuggingFace (link will be updated upon public model release)
Place the downloaded Fine-UNETR.ckpt file anywhere accessible (e.g., inside the SlicerPSMASegmentation/ folder or another directory of your choice). The module will prompt you to browse to this file on first use.
- Set CT DICOM folder — directory containing CT DICOM files
- Set PET DICOM folder — directory containing PET DICOM files
- Enable Auto-detect CT/PET subfolders if CT and PET share a common root
- Browse to the Model checkpoint (
.ckptfile) - Adjust Threshold (default 0.5) and Min lesion size (default 0 = keep all)
- Enter a Case ID (used as prefix in output files)
- Set an Output folder and enable desired export options
- Click Run Fine-UNETR Segmentation
| File | Description |
|---|---|
| Slicer scene | Orange segmentation overlay in all views |
<CaseID>_Fine-UNETR_segmentation.nii.gz |
Binary lesion mask (optional) |
psma_lesion_metrics.xlsx |
Per-lesion and summary metrics (optional) |
<CaseID>_MIP_Coronal.png |
Coronal PET MIP + prediction (optional) |
<CaseID>_MIP_Sagittal.png |
Sagittal PET MIP + prediction (optional) |
Fine-UNETR is based on the UNETR architecture (Hatamizadeh et al., 2021) adapted for PSMA PET/CT:
- Encoder: Vision Transformer (ViT-B/8), patch size 8³, 12 layers, hidden size 768
- Input: 2-channel [CT, PET] volume, normalized to [0, 1]
- Decoder: CNN with skip connections at ViT layers 3, 6, 9, 12
- Output: Single-channel binary lesion probability map
- Inference: Sliding window, ROI 96³ voxels, stride 64³, 32-voxel overlap
Training data: 2700 PSMA PET/CT scans for self-supervised pre-training; 80 scans with pixel-level lesion annotations for supervised fine-tuning.
SlicerPSMASegmentation/
├── PSMASegmentation.py # Main Slicer module (GUI + Logic)
├── CMakeLists.txt # Slicer extension build file
├── PSMA_Segmentation_User_Guide.html
├── Resources/
│ └── Icons/
│ └── PSMASegmentation.png
└── PSMASegmentationLib/
├── __init__.py
├── dicom_preprocessor.py # DICOM reading, SUV conversion, registration
├── inference_engine.py # Model loading and sliding window inference
├── sliding_window.py # Custom sliding window for 2-channel input
├── volume_preprocessor.py # Preprocessor for pre-loaded Slicer volumes
├── slicer_output.py # Segmentation node creation, NIfTI/MIP export
├── metrics_reporter.py # Per-lesion TTV/SUV metrics and Excel export
└── models/
├── __init__.py
└── unetr8ps_standalone.py # Standalone Fine-UNETR model (no mmcv)
If you use this module in your research, please cite:
@software{fineunetr_slicer,
author = {Abtahi, Mansour},
title = {SlicerPSMASegmentation: Fine-UNETR for PSMA PET/CT Lesion Segmentation},
year = {2024},
url = {https://github.com/mansour2002/SlicerPSMASegmentation}
}The UNETR architecture:
@inproceedings{hatamizadeh2022unetr,
title = {UNETR: Transformers for 3D Medical Image Segmentation},
author = {Hatamizadeh, Ali and Tang, Yucheng and Nath, Vishwesh and Yang, Dong
and Myronenko, Andriy and Landman, Bennett and Roth, Holger R
and Xu, Daguang},
booktitle = {Proceedings of the IEEE/CVF Winter Conference on Applications
of Computer Vision (WACV)},
year = {2022}
}MIT License — see LICENSE for details.
Mansour Abtahi — mansour.abtahi@gmail.com
Issues and pull requests are welcome.