---
title: Voxel Histogram Loss in Radiotherapy
url: https://www.emergentmind.com/topics/voxel-histogram-based-loss
type: topic
---

# Voxel Histogram Loss in Radiotherapy

A voxel histogram-based loss is an objective function for supervised deep learning that directly optimizes histogram-derived metrics of a volumetric prediction, such as dose–volume histogram (DVH) criteria in radiotherapy dose planning. Unlike conventional voxel-wise regression losses (e.g., MAE), which lack alignment with clinical or evaluation objectives based on histogram-derived summary statistics, these loss functions enforce compliance with integral properties—percentile doses, fraction-of-volume constraints, and quantile doses—by operating on the spatial histogram of the predicted volume. Clinical use cases have shown that histogram-based losses can substantially improve compliance with target coverage and organ-at-risk constraints relative to traditional supervision.

## 1. Differentiable D-Metrics and Surrogate V-Metrics

The formulation begins with a predicted 3D dose distribution $D^\text{pred}(v)$ on a voxel grid $\Omega$ and binary region-of-interest (ROI) masks $S_r(v)\in\{0,1\}$ for each structure $r$. For each ROI, the per-voxel dose values $\{d_i\}_{i=1}^{N_r}$ are sorted in descending order ($d_1^\downarrow \geq \cdots \geq d_{N_r}^\downarrow$), with $N_r=\sum_{v\in\Omega}S_r(v)$.

**D-metrics** include quantile-based and volume-based dose summaries:
- Quantile-based minimum dose ($D_{x\%}$): $D_{x\%}^{(r)}=d_k^\downarrow$, where $k=\lceil (x/100)N_r\rceil$
- Minimum dose in hottest $x$ cc ($D_{x\,cc}$): $D_{x\,cc}^{(r)}=d_k^\downarrow$, $k=\lceil x/V_\text{voxel}\rceil$
- Maximum/minimum dose ($D_\text{max}^{(r)}, D_\text{min}^{(r)}$): $d_1^\downarrow,\, d_{N_r}^\downarrow$
- Mean dose ($D_\text{mean}^{(r)}$): $\frac{1}{N_r}\sum_{i=1}^{N_r} d_i$

Modern deep learning frameworks (e.g., PyTorch’s top-k) allow differentiation through index-gathering operations to maintain end-to-end gradients through these metrics.

**V-metrics** (fractional volume above threshold) are approximated by sigmoidal surrogates to permit gradient-based optimization. For $V_{x\%}^{(r)} = (1/N_r)\sum_{i=1}^{N_r} H(d_i-T)$, where $H$ is the Heaviside function and $T$ a dose threshold, one substitutes $H(t)$ with $\sigma_\alpha(t)=1/(1+\exp(-\alpha t))$. The resulting differentiable surrogate is
$$
\hat{V}_{x\%}^{(r)} = \frac{1}{N_r}\sum_{i=1}^{N_r} \sigma_\alpha(d_i-T)
$$
Selecting $\alpha$ to control surrogate error uses dose margin $m$ and tolerance $\varepsilon$ to yield
$$
\alpha \geq \frac{1}{m} \ln\bigg(\frac{1-q_m}{\varepsilon-q_m/2}\bigg)
$$
where $q_m$ is the fraction $|d_i-T|\leq m$. In practice, $m=0.5$ Gy and $\varepsilon=1\%$ yield $\alpha\approx 209$ for PTV$_{54.25}$ and $\alpha\approx 176$ for PTV$_{70}$ [2603.29670].

## 2. Combined Clinical DVH Metric Loss Formulation

The Clinical DVH Metric (CDM) loss is designed to optimize clinically relevant histogram metrics for each ROI. Clinical targets and constraints for each structure $r$ are encoded as a set of metrics $\mathcal{M}_r$ using a template (e.g., JSON). For metric $k\in\mathcal{M}_r$, with predicted and reference values $M_\text{pred}^{(r,k)}$ and $M_\text{gt}^{(r,k)}$, and weight $w_{r,k}$:
$$
L_\text{CDM} = \sum_{r\in\mathcal{R}} \sum_{k\in\mathcal{M}_r} w_{r,k} \left| M_\text{pred}^{(r,k)} - M_\text{gt}^{(r,k)} \right|
$$
where $\mathcal{R}$ is the set of ROIs. To maintain voxel-wise dose fidelity, a global mean-absolute-error term is included:
$$
L_\text{MAE} = \frac{1}{|\Omega|}\sum_{v\in\Omega} |D^\text{pred}(v) - D^\text{gt}(v)|
$$
The final loss:
$$
L_\text{total} = \lambda_1 L_\text{MAE} + \lambda_2 L_\text{CDM}
$$
Typical settings: $\lambda_1=1$, $\lambda_2=0.5$; $w=1$ for planning target volume (PTV) constraints, $w=0.1$ for organs-at-risk (OAR).

## 3. Lossless Bit-Mask ROI Encoding for Efficient Training

Complex radiotherapy scenarios may have 20+ overlapping ROIs per case; conventional one-hot ROI masking is memory-intensive. All binary masks $S_i(v)$ are losslessly packed into a single 32-bit integer per voxel:
$$
B(v)=\sum_{i=1}^{N_\text{ROI}} S_i(v)2^{i-1}, \quad N_\text{ROI}\leq 32
$$
CPU-side preprocessing loops over voxels, bitwise-ORs ROI channels into $B(v)$. GPU-side, individual ROIs are decoded on demand with bitmasking. This scheme enables:
- Single-channel ROI input (vs $N_\text{ROI}$ channels)
- 5× faster CPU-side preprocessing
- 80% reduction in CPU-to-GPU data transfer overhead
- 4.5% reduction in peak GPU memory usage
These efficiency improvements enable training at full volumetric resolution and support complex ROI geometries.

## 4. Experimental Protocol and Quantitative Outcomes

Gao et al. [2603.29670] evaluated the CDM loss on 174 head-and-neck VMAT patients (n=137 train, n=37 test, Feb 2021–Jul 2025). CT was resampled to $2\times2\times2$ mm$^3$, cropped, intensity-normalized, and dose was normalized to 70 Gy. A 3D U-Net with InstanceNorm and bf16 precision served as the baseline architecture. Training used AdamW optimizer (lr=$3\times10^{-4}$, cosine-annealing, 1000 epochs, batch size 1, NVIDIA RTX 6000 Ada GPU).

Loss function comparison demonstrated:

| Loss Function    | PTV Score (%) | OAR Score (Gy) | Dose Score (Gy) |
|------------------|:------------:|:--------------:|:---------------:|
| MAE only         | 1.544 ± 1.188| 2.103 ± 0.704  |1.300 ± 0.229    |
| MAE + DVH-curve  | 0.992 ± 0.466| 2.162 ± 0.518  |1.385 ± 0.217    |
| MAE + DVH + CDM  | 0.567 ± 0.300| 1.933 ± 0.481  |1.389 ± 0.228    |
| MAE + CDM        | 0.491 ± 0.250| 1.999 ± 0.497  |1.370 ± 0.245    |

Only MAE+CDM satisfied all PTV $V_{95\%}\geq98\%$ and $D_{0.03\,cc}\leq110\%$ constraints on all test cases.

Bit-mask encoding reduced GPU memory from 20.50 GB to 19.57 GB (–4.5%) and per-epoch time from 241 s to 43 s (–82.2%).

Across architectures (with MAE+CDM loss), PTV Score ranged between 0.491% (3D U-Net, Pyfer, MedNeXt) and 0.699% (SwinUNETR).

## 5. Alignment with Clinical Evaluation Criteria

Empirical results demonstrate that voxel-wise MAE alone optimizes average-dose metrics (Dose Score=1.3 Gy) but does not ensure clinical coverage: PTV Score=1.544%, with mandatory $V_{95\%}\geq98\%$ constraints violated in ≈20% of cases. DVH-curve losses reduce PTV Score to 0.992% but still fail constraints in ≈10% of patients. Directly optimizing DVH-derived D- and V-metrics with CDM loss achieves PTV Score=0.491%, meets all coverage/OAR constraints, and matches clinical plan performance.

This underscores that clinical acceptability is determined by integral dose–volume histogram features, not simply voxel-wise similarity. Optimizing objectives aligned with evaluation metrics produces compliant plans even for relatively simple model architectures.

## 6. Generalization and Applications Beyond Radiotherapy

While the presented framework is validated for head-and-neck radiotherapy, Gao et al. note that the CDM approach is template-driven and readily extendable to other anatomical sites (pelvis, lung) with edit to the clinical-criteria JSON. More broadly, any application requiring control over voxel histogram properties—such as segmentation tasks with class-volume constraints or quantitative image analysis—may benefit from differentiable histogram-based losses.

A plausible implication is that domains with evaluation metrics expressed as spatial quantiles or integrals may see substantial performance gains from histogram-supervised learning, in contrast to strictly voxel-wise losses.

## 7. Limitations and Prospects

Reported results are based on a single-institution cohort and clinical protocol; multi-institutional validation remains outstanding. Integration of CDM-based dose predictors with downstream decision modules (e.g., dose-mimicking, plan deliverability) is an open area. The current framework’s efficiency and flexibility derive from its template-driven, lossless encoding and modularity, suggesting it is well suited for extension to broader volumetric prediction problems involving histogram constraints [2603.29670].

Source: https://www.emergentmind.com/topics/voxel-histogram-based-loss