{'fraction_non_alphanumeric': 0.023447983614662053, 'fraction_numerical': 0.006356381100360195, 'mean_word_length': 4.992382564536606, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
BrachyGUI: an adjunct to an accelerated Monte Carlo photon transport code for patient-specific brachytherapy dose calculations and analysis

A number of accelerated Monte Carlo (MC) codes have been developed in recent years for brachytherapy applications, one of which is PTRAN_CT. Developed as an extension to the well-benchmarked PTRAN code, PTRAN_CT can be used to perform efficient patient-specific dose calculations. The code can explicitly account for the patient geometry converted from computed-tomography (CT) images, as well as perturbations due to the brachytherapy applicator and seeds. We have developed a software tool called BrachyGUI that provides an integrated environment for preparing patient and treatment plan-specific input data files for PTRAN_CT. It also comes with dose calculation, analysis, and treatment planning capabilities. In this article, we will describe the interface of BrachyGUI with PTRAN_CT for CT-based calculations, and examine the calculation efficiency of PTRAN_CT. We conclude that it is now feasible to use PTRAN_CT for high dose rate brachytherapy treatment planning on a routine clinical basis.


Introduction
In recent years, several accelerated Monte Carlo (MC) codes have been developed for brachytherapy applications [1][2][3]. These codes employ efficient particle transport and dose scoring algorithms, and therefore tend to be much faster than general purpose MC codes. However, preparing the input data for patient-specific dose calculations is often time-consuming. In addition to specifying the relevant MC transport and treatment planning parameters, one also needs to define the three-dimensional (3D) patient voxel geometry as well as the brachytherapy applicator and/or seed structures in the patient's coordinate system. Setting up these input data manually can be error-prone.
We have developed a multi-purpose tool called BrachyGUI to facilitate computed tomography (CT)-based calculations with the PTRAN_CT photon transport code [1,4]. BrachyGUI is developed in MATLAB (version 7.0.4, The MathWorks, Natick, MA) for brachytherapy dose calculation and analysis [5]. It has been used at our institution for several brachytherapy applications, including a patient study to evaluate the effects of a metal-shielded applicator for 192 Ir high dose rate (HDR) rectal brachytherapy [6]. BrachyGUI is undergoing steady development and its features are listed in table 1.  [4]. The voxel elements can be assigned individual material and density values derived from CT images. Moreover, the brachytherapy source and applicator structures can be defined independently of the voxel grid. PTRAN_CT features an integrated analytic and voxel ray tracing approach for efficient path length determination. A phase space (PHSP) source option is available for particle generation. Similar to the previous PTRAN versions, the simulation parameters are specified in a main input file. These parameters include the spatial location and material of each geometrical component, source geometry and generation options, scoring method, variance reduction options, the number of particle histories, etc. We have made slight modifications to the input interface to allow for importing additional data. A list of the data files required for CT-based calculations is shown in Table 2. In the following subsections, we will describe some aspects of PTRAN_CT pertinent to patient calculations.
2.1.1. PHSP source option. The energy, position, and direction of each photon reaching the surface of an encapsulated source can be stored in a PHSP file for subsequent patient calculations. When using the PHSP source option for HDR applications, the source does not need to be explicitly modelled; we only need to specify the positions, orientations, and weights of all active dwell positions in the main input file. Coordinate transformations will be applied on the PHSP photons. To simulate the effects of interseed attenuation for low dose rate (LDR) implant cases, we may still model the seeds while using the PHSP source option.  Table 2. A list of data files required for PTRAN_CT patient calculations.

File type Description
Main input file Specifies the simulation parameters: applicator/seed geometry, scoring option, source positions, orientations and weights, etc.
Phase space file Records the PHSP data (energy, position, and direction) of photons reaching the capsule surface from the core of an encapsulated source Patient data file Contains the voxel grid, material and density data representative of the patient Voxel data file Identifies each voxel occupied by the applicator/seed with a unique index; stores the respective region number of the overlapping structure and the fraction of the volume intersected by it Output preference file Stores the output option and parameters for absolute dose conversion (air kerma strength, total treatment time, and dose conversion factor)

Patient anatomical data input.
PTRAN_CT reads the patient material and density data from an ASCII file in the EGSnrc egsphant format [7]. The format has been modified slightly to allow for more than nine simulation media. The voxels along each dimension must be equal in length, and not exceed a maximum of 200. This voxel number limit may be adjusted according to the amount of computer memory available. The region exterior to the patient voxel grid should be defined as a homogeneous volume (e.g. an air or water sphere).

Applicator and seed geometry definition.
The brachytherapy applicator and/or seed structures are to be defined in the main input file, in the same coordinate system as the patient voxel geometry.
To create an input file with the seeds at multiple locations in the patient's frame of reference, PTRAN_CT preprocessor codes may be used. Within these structures, dose is not scored and the intersected voxels need to be recorded in a voxel data file. This file can be generated using another preprocessor code, which assigns each of these voxels a unique index, and records the region number of the overlapping structure together with the fraction of the voxel volume intersected by it. Such voxel data are used in PTRAN_CT for ray-tracing and for normalizing the energy deposition along a given intersected voxel by the correct volume.

Dose calculation output specification.
PTRAN_CT scores the total, primary and scatter dose components and the history-by-history statistical uncertainties for all voxel elements. The user may specify in an output preference file how to extract such information. One of the options is to store all the results in a binary file and then extract the data of interest later using BrachyGUI. Another option is to output the dose distributions directly in the EGSnrc 3ddose format [7]. The output preference file also stores the data needed for absolute dose conversion, which include the source air kerma strength, total treatment time, and a dose conversion factor derived from an air kerma calculation [6].

Data processing and analysis using BrachyGUI
As the flowchart in figure 1 illustrates, BrachyGUI plays several essential roles in PTRAN_CT calculations and treatment plan evaluation. We will now introduce the major features of BrachyGUI.

Input file formats.
BrachyGUI reads dose distributions in the EGSnrc 3ddose format, patient material and density data in egsphant format, and CT data directly from DICOM images or a single binary file converted from the DICOM images. There are options for converting egsphant and 3ddose files between ASCII and binary formats. We implemented this file format conversion option because binary files tend to be more compact in size and faster to load. All dose distributions are generated in binary 3ddose format by default. The egsphant and 3ddose files produced from DOSXYZnrc [7] can also be imported into BrachyGUI for display and analysis.

Figure 1.
A flowchart showing the procedure to perform patient-specific calculations and treatment plan evaluation using PTRAN_CT and BrachyGUI.

Extraction of patient treatment plan data.
BrachyGUI is able to read patient treatment plan data in Digital Imaging and Communications in Medicine (DICOM) format. When generating PTRAN_CT input files, BrachyGUI extracts the relevant data from the DICOM files, which include the source strength, source dwell positions and weights, CT numbers and image orientation, voxel dimensions and boundaries, etc.

Generation of patient data file.
BrachyGUI provides an interactive interface for converting CT images to egsphant format. The CT number to material and mass density conversion curves are defined separately, each of which can be composed of any number of linear segments. There are options for changing the default conversion scheme, selecting the voxel grid dimensions, and manipulating voxel data in any region according to user-defined criteria.

Treatment plan evaluation and comparison.
After importing the dose distribution and structure contour data into BrachyGUI, DVHs and dosimetric indices can be calculated. In the calculations, it is possible to exclude voxels associated with certain media (e.g. non-tissue regions such as air and metal clips) as defined in the egsphant file. Up to two sets of isodose lines can be drawn concurrently on the images, and several options are available for comparing treatment plans.

Treatment planning capabilities.
We have implemented a number of treatment planning capabilities in BrachyGUI for our HDR rectal study. The user may construct catheters, define reference dose points, activate dwell positions, and outline structure contours. There is also an option to transform the coordinates of structure contour points and dwell positions from the planning CT images' frame of reference to that of the cone-beam CT images taken prior to treatment. This feature provides a means for treatment delivery verification. We are currently working on dwell position and dwell time optimization based on a kernel superposition calculation algorithm that accounts for applicator and shielding heterogeneities. The calculations use a set of dose kernels pre-generated using PTRAN_CT. To evaluate the dose to organs where patient anatomical structures and dimensions may perturb the dose, the optimized plan can be re-calculated using PTRAN_CT.

Screenshots and functionalities of BrachyGUI
The design philosophy of BrachyGUI is one of simplicity. As can be seen in the screenshots in figure  2, BrachyGUI has a simple layout and minimal control buttons. Functions can be called from the menu bar or using shortcut keys. Axial, coronal and sagittal images can be displayed in a single or multiple panels. Alongside the images, dose distributions, uncertainties, ratios, differences, gamma indices, etc, can be viewed. The user may also make use of the thumbnail view for image selection.   Figure 3a illustrates the data profile function, which is for extracting profiles of the dose and patient anatomy. When two dose distributions have been loaded, this function can also be used for plotting dose ratio and dose difference profiles. The cumulative and differential DVHs for a patient case are shown in figure 3b. The user may select to display the analysis data on the command window or store them in a text file.  For each plan, we ran 40 million particle histories using the PHSP source option and 2x2x2 mm 3 voxels. On average, the 3D patient grid is composed of 1 million voxels, and the overall onesigma uncertainty is 1.7%. PTRAN_CT can achieve 0.48% mean uncertainty in the planning target volume (PTV, mean volume: 29.0 cm 3 ) in 2.68 h on a single 64 bit AMD Opteron computer (mean processor speed: 2.67 GHz). We calculated the efficiency, ε , defined as: where t represents the calculation time in minutes, and σ represents the mean statistical uncertainty in the PTV in percent [2]. The inverse of ε can be interpreted as the time required for achieving 1% target uncertainty. Figure 4 shows a histogram of 1/ ε for the 40 patient calculations. The median of 1/ ε is 32.5 minutes, which implies that 2% target uncertainty requires about 8 minutes of calculation time. However, as indicated in this unevenly-distributed histogram, the efficiency is quite casespecific: it depends on the number of voxels in the calculations, as well as the PTV volume. For one of the HDR rectal treatment plans, we evaluated the efficiency as a function of the number of voxels using a 2.8 GHz processor. The 3D voxel grid is surrounded by unbounded water, and the target (28.6 cm 3 ) is located at approximately the center of the voxel grid. The results summarized in table 3 indicate that there is a gradual decrease in efficiency with an increasing number of voxels. Due to the inverse square law effect, the mean overall uncertainty also tends to increase with an increasing voxel grid size. Therefore, a longer calculation time will be required when dose to critical organs far away from the target is of clinical significance.
Following the workflow of figure 1, we estimate that it takes less than 30 min to export a HDR treatment plan from a planning system to a personal computer and to prepare the PTRAN_CT input files. The process might take slightly longer for LDR implant cases, or when extensive manual changes to the treatment plan and the egsphant file are needed. In cases where applicator and tissue heterogeneity effects might cause significant dose perturbations, it is now feasible to use PTRAN_CT together with BrachyGUI for verifying HDR treatment plans and for LDR post-implant analysis.  Table 3. PTRAN_CT calculation efficiency and the estimated time to achieve 2% mean target uncertainty as a function of the number of voxels for a typical HDR rectal patient case. The last column shows the overall mean uncertainty of all voxels with 10 million initial particle histories.

Conclusions
BrachyGUI streamlines the process of performing patient-specific brachytherapy dose calculations with PTRAN_CT. Its dose evaluation and analysis capabilities are also applicable for many other radiotherapy applications that can provide dose and patient files with the appropriate formats.