Articles · AI and medicine
Deep learning for automatic segmentation in radiotherapy
How deep learning is transforming the segmentation of organs and tumours in radiotherapy: U-Net, nnU-Net and clinical applications.
Introduction: the contouring challenge in radiotherapy
The segmentation of anatomical structures — organs at risk (OAR) and tumour target volumes — is a fundamental step in radiotherapy treatment planning. The quality of this segmentation directly determines the quality of the treatment plan: imprecise contouring can lead to under-irradiation of the tumour or overexposure of the adjacent healthy organs.
Traditionally, contouring is carried out manually by the radiation oncologist on the planning CT (scanner) images, slice by slice. This process is long (30 minutes to several hours depending on the site), subjective (significant inter-observer variations) and a source of delay in the patient’s care.
Deep learning offers a promising solution to these problems by automating the segmentation of anatomical structures with an accuracy approaching that of human experts, in a fraction of the time.
Convolutional neural networks for segmentation
Fundamental principles of CNNs
Convolutional neural networks (CNNs) are the basis of almost all deep learning methods for medical image analysis. A CNN automatically learns to extract relevant characteristics (features) from raw images, without the need to define the descriptors manually.
A CNN is made up of several types of layers:
- Convolution layers: apply learned filters to the image to extract local characteristics (edges, textures, shapes)
- Pooling layers: reduce the spatial resolution to capture information at a larger scale
- Activation layers: introduce the non-linearity needed to learn complex functions (ReLU, Leaky ReLU)
- Normalisation layers: stabilise learning (Batch Normalization, Instance Normalization)
From classification to segmentation
Semantic segmentation consists in assigning a class (organ, tumour, background) to each pixel (or voxel in 3D) of the image. Unlike classification, which assigns a global label to an entire image, segmentation produces a dense map of predictions.
The technical challenge is to combine:
- Contextual information: understanding the overall scene to identify the structures
- Spatial precision: locating the contours of each structure precisely
It is this dual requirement that led to the development of specialised architectures such as U-Net.
The U-Net architecture
Concept and structure
U-Net is a neural network architecture proposed in 2015 by Ronneberger et al. at the University of Freiburg. It was originally designed for the segmentation of biomedical microscopy images, but it quickly became the reference architecture for medical image segmentation in general.
The architecture takes its name from its U shape, made up of two branches:
The contracting branch (encoder): a succession of convolutions and pooling that gradually reduces the spatial resolution while increasing the number of feature channels. At each level, the resolution is halved and the number of filters is doubled.
The expansive branch (decoder): a succession of transposed convolutions (upsampling) and convolutions that gradually restores the spatial resolution. At each level, the resolution is doubled and the number of filters is halved.
Skip connections
The central element of U-Net is the presence of skip connections between the corresponding levels of the encoder and the decoder. These connections concatenate the feature maps of the encoder with those of the decoder at the same resolution level.
Skip connections make it possible to:
- Preserve the spatial details that would be lost during downsampling
- Facilitate the gradient flow during training (fewer vanishing gradient problems)
- Combine the contextual information of low level (edges, textures) and high level (semantics)
where l represents the resolution level, conv the convolution operations, concat the concatenation and upsample the upsampling.
U-Net variants
Since its publication, many variants of U-Net have been proposed:
| Variant | Main modification | Advantage |
|---|---|---|
| 3D U-Net | 3D convolutions | Exploits the inter-slice context |
| V-Net | Volumetric Dice loss | Better handling of imbalanced classes |
| Attention U-Net | Attention mechanisms | Focus on the relevant regions |
| U-Net++ | Dense skip connections | Improved multi-scale fusion |
| ResU-Net | Residual blocks | Deeper and more stable training |
nnU-Net: intelligent self-configuration
The configuration problem
One of the major difficulties in applying deep learning to medical segmentation is the large number of hyperparameters to configure: network architecture, patch size, data augmentation strategy, loss function, learning rate, image pre-processing, post-processing of the predictions.
The optimal choice of these parameters depends strongly on the dataset in question (imaging modality, resolution, size of the structures, number of examples), and manual tuning is both tedious and often suboptimal.
The nnU-Net solution
nnU-Net (no-new-Net) is a framework proposed by Isensee et al. (DKFZ, Heidelberg) that automates the entire segmentation pipeline. The principle is that most performance improvements come not from new architectures, but from an optimal configuration of the existing architecture (U-Net) for each specific problem.
nnU-Net automatically analyses the dataset and determines:
- The pre-processing: intensity normalisation, spatial resampling, cropping
- The architecture: 2D U-Net, full-resolution 3D U-Net or 3D cascade (a first 3D network at low resolution, then a second one at full resolution), number of levels, number of filters
- The patch size: adapted to the resolution and to the available GPU memory
- The data augmentation: rotations, elastic deformations, intensity adjustments
- The post-processing: removal of small regions, selection of the main connected component
Training pipeline
The nnU-Net pipeline follows these steps:
- Dataset analysis: extraction of the statistics (resolution, image size, class distribution)
- Planning: automatic determination of the optimal configuration
- Pre-processing: application of the transformations determined in the previous step
- Training: 5-fold cross-validation with the selected configuration
- Post-processing: optimisation based on the results of the cross-validation
- Model selection: choice of the best configuration (2D, 3D full, 3D cascade)
Training data
The challenge of medical data
Training a segmentation network requires annotated data, that is, images accompanied by reference contours (ground truth). In medical imaging, obtaining these annotations is particularly costly because it requires the expertise of specialist physicians.
The specific constraints are:
- Data volume: 3D images (CT, MRI) are large (512 x 512 x several hundred slices)
- Annotation time: contouring a complete case can take several hours
- Inter-observer variability: different experts can produce significantly different contours
- Confidentiality: medical images are subject to strict data protection regulations
Strategies for small datasets
Several techniques make it possible to compensate for the scarcity of annotated data:
- Data augmentation: rotations, mirroring, elastic deformations, contrast adjustments to artificially multiply the number of training examples
- Transfer learning: use of weights pre-trained on a large dataset (ImageNet or similar medical data)
- Self-supervised learning: pre-training on unannotated data using pretext tasks
- Semi-supervised learning: combined use of annotated and unannotated data
- Federated learning: distributed training on data spread across several centres without exchanging raw data
Evaluation metrics
The Dice coefficient (DSC)
The Dice coefficient (Dice Similarity Coefficient) is the most widely used metric for evaluating the quality of a segmentation. It measures the overlap between the model’s prediction and the ground truth:
where P is the set of voxels predicted as belonging to the structure, V is the set of ground-truth voxels, and |P n V| is the number of voxels common to both sets.
The DSC ranges from 0 (no overlap) to 1 (perfect overlap). In practice:
| Structure | Typical DSC (state of the art) | Interpretation |
|---|---|---|
| Lungs | 0.97 - 0.99 | Excellent |
| Heart | 0.92 - 0.96 | Very good |
| Liver | 0.94 - 0.97 | Very good |
| Kidneys | 0.93 - 0.96 | Very good |
| Spinal cord | 0.85 - 0.92 | Good |
| Parotid glands | 0.82 - 0.90 | Good |
| Oesophagus | 0.70 - 0.82 | Moderate |
| Optic chiasm | 0.55 - 0.70 | Difficult |
Other metrics
Other metrics complement the DSC:
- Hausdorff distance (HD95): measures the maximum distance (at the 95th percentile) between the predicted and reference surfaces. It is sensitive to gross local errors.
- Mean surface distance (MSD): average of the distances between the two surfaces, less sensitive to outliers than the Hausdorff distance.
- Volumetric precision and recall: assess false positives and false negatives respectively.
Clinical applications in radiotherapy
Segmentation of organs at risk (OAR)
Automatic OAR segmentation is the most mature application of deep learning in radiotherapy. The structures commonly segmented include:
Head and neck region: parotid glands, submandibular glands, spinal cord, brainstem, optic chiasm, optic nerves, eyes, lenses, mandible, cochleae.
Thoracic region: lungs, heart, oesophagus, spinal cord, trachea, brachial plexus.
Pelvic region: bladder, rectum, femoral heads, small bowel, anal canal.
Commercial automatic segmentation systems (Limbus AI, MVision, Mirada DLCExpert) offer pre-trained models for these structures, integrated into treatment planning systems.
Segmentation of target volumes
Automatic segmentation of tumour target volumes (GTV, CTV) is more complex because:
- Tumours are more variable in shape, size and location than healthy organs
- Tumour boundaries are often poorly defined on CT images
- The input of multimodal information (MRI, PET) is often necessary
Significant progress has been made for certain sites, notably nasopharyngeal cancer, glioblastoma (on multiparametric MRI), and cervical cancer.
Current challenges and limitations
Generalisation and domain shift
The problem of domain shift is one of the major challenges: a model trained on data from centre A can see its performance degrade significantly when it is applied to data from centre B, because of differences in acquisition protocols, devices and patient populations.
Approaches to mitigate this problem include:
- Training on multi-centre data
- Domain adaptation techniques
- Image normalisation in pre-processing
- Fine-tuning on a small sample from the new centre
Small structures
Small structures (optic chiasm, optic nerves, cochleae) remain difficult to segment accurately. The small number of voxels representing them in the image makes learning more difficult and the performance metrics less stable.
Rigorous clinical validation
The clinical integration of automatic segmentation tools requires:
- Prospective validation on real clinical data
- Demonstration of the dosimetric impact (do the differences in contouring lead to clinically significant differences in the treatment plans?)
- Setting up verification workflows (the physician must always approve and correct the automatic contours)
- Meeting regulatory requirements (CE marking, FDA clearance)
Future outlook
The field is evolving rapidly towards:
- Foundation models: large models pre-trained on millions of medical images, adaptable to new tasks with little data (SAM-Med, UniverSeg)
- Interactive segmentation: the user guides the model with clicks or bounding boxes to refine the segmentation
- Continual learning: models improve over time by learning from the corrections made by physicians
- Multimodal integration: fusion of CT, MRI and PET for more accurate segmentation of target volumes
FAQ
Which GPU is needed to train a segmentation model?
To train a U-Net or nnU-Net model in 3D on CT images, a GPU with at least 8 GB of VRAM is recommended (NVIDIA RTX 3070 or better). For large volumes or deeper architectures, 16 to 24 GB of VRAM is preferable (RTX 3090, A5000, A6000). Complete training of an nnU-Net model with 5-fold cross-validation typically takes 3 to 5 days on a modern GPU. For inference (prediction), a GPU with 4 GB of VRAM is generally sufficient.
Is automatic segmentation reliable enough for clinical use?
For large organs at risk (lungs, heart, liver), automatic segmentation achieves performance comparable to human experts and is increasingly used in routine clinical practice. For small structures or tumour target volumes, checking and correction by a physician remain essential. International guidelines recommend an “AI-assisted” approach in which automatic segmentation serves as a starting point that the clinician approves and adjusts.
What is the difference between U-Net and nnU-Net?
U-Net is a neural network architecture (the structure of the model). nnU-Net is a complete framework that uses the U-Net architecture but adds a self-configuration layer: it automatically analyses the dataset and determines the best configuration (pre-processing, 2D/3D architecture, data augmentation, post-processing). nnU-Net does not invent a new architecture, but methodically optimises the use of U-Net for each specific problem, which often gives it better performance than more complex architectures that are poorly configured.
How do you build a dataset for segmentation in radiotherapy?
The process includes collecting planning CT images with the corresponding contours (exported from the TPS in DICOM RT-Struct format), anonymising the data, converting to the suitable format (NIfTI for nnU-Net), and checking the quality of the annotations. It is recommended to have the cases annotated by at least two experts and to resolve disagreements by consensus. A minimum of 50 to 100 cases is generally necessary to obtain usable results, although larger datasets (200 to 500 cases) significantly improve the performance and robustness of the model.