IMPACTSeg / README.md
HCedric's picture
Run the networks as KonfAI apps: fine-3d, fine-2.5d and coarse
0c3aa26 verified
|
Raw History Blame Contribute Delete
9.98 kB
---
license: apache-2.0
library_name: konfai
pipeline_tag: image-segmentation
datasets:
- HCedric/IMPACTSeg
tags:
- medical-imaging
- segmentation
- 3d
- CT
- CBCT
- MRI
- radiotherapy
- konfai
- nifti
---
<p align="center"><img src="ImpactSeg.png" alt="IMPACT-Seg logo" width="180"></p>
<h1 align="center">IMPACT-Seg models</h1>
<p align="center"><b>One model. One label set. CT, CBCT and MRI.</b></p>
<p align="center"><a href="https://github.com/HEMONCedric/IMPACTSeg">💻 Code on GitHub</a> · <a href="https://huggingface.co/datasets/HCedric/IMPACTSeg">🗂️ Dataset</a> · <a href="#quick-start">🚀 Quick start</a></p>
<table>
<tr>
<td width="32%" align="center"><img src="anatomy_3d.png" alt="126 structures predicted on a whole-body CT"></td>
<td>
IMPACT-Seg segments **126 anatomical structures** with the same weights on **planning CT, cone-beam CT and MRI**:
abdominal and thoracic organs, the five lung lobes, heart chambers and great vessels, every vertebra and rib by level,
pelvic and limb bones, trunk muscles and head-and-neck organs at risk. It was built for radiotherapy imaging, where the
same patient is imaged on a planning CT, daily CBCTs and MRI.
- **One model for three modalities**: no modality flag, no per-modality fine-tuning.
- **Robust on CBCT**: Dice 0.84 on real CBCT, where the best compared method reaches 0.67, and 0.58 on independent
clinical pancreatic CBCT, against 0.49 for TotalSegmentator; the predictions on the planning CT and on the registered
real CBCT of the same patient agree at 0.88 Dice, against 0.49–0.69 for the compared methods.
- **Fast**: a whole-body CT in 8.0 s (2.5D) or 14.8 s (3D) on one GPU with less than 6 GB of memory.
- **A representation**: the features of the last decoder layer of the 3D network, used as the similarity of a
multimodal registration, rank **first on the
Learn2Reg [AbdomenMRCT](https://learn2reg.grand-challenge.org/evaluation/test/leaderboard/) and
[ThoraxCBCT](https://learn2reg.grand-challenge.org/evaluation/thoraxcbct/leaderboard/) leaderboards**.
<sub>Left: 126 structures predicted by the 3D network on a held-out whole-body CT (lungs and large muscles translucent).</sub>
</td>
</tr>
</table>
<p align="center"><img src="multimodal.png" alt="IMPACT-Seg 3D on CT, simulated and real CBCT, and whole-body MRI" width="100%"></p>
<p align="center"><sub>Out-of-fold predictions of the 3D network: whole-body CT, CBCT simulated from a whole-body CT, real thoracic CBCT,
and a whole-body MRI from an external dataset (five-fold ensemble).</sub></p>
<video controls muted loop playsinline width="100%" poster="https://huggingface.co/HCedric/IMPACTSeg/resolve/main/video_poster.jpg"
src="https://huggingface.co/HCedric/IMPACTSeg/resolve/main/impactseg.mp4"></video>
<p align="center"><sub>IMPACT-Seg in 55 s: one model on CT, CBCT and MRI, 126 structures, and its features used for
multimodal registration. Images: MTBD / Multimodal-HC (Hinge et al., <i>Scientific Data</i> 2026, CC BY 4.0) and Learn2Reg AbdomenMRCT.</sub></p>
> Research use only, not a clinically validated device. The manuscript is in preparation.
## Models
| App | Network | Input / patch | Normalization | Weights | Whole-body CT (RTX A6000) |
|---|---|---|---|---:|---|
| `fine-2.5d` | 2.5D residual-encoder U-Net, five folds | 5 adjacent axial slices, 288 × 288 | BatchNorm | 206 MB / fold | 8.0 s · 5.7 GB |
| `fine-3d` | 3D residual-encoder U-Net, five folds | 128 × 128 × 128 | InstanceNorm | 608 MB / fold | 14.8 s · 4.4 GB |
| `coarse` | light 3D residual-encoder U-Net (7 M parameters) | 128 × 128 × 128 at 3 mm | InstanceNorm | 29 MB | < 3 s · < 1 GB |
The **2.5D and 3D networks** predict 126 of the 131 labels of the dataset's `mask_fine`: the cochleae, the optic
chiasm and the optic nerves, a few tens of voxels at the training resolution, were not learned and are never output
(`not_output_by_the_models` in `labels.json`). They were trained for 2 M iterations on CT, real and simulated CBCT and
MRI, as five folds on different patient splits. Every fold is a complete model; the five-fold ensemble is the most
accurate option on new data. The 3D network is the more accurate, thanks to its wider context (vertebra and rib
levels); the 2.5D network is the faster.
The **coarse network** predicts the 11 body-region and tissue classes of `mask_coarse` (subcutaneous tissue, muscle,
abdominal and thoracic cavities, bones, glandular structure, pericardium, breast implant, mediastinum, spinal cord,
brain). It was trained on one split (2661 training, 100 validation and 64 test volumes) and reached a case-level Dice
of 0.888 on CT, 0.859 on CBCT and 0.812 on MRI on the test volumes, and 0.768 on the 100 validation MRIs (indicative:
part of the coarse references are audited pseudo-labels).
### Results of the 2.5D and 3D networks
Mean Dice on the structures shared with the compared methods, out-of-fold predictions, same cases and labels for
every method (preliminary, the manuscript is in preparation):
| Benchmark | 2.5D | 3D | Best other method |
|---|---:|---:|---:|
| Real CBCT (SynthRAD, 139 cases) | 0.819 | **0.842** | 0.671 (NV-Segment-CTMR) |
| Simulated CBCT (497 cases) | 0.833 | **0.855** | 0.741 (TotalSegmentator) |
| CT (VISCERAL, 58 cases) | 0.833 | 0.850 | **0.853** (TotalSegmentator) |
| MRI (SynthRAD, 52 cases) | 0.817 | **0.822** | 0.820 (TotalSegmentator) |
| External CT, TotalSegmentator v3 (247 cases, 5-fold ensemble) | 0.816 | 0.846 | **0.932** (TotalSegmentator) |
| External MRI, TotalSegmentator v3 (253 cases, 5-fold ensemble) | 0.780 | 0.795 | **0.843** (TotalSegmentator) |
| External clinical CBCT, pancreatic radiotherapy (MSKCC, 80 CBCTs) | 0.564 | **0.584** | 0.487 (TotalSegmentator) |
On the external pancreatic CBCTs (small bowel and stomach-duodenum within the treated region), rigidly propagated
planning-CT contours reached 0.640, a clinical reference rather than an automatic competitor.
## Quick start
The three networks are [KonfAI](https://github.com/fideus-labs/KonfAI) apps: no configuration to write, and the weights
download on first use. They need KonfAI 1.9.0 or later.
```bash
pip install impact_seg_konfai
impact-seg-konfai segment fine-3d -i image.nii.gz -o output/ --gpu 0 # or fine-2.5d, coarse
```
- `--ensemble 1` runs one fold instead of five: five times faster, and one set of weights to download.
- The same apps with the generic runner: `konfai-apps infer HCedric/IMPACTSeg:fine-3d -i image.nii.gz -o output/`.
- In 3D Slicer: the [IMPACT-Seg extension](https://github.com/vboussot/SlicerImpactSeg).
An app applies the whole pipeline: reorientation to RAS, z-score normalization over the volume (no HU window),
resampling (1.5 × 1.5 × 2.0 mm, 3 mm for the coarse model), sliding-window inference where overlapping patches keep the
most confident prediction (with several folds, the probabilities are averaged first), and return to the original grid
with nearest-neighbour interpolation. The fine apps use a 50 % overlap; the coarse app uses the training patch grid,
since padded edge patches that contain only air can make it predict spurious tissue on large fields of view. The input
is read by regions: against the whole-volume evaluation pipeline, the labels are the same voxels on a CT or CBCT in HU
with the 3D networks, and at most 0.02 % of the foreground voxels apart on a float volume. Label names are in
`labels.json`.
```text
.
├── fine-3d/, fine-2.5d/ app.json, Prediction.yml, Evaluation.yml, model.py (the network), fold1…5.safetensors
├── coarse/ the same, with coarse.safetensors
│ each app: fusion.py (the patch fusion) and impactseg.wasm (the same for KonfAI Edge)
├── extension/ the source of impactseg.wasm
└── labels.json, LICENSE, NOTICE
```
## Intended use and limitations
- **Scope**: adult anatomy from head and neck to pelvis on CT, CBCT and MRI. Paediatric scans, limb-only or joint
acquisitions and brain-only scans are outside the intended scope.
- **Evaluation on the dataset**: every case of the [IMPACT-Seg dataset](https://huggingface.co/datasets/HCedric/IMPACTSeg)
was used for training by some of the folds. Do not evaluate a fold or an ensemble on these cases: the splits and a
crosswalk to the dataset folders are in the [code repository](https://github.com/HEMONCedric/IMPACTSeg).
- **Known weaknesses**: vertebra and rib levels can be shifted by one (less often with the 3D network); accuracy is
lower on MRI protocols that are rare in the training data (e.g. whole-body Dixon) and on very small structures.
- **Security**: the weights are safetensors, which load no code; an app runs its own `model.py` and `fusion.py`, as
every KonfAI app does.
## Training data and license
The networks were trained on the [IMPACT-Seg dataset](https://huggingface.co/datasets/HCedric/IMPACTSeg) (CT, real
and simulated CBCT and MRI from public cohorts with harmonized references); its card lists the sources and their
licenses, several of which are non-commercial. The model files are distributed under the Apache License 2.0
(`LICENSE`); check that the terms of the training sources are compatible with your intended use. Training code and
splits: [github.com/HEMONCedric/IMPACTSeg](https://github.com/HEMONCedric/IMPACTSeg), built with
[KonfAI](https://github.com/fideus-labs/KonfAI).
## Citation
The manuscript is in preparation (Cédric Hémon, Valentin Boussot, Matthew McCormick, Lukas Zimmermann, Christopher Kurz, Guillaume Landry). Until it is
published, please cite this repository:
```bibtex
@misc{impactseg2026,
title = {{IMPACT-Seg}: dense anatomical segmentation across {CT}, {CBCT} and {MRI}},
author = {H{\'e}mon, C{\'e}dric and Boussot, Valentin and McCormick, Matthew and Zimmermann, Lukas and Kurz, Christopher and Landry, Guillaume},
year = {2026},
howpublished = {\url{https://huggingface.co/HCedric/IMPACTSeg}}
}
```