**Fo**rward Dose **Ca**lculation for Proton Therapy

**Daniel Sánchez-Parcerisa**Universidad Complutense de Madrid

dsparcerisa [at] ucm.es

FoCa is an in-house modular treatment planning system, developed entirely in MATLAB, which includes forward dose and LET calculation of proton radiotherapy plans in both active and passive modalities as well as a generic optimization suite for inverse treatment planning. The software has a dual education and research purpose. From the educational point of view, it can be an invaluable teaching tool for educating medical physicists, showing the insights of a treatment planning system from a well-known and widely accessible software platform. From the research point of view, its current and potential uses range from the fast calculation of any physical, radiobiological or clinical quantity in a patient CT geometry, to the development of new treatment modalities not yet available in commercial treatment planning systems.

FoCa's rights belong to the University of Pennsylvania. FoCa has been developed as an incremental research tool, rather than as a complete software. For this reason, there are a number of features that have not been implemented. In particular, the current version of the system is not able to The software is provided ‘as is’. Although it has gone through thorough commissioning and testing, bugs are expected. Please report any found bugs and proposed solutions.
Version 1.7b does |

FoCa has been developed with MATLAB (R2014a) and observed to work with all versions of MATLAB from 2013a.

There are a number of external functions libraries used in MATLAB coding, with varying licensing schemes. The files are located under the /libs folder of the FoCa data path. **No libraries have to be manually installed to run FoCa.** For more information:

- matGeom library (http://matgeom.sourceforge.net/wiki/index.php/MatGeom).
- ini2struct function (http://www.mathworks.com/matlabcentral/fileexchange/17177-ini2struct).

FoCa files must be copied to a local directory and added to the MATLAB path. In summary, what must be added to the MATLAB path is:

- FoCa folder
- FoCa folder/libs with all subfolders

Additionally, the FoCa data path is specified in the MATLAB environment variable FOCA_DATA_PATH. Within this folder, the following items must exist

- beamdata/ folder, including all machines, with each folder corresponding to either a PBS or a DS machine.
- aux_files/ folder.

The command **testPWD** returns the FoCa installation directory, making the first line of all FoCa scripts to be:

setenv('FOCA_DATA_PATH',testPWD)

As a final step, FoCa installation can be verified by running the following command

verifyFoCaInstallation

Each of the FoCa classes can be instantiated separately from any piece of MATLAB code. Despite the object oriented (OO) paradigm, we have decided to make all properties of public access, to facilitate experimental programming. Do take time to explore the classes and find solutions that suit your needs. This is a **non-comprehensive **list of the available functionalities:

- Perform dose (and LET) calculations of PBS and DS plans on patient geometries.
- Perform any type of dose or dose+LET calculations on water-phantoms, created with a given size at given coordinates.
- Perform a cropping of a CT in order to do the calculations taking into account only a certain volume.
- Normalize the dose calculated by FoCa on the Result grid using several algorithm.
- Plot a 2D dose or LET distribution at any given plane (parallel to the axes) superimposed to the CT.
- Save dose or dose+LET to DICOM files. Requires voxel size in X and Z to be the same and requires a model ED DICOM file.
- Crop everything outside body: Makes every voxel outside the Body contour have the density of air.
- Override artifacts defined in the structure set either based on a given water-equivalent density or on a based HU number.
- Plot dose/LET slice with structures over CT.
- Calculate Gamma Index and Distance To Agreement matrices.

- Find the ROI number of a structure given its name.
- Plot a 2D contour plot a given slice of a structure.
- Determine if a given point belongs to a ROI or not.
- Create a binary mask with information of the structures to which a point belongs (or for the complete DG).
- Calculate the geometrical distance between the edge of the BODY contour and the field isocentre.
- Calculate the geometrical range for a given BODY and TARGET structures, for a given gantry/couch position.

- Apply a HU-to-WET conversion to a given CT.
- Extract or plot a 2D slice of the CT at an arbitrary plane parallel to the axes.
- Calculate the water-equivalent path length between two points in the CT.

- Calculate dose and LET kernels of a given size for given machine and beam conditions.

- Plot the calculation grid in 3D including fluence, dose and LET information.
- Plot the polygon defined by a given MLC position over a heatmap of the fluence matrix in BEV coordinates.

- Load a DICOM RD file containing a dose matrix.
- Extract or plot a 2D slice of the external dose matrix or an arbitrary plane parallel to the axes.
- Create a 1D plot of the external dose distribution containing any given point, in a direction parallel to any of the axes.

- Load a DICOM file containing a proton plan.
- Print plan information.
- Extract the projection of the MLC shape into the isocentre as a polygon.
- Display a heatmap of the spot of a given layer of a PBS field.

- Create dose-volume histograms and LET-volume histograms of FoCa-calculated plans.
- Create dose-volume histograms and LET-volume histograms of external dose files.

- FoCa V1.7d (public package). Includes Example (
**non-physical**) Double Scattering and Pencil Beam Scanning data. - FoCa User Manual (PDF).
- FoCa introductory exercises.

- D Sánchez-Parcerisa
*et al*(2014). FoCa: a modular treatment planning system for proton radiotherapy with research and educational purposes. Phys. Med. Biol. 59, 7341. (download preprint) -
D Sánchez-Parcerisa

*et al*(2016). Analytical calculation of proton linear energy transfer in voxelized geometries including secondary protons. Phys. Med. Biol. 61, 1705. (download preprint) -
D Sánchez-Parcerisa & JM Udías (2018). Teaching treatment planning for protons with educational open source software: experience with FoCa and matRad. Journal of applied clinical medical physics 19 (4), 302-306. (download)