Code Monkey home page Code Monkey logo

ortho_tps's Introduction

OrthoPlan and OrthoDose

This suite of Python applications was created as part of PhD research focusing on optimising kilovoltage radiotherapy. The relevant publication can be accessed in the Journal of Applied Clinical Medical Physics:

Nikandrovs, Mihails, et al. "Clinical treatment planning for kilovoltage radiotherapy using EGSnrc and Python." Journal of Applied Clinical Medical Physics (2022): e13832.

The suite contains two applications - OrthoPlan and OrthoDose. OrthoPlan facilitates the user with the CT based Monte Carlo simulation setup for DOSXYZnrc code of the EGSnrc general purpose Monte Carlo package. OrthoDose facilitates the user in analysing the resulting dose distribution.

Disclaimer

OrthoPlan and OrthoDose are not CE marked medical device softwares and hence are not to be used for clinical decision making. These applications are intended to be used solely for education and guidance purposes.The applications are provided 'as is' without warranty of any kind. In no event shall the author be liable for any claim, damages, harm or other liability, arising from, out of or in connection with the applications or the use or other dealings in the applications.

Pre-requisites

The applications were developed to work in the centre in which the research was carried out. Some lines of code and constants in the code will have to be adjusted to make them compatible with the user kilovoltage unit model. Majority of constants are defined before various functions in both OrthoPlan and OrthoDose codes, however there may be a few other hardcoded constants throughout the code which will have to be identified via user testing.

Main OrthoPlan functions to review are 'write_phantom_file' and 'write_input_file' which create DOSXYZnrc phantom and input files respectively. The strings in these functions should be adjusted to suit the user needs for the Monte Carlo parameters.

Furthermore, two DOSXYZnrc user code modifications were carried out:

  1. Lines of code used to 'zeroairdose' were copied and altered to zero dose in voxels with high density such as lead or gold.
  2. Maximum number of materials allowed in the phantom was increased from default 9 to 20 and appropriate fortran code was altered to read material number in the phantom files as double digits instead of single digits. OrthoPlan code writes double digit material numbers when generating the phantom file; for example first material on the list is '01' and not '1'.

A custom PEGS4 file was created using EGSgui. Tissue compositions were taken from literature (references in aforementioned publication). Density correction files were generated using NIST tool eStar. The names of tissues from this PEGS file are used in Tissue Segmentation tab of OrthoPlan.

Applications operate in Python 3.8 and all required Python packages are listed in the requirements.txt file.

Operation

The outlined workflow represents the workflow of the author of these applications and may change depending on the centre. The testing of the applications was limited to the center where they were developed and hence some adjustments may be required in other centers.

File Preparation

Patient CT images should be contoured in a clinical treatment planning system e.g. Monaco or Eclipse. Where applicable, the structure set should include contours of lead/gold cutouts and/or shields which will be used for patient treatment. Since lead cannot be scanned with the patient (causing CT metal artifact), best effort must be made to estimate the position and dimentions of these structures when contouring. DICOM CT files and the accompanying structure set file should be exported into an empty folder on the PC. Anonymising the files on export is strongly suggested for GDPR purposes.

OrthoPlan

OrthoPlan application contains 4 tabs representing the typical workflow of simulation setup. In the first tab, (IMPORT CT FOLDER) button allows the user to browse for a folder containing DICOM CT images which will then be displayed in three standard orthogonal views. The user can use radio buttons to focus on a particular view and sliders to navigate through the slices and adjust HU window width and level. HU values of pixels can be displayed by mousing over the interactive Plotly graphs which also allow the user to zoom in/out and move the images.

(IMPORT STRUCTURE SET) button allows the user to select the appropriate DICOM structure set file associated with the imported CT data. A checklist of the available structures will be displayed and the user can select which structures to display as an overlay on the CT slices.

Once satisfied with the correct CT and structre set selection, the user can then use the panel on the right to overwrite the HU values of selected structures one at a time. Using the dropdown menu the user can select a structure and enter the required HU value in the input field below. Pressing (CHANGE HU VALUE) button will generate a copy of the folder containing DICOM CT files and save modified CT files, leaving original files untouched. If more than one structure is overwritten, all modifications are saved to the copied CT files. Note that if two or more structures are overlapping, the order of HU value overwriting matters. The chosen HU value can be estimated by extrapolating the CT HU to mass density curve utilised in your department (for the default curve included in the code, lead = 8335 HU and gold = 14260 HU). Once HU values are overwritten, interacting with the slice selection slider will display the updated CT images. Clicking (ACCEPT CT IMAGES) allows the user to proceed to the 'Region Of Interest' tab.

The purpose of the 'Region of Interest' tab is to select a volume where dose will be scored similar to a 'dose grid' in commercial treatment planning systems. The user can adjust the range on the coloured sliders to minimise the region of interest in three orthogonal views while ensuring that enough of the tissue will be included in the simulation for adequate scattering conditions. The number of voxels that will be simulated is displayed on the bottom panel. At the time of the original research, DOSXYZnrc simulations would crash if the total number of voxels exceeded a certain amount and hence a suggested maximum number of total voxels is included on that panel. Once the user is satisfied with the selected region of ineterst, (ACCEPT) button allows the user to proceed to the Tissue Segmentation tab.

Here the user must first select a tissue preset. Please refer to the aforementioned publication for more detail on tissue segmentation and HU value ranges. Once a preset is selected, the CT HU to mass density plot will be colour coded into different HU value ranges representing different tissue types. Assigned tissue types can be checked by mousing over the CT images on the right side. Clicking (CREATE PHANTOM) button will begin writing a long DOSXYZnrc phantom file which the user will be prompted to save in a desired location. The progress bar should indicate how long is left in this process. Expect between 5 and 10 minutes depending on the dimentions of the selected region of interest in the previous step. Once the file is written the user will be notified with a pop up window after which the user can proceed to the final 'Treatment Planning' tab.

Here the user selects the minimum HU value to display as a surface within the selected region of interest and the smoothness of the 3D image. Note: smoothness of 1 will result in a detailed surface plot but will take longer to display and visa versa for smoothness of 10. Default minimum HU value of -250 successfully captures the skin (surface) of the patient. Clicking the (CALCULATE 3D SURFACE) button will generate the 3D surface of the CT image but will not display it yet. The user then selects the kilovoltage energy and applicator combination required for this treatment and clicks (ACCEPT KV APPLICATOR) button. This will display the 3D CT phantom surface and a 2D red shape representing the exit plane of the applicator (the red line normal to this plane represents the central axis of the applicator and the direction FROM which the beam will be simulated i.e. the red line should be outside the patient). Sliders on the right hand panel allow the user to manouver the red applicator plane in 3D space in spherical polar coordinated consistent with DOSXYZnrc input file. The red plane should be positioned flush with the intended treatment area representing the contact of the kilovoltage unit applicator with the patient. Once the geometry is satisfactory, (EXPORT SETUP FILE) button will first prompt the user to select the previously created phantom file and then chose a location to save the input file.

Monte Carlo simulation

The generated phantom and input files are then used in DOSXYZnrc simulation resulting in a (.3ddos) dose file.

OrthoDose

Since this application allows the user to preview the simulated dose distribution, the user must first acknowledge the disclaimer message. Then, similar to OrthoPlan, the user can import CT images by browsing for a folder using (IMPORT CT FILES) button. The DOSXYZnrc dose distribution file can be imported using (IMPORT MC DOSE) button. The dose heatmap will be displayed on top of CT images in all three orthogonal views. The dose values are all relative and typically of the order of $\approx 10^{-18}$Gy and need to be normalised. Normalisation can be dose either by specifying required dose at a point (defined by x,y,z coordinates) or based on the output of the unit in which case the user must select the simulated applicator energy combination and the prescribed MU. Min and Max values can be enetered to hide doses outside of desired range. Normalised dose can be previewed using the (UPDATE DOSE) button. (EXPORT DICOM DOSE) button generates a DICOM dose file using the currently displayed dose values and the DICOM ID information from the imported CT images to ensure the files are compatible in a clinical treatment planning system such as Monaco or Eclipse. If there is no possibility to export and preview DICOM dose file on a commercial treatment planning system, the user can mouse over the dose values to do some basic analysis. Note: simulated dose is dose-to-medium and hence will display significant dose enhancement in bones and dose reduction in adipose tissue for kilovoltage energy beams. Dose Volume Histogram tab allows the user to import the appropriate DICOM structure set file using (IMPORT CONTOURS) button. The prescribed dose should be entered into the 'Norm Dose' input field and will be used as reference 100% dose for relative DVH graphs. Volume and Dose axes units are selected using the radio buttons and DVH table and graph are displayed using (CALCULATE DVH) button. Note that parameters such as Dmax are prone to significantly high/low values due to contouring uncertainty and potential inclusion of bone/adipose voxels into a contour which have dose escalation and reduction effects.

ortho_tps's People

Contributors

nikandrovs94 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.