This repository provides a framework for setting up reinforcement learning (RL) on patient data to create personalized treatment plans using Proton Beam Therapy (PBT). The current implementation includes data processing and beam modeling components essential for simulating and analyzing proton beam interactions with patient-specific density maps.
- Features
- Requirements
- Installation
- Usage
- File Structure
- Contributing
- License
- Quick Start Example
- Contact
- Data Processing: Converts and prepares DICOM data for use in beam modeling.
- Beam Modeling: Simulates proton beam interactions with patient-specific density maps and visualizes dose distributions.
- Extensible Framework: Designed to incorporate reinforcement learning algorithms for optimizing treatment plans.
- Operating System: Windows
- Python Version: 3.8 or higher
- Libraries:
numpymatplotlibpydicomopencv-pythonscipypickleprotonbeam(custom module)
-
Clone the Repository
git clone https://github.com/haydentbs/PBT_RL_GAMIFICATION.git cd PBT_RL_GAMIFICATION -
Set Up a Virtual Environment (Optional but Recommended)
python -m venv venv venv\Scripts\activate
-
Install Dependencies
pip install -r requirements.txt
If
requirements.txtis not available, you can install the necessary libraries manually:pip install numpy matplotlib pydicom opencv-python scipy
Ensure that the custom
ProtonBeammodule is available in your Python path.
Before running the beam simulation, you need to process the patient DICOM data.
-
Prepare DICOM Data
Ensure that your DICOM files are placed in the appropriate directory as specified in
data_processing/data_processing.py. By default, the base path is set to:base_path = r"data"
-
Run Data Processing Script
Execute the
data_processing/data_processing.pyscript to process the DICOM data and generate the necessary pickle files.python data_processing/data_processing.py
This will create processed data files, such as:
pickles/example_dicom_processed_data.pkl
After processing the data, you can run the beam simulation to generate and visualize proton beam dose distributions.
-
Run Beam Test Script
Execute the
test_beam.pyscript to simulate the proton beam and visualize the results.python test_beam.py
This script performs the following:
- Loads the processed DICOM and beam data.
- Simulates a proton beam at specified coordinates and angle.
- Visualizes the dose distribution on the density map.
- Generates dose vs. water equivalent distance plots.
proton-beam-therapy-rl/
│
├── data_processing/
│ └── data_processing.py
│
├── pickles/
│ ├── example_dicom_processed_data.pkl
│ └── beam_data.pkl
│
├── structures_to_display.py
│
├── test_beam.py
│
├── ProtonBeam/
│ ├── init.py
│ └── ProtonBeamV4.py
│
├── requirements.txt
│
└── README.md
- data_processing/: Contains the data processing scripts.
- pickles/: Stores processed data files.
- structures_to_display.py: Defines structures for display purposes.
- test_beam.py: Script for beam simulation and visualization.
- ProtonBeam/: Custom module for proton beam modeling.
- requirements.txt: Lists Python dependencies.
- README.md: Project documentation.
This project is licensed under the MIT License.
-
Run Data Processing
python data_processing/data_processing.py
-
Run Beam Simulation
python test_beam.py
-
View Generated Plots
The script will display two plots:
- Dose vs. water equivalent distance plot for the phantom.
- Dose beam through a patient CT slice.
Ensure that all dependencies are installed and the data paths in the scripts are correctly set according to your system.
For further information, please contact hayden@htibbals.com.

