gamos radiotherapy optimisation wc2009, sept. 12th 2009 1 optimization of an external beam...
TRANSCRIPT
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 1
Optimization of an external beam radiotherapy treatment using
GAMOS/Geant4
Pedro ArceJuan Ignacio Lagares
Daniel Pérez-Astudillo (CIEMAT, Madrid)
John ApostolakisGabriele Cosmo
(CERN, Geneva)
World Congress 2009, Munich, 12 September 2009
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 2
1. GAMOS radiotherapy framework RT simulation in Geant4 GAMOS RT: geometry GAMOS RT: source GAMOS RT: scoring GAMOS RT: phase space files GAMOS RT: dose in phantoms
Outline
3. GAMOS usage Documentation Tutorials Installation
Summary Future prospects
2. OPTIMISATION Automatic optim. physics cuts Geant4 EM physics parameters Fast navigation in phantoms CPU time comparison BEAMnrc / DOSXYZnrc CPU time reports Particle spliting
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 3
GAMOS Radiotherapy framework
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 4
GEANT4 is a very powerful and flexible toolkit Outstanding geometry and visualisation Well proven physics Big flexibility Many thousands of users…
But it is not easy for a beginner to simulate a radiotherapy treatment Everything requires writing C++, and a good knowledge of GEANT4 details Very few tools specific for radiotherapy No optimisation specific for radiotherapy
GAMOS provides a Geant4-based framework easy to use and flexible EASY: With a few simple commands you can simulate a full radiotherapy treatment using a text
file FLEXIBLE: Based on plug-in technology.
No predefined components, they are selected ‘on the fly’, by the user commands If you have a new requirement not covered by GAMOS, it is very easy to plug your code into the GAMOS
framework and select your code with a user command
+ several tools have been developed to optimise a radiotherapy application
Radiotherapy simulation with GEANT4
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 5
Any accelerator geometry can be built with a simple geometry format
Based on solids (box, tube, polycone, ..) + their union/substraction/intersection
Any material can be used (+400 predefined for user convenience)
Several modules to simplify complicated elements (jaws, applicators, MLCs)
// PRIMARY COLLIMATOR:P PC_ZMIN 1.6*cm:P PC_ZMAX 7.6*cm:VOLU “primary collimator" TUBE 0 10*cm ($PC_ZMAX-$PC_ZMIN)/2. G4_W:VOLU "primary collimator_hole" CONE 0. 4. 0. 20. ($PC_ZMAX-$PC_ZMIN)/2. G4_AIR // continuation line:PLACE "primary collimator" 1 expHall RM0 0. 0. $PC_ZMIN+$PC_ZMAX)/2.:PLACE "primary collimator_hole" 1 "primary collimator" RM0 0. 0. 0. :COLOR "primary collimator" 1. 0. 1. // RGB color
Movements: Any volume can be moved with a user command
GAMOS Radiotherapy frameworkGeometry
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 6
Flexible source generator: One or several particles of any type: photon, electron, positron, proton,
neutron, isotopes, ...
Each one can be assigned a distribution of position, direction, energy and time
The usual medical physics distributions are available Users can easily add a new one (plug-in’s)
GAMOS Radiotherapy frameworkSource (primary generator)
/gamos/generator/directionDist my_source GmGenerPositionDiscGaussian 1*mm/gamos/generator/timeDist my_source GmGenerTimeDecay
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 7
Scoring is an important part of your simulation powerful and flexible framework:
Many possible quantities can be scored in one or several volumes● Dose ● Deposited energy ● Flux (in/out/passage)● Current (in/out/passage) ● Charge ● Step length● Number of particles ● Number of interactions ● Number of 2ary particles● Number of steps ● Minimum kinetic energy ● …
For each scored quantity one or several filters can be used (almost 100 available)
• Only electrons, only particles in a certain energy range, …
Several ways to classify the different scores• One different score for each different volume name, or volume copy, or energy bin, …
Results can be printed in one or several formats for each scored
quantity• Standard output, text file, binary file, histograms
All scored quantities can be calculated with/without errors
All scored quantities can be calculated per event or per job• Taking into account correlations from particles from same event
Everything managed with user commands
GAMOS Radiotherapy frameworkScoring
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 8
Write phase space files at one or several Z planes Energy, position, direction Save extra info:
Regions particle traversed Regions particle created Regions particle interacted Particle origin Z BIG FLEXIBILITY
More can be easily added (they are plug-in’s) User selects which infos and how many bytes each one occupies
Use phase space files as generator Displace or rotate phase space particles Reuse phase space particles
Optional automatic calculation of reuse number Optional mirroring in X, Y or XY
Recycle phase space files Command for skipping of first N events Command for optional histograms of particles read Filter particles by extra info Also read EGSnrc phase space format
GAMOS Radiotherapy frameworkPhase space files
VRML view of VARIAN 6000 accelerator
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 9
Simple voxelised phantoms ones with a few user commands
Read DICOM files Read GEANT4 format (example advanced/medical/DICOM)
Read EGS format
Several outputs standard output text file binary file histograms
Displace or rotate read-in phantom geometry
PTV/CTV/GTV management
Many filters to write several dose files
in the same job
We have developed a tool that allows to insert objects in phantom geometries and
produce the interactions in them Realistic simulation of brachytherapy sources or ionisation chambers inside phantoms!
GAMOS Radiotherapy frameworkDose scoring in phantoms
gMocren visualisation of DICOM geometry and tracks
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 10
Dose visualisation
IMRT dose visualisation with CIEMAT’s tool (MIRAS)
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 11
Optimisation:
physics cuts
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 12
Optimisation: physics cuts Two kind of physics cuts in Geant4:
Production cuts Limit secondary production for ionisation and bremsstrahlung
User Limits:
Limit step size: better done tuning EM physics parameters
Limit track length: not relevant in accelerator simulation
Limit time of flight: not relevant in accelerator simulation
Kinetic energy/range minimum (stop particle if kinE/range below a
limit): useful to kill particles when energy not enough to reach target
Better use range as more uniform for different regions
Better use kinetic energy as more efficient calculation
GAMOS solution: use kinetic energy inside but user provides it as
range through a command
Different physics cuts per particle and region (group of volumes) can
be defined through user commands
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 13
Optimisation: setting best cuts
Normally people want that optimising the cuts produces only few % (or less) difference in results
need to run very big statistics Cuts can be very different for different particle/regions, and a cut in one particle/region may affect another
need to run many sets of cut values
RESULT: usually people think it is too complicated Do not optimise cuts Just copy the cuts from someone, which usually are not the best one for them
In GAMOS we propose anAutomatic determination of best production cuts or user limits in
one job
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 14
Which is the highest cuts we can use without decreasing the number of particles reaching the phase space plane?
In GAMOS we use an ‘inverse reasoning’:
For each particle reaching the plane Get range of particle when it was created Get range of mother particle where it was created Do it consecutively for all ancestors
Make statistics of all these ranges, per particle, region and process
At EndOfRun print statistics of which is the minimum range per particle, region and process You know that if you use a bigger production cut at least one
particle would be killed and this particle or one of its children would not reach the phase space
Accelerator: Automatic optim. prod cuts
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 15
Often you allow some small % loss of particles.. Make histograms of all ranges per particle, region and proces Provide an script so that for a given cut it gives you the proportion of particles
killed
Be aware of double counting (very low: < 1%) Make histogram of minimum range
(one entry per particle + particle ancestors) and
use it for statistics of % particles killed
Check distributions of killed particles
How to use it in GAMOS: Add one user command in one job
/gamos/userAction GmProdCutsStudy RTPhaseSpaceFilter
Similar approach for user limits…
Accelerator: Automatic optim. prod cuts
log10(range) of gammas created at target that reach the patient or produce a secondary that reaches the patient
CUT
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 16
In GAMOS we use an ‘inverse reasoning’:
Compute dose due to particles that would be killed with a certain cut (and all their daughters)
When a particle is killed dose is deposited locally only count dose in voxels different that where particle is killed by cut
GAMOS can estimate in one job the dose with several different cut values
Use GAMOS filters
/gamos/filter ProdCutFilter GmProdCutOutsideVoxelFilter 10.*mm 1.*mm
/gamos/scoring/addFilter2Scorer ProdCutFilter PDDscorerPC10.1.
It may happen that dose is small but distributed in a different manner than total dose (produces bias)
Use GAMOS dose histograms
to check dose shape
Similar approach for user limits…
Dose: Automatic optim. prod cuts
Percent Depth Dose curve for all particles and particles rejected by cut 1mm/e- 10
mm/gamma
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 17
We have simulated a VARIAN accelerator– Plane at 100 cm from the source and of halfwidth 100 cm in X and Y.
We have computed the dose in a water phantom of 104 voxel
Select the maximum cut values that change the total dose << 1 %
A command serves to apply production cuts to other processes, not only ionisation & bremsstrahlung (not needed but useful) We gain an extra 3% in CPU time
RANGE REJECTION: Automatic procedure gives you also information on number of
particles that would be killed by range rejection Does not improve CPU significatively (few particles are killed by
it)
RESULTS: Optim. production cuts
CPU gain
Accelerator: 20% w.r..t cuts ‘standard’ in BEAMnrc/DOSXYZnrc (700 keV for e-/e+, 10 keV for gamma)
Dose: 0-30% w.r..t cuts ‘standard’ in BEAMnrc/DOSXYZnrc
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 18
Optimisation:
Geant4 electromagnetic
physics parameters
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 19
Select EM physics parameters In Geant4 there is a long list of parameters that a user can change...
METHOD: Start with default values which have been found good for radiotherapy
simulations They are quite conservative Except dE/dx and lambda tables bin size
Change values to less precision and watch CPU time Only consider those for which CPU gain is not neglibible Try also higher precision to check
Watch for change in dose (look also at change in phase space)
OUTCOME: Increase number of bins in dE/dx and lambda tables Switch off energy loss fluctuations Parameters that change charged particles step size vs precision
Option 1: msc range factor = 0.05Option2: Rover range = 0.8 Lambda factor = 0.2
Msc step limitation = MinimalDetailed study can be found at http://fismed.ciemat.es/GAMOS/RToptim
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 20
Number of bins dE/dx and lambda tables
Number of bins of dE/dx and lambda tables: 120 1200 No change in Emax (for 10 MeV 500 bins would have same effect)
Phase space change: About 1 % less particles, uniformly distributed in E and space
Dose change: 0.6 – 0.8 % decrease in dose, increasing with energy
CPU gain: -1 % default cuts 0% optimised cuts
CONCLUSIONS: we recommend using new values
PDD: new/old
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 21
No energy loss fluctuations
Phase space: - Reduces substantially number of low energy (< 0.2 MeV particles)
Dose: - Increases dose by 0.2 - 0.3 % quite uniformly
CPU gain: 13 % default cuts 1 % optimised cuts
CONCLUSIONS: acceptable, but not really needed
PDD: new/old
phase space E: new/old
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 22
Fewer e-/e+ steps option 1
Phase space: - About 1.5 % more particles, uniformly distributed in E and space
Dose: - 1.3 – 1.4 % increase in dose, quite uniformly
CPU gain: 29 % default cuts 12 % optimised cuts
CONCLUSIONS: acceptable, with caution(if change in dose is fully uniform it does
not matter)
PDD: new/old
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 23
Phase space: - About 1.8 % more particles, uniformly distributed in E and space
Dose: - ~2 % increase in dose, bigger at low Z
CPU gain: 47 % default cuts20 % optimised cuts
CONCLUSIONS: not acceptable, too big change, not uniform
PDD: new/old
Fewer e-/e+ steps option 2
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 24
Optimisation:
Fast dose calculation in
phantom voxels
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 25
Indexes voxels and voxel materials
Takes profit of regular geometry to quickly locate distance to next voxel
and next voxel ID
Voxel frontiers are skipped ‘on the fly’ if voxels share same material Distributes dose along voxels traversed taking into account correcctions in
energy loss and multiple scattering due to energy loss along path
4-6 times faster than other Geant4 algorithm- Depends on number of voxels and number of materials
Fast voxel navigation algorithm
CPU Time spent on transporting 1000 PARTICLES in 4.5 million-voxel phantom using diffferent Geant4 algorithms
Old Vx 3D Nested Reg.(4 mate.)
Reg.(57 mate.)
Reg.(500 mate.)
Reg.(No skip)
2030 1.98 1.62 0.30 0.40 0.74 1.45
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 26
Optimisation:
CPU time comparison with
BEAMnrc/DOSXYZnrc
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 27
VARIAN 2100 gamma accelerator:
106 events on Pentium Dual-Core 3 GHz
BEAMnrc GAMOS/GEANT4 GAMOS/GEANT4(auto. optim cuts)
6 MeV 277 s 359 s 248 s18 MeV* 1020 s 897 s 599 s
CPU time comparison with BEAMnrc
* Same parameters as for 6MeV
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 28
DOSXYZnrc GAMOS/GEANT4 GAMOS/GEANT4(auto. optim cuts)
water 234 s 215 s 167 s
patient 300 s 170 s 166 s
Dose in 104 5x5x3 mm water phantom: 106 events on Pentium Dual-Core 3 GHzDose in 4.5 106 patient, 23 materials: 106 events on Pentium Dual-Core 3 GHz
CPU time comparison with DOSZXYnrc
DOSXYZnrc:
• Only 4 densities: 297 s
• All densities: 300 s
GEANT4: • 4 materials: 166 s• 23 materials: 274 s• 68 materials: 360 s• 196 materials: 454 s
Dependency with number of materials
Need to implement density-changing materials in Geant4…
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 29
Optimisation: time reports
User commands to get CPU time report By particle, energy bins, volume, region (or combination of them)
Just add a user command, for example:/gamos/userAction GmTimeStudyUA GmClassifierByParticle GmClassifierByEnergy
gamma/0.001-0.01: User=0.01 Real=0 Sys=0gamma/0.01-0.1: User=2.01 Real=2.45 Sys=0.27gamma/0.1-1: User=19.12 Real=22.05 Sys=1.51gamma/1-10: User=4.25 Real=5.4 Sys=0.3e-/0.0001-0.001: User=0.07 Real=0.1 Sys=0e-/0.001-0.01: User=0.54 Real=0.69 Sys=0.06e-/0.01-0.1: User=4.71 Real=5.41 Sys=0.38e-/0.1-1: User=15.59 Real=18.19 Sys=1.79e-/1-10: User=82.83 Real=98.62 Sys=7.45
Example to get detailed gprof profiling about where (in which methods) the time is spent
Time spent in a method and integrated time in all the methods called by it
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 30
Optimisation:
Particle splitting
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 31
Particle splitting
UNIFORM BREMSSTRAHLUNG SPLITTING All bremmstrahlung photons are replicated the same number of times
Z-PLANE DIRECTION BREMSSTRAHLUNG SPLITTING User defines a Z plane with limits in X & Y (represents entrance of phantom) Same as uniform BS, but if gamma does not aim at Z plane, Russian roulette is played
EQUAL-WEIGHT SPLITTING Similar as Z-plane direction BS, but splits every gamma produced, not only from bremsstrahlung Russian roulette is played with e-/e+, so that very few reach Z plane Aim is that all particles that reach phantom have the same weight Based on EGSnrc DBS technique
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 32
Particle splitting: RESULTS
UNIFORM BREMSSTRAHLUNG SPLITTING
Maximum efficiency gain: 2.2
Z-PLANE DIRECTION BREMSSTRAHLUNG SPLITTING
Maximum efficiency gain: 6.5
EQUAL-WEIGHT SPLITTING
Maximum efficiency gain: 45
EGSnrc results with same accelerator: gain 80
Algorithm in GAMOS is not fully implemented yet…
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 33
Documentation, installation,
usage
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 34
Documentation
User’s Guide: Installation All available functionality How to provide new functionality by creating a plug-in
Examples:
A simple one and a few more complicated ones
/gamos/setParam GmGeometryFromText:FileName mygeom.txt
/gamos/geometry GmGeometryFromText
/gamos/physics GmEMPhysics
/gamos/generator GmGenerator
/run/initialize
/gamos/generator/addSingleParticleSource my_source gamma 6.*MeV
/run/beamOn 1000
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 35
Tutorials
Four tutorials Radiotherapy tutorial PET tutorial Histograms and scorers tutorial plug-in tutorial
Propose about 15 exercises each Explained in detail Increasing in difficulty Reference output provided Solutions provided
4 GAMOS tutorial courses have been given in Europe and America
About 70 attendees Next tutorial in European School of Medical Physics (October-November 2009)
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 36
Installation
GAMOS is freely available from CIEMAT web• User registers and downloads installation scripts
We provide a no-choice but very easy way: one-line installation sh installGamos.csh/sh $HOME/gamos
No need to manually download and install packages No need to define enviromental variables Checks that your system has the needed components Downloads, installs and compiles CLHEP, Geant4, (optionally) ROOT and GAMOS in one directory GAMOS compiles = Geant4
Optionally an expert user can make several choices
Current installation tested on Scientific Linux, Fedora Core, Debian and Ubuntu, and on MacOS
> 50 tests are run to check each new release
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 37
Summary And
Future prospects
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 38
Summary
We have implemented in GAMOS many user commands & analysis tools
to make easy an radiotherapy accelerator simulation many GAMOS tools are already being used for other fields (PET,
brachytherapy, microdosimetry, damage in electronics, …)
We have developed several tools to optimise the CPU time of an
radiotherapy simulation• Automatically optimise production cuts and user limits
• Optimisation of Geant4 electromagnetic physics parameters
• Do detailed time studies with a user command
• Algorithm for fast navigation in voxelised phantoms
• Particle splitting techniques for acceleartor simulation
We improve CPU time by a factor of 100 w.r.t. ‘bare’ Geant4
We get similar CPU times as BEAMnrc / DOSXYZnrc
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 39
Future prospects
Improve particle splitting (factor ~ 2 - 3)
Implement history repetition (factor ~ 2 - 5)
Fast Monte Carlo (factor ~ 10 - 100)
Provide standard and fast Monte Carlo in the same
framework Thanks to Geant4 flexibility
Everybody is invited to contribute!
GAMOS radiotherapy optimisation WC2009, Sept. 12th 2009 40
http://fismed.ciemat.es/GAMOS