A Review of Monte Carlo Methods and Their Application in Medical
A Review of Monte Carlo Methods and Their Application in Medical
Spring 2022
Part of the Analytical, Diagnostic and Therapeutic Techniques and Equipment Commons, Computer
Sciences Commons, and the Physics Commons
Recommended Citation
Shields, Joe, "A Review of Monte Carlo Methods and Their Application in Medical Physics for Simulating
Radiation Transport" (2022). Honors Theses and Capstones. 657.
https://scholars.unh.edu/honors/657
This Capstone is brought to you for free and open access by the Student Scholarship at University of New
Hampshire Scholars' Repository. It has been accepted for inclusion in Honors Theses and Capstones by an
authorized administrator of University of New Hampshire Scholars' Repository. For more information, please
contact [email protected].
A Review of Monte Carlo Methods and Their Application in
Medical Physics for Simulating Radiation Transport
Joseph Shields
Monte Carlo methods are used to calculate statistical behavior through the use of
random number generators and probability density functions. They have been used
extensively in medical physics for research in radiotherapy, designing technology,
dosimetry, and advanced clinical applications. This paper provides a background
on Monte Carlo methods and a review of radiation therapy physics and dosimetry.
Additionally, there is a discussion of the different ways Monte Carlo methods are
used in medical physics as well as a review of current research related to Monte Carlo
methods. The final portion of this paper contains my own Monte Carlo simulation
using the EGSnrc software toolkit to carry out two different simulations. One
simulation serves as a basic introduction to using the software and demonstrates
some of its capabilities, while the other is a more complex simulation that models
a realistic scenario in medical physics.
1
Contents
1 Background 3
1.1 Review of Monte Carlo Methods . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Review of Radiation Therapy Physics and Dosimetry . . . . . . . . . . . . . 6
4 Conclusion 32
5 References 34
2
1 Background
The Monte Carlo (MC) method is a widely used technique with a variety of applica-
tions. It can be difficult to provide an exact definition for MC method due their diversity
in application, therefore for our purposes it will be defined in the general context of med-
ical physics as the following: Monte Carlo is a numerical method to solve equations or to
calculate integrals based on random number sampling [28].
Random number generators (RNG) are required for a MC simulation in order to pro-
duce a large set of uncorrelated numbers. Since computer program outputs are inherently
predictable, they must appear random. Therefore the result of these RNGs must be “psue-
dorandom”. A useful RNG for applications in radiation therapy must have the following
attributes.
• Have a period long enough such that it is not used several times, making the results
of the MC simulation correlated.
One class of simple RNGs is the linear congruential generators which produces a sequence
of integers In by the recurrence relationship
Ncir Acir π
≈ = (2)
Nbox Abox 4
3
From this, we obtain the estimation for pi that can be calculated with the MC method
[24].
Ncir
π≈4 (3)
Nbox
The accuracy of this estimation increases as the total number of samples is increased. To
demonstrate this example using the Python random module, I created the following script
which provides a visualization for the MC method used, shown in Figure (1).
import random
import m a t p l o t l i b . p y p l o t a s p l t
import numpy a s np
N = 1000
c i r c l e s a m p l e s= 0
s q u a r e s a m p l e s= 0
x1 = [ ]
y1 = [ ]
a n g l e = np . l i n s p a c e ( 0 , 2 ∗ np . p i , 150 )
radius = 1
x2 = r a d i u s ∗ np . c o s ( a n g l e )
y2 = r a d i u s ∗ np . s i n ( a n g l e )
fig = plt . figure ()
ax = f i g . a d d s u b p l o t ( 1 1 1 )
f o r i in range (N ) :
random x = random . u n i f o r m ( −1 , 1 )
random y = random . u n i f o r m ( −1 , 1 )
d i s t f r o m o r i g i n = random x ∗∗2 + random y ∗∗2
i f d i s t f r o m o r i g i n <= 1 :
c i r c l e s a m p l e s += 1
s q u a r e s a m p l e s += 1
x1 . append ( random x )
y1 . append ( random y )
pi = 4∗( c i r c l e s a m p l e s / square samples )
p l t . t i t l e ( ’N = 1000 ’ )
ax . s c a t t e r ( x1 , y1 , s = 1 )
ax . p l o t ( x2 , y2 , c o l o r = ’ r ’ )
ax . s e t a s p e c t ( 1 )
print ( ” E s t i m a t i o n o f Pi =” , p i )
The calculation was repeated for N =100, N =1,000, N =10,000. The results of the estima-
tion for pi was 3.2401, 3.0840, and 3.1416 respectively. The estimation could be repeated
further with higher values of N to produce more accurate results.
4
Figure 1: MC estimations of pi with the total number of samples N = 100, 1000, 10000.
As the total number of samples increases, the accuracy of the estimation increases. The
increase in accuracy also requires an increase in computing time. These are two important
characteristics of MC simulations.
The MC method can be used as a stochastic method for numerical integration which is
capable of solving equations that would otherwise be impossible analytically [28]. Consider
an area A enclosed by the function f (x) on the interval [a, b].
Z b
A= f (x)dx (4)
a
Then a randomly generated number ηi uniformly distributed in the range [0,1] can be
scaled to the range [a, b] by
ξi = (b − a)ηi + a (5)
thus ξi is uniformly distributed in the range [a, b]. Then we can give a rough estimate of
the area A by
A1 = (b − a)f (ξ1 ) (6)
then repeating and improving this estimate by averaging the areas from two runs
1
A2 = [(b − a)f (ξ2 ) + A1 ]
2 (7)
b−a
= [f (ξ1 ) + f (ξ2 )]
2
therefore the generalization becomes obvious after continuously repeating this process.
N
b−aX
AN = f (ξi ) (8)
N
i=1
In the limit N → ∞, the estimated area AN converges to the real integral A. This method
can be expanded to multiple dimensions. Assume f (x) is now a function that shall be
5
integrated in a volume V with D dimensions. Now instead of random numbers for the
MC integration, we need a set of random points (or vectors) uniformly distributed in the
multidimensional volume V . If we have our randomly generated set ξ1 ...ξN , then this leads
us to the basic theorem of MC integration which includes the uncertainty of the estimation
r
⟨f 2 (x)⟩ − ⟨f (x)⟩2
Z
dV f (x) ≈ V ⟨f (x)⟩ ± (b − a) (9)
N
where Eq.(10) is the average function value and average function value squared respec-
tively [28].
N N
1 X 2 1 X 2
⟨f (x)⟩ = f (ξi ) and ⟨f (x)⟩ = f (ξi ) (10)
N N
i=1 i=1
Radiation therapy uses ionizing radiation to harm and destroy cancer cells. Ionization
is the process of a neutral atom either gaining or losing an electron, becoming a negatively
or positively charged ion respectively. When charged particles such as protons, electrons,
and α particles have a sufficient amount of kinetic energy capable of ionizing a neutral
atom through collisions, they are known as directly ionizing radiation. Alternatively,
neutral particles such as neutrons and photons capable of ionization are known as indirectly
ionizing radiation [8].
The four primary processes responsible for ionization in radiotherapy are the Compton
effect, photoelectric effect, coherent scattering, and pair production. Compton scattering
occurs when an incident photon collides with a charged particle such as an electron. During
the collision the energy and momentum are transferred to the charged particle while the
photon deflects with reduced energy and a change in momentum [14].
The photoelectric effect occurs when an incident photon has a collision and transfers
its entire energy hν to the atom, where h is Planck’s constant and ν is the frequency. This
process ejects an orbital electron from the atom with energy equal to hν − EB where EB
is the binding energy of the particular atom.
Coherent scattering, also known as Rayleigh scattering, can be described by considering
the wave nature of electromagnetic radiation. This interaction occurs when an incident
wave passes by an electron and sets it into oscillation, causing the electron to re-radiate
the energy at the same frequency. This emits a wave with the same wavelength as the
incident wave, thus no energy is transferred into the medium [8]. The intensity (I)
6
Figure 2: Diagram illustrating the Compton effect. In this interaction, the free electron
receives energy from the incident photon and is emitted at an angle θ. The incident
photon, with reduced energy, is scattered at an angle ϕ. Reproduced from [8].
Figure 3: Diagram illustrating the photoelectric effect. In this interaction, the entire
energy of the photon is transferred to the atom which ejects an electron known as the
photo-electron. The vacancy from the emitted photo-electron is filled by outer orbital
electrons which emit characteristic x-rays. There is also the possibility of Auger electrons
which are produced by the internal absorption of characteristic x-rays. Reproduced
from [8].
1
of the scattered wave has the relationship I ∝ λ4
, therefore this interaction is most de-
pendent on short incident wavelengths.
Similar to the photoelectric effect, pair production results in total attenuation of the
incident photon. Pair production occurs at higher energies of at least 1.022 MeV (2me ).
As the photon interacts with the strong electromagnetic field of the atom it undergoes a
change of state, transforming into an electron and positron.
7
Figure 4: Diagram illustrating Coherent scattering. The effect of this interaction is the
scatter of the incident photon at small angles. Reproduced from [8].
It is important to define the characteristics of the beam emitting x-rays or γ-rays from
a radioactive source. These beams contain a large number of photons in a variety of
energies [8]. The fluence (Φ) of a beam, which has units of m−2 , is analogous to flux in
electromagnetism. It is defined as the number of photons (dN ) that enter a cross-sectional
area (da) [8].
dN
Φ= (11)
da
Then naturally the fluence rate (ϕ), also known as flux density, is defined as the fluence
per unit time.
dΦ
ϕ= (12)
dt
Similarly we can define the energy fluence (Ψ) and the energy fluence rate (ψ), also known
as energy flux density or intensity.
dEfl
Ψ= (13)
da
8
dΨ
ψ= (14)
dt
For a monoenergetic beam, the sum of the photon energies (dEfl ) is the number of photons
(dN ) times the energy of each photon (hν).
dEfl = dN hν (15)
It’s also important to discuss how photons are attenuated when passing through material.
This can be characterized by the intensity of the photons as well as the material it is
traveling through [8].
I(x) = I0 e−µx (16)
Eq. (16) shows how the attenuation of a photon beam is described by an exponential
function, where I(x) is the intensity as a function of distance, I0 is the initial intensity,
and µ is the attenuation coefficient that is material dependent.
Radiation dosimetry deals with methods for quantitative determination of energy de-
posited in a medium through direct or indirect ionizing radiation [15]. A variety of quan-
tities and key calculations will be defined in this section. Kerma, which stands for kinetic
energy released per unit mass, is a non-stochastic quantity that is applicable for indirectly
ionizing radiation such as photons and neutrons. It represents the energy transferred from
indirectly ionizing radiation to the charged particles. It can be defined quantitatively as
µ̄en
K=Ψ /(1 − ḡ) (17)
ρ
where µ̄en /ρ is the averaged mass-energy absorption coefficient and ḡ is the average fraction
of an electron energy lost to radiative processes [8]. Kerma has units of J/kg or, in SI
units, Gray (Gy). Kerma can also be divided into two components; inelastic collisions
with atomic electrons (K col ) and radiative collisions with atomic nuclei (K rad ). Therefore
Kerma can be written as a sum.
Similarly cema, which stands for converted energy per unit mass, is a non-stochastic
quantity that is applicable for directly ionizing radiation such as electrons and protons. It
represents the energy lost by charged particles (dEc ) in a unit of mass (dm) of material.
It can be described quantitatively by Eq. (19) and it has the same units as Kerma.
dEc
C= (19)
dm
9
The linear stopping power (S) is defined as the expectation value of the rate of energy
lost per unit path length of the charged particle (dE/dx). For electrons and positrons,
Bethe theory is used to calculate stopping powers [15]. Additionally, the mass stopping
power is defined as the linear stopping power divided by the density of the absorbing
medium. The typical units for linear stopping power and mass stopping power respectively
are MeV/cm and MeV·cm2 /g.
Absorbed dose (D) is applicable to both indirectly and directly ionizing radiation and
can be defined as the mean energy (ϵ̄) imparted by ionizing radiation to matter of mass m.
The absorbed dose is often usually derived from energy loss along a particle path-length
segment, thus it’s related to particle fluence. It’s common to calculate fluence differential in
energy (ΦE ), which has units cm−2 MeV−1 [1]. When calculated through MC simulations,
for either charged or uncharged particles, the absorbed dose in the medium (Dmed ) can
be calculated by the following equations.
Z Emax
CPE
Dmed = [ΦE ]med [Sel (E)/ρ]med dE for charged particles (20)
0
Z kmax
TCPE
Dmed = k [Φk ]med [µen (k)/ρ]med dk for photons (21)
0
Eq.(20) and Eq.(21) can also be used to calculate the absorbed dose in a detector (D̄det ).
The acronyms over the equal signs CPE and TCPE stand for charge-particle equilibrium
and transient charged-particle equilibrium respectively. Charged-particle equilibrium ex-
ists for a volume V if each charged particle of a given type and energy leaving the volume
is replaced by an identical particle entering [12]. This is for lower energy particles, typ-
ically below 500 keV, since attenuation can be neglected. If there is no CPE then the
quantity calculated in Eq. (20) is not absorbed dose, instead it is cema (C). Transient
charged-particle equilibrium occurs for higher energy particles since attenuation causes
there to be less charged particles produced with increased depth [7]. If there is no TCPE
then the quantity calculated is kerma (K). Additionally it is important to note k as the
photon energy and Sel/ρ as the mass electronic stopping power (additional info can be
found in ICRU Report 85 [1]).
Using Eq.(20) and Eq.(21), the Bragg-Gray stopping power ratio can be defined as
R Emax h prim i
0 ΦE [Sel (E)/ρ]med dE
sBG
med,det = R Emax h prim i
med
(22)
0 Φ E [S el (E)/ρ]det dE
med
10
where we use the Bragg-Gray assumption which says that the cavity (detector) is so
small that it does not disturb the fluence of the charged particles when inserted into the
medium [5]. This gives us the condition Φmed ≈ Φdet . It is also assumed that the primary
charged-particle fluence does not include secondary or higher-order particles produced by
collisions with the primary particles.
11
2 Monte Carlo Methods in Medical Physics
Monte Carlo methods help both clinical physicists and researchers in better under-
standing dose calculations and modeling a variety of radiation sources. This section ex-
plores the use of Monte Carlo methods in dosimetry, external beam source modeling, and
for advanced treatment planning. Additionally, current research being done to improve
Monte Carlo simulations and their efficiency for clinical use is also discussed in this section.
When determining dose calculations experimentally, there are often quantities that
are difficult or even impossible to calculate analytically. Therefore these quantities need
to be determined numerically through the use of MC methods. In radiation dosimetry,
detectors are typically composed of several different components. The materials of each
of these components differ substantially from the medium where the absorbed dose is
to be determined [28]. This leads to a well established problem that is characterized
in terms of perturbation factors. Inserting a detector in a medium causes a change in
the electron spectrum within the detector radiation sensitive volume relative to that in
the homogeneous medium. This effect is known as perturbation [1]. Now taking into
account these perturbation factors, and assuming the Bragg-Gray assumption is valid, the
absorbed dose of the medium becomes
where pdet (Q) is the perturbation factors of the detector and Q is a given radiation beam
quality. A major constraint imposed on the perturbation factors is that they are small
and independent of each other. Under these assumptions, the perturbation factors can be
described as the following by the different detector components or effects
Y
pdet (Q) = pdet,i
i (24)
= pdis · pwall · pfl · pcel · pstem ...
where pdis accounts for the effect of replacing a volume of water by that of the detector,
pwall accounts for the presence of non-water-equivalent materials in the detector body and
walls, pfl corrects for the intrinsic difference in fluence between water and the detector
volumes, and pcel and pstem correct for the presence of a central electrode and stem,
12
respectively, if they are relevant to the type of detector involved [1]. Other factors may
be included as well depending on the case being considered.
Figure 6: Chain of dose ratios to calculate ionization chamber perturbation factors [1, 29].
Reproduced from [29].
Difficulties in electron simulations has led to special consideration into the MC calcula-
tions of perturbation factors. The first MC calculations for ionization chamber perturba-
tion factors were made for 60 Co in-air measurements [3, 13, 4]. In a separate development
by Wulff et al. [29], the perturbation factors from Eq.(24) are calculated using a chain of
dose ratios that include the effects from different chamber components. This process is
illustrated in Figure (6).
Monte Carlo methods are an incredibly powerful tool that can be used to accurately
model radiation transport for applications in radiotherapy. A common use of MC modeling
in external beam therapy is creating a virtual model of the radiation source. External beam
therapy can be performed using lower-energy photon beams, electron beams, or hadron
beams. Applications of these MC models include the design and optimization of the source,
studying radiation detector response, and for treatment planning [28]. MC methods have
provided a simple approach in deriving photon spectra from radiation sources. They
were also used extensively in the design of linear accelerators (LINAC) for photon beam
optimization. These MC models used a modular approach that are a popular practice
today.
Clinically used photon beams produced by a LINAC typically have an energy range of
4-25 MeV. A generic design of a LINAC is shown in Figure (7). The order of the compo-
13
Figure 7: Schematic of LINAC components in a Monte Carlo model of a photon LINAC.
In a photon LINAC, the photons are produced by electrons colliding with a metal target.
After that the beam is shaped by primary and secondary collimators. The flattening
filter and wedge both act as an attenuators to create a uniform field. Some LINACs
have multileaf collimators to create beams that conform to the shape of the tumor.
Reproduced from [28].
nents shown may vary depending on the manufacturer. In order to build a truly accurate
model of the LINAC for a MC simulation, the components must be known in great detail.
This includes; their mass densities; position, dimensions, and shape of defining surfaces;
and their motion. In order to calculate uncertainties in the calculations of the simula-
tion, it helps to determine the uncertainties of the physical qualities just listed. However,
this has proven not to be a trivial task. To combat miscalculations, the simulations are
validated against known dose calculations.
The BEAM/EGSnrc user interface is currently the most widely used LINAC simulation
package. It allows the user to easily assemble a LINAC model and building blocks with
a variety geometries. The code also allows for extensive beam analysis through the use
of particle tagging and according to interaction types, interaction sites, etc. for photons,
electrons, and positrons. The most important components in this model are the target,
14
Figure 8: Simple BEAM Monte Carlo model of an 18 MeV LINAC photon beam. From
right to left we see; the photon beam hitting the target (T), the primary collimator (PC),
the flattening filter (FF), and a few secondary collimators (SC). Reproduced from [28].
flattening filter, secondary collimators, and wedges. Target and flattening filters are the
most important sources of contaminant electrons, unless a wedge is present. For clinical
applications, the MC method requires extensive information on the beam characteristics
such as energy, angular, and spatial distributions of the particles in the beam. Efforts to
improve these models are continuously being made, such as modeling a multiple-source
photon beam based on the characterization of clinical photon beams used in radiother-
apy [6].
Photon beams have alternative methods for calculating patient dose that rival the ac-
curacy and performance of Monte Carlo simulations. For electron beams, this is not the
case as MC methods are necessary for proper dose calculations. It is for this reason that
MC methods have gained popularity in electron beam radiotherapy. Electron beam radio-
therapy is administered less often than photon therapy. Typical electron beam energies
for clinical use range from 4-20 MeV. At these energies, electron beams can be used for
superficial tumors (5 cm or less) with a characteristically sharp drop-off in dose after the
tumor [8].
A schematic for a Monte Carlo model of an electron beam LINAC is shown in Fig-
ure (9). This model differs from the photon beam LINAC in several key ways; the absence
15
Figure 9: Schematic of LINAC components in a Monte Carlo model of an electron beam
LINAC. Unlike the photon LINAC, the electron LINAC has no metal target. It also
has a scattering foil which broadens the beam and enhances uniformity. Reproduced
from [28].
of the photon target; the presence of a scattering foil to broaden the beam; and a mul-
tistage collimator to help shape the beam close to the irradiated volume. The latter is
necessary since electrons scatter much more in air than photons, therefore it is required
that the beam is collimated close to the surface of the patient [28].
Similarly to photon beam LINACs, BEAM/EGSnrc software is the primary tool for
Monte Carlo simulations of the electron beam LINAC. It is known that electron beam
models are particularly sensitive to the details of scattering foils, especially for fields
of high energy. One study considered four different parameters of the scattering foils
and found that the distance between the foils is critical [2]. Additional research is being
carried out to improve computational time required for simulating electrons using variance
reduction techniques.
16
2.4 Applications in Quality Assurance
In advanced radiotherapy, more complex techniques are employed in order to allow for
precise dose distributions. 3D conformal radiotherapy (CFRT) has the high-dose volume
match the target volume and avoids normal tissues. This allows for safer and more effective
radiotherapy and it has been a major development in the field. Intensity modulated
radiation therapy (IMRT) is the most advanced form of CFRT. It has the ability to
automatically geometrically shape radiation fields, modulate the intensity of the radiation
via computer control, verify that the radiation is being delivered accurately, and eliminate
or quantify uncertainties [27].
To provide quality conformal dose distributions, these advanced forms of radiation
therapy require complex treatment planning and a more complex beam delivery system.
Furthermore, the patient anatomy, heterogeneity, organ motion, and deformation cause
additional complexities. The long list of uncertainties and complexity of the treatment
process, in addition to the serious consequences of any errors, requires there to be a
comprehensive quality assurance (QA) to ensure that the patient will receive the proper
dose distributions [28].
Monte Carlo simulations can be used as a comprehensive tool for QA since it can
perform numerical experiments in the patient geometry and the treatment head. The
kinematics of the radiation beam can be represented by a phase-space data set which
allows for the retrieval of properties of the particles, such as type, energy, direction, and
location. The data set can be generated from a set of parameters that analytically describe
the beam, and its accuracy is critical for the performance of the MC simulation [23, 26].
In addition to the phase space data and patient specific data as specified by a CT or other
imaging data, the MC QA analysis process requires treatment delivery information. This
is depicted in Figure (10).
Through the use of MC simulations, a patients treatment plan can be verified with
confidence. The MC calculated dose distribution incorporated into the patient’s geometry,
setup, organ movement/deformation information can be used for treatment assessment
and outcome analysis. These capabilities allow for advanced radiotherapy treatment to
be performed reliably and with accuracy, making MC simulations a very valuable tool
throughout the entire process.
17
Figure 10: Treatment beam information used for a Monte Carlo based dose verification. If
the patient’s three-dimensional (3D) image data is available in real time, the actual dose
received by the patient can be determined using Monte Carlo simulation and compared
with that of the original treatment plan. This will verify the entire radiotherapy process
for a particular treatment, which will be the most complete patient-specific treatment
QA procedure. Reproduced from [28].
Due to the nature of MC methods, the computation time that is required can be
exhaustive and often impractical for clinical applications. A great deal of research is
focused on solving these problems and progress has certainly been made throughout the
years. These techniques that are used to speed up simulation times are known as variance
reduction techniques (VRT) [10]. These VRTs can give more emphasis on the quantities of
interest, therefore producing more relevant information for a given CPU time [16]. They
operate either by manipulating the numbers and weights of the transported particles or
by modifying the mean free paths for the relevant interaction processes. In a paper by
Garcia-Pareja et al. [9], multiple VRTs were compared and assessed on their performance.
Figure (11) shows the results of combining two VRTs; interaction forcing and splitting.
Interaction forcing essentially shortens the mean free path to increase the frequency of
interactions while the technique of splitting exploits local symmetries such as a particles
that are symmetric under rotations around an axis.
18
Figure 11: X-ray emission spectra from a tungsten target being bombarded by 100 keV
electrons at normal incidence. The left plot is from a 30 minute simulation. The right plot
was generated in 15 minutes with the same code but also using the VRTs of interaction
forcing and emission splitting bremsstrahlung photons and x-rays. Additionally, the
error bars that represent statistical uncertainty have been significantly reduced from the
left plot to the right plot. Reproduced from [9].
Another paper by Sarrut et al. [21] explores the use of artificial intelligence (or neural
networks) being used for applications in Monte Carlo simulations. A neural network is
composed of connected neurons that are typically organized in layers. A neuron in a neural
network is similar to a biological neuron. It receives input from other neurons, performs
some processing, and produces an output. The connections between the neurons have
associated weights and each neuron has an associated activation function that generates
the neuron’s output, for example a non-linear function which maps from an open domain
to a closed domain. The input to the neuron’s activation function is the weighted sum
over the outputs of all the connected neurons from the previous layer.
x(i+1) = f W (i) x(i) + b(i) (25)
In Eq. (25), f is the activation function where x(i) represents the output, W (i) represents
the weights matrix, and b(i) represents the bias for the layer i. The weights’ values are
determined during the training phase, meaning each weight has a value that is optimized
to adapt the neural network to handle a particular task. This is carried out with a training
data set.
19
A Generative Adversial Network (GAN) is a special deep neural network that, once
trained, can be used to generate data with similar statistics as the training set. Recent
works in medical physics have explored the used of GANs to model particle source distri-
butions and potentially speed up MC simulations [19, 20]. For these methods, the training
data set for the GAN is a phase space file generated by a standard MC simulation which
contains particle information (energy, position, direction) when they reach a specific sur-
face. Once the GAN is trained, its network can act as a compact and fast phase space
generator for MC simulations that replaces files that were several gigabytes in size with a
neural network that is several megabytes in size. This neural network has the ability to
generate a large number of particles which allows the user to speed-up the MC simulations
significantly.
Figure 12: Schematic showing the layers of a simple neural network. W and f represent
weights and activation functions respectively.
Simulations performed with the GAN as a phase space generator showed a very good
dosimetric accuracy in comparison to the real phase space generator [21]. However, despite
a large number of successful results, GANs have been shown to be notoriously difficult
to train. They tend to suffer from issues such as instability which has led to attempts of
various formulations based on different methods. An in-depth study on the most suitable
variants for a MC simulation is yet to be undertaken.
20
3 Monte Carlo Simulation Using EGSnrc Software
This portion of the paper will provide a brief overview of EGSnrc software and a few
examples of simulations I performed using it. EGSnrc is a collection of generic routines that
simulate the transport and interactions of ionizing radiation such as electrons, photons, and
positrons in matter [25]. It is free to used and it has a wide range of applications utilizing
radiation transport physics. Most applications are written in MORTRAN3 (native EGSnrc
language) or C++, although they can also be written in FORTRAN and C.
Figure 13: Schematic of EGSnrc applications and their corresponding languages. Repro-
duced from [25].
In order to install and run EGSnrc on a Windows computer, it is required to have com-
pilers for FORTRAN, C++, and C. Additionally, the GNU make utility is necessary and
features such as the git utility, Tcl/Tk interpreter, and Grace plotting tool are strongly
recommended [11].
For a simple demonstration of some of the capabilities of the EGSnrc software, I
simulated radiation that is incident on a 1mm thick tantalum slab. This was carried
out using a egs++ application, where egs++ is a C++ class library that allows for C++
applications to interface directly with the MORTRAN3 EGSnrc core [25]. The egs++
input file, titled slab.egsinp, is an input file that defines the conditions of the simulation.
It contained the following contents (note that the syntax of the text editor is set to ruby
since it resembles the syntax used by EGSrnc).
21
################################
#
# S imp l e s l a b s i m u l a t i o n
#
################################
################################
### RUN CONTROL
################################
: s t a r t run c o n t r o l :
n c a s e = 1 e3 # The number o f h i s t o r i e s t o s i m u l a t e
: s t o p run c o n t r o l :
################################
### GEOMETRY
################################
: s t a r t geometry d e f i n i t i o n : # Only 1 geometry d e f i n i t i o n b l o c k a l l o w e d
### D e f i n e a p l a t e o f t a n t a l u m
: s t a r t geometry : # Many geometry b l o c k s can be d e f i n e d
name = s l a b # This name can be a n y t h i n g you l i k e
l i b r a r y = egs ndgeometry
t y p e = EGS XYZGeometry
x−p l a n e s = −5, 5 # i n cm
y−p l a n e s = −5, 5 # i n cm
z−p l a n e s = −10 , 0 , 0 . 1 , 10 # i n cm
: s t a r t media i n p u t :
media = vacuum tantalum # I n d e x e d as 0 1
s e t medium = 1 1 # S e t r e g i o n 1 t o medium 1 ( t a n t a l u m )
# Other r e g i o n s d e f a u l t t o medium 0 ( vacuum )
: s t o p media i n p u t :
: s t o p geometry :
: s t o p geometry d e f i n i t i o n :
################################
### MEDIA
################################
: s t a r t media d e f i n i t i o n : # Only 1 media d e f i n i t i o n b l o c k a l l o w e d
22
# D e f i n i n g media i n t h e i n p u t f i l e like t h i s i s c a l l e d ” p e g s l e s s ” mode
### C u t o f f e n e r g i e s , i n MeV
ae = 0 . 5 2 1 # l o w e s t e n e r g y f o r e l e c t r o n s ( k i n e t i c +0.511)
ap = 0 . 0 1 # l o w e s t e n e r g y f o r p h o t o n s ( k i n e t i c )
ue = 5 0 . 5 1 1 # maximum e n e r g y f o r e l e c t r o n s ( k i n e t i c +0.511)
up = 50 # maximum e n e r g y f o r p h o t o n s ( k i n e t i c )
### Tantalum
: s t a r t tantalum : # t h i s name can be a n y t h i n g
density correction f i l e = tantalum # name t h e f i l e ( no e x t . )
: s t o p tantalum :
### Lead
: start lead :
density correction f i l e = lead
: stop lead :
### Water
: s t a r t water :
density correction f i l e = water liquid
: s t o p water :
: s t o p media d e f i n i t i o n :
################################
### SOURCE
################################
: s t a r t s o u r c e d e f i n i t i o n : # Only 1 s o u r c e d e f i n i t i o n b l o c k a l l o w e d
### P e n c i l beam
: start source :
name = p e n c i l b e a m
library = egs parallel beam
c h a r g e = −1
direction = 0 0 1
: s t a r t spectrum :
type = monoenergetic
e n e r g y = 20 # i n MeV
: s t o p spectrum :
: s t a r t shape :
type = point
23
p o s i t i o n = 0 0 −10 # i n cm
: s t o p shape :
: stop source :
: stop source d e f i n i t i o n :
################################
### VIEWER CONTROL
################################
: s t a r t view c o n t r o l :
# Here we a r e j u s t a s s i g n i n g some c o l o r s f o r n i c e
# viewing in the egs view a p p l i c a t i o n
s e t c o l o r = l e a d 120 120 200 200
s e t c o l o r = tantalum 120 255 120 255
s e t c o l o r = water 0 220 255 200
: s t o p view c o n t r o l :
################################
### AUSGAB OBJECTS
################################
: s t a r t ausgab o b j e c t d e f i n i t i o n : # Only 1 a u s g a b d e f i n i t i o n b l o c k a l l o w e d
### P a r t i c l e t r a c k s
: s t a r t ausgab o b j e c t :
name = t r a c k s
library = egs track scoring
: s t o p ausgab o b j e c t :
: s t a r t ausgab o b j e c t :
name = d o s e
library = egs dose scoring
dose r e g i o n s = 1
volume = 10
: s t o p ausgab o b j e c t :
: s t o p ausgab o b j e c t d e f i n i t i o n :
The key portions of this input file that are worth noting is the geometry, media, source,
and ausgab objects. The geometry is where we define the object that the radiation will
24
be incident upon. This is where we create a tantalum slab with our desired dimensions.
Next, the media sections is where we define the range of allowed energies of the incident
particles as well as the possible materials for the slab. Notice how we also define media
for lead and water, which allows us to switch the material of our slab in the geometry
section. The source section is where we define the shape and properties of our radiation
source. We defined a source that will emit electrons (charge -1) in the shape of the tip of
a pencil. Additionally, we gave the electrons an energy of 20 MeV and a starting position
of (0,0,-10cm). Finally we have the ausgab section which allows us to add features such
as particle tracking and dose calculations. The particle tracks allow for a visualization of
the path of the particles before and after interacting with the tantalum slab. The dose
calculations provides information on the dose deposited in every region of the geometry.
The simulation was ran for a couple different scenarios in order to demonstrate the
physics capabilities of the EGSnrc code. First, the simulation was ran for 20 MeV incident
electrons. The visual portion of the simulation output, produced by egs view, is shown
in Figure (14). The electron beam originates on the left side of the slab (negative z) in
the pencil beam shape we had previously defined. The red lines represent electrons, the
yellow lines represent photons, and the blue lines represent positrons. Additionally, the
black regions before and after the green tantalum slab are a vacuum. Clearly there are a
lot more particles on the right side of the slab than there are on the left. These particles
Figure 14: Particle tracks for 20 MeV electrons incident on a tantalum slab.
25
originate from the variety of mechanisms that were covered in 1.2. Although there are only
a few, positrons were produced during the collisions. This is expected since the incident
electrons are carrying 20 MeV of energy, well above the 1.022 MeV threshold necessary
for pair production. The simulation was repeated with water and lead slabs.
The dose calculation, which was outputted in the command line, is shown in Table (1).
As discussed before, the dose (D) is defined as the energy deposited per unit mass. The
volume (V ) and density (ρ) of the tantalum plate respectively are 10 cm3 and 16.654 g/cm3 .
Therefore the mass is 166.54 g and the dose can be calculated to be 2.472 × 10−12 Gy.
Next, I changed the incident particle to photons to compare its dose and tracks to
that of the electrons. This adjustment is made by simply changing the charge to zero in
the source section of the egs input file. The visual output produced by egs view is shown
in Figure (15). The simulation was carried out twice with two different energies, 1 MeV
and 20 MeV. It is clear that more particles are produced by the 20 MeV photons than
the 1 MeV photons. Additionally, there are no positrons produced by the 1 MeV incident
photons since it did not reach the threshold for pair production. There is clearly pair
production for the 20 MeV incident photons.
Shown in Table (2) and Table (3) are the dose calculations for 1 MeV and 20 MeV
incident photons respectively. Notice that the dose is lower than that of the electrons by
a factor of roughly 10 and 100 for the 1 MeV and 20 MeV incident photons respectively.
As expected, this indicates that photons interact with matter less than electrons do. This
decrease in interactions also led to a higher uncertainty since there were fewer events
sampled in the slab. Additionally, the computation time was about 10 times faster for the
photons since there were fewer events. The 1 MeV incident photon simulation was faster
26
Figure 15: Particle tracks for 1 MeV incident photons (top) and 20 MeV incident photons
(bottom), each incident on a tantalum slab.
27
than the 20 MeV incident photon simulation as well, the general rule of thumb being that
lower energy simulations require less computational time.
This simple example provides a good introduction into how to use the egs++ code and
for learning some of its basic, yet powerful, capabilities. We saw how electrons could be
backscattered and how they produced secondary particles. We also saw how photons had
less interactions and how varying their energies influences the production of secondary
particles. Lastly, we also saw how dose calculations are made so that we can interpret our
results with greater detail. The next simulation will use some more advanced features of
EGSnrc software.
28
3.2 LINAC and Beam Simulation
Ex : 2 s t a t i c f i e l d s , 1 dynamic , f o r 2 j a w s
6
0.0
4 0 , 5 0 , −1, −1, −2, −2
5 1 , 6 1 , −1, −1, −2, −2
0.3
4 0 , 5 0 , −1, −1, −2, −2
5 1 , 6 1 , −1, −1, −2, −2
0.3
40 , 50 , 2 , 2 , 1 , 1
51 , 61 , 2 , 2 , 1 , 1
0.6
40 , 50 , 2 , 2 , 1 , 1
51 , 61 , 2 , 2 , 1 , 1
0.6
4 0 , 5 0 , 1 , 1 , −1, −1
5 1 , 6 1 , 0 . 0 5 , 0 . 0 5 , −0.05 , −0.05
1.0
4 0 , 5 0 , 1 , 1 , −1, −1
5 1 , 6 1 , 1 , 1 , −1, −1
The format of the sequence file is described in section 15.3.8 of the BEAMnrc User Man-
ual [18]. The sequence defines two static fields and one dynamic field in six steps. In units
of cm, the upper y-jaws are at 40 ≤ z ≤ 50 and the x-jaws are at 51 ≤ z ≤ 61. From
index 0.0 to 0.3 (30% of the simulation), the jaws are in a static position. The repeated
indices, 0.3 and 0.6, result in simulated collimator shifts while the beam is off. Then from
29
index 0.6 to 1.0 there is motion of the x-jaws from a nearly closed position to a 2 × 2
opening. The view of the first position of the jaws before any motion begins is shown in
Figure (16).
Figure 16: Jaw positions of simulated LINAC before motion. The blue region represents
air while the purple region represents media from the 700icru data file [17].
Once all parameters were properly set and the LINAC was compiled, the simulation
was ran with 100,000 histories. The simulation ran fairly quickly and outputs a phase
space file. This phase space file was then analyzed using the Grace plotting software. A
scatter plot containing the phase space data was produced and is shown in Figure (17).
The plot shows how the jaws collimated the source and as expected, there are two off-axis
fields and one field in the center. It is easy to confirm that the field matches the 2 × 2
collimator openings that were specified but the jaws sequence. It is also easy to see the
other smaller openings on either side.
Next, to create an MC simulation on a patient phantom, measured images such as
a CT image need to be converted into a egsphant format. A patient phantom acts as a
stand-in for human tissue to ensure that systems and equipment will be working properly
for the patient. The egsphant is a rectilinear voxel format in a plain text file. This
essentially takes data structures that store geometric information in a continuous domain
and converts them into a rasterized image (a discrete grid). CT and MRI images are
acquired in a special digital format known as DICOM which ensures that the high quality
of the images is retained. There is a tool distributed with EGSnrc called ctcreate that can
be used to convert DICOM files to the egsphant format.
30
Figure 17: X-Y scatter plot of phase space data from LINAC simulation. This plot
demonstrates that the beam is primarily concentrated in the 2 × 2 opening specified by
the jaws sequence.
Figure 18: Dose distribution created from the LINAC simulation and CT DICOM data.
As expected, the primary concentration of the dose is in the center of the 2 × 2 opening
as well as the center of the two other smaller openings.
For this simulation, a sample CT DICOM file was used from the EGSnrc github release
page. The next stage of the radiotherapy simulation process, a dose calculation, can be
performed now using this CT DICOM file. This was done using DOSXYZnrc and the
BEAMnrc accelerator that was just created. The simulation was ran and it produced a
3D map of the dose. The distribution is shown in Figure (18).
31
4 Conclusion
This review provided a brief background on the physics of radiotherapy and dosimetry
in order to give a more complete review of how Monte Carlo methods are used in medical
physics. Monte Carlo methods are a great tool to accurately simulate radiation trans-
port which allows physicists to simulate linear accelerators, perform dose calculations,
and more. This makes Monte Carlo simulations a great tool for academic research and
engineering in the field of medical physics. However, the extensive computational time
required for complex Monte Carlo simulations make them impractical for routine clinical
use. This has led to modern research that explores new ways to improve the computational
time needed for the simulations.
Research by Sarrut et al. [21] demonstrates how the use of artificial intelligence shows
promise, but some of the neural networks being used are proving to be notoriously difficult
to train. Future research in the use of AI in Monte Carlo simulations is still needed to
try and find more effective methods to train the neural networks that would make the
simulations practical. Additionally, since neural networks in Monte Carlo simulations
learn from properties of data sets, there is no guarantee that they are providing a plausible
representation of the physics it is simulating. This is another challenge that will have to
be overcome with further research.
Other research by Garcia-Pareja et al. [9] explores variance reduction techniques that
also aim to reduce the computation time of Monte Carlo simulations. These techniques
operate either by manipulating the numbers and weights of the transported particles
or by modifying the mean free paths for the relevant interaction processes. Multiple
techniques were found to be effective in achieving lower computation time if used in proper
scenarios. Their work provided evidence of the usefulness of VRTs to speed up simulations
of radiation transport.
The EGSnrc software is widely used throughout the medical physics community. It
has vast capabilities that are used to simulate radiation transport and to model linear
accelerators. This review provided a brief background into the EGSnrc code and explored
some of the capabilities it has. This included an analysis of the dose on a slab of different
materials when exposed to electrons or photons. We also saw how the EGSnrc code can
be used to construct and compile a model for a linear accelerator. Using this model, we
could simulate how radiation is delivered and received by a patient phantom provided by
32
CT DICOM data. These simulations provided an introduction to EGSnrc software, but
future work can further explore the vast capabilities it has.
33
5 References
[1] Pedro Andreo. Monte Carlo simulations in radiotherapy dosimetry. pages 1–15, 2018.
[2] Michael R. Bieda, John A. Antolak, and Kenneth R. Hogstrom. The effect of scat-
tering foil parameters on electron-beam monte carlo calculations. Medical Physics,
28(12):2527–2534, 2001.
[3] J E Bond, R Nath, and R J Schulz. Monte carlo calculation of the wall correction
factors for ionization chambers and a/sub eq/ for /sup 60/co. gamma. rays. Med.
Phys.; (United States), 9 1978.
[4] A Monte Carlo. A Monte Carlo technique for evaluation of cavity ionisation chamber
correction factors. 1983.
[6] Jun Deng, Steve B Jiang, Ajay Kapur, Jinsheng Li, and Todd Pawlicki. Photon
beam characterization and modelling for Monte Carlo treatment planning Photon
beam characterization and modelling for Monte Carlo treatment planning. (May
2014), 2000.
[7] Important Dosimetric, Quantities When, Icru Report, Fundamental Quantities, Ion-
izing Radiation, Radiological Physics, and Radiation Dosimetry. 4 Radiation Dosime-
try. 2015.
[8] Khan Faiz M. The Physic of Radiation Therapy. Lippincott Williams & Wilkins,
2003.
[10] Keyvan Jabbari. Review of Fast Monte Carlo Codes for Dose Calculation in Radiation
Therapy Treatment Planning.
34
[12] C-m Charlie Ma and D Ph. Measurement of Radiation Table of Contents.
[13] R Nath and RJ Schulz. Calculated response and wall correction factors for ionization
chambers exposed to 6 0co gamma-rays. Med. Phys.; (United States), 1981.
[14] James E Parks. The Compton Effect– Compton Scattering and Gamma Ray Spec-
troscopy. 2015.
[16] Academic Press. Monte Carlo Techniques of Electron and Photon Transport for Ra-
diation Dosimetry D . W . O . Rogers and A . F . Bielajew National Research Council
of Canada Ottawa , Canada Reprinted from Chapter 5 , Vol . III The Dosimetry of
Ionizing Radiation Edited by Kenneth R . Kase , Bengt E . Bjarngard and Frank H
. Attix. 1990.
[19] D Sarrut, A Etxebeste, N Krah, and JM Létang. Modeling complex particles phase
space with GAN for monte carlo SPECT simulations: a proof of concept. Physics in
Medicine & Biology, 66(5):055014, feb 2021.
[20] D Sarrut, N Krah, and J M Létang. Generative adversarial networks (GAN) for
compact beam source modelling in monte carlo simulations. Physics in Medicine &
Biology, 64(21):215004, oct 2019.
[21] David Sarrut, Ane Etxebeste, Enrique Muñoz, Nils Krah, and Jean Michel Létang.
Artificial Intelligence for Monte Carlo Simulation in Medical Physics. 9(October):1–
13, 2021.
[22] Jamie Shiers and Michel Goossens. CERNLIB. CERN Program Library. CERN,
Geneva, 1996. CERN Program Library Short Writeups.
[23] J V Siebers, P J Keall, B Libby, and R Mohan. Comparison of EGS4 and MCNP4b
monte carlo codes for generation of photon phase space distributions for a varian
2100c. Physics in Medicine and Biology, 44(12):3009–3026, nov 1999.
35
[24] Svetlana Strbac-savic and Ana Miletic. The estimation of Pi using Monte Carlo
technique with interactive animations THE ESTIMATION OF PI USING MONTE
CARLO TECHNIQUE WITH. (October), 2015.
[25] R Townson, F Tessier, E Mainegra, and B Walters. Getting Started with EGSnrc.
National Research Council of Canada, Ottawa, 8(May):1–72, 2005.
[26] Qianxia Wang, Cong Zhu, Xuemin Bai, Yu Deng, Nicki Schlegel, Antony Adair,
and Zhi Chen. Automatic phase space generation for Monte Carlo calculations of
intensity modulated particle therapy Automatic phase space generation for Monte
Carlo calculations of intensity modulated particle therapy.
[28] Hendee William R. Monte Carlo Techniques in Radiation Therapy. Taylor and Francis
Group, 2013.
[29] Klemens Zink. Monte Carlo based perturbation and beam quality correction factors
for thimble ionization chambers in high-energy photon beams. (May 2014), 2008.
36