Skip to main content

Gymnasium-compatible RL environments for radiation therapy treatment planning

Project description

oncosim

Gymnasium environments for reinforcement learning in radiation therapy treatment planning.

Python 3.10+ License: MIT Tests PyPI version


OncoSim provides three Gymnasium-compatible reinforcement learning environments for radiation therapy treatment planning research. Each environment models a distinct clinical decision problem with physically grounded dynamics based on the linear-quadratic model of cell kill, Poisson TCP, and Lyman-Kutcher-Burman NTCP.

The package includes analytical dose calculation, radiobiological tissue models, configurable difficulty tiers, baseline agents (random, heuristic, PPO), and a benchmark suite for reproducible evaluation.

Installation

pip install oncosim              # Core (numpy, scipy, gymnasium)
pip install oncosim[train]       # + SB3, PyTorch for RL training
pip install oncosim[all]         # Everything

Development install:

git clone https://github.com/HassDhia/oncosim.git
cd oncosim
pip install -e ".[all]"

Quick Start

import gymnasium as gym
import oncosim

env = gym.make("oncosim/BeamSelection-v0")
obs, info = env.reset(seed=42)
for _ in range(100):
    action = env.action_space.sample()
    obs, reward, terminated, truncated, info = env.step(action)
    if terminated or truncated:
        obs, info = env.reset()
env.close()

Environments

Environment Paradigm Observation Action Key Challenge
oncosim/BeamSelection-v0 Beam angle optimization 64x64 dose grid, tumor/OAR masks, selected beams Discrete(36): angle index at 10-degree steps Maximize tumor coverage while sparing organs at risk
oncosim/DoseFractionation-v0 Fractionation scheduling Fraction number, tumor volume, cumulative dose, TCP, NTCP Box(0.5, 4.0): dose per fraction in Gy Balance tumor control probability against normal tissue toxicity
oncosim/AdaptiveRT-v0 Adaptive replanning Treatment progress, plan quality, tumor response, dose deviation MultiDiscrete([2, 5]): replan decision + dose adjustment Decide when to replan based on anatomical changes during treatment

All environments support configurable difficulty tiers and deterministic seeding for reproducibility.

Architecture

oncosim/
  physics/          # Dose calculation, tissue models, beam geometry
    dose_calc.py    # Pencil beam analytical model
    tissue_models.py # LQ surviving fraction, TCP, NTCP, BED
    beam_geometry.py # 2D beam profiles, structure masks, DVH
  envs/             # Gymnasium environments
    beam_selection.py
    dose_fractionation.py
    adaptive_rt.py
    wrappers.py     # FlattenObs, NormalizeReward
  agents/           # Baseline agents
    random_agent.py
    heuristic_agent.py
    ppo.py          # Stable-Baselines3 PPO wrapper
  training/         # Training and evaluation pipeline
  benchmarks/       # Configurable benchmark suite (5 difficulty tiers)

Benchmarks

Run the benchmark suite:

oncosim-benchmark                          # All tiers
oncosim-benchmark --tiers trivial easy     # Specific tiers

Training

Train PPO agents on all environments:

pip install oncosim[train]
oncosim-train                              # Default: 100k timesteps each
oncosim-train --timesteps 500000           # Custom timesteps

Paper

The accompanying paper is available at:

Citation

If you use oncosim in your research, please cite:

@software{dhia2026oncosim,
  author = {Dhia, Hass},
  title = {OncoSim: Gymnasium Environments for Reinforcement Learning in Radiation Therapy Treatment Planning},
  year = {2026},
  publisher = {Smart Technology Investments Research Institute},
  url = {https://github.com/HassDhia/oncosim}
}

License

MIT License. See LICENSE for details.

Contact

Hass Dhia -- Smart Technology Investments Research Institute

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oncosim-0.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oncosim-0.1.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

Details for the file oncosim-0.1.0.tar.gz.

File metadata

  • Download URL: oncosim-0.1.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for oncosim-0.1.0.tar.gz
Algorithm Hash digest
SHA256 26b459547c154a16e7502568c07707f23bc893b96eeac25d61a04a8478c0558f
MD5 9ec60f8716a055fa2ac8ba8575d9d358
BLAKE2b-256 fa9acb40dafec3aa5351539ae68900bbb680fa9794d4718e8cab08abc4c9c72a

See more details on using hashes here.

File details

Details for the file oncosim-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oncosim-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for oncosim-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ead3017aadc47638f71ba52b2ae91628a38958c3ae811667ee1ce6c313693ec
MD5 cdada64e1ca879cf9538f5c2c1bf9237
BLAKE2b-256 492a62de5ea22a6465fd9ad065fb01e780a385e5c997ce212122c564d2fdbb74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page