Analyzing Dose-Volume Histograms Using Dvhmetrics For R: Wollschlaeger@Uni-Mainz - de Karle@Uni-Mainz - de
Analyzing Dose-Volume Histograms Using Dvhmetrics For R: Wollschlaeger@Uni-Mainz - de Karle@Uni-Mainz - de
DVHmetrics for R
Daniel Wollschlaeger Heiko Karle
wollschlaeger@uni-mainz.de karle@uni-mainz.de
University Medical Center Mainz, Germany
November 22, 2017
Contents
1 Introduction 2
2 Interfaces 2
2.1 R command line interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Web-based graphical user interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
4 DVH metrics 5
4.1 Calculate DVH metrics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.2 Save DVH metrics to file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.3 Convenience functions for DMEAN, gEUD, NTCP, TCP . . . . . . . . . . . . . . . . . 10
4.4 Point-wise mean DVH with standard deviations . . . . . . . . . . . . . . . . . . . . . . 11
5 DVH diagrams 11
5.1 Plot DVH diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
5.2 Save cumulative DVH diagrams to file . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
References 21
1
1 Introduction
DVHmetrics is an add-on package for the free statistical environment R1 (R Development Core Team,
2017) with applications in radiation oncology. It provides functionality to read dose-volume-histogram
(DVH) text files, to calculate DVH metrics, and to plot DVHs. In addition, it checks and visualizes
quality assurance constraints for the DVH.2
To install DVHmetrics, you need a current version of R and be online. Preferably, a free development
environment like RStudio (RStudio Inc, 2017) or Architect (OpenAnalytics BVBA, 2017) should be
used.
2 Interfaces
DVHmetrics provides two interfaces geared towards users with different levels of familiarity with R:
The regular command line functions and a built-in web application.
Users familiar with R can use the DVHmetrics package functions from the R command line. This facil-
itates statistical post-processing of results with the full capabilities of R. After installing DVHmetrics,
you should be able to run (function getMetric() is explained in section 4.1):
For users who are unfamiliar with R, DVHmetrics includes a shiny-based web application (Chang,
Cheng, Allaire, Xie, & McPherson, 2017) running locally that eliminates the need to use R syntax.
For information on how to use this app, see the documentation by running this from the command
line:
1
Free short introductions to R can be found at
http://www.splusbook.com/RIntro/RCourse.pdf and http://www.statmethods.net/.
2
For a solution that also reads files in DICOM-RT format, see the RadOnc package for R (Thompson, 2017).
2
vignette("DVHshiny")
To import DVH data into R, it should be exported as a plain text file from Varian EclipseTM
(Versions 10–15), CadPlanTM , Pinnacle3 TM (version 93 ), Oncentra MasterPlanTM (version 4.3),
Elekta MonacoTM (version 5), TomoTheray HiArtTM , RaySearch Labs RayStationTM , Medcom
ProSomaTM , or from PRIMO (version 0.3.1.1558). DVH files from different TPSs can be combined
into one set of DVHs. Cumulative and differential DVHs are supported, as are sum plans. The
measurement unit for absolute dose can be Gy, cGy, or eV/G for uncalibrated PRIMO files. The
measurement unit for volume has to be cm3 . Multiple DVH text files can be read with readDVH() in
one step.
Example: Read one Eclipse file dvhFile.txt from folder "c:/folder" and save the result in object
res.4
Basic information about the files can be displayed with print(), or just by entering the name of a
DVH object at the prompt – here used with built-in DVHs from three patients with radiotherapy,
each with seven heart structures.5
print(dataMZ)
DVH list:
Patient 'John Doe' (ID P123, prescription dose 60GY) with 7 Structures:
HEART, AOVALVE, AMYOCR, PULMVALVE, MYOCARD, AMYOCL, AVNODE
DVH list:
Patient 'Jane Doe' (ID P234, prescription dose 60GY) with 7 Structures:
AMYOCR, AVNODE, HEART, AOVALVE, PULMVALVE, MYOCARD, AMYOCL
DVH list:
Patient 'Jane Smith' (ID P345, prescription dose 60GY) with 7 Structures:
HEART, AOVALVE, PULMVALVE, MYOCARD, AMYOCL, AMYOCR, AVNODE
3
Pinnacle3 files have to be exported such that information from one patient is contained in one directory. The directory
layout and required files are explained in help(readDVH).
4
Note that the way to indicate the path to these files is different from the usual Windows style path: Instead of writing
the backslash "\" as folder separator, the forward slash "/" must be used.
5
Sample data courtesy of Department of Radiation Oncology (Prof. Dr. Schmidberger), University Medical Center
Mainz, Germany.
3
print(dataMZ, verbose=TRUE)
DVH list:
Patient 'John Doe' (ID P123, prescription dose 60GY) with 7 Structures:
DVH: Structure 'HEART' (600 CC), Dose: 0-62GY
DVH: Structure 'AOVALVE' (12 CC), Dose: 0-62GY
DVH: Structure 'AMYOCR' (57 CC), Dose: 0-62GY
DVH: Structure 'PULMVALVE' (3.8 CC), Dose: 0-62GY
DVH: Structure 'MYOCARD' (310 CC), Dose: 0-62GY
DVH: Structure 'AMYOCL' (60 CC), Dose: 0-62GY
DVH: Structure 'AVNODE' (38 CC), Dose: 0-62GY
DVH list:
Patient 'Jane Doe' (ID P234, prescription dose 60GY) with 7 Structures:
DVH: Structure 'AMYOCR' (53 CC), Dose: 0-63GY
DVH: Structure 'AVNODE' (43 CC), Dose: 0-63GY
DVH: Structure 'HEART' (730 CC), Dose: 0-63GY
DVH: Structure 'AOVALVE' (15 CC), Dose: 0-63GY
DVH: Structure 'PULMVALVE' (6.7 CC), Dose: 0-63GY
DVH: Structure 'MYOCARD' (330 CC), Dose: 0-63GY
DVH: Structure 'AMYOCL' (81 CC), Dose: 0-63GY
DVH list:
Patient 'Jane Smith' (ID P345, prescription dose 60GY) with 7 Structures:
DVH: Structure 'HEART' (550 CC), Dose: 0-62GY
DVH: Structure 'AOVALVE' (11 CC), Dose: 0-62GY
DVH: Structure 'PULMVALVE' (5.7 CC), Dose: 0-62GY
DVH: Structure 'MYOCARD' (270 CC), Dose: 0-62GY
DVH: Structure 'AMYOCL' (43 CC), Dose: 0-62GY
DVH: Structure 'AMYOCR' (52 CC), Dose: 0-62GY
DVH: Structure 'AVNODE' (24 CC), Dose: 0-62GY
Multiple files with the same name pattern can be specified using wildcards like *. Example: Read all
CadPlan files with the file name pattern dvhFile*.txt from folder "c:/folder" and save the result
in object res.
When no file pattern is specified, multiple files can be selected using the standard Windows file picker
dialogue. On MacOS and Linux, only a single file can be selected interactively.
For DVH files from a sum plan, prescribed dose can be encoded in the plan name like name_70Gy_etc.
It will then be assumed that “% for dose” is 100.
4
res <- readDVH("c:/folder/*", type="Eclipse", planInfo="doseRx")
4 DVH metrics
Function getMetric() calculates freely-defined DVH metrics based on data that has been read in as
demonstrated in section 3. getMetric() has the following options:
5
– Example metrics are listed in table 1. By default, metrics are calculated using linear
interpolation between adjacent supporting points of the cumulative DVH – without extrap-
olating beyond the observed volume or dose. The interpolation method can be changed to
use monotone Hermite splines (Fritsch & Carlson, 1980), or to local polynomial regression
with a Gaussian kernel (Wand & Jones, 1995). The kernel bandwidth is then determined
by the direct plug-in method (Ruppert, Sheather, & Wand, 1995).
• Option patID: Which patient IDs should be analyzed. With fixed=FALSE, IDs are interpreted
as regular expressions matched against those found in the DVH files. By default, IDs are
matched exactly. If missing, the metrics are calculated for all patients.
• Option structure: Which structure should be analyzed. With fixed=FALSE, structure names
are interpreted as regular expressions matched against those found in the DVH files. By default,
structure names are matched exactly. If missing, the metrics are calculated for all structures.
• Option sortBy: Results can be sorted according to these variables:
– "observed": observed value of the metric
– "structure": structure for which the metric is calculated
– "metric": type of calculated metric
– "patID": patient ID
• Option splitBy: Results can be divided into different tables according to these variables:
– "structure": structure for which the metric is calculated
– "metric": type of calculated metric
– "patID": patient ID
If volume or dose values outside the range of possible values for a structure are requested, it may be
that metrics cannot be calculated, and the result will be NA (missing value) with a warning.
6
In the following examples, we use object dataMZ that is built into the DVHmetrics package. dataMZ
was the result from reading three Eclipse DVH files, each with seven structures – as demonstrated in
section 3.
Calculate metric DMEAN for all structures for all patients in dataMZ.
getMetric(dataMZ, metric="DMEAN")
Calculate metric D5cc just for structure HEART for all patients in dataMZ.
Calculate metric D5cc just for structure HEART for all patients in dataMZ, and sort result by the
observed value of the metric.
7
Calculate metrics D10% and V5Gy for all structures containing the text AMYOC or VALVE, for patient
IDs in dataMZ containing the text 23, and sort result by metric and observed value.
Calculate metrics DMEAN and D5cc for structure HEART for all patients in dataMZ, sort by the observed
value of the metric, and split the output such that one table is generated for each metric.
$D5CC
observed metric structure patID
4 3.474 D5CC HEART P234
2 31.482 D5CC HEART P123
6 41.618 D5CC HEART P345
$DMEAN
observed metric structure patID
3 0.995 DMEAN HEART P234
5 10.389 DMEAN HEART P345
1 18.110 DMEAN HEART P123
Calculate metrics DMEAN and D5cc for structures HEART and AOVALVE for all patients in dataMZ, sort
by observed value, and split the output such that one table is generated for each combination of
structure and metric. Also store the result in object met that can be saved later.
8
met <- getMetric(dataMZ, metric=c("DMEAN", "D5cc"),
structure=c("HEART", "AOVALVE"),
sortBy="observed",
splitBy=c("structure", "metric"))
met # print the calculated results
$AOVALVE.D5CC
observed metric structure patID
8 2.064 D5CC AOVALVE P234
12 8.337 D5CC AOVALVE P345
4 21.752 D5CC AOVALVE P123
$HEART.D5CC
observed metric structure patID
6 3.474 D5CC HEART P234
2 31.482 D5CC HEART P123
10 41.618 D5CC HEART P345
$AOVALVE.DMEAN
observed metric structure patID
7 1.959 DMEAN AOVALVE P234
11 11.283 DMEAN AOVALVE P345
3 21.454 DMEAN AOVALVE P123
$HEART.DMEAN
observed metric structure patID
5 0.995 DMEAN HEART P234
9 10.389 DMEAN HEART P345
1 18.110 DMEAN HEART P123
The calculated DVH metrics can be saved to tab-delimited text files with saveMetric(). These files
are easy to import, e. g., into spreadsheets like Excel or into other statistics programs.
Assume object met has been calculated before as demonstrated in section 4.1. If met is not split into
different tables, the following command saves met to the file metrics.txt. If met is divided into
multiple tables, this saves met into different files that all have the name pattern metrics_NAME.txt,
where NAME stands, e. g., for the names of different structures.
saveMetric(met, file="c:/folder/metrics.txt")
Per default, numbers use the . as decimal separator. This can be changed with option dec="," .
9
saveMetric(met, file="c:/folder/metrics.txt", quote=TRUE)
DMEAN, gEUD, NTCP and TCP may be calculated together with other metrics using getMetric(),
but there are specialized convenience functions for this task as well. In particular, getDMEAN()
calculates the dose mean, median, mode, minimum, and maximum based on the (interpolated)
differential DVH instead of relying on the values exported by the TPS.
10
4 0.2398 P123 PULMVALVE
5 0.1832 P123 MYOCARD
6 0.1882 P123 AMYOCL
7 0.1948 P123 AVNODE
Function getMeanDVH() returns the point-wise mean and median DVH with the point-wise standard
deviation for a given list of input DVHs. Other point-wise measures may be calculated as well. Before
calculating the point-wise mean and SD, DVHs are first linearly interpolated such that they possess
the same set of nodes. This feature can be useful for evaluating different plan options: The DVHs for
each plan need to be exported using a different patient ID which thus serves as a plan identifier. See
section 5.1 to show the mean DVH with SD regions.
5 DVH diagrams
Cumulative as well as differential DVH diagrams can be generated with showDVH(). If you are using
RStudio or Architect, all produced diagrams are accessible in the plots tab by clicking on the left
and right arrows. Depending on the option byPat, each DVH diagram either shows one patient with
multiple structures (byPat=TRUE) or one structure with multiple patients (byPat=FALSE).
showDVH(dataMZ, byPat=TRUE)
11
Patient P123 Patient P234
100 100
75 75
structure structure
AMYOCL AMYOCL
AMYOCR AMYOCR
Volume [%]
Volume [%]
AOVALVE AOVALVE
50 AVNODE 50 AVNODE
HEART HEART
MYOCARD MYOCARD
PULMVALVE PULMVALVE
25 25
0 0
0 10 20 30 0 1 2 3 4
Dose [GY] Dose [GY]
Patient P345
100
75
structure
AMYOCL
AMYOCR
Volume [%]
AOVALVE
50 AVNODE
HEART
MYOCARD
PULMVALVE
25
0
0 10 20 30 40
Dose [GY]
Patient IDs and structures can be selected with the patID="hIDi" option and the structure="hNAMEi"
option. With fixed=FALSE, both accept regular expressions. By default, IDs and structure names
are matched exactly. By default, all patients/structures are shown.
12
Structure HEART Structure AOVALVE
100 100
75 75
Volume [%]
Volume [%]
patID patID
P123 P123
50 50
P234 P234
25 25
0 0
0 10 20 30 0 10 20 30
Dose [GY] Dose [GY]
75 75
Volume [%]
Volume [%]
patID patID
P123 P123
50 50
P234 P234
25 25
0 0
0 10 20 30 0 10 20
Dose [GY] Dose [GY]
75 75
Volume [%]
Volume [%]
patID patID
P123 P123
50 50
P234 P234
25 25
0 0
0 10 20 30 0 10 20
Dose [GY] Dose [GY]
13
Structure AVNODE
100
75
Volume [%]
patID
P123
50
P234
25
0
0 10 20
Dose [GY]
By default, the relative DVH is shown. Absolute volume (if available in the input files) can be plotted
with the rel=FALSE option. For differential DVH, set cumul=FALSE.
100
75
structure structure
Volume [CC/GY]
Volume [CC/GY]
6 AMYOCL AMYOCL
AMYOCR AMYOCR
AOVALVE 50 AOVALVE
PULMVALVE PULMVALVE
25
0
0 10 20 30 0 1 2 3 4
Dose [GY] Dose [GY]
14
Patient P345
30
20
structure
Volume [CC/GY]
AMYOCL
AMYOCR
AOVALVE
PULMVALVE
10
0
0 10 20 30 40
Dose [GY]
Option thresh allows to restrict the range of the x-axis such that only relative volumes larger than
thresh appear. Use option show=FALSE to prevent the diagrams from being shown if you just need
the returned object (here: dvhPlot) to later save the diagrams to file.
With option addMSD=TRUE, the diagram also shows the point-wise mean DVH as a black curve as well
as grey shaded areas for the regions defined by the point-wise 1 standard deviation and 2 standard
deviations around this mean (see section 4.4). With byPat=FALSE and addMSD=TRUE, the average
DVH for one structure over many patients can be visually assessed.
Structure HEART
100
75
patID
Volume [%]
P123
50 P234
P345
25
0
0 10 20 30 40
Dose [GY]
15
5.2 Save cumulative DVH diagrams to file
DVH diagrams can be saved to file using saveDVH(). A file name pattern can then be supplied to
option file. By using different file extensions like .pdf, .jpg, .png, different graphics formats can
be automatically selected. In addition, the width and height of the diagram can be specified in inch.
For quality assurance, it is possible to define, check, and visualize constraints on the dose-volume
relationship for DVHs.
A DVH constraint is a character string that consists of three parts: The DVH metric (see section 4.1),
a comparison operator among <, >, <=, >=, and the reference value together with the measurement
unit – one among among Gy, cGy, cc, %. For constraints involving the relative dose, the DVH must
contain the prescription dose.
Some example constraints are "V10Gy > 80%" (more than 80% of the structure should have received
10Gy), "V20% < 10CC" (less than 10cm3 of the structure should have received 20% of the prescription
dose), or "D10CC > 500cGy" (The “hottest” 10cm3 of the structure should have received more than
500cGy). Constraints can also apply to the dose mean, median, and standard deviation as well as to
the gEUD and to the (N)TCP.
A DVH constraint can apply to a specific patient or to all patients, and to a specific structure or to
all structures.
• If constraints apply to all patients/structures, the constraint can be a character vector with
elements like the examples above.
• If constraints apply only to some patients/structures, the constraint must be a data frame with
variables constraint, patID and structure. Each row then defines one constraint and its
scope: constraint must be a character string with one constraint definition as in the examples
above. patID must be either a character string with a valid patient ID, or "*" if the the
constraint applies to all patients. structure must be either a character string with a valid
structure name, or "*" if the the constraint applies to all structures. If variable patID is missing
from the data frame, the constraints apply to all available patients. If variable structure is
missing from the data frame, the constraints apply to all available structures.
Alternatively, it is possible to specify a set of constraints as a table in a text file with one row per
constraint and one column for the constraint expression, structure, and patient ID. A table like this
can be created in a spreadsheet program like Excel (fig. 1), be exported to a tab-delimited text-file,
and be read in by function readConstraints(). Table 2 shows some examples.
16
Table 2: Example for pasted constraints.
Constraints that apply to all patients and to all structures
"D10cc < 20%"
"V5cGy > 100cc"
"DMEAN < 10Gy"
The constraint data frame dataConstr is built into DVHmetrics and applies to the dataMZ DVH
data.
For checking constraints, and for calculating the difference between the observed DVH and the
constraint, the DVH is linearly interpolated, by using monotone Hermite splines, or by local polynomial
kernel regression.
Constraints are checked with checkConstraint(). The output returns information on the observed
value of the tested metric, on the compliance with respect to this metric, and on the absolute/relative
deviation in volume as well as in dose to the specified constraint value. The units for the absolute
deviation are those used in the constraint expression. When the constraint defines a point in dose-
volume space, checkConstraint() reports another quantitative measure for the degree of violation:
The closest point on the DVH to the constraint as well as its Euclidean distance to the constraint
point.
For calculating the minimal Euclidean distance between the constraint point and the DVH, the
constraint point is orthogonally projected onto each DVH segment between (interpolated) DVH nodes.
17
Figure 1: Defining constraints in a spreadsheet program like Excel
The relative Euclidean distance is the minimum of these distances divided by the distance of the
constraint point to the closest axis (dose and volume) along the same direction. In doing so, the
devation from the expected volume per dose and the devation from the expected dose per volume are
condensed in a single metric.
As an example, we use the DVHs and corresponding constraints that are built into the DVHmetrics
package.
The result from a constraint check can be saved with function saveConstraint() that works like
saveMetric() (see section 4.2).
18
saveConstraint(cc, file="c:/folder/constrCheck.txt")
Constraints that define a point in dose-volume space can be visualized in a DVH with relative volume
or absolute volume. The constraints will be converted to match the DVH plot. Only patients and
structures within the scope of the defined constraints are shown. The diagram also shows the point
on the DVH closest to the constraint. This can be verified visually only if the aspect ratio of the
diagram is 1.
As in showDVH() (see section 5.1), either one diagram per patient with multiple structures is shown
(byPat=TRUE), or one diagram per structure with multiple patients (byPat=FALSE).
75 75
structure
● ● structure ● AOVALVE
Volume [%]
Volume [%]
● AVNODE ● HEART
50 50
constraint constraint
● V1.2GY_% > 60% ● D200CC_% > 2%
D80%_GY < 1.8GY
●●
25 25
0 0
0 10 20 0 1 2 3
Dose [GY] Dose [GY]
Patient P345
100
75
constraint
● V4%_% > 25%
Volume [%]
structure
● HEART
●
25 ●
0
0 10 20 30 40
Dose [GY]
19
## plot absolute volume - store result in sc to save to file later
sc <- showConstraint(dataMZ, constr=dataConstr,
byPat=FALSE, rel=FALSE)
saveDVH(sc, file="c:/folder/dvhConstraint.pdf")
The linear-quadratic model for the proportion of surviving cells S after dose d is (IAEA & ICRU,
2008):
2)
S = e−(αd+βd
According to the model, the biologically effective dose (BED) with total dose D, fraction dose d and
a tissue-dependent α/β ratio is:
d
BED = D 1 +
α/β
Given two different fractionation schemes, the total dose D2 for the new fraction dose d2 that
corresponds to the total dose D1 from the reference fraction dose d1 can be calculated from solving
the following equation for the desired measure:
D2 d1 + (α/β)
=
D1 d2 + (α/β)
As a special case, the dose in 2Gy fractions biologically equivalent dose (EQD2 ) is given by:
d1 + (α/β) BED
EQD2 = D1 · =
2 + (α/β) 2
1 + α/β
The following convenience functions allow for easy calculation of these measures:
BED fractDose ab
1 112.50 2.5 2
2 91.67 2.5 3
3 81.25 2.5 4
20
EQD2 fractDose ab
1 56.25 2.5 2
2 55.00 2.5 3
3 54.17 2.5 4
The same functions can be used to convert complete DVHs to BED, EQD2, or to the iso-effective
dose corresponding to some other fraction dose.
DVH: Patient 'John Doe' (ID P123), structure 'HEART' (600 CC), Dose: 0.11-68GY
Acknowledgements
The authors thank Marcus Stockinger for ideas on checking quality assurance constraints as well as
Sandra Bührdel, Hannes Rennau, Ulrich Wolf, Bjorne Riis, Nico Banz, and Michael R. Young for
example DVH files exported from different treatment planning systems.
References
Chang, W., Cheng, J., Allaire, J. J., Xie, Y., & McPherson, J. (2017). shiny: Web application
framework for R [Computer software]. URL http://CRAN.R-project.org/package=shiny
(R package version 1.0.5)
Fritsch, F. N., & Carlson, R. E. (1980). Monotone piecewise cubic interpolation. SIAM Journal on
Numerical Analysis, 17 , 238–246.
IAEA, & ICRU. (2008). Relative biological effectiveness in ion-beam therapy (Tech. Rep. No. IAEA-TR
461). Vienna, Austria: IAEA (International Atomic Energy Agency) and ICRU (International
Commission on Radiation Units and Measurements).
Källman, P., Ågren, A., & Brahme, A. (1992). Tumor and normal tissue responses to fractionated
non-uniform dose delivery. International Journal of Radiation Biology, 62 (2), 249–262.
Lyman, J. T. (1985). Complication probability as assessed from dose volume histograms. Radiation
Research, 104 (2), S13–19.
Niemierko, A. (1999). A generalized concept of equivalent uniform dose [abstract]. Medical Physics,
26 (6), 1100.
OpenAnalytics BVBA. (2017). Architect [Computer software]. URL https://getarchitect.io/
(Version 0.9.11)
R Development Core Team. (2017). R: A Language and Environment for Statistical Computing
[Computer software manual]. Vienna, Austria. URL http://www.r-project.org/
RStudio Inc. (2017). RStudio: Integrated development environment for R [Computer software]. URL
http://www.rstudio.org/ (Version 1.1.383)
21
Ruppert, D., Sheather, S. J., & Wand, M. P. (1995). An effective bandwidth selector for local least
squares regression. Journal of the American Statistical Association, 90 (1), 1257–1270.
Thompson, R. F. (2017). RadOnc: Analytical tools for radiation oncology [Computer software]. URL
http://CRAN.R-project.org/package=RadOnc (R package version 1.1.4)
Wand, M. P., & Jones, M. C. (1995). Kernel smoothing. Boca Raton, FL: Chapman & Hall/CRC.
Wu, Q., Mohan, R., Niemierko, A., & Schmidt-Ullrich, R. (2002). Optimization of intensity-modulated
radiotherapy plans based on the equivalent uniform dose. International Journal of Radiation
Oncology · Biology · Physics, 52 (1), 224–235.
22