pyRadPlan 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyradplan-0.0.1/.gitignore +175 -0
- pyradplan-0.0.1/.gitlab-ci.yml +80 -0
- pyradplan-0.0.1/.gitmodules +4 -0
- pyradplan-0.0.1/.pre-commit-config.yaml +16 -0
- pyradplan-0.0.1/CONTRIBUTING.md +19 -0
- pyradplan-0.0.1/LICENSE +28 -0
- pyradplan-0.0.1/PKG-INFO +70 -0
- pyradplan-0.0.1/README.md +33 -0
- pyradplan-0.0.1/examples/carbon_pencilbeam.py +87 -0
- pyradplan-0.0.1/examples/helium_pencilbeam.py +80 -0
- pyradplan-0.0.1/examples/import_matrad_patient.py +102 -0
- pyradplan-0.0.1/examples/photon_pencilbeam.py +66 -0
- pyradplan-0.0.1/examples/proton_pencilbeam.py +80 -0
- pyradplan-0.0.1/pyRadPlan/GUI.py +5 -0
- pyradplan-0.0.1/pyRadPlan/__init__.py +34 -0
- pyradplan-0.0.1/pyRadPlan/core/__init__.py +15 -0
- pyradplan-0.0.1/pyRadPlan/core/_exceptions.py +9 -0
- pyradplan-0.0.1/pyRadPlan/core/_grids.py +231 -0
- pyradplan-0.0.1/pyRadPlan/core/datamodel.py +68 -0
- pyradplan-0.0.1/pyRadPlan/core/np2sitk.py +147 -0
- pyradplan-0.0.1/pyRadPlan/core/resample.py +130 -0
- pyradplan-0.0.1/pyRadPlan/cst/__init__.py +15 -0
- pyradplan-0.0.1/pyRadPlan/cst/_cst.py +307 -0
- pyradplan-0.0.1/pyRadPlan/cst/_voi.py +603 -0
- pyradplan-0.0.1/pyRadPlan/ct/__init__.py +4 -0
- pyradplan-0.0.1/pyRadPlan/ct/_ct.py +525 -0
- pyradplan-0.0.1/pyRadPlan/ct/_hlut.py +27 -0
- pyradplan-0.0.1/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/machines/helium_Generic.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/machines/photons_Generic.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/machines/protons_Generic.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/phantoms/TG119.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/stf/matRad_stf.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/dij/__init__.py +4 -0
- pyradplan-0.0.1/pyRadPlan/dij/_dij.py +410 -0
- pyradplan-0.0.1/pyRadPlan/dose/__init__.py +6 -0
- pyradplan-0.0.1/pyRadPlan/dose/_calc_dose.py +64 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/__init__.py +17 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_base.py +591 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_base_pencilbeam.py +806 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +1015 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_factory.py +108 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_hongpb.py +75 -0
- pyradplan-0.0.1/pyRadPlan/dose/engines/_svdpb.py +275 -0
- pyradplan-0.0.1/pyRadPlan/geometry/__init__.py +7 -0
- pyradplan-0.0.1/pyRadPlan/geometry/lps.py +122 -0
- pyradplan-0.0.1/pyRadPlan/io/.gitkeep +0 -0
- pyradplan-0.0.1/pyRadPlan/io/__init__.py +3 -0
- pyradplan-0.0.1/pyRadPlan/io/matLabFileHandler.py +25 -0
- pyradplan-0.0.1/pyRadPlan/io/matRad.py +22 -0
- pyradplan-0.0.1/pyRadPlan/io/readHLUT.py +17 -0
- pyradplan-0.0.1/pyRadPlan/io/temp_files/cst.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/io/temp_files/ct.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/io/temp_files/pln.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/io/temp_files/stf_with_separate_rays.mat +0 -0
- pyradplan-0.0.1/pyRadPlan/machines/__init__.py +19 -0
- pyradplan-0.0.1/pyRadPlan/machines/_base.py +164 -0
- pyradplan-0.0.1/pyRadPlan/machines/_ions.py +528 -0
- pyradplan-0.0.1/pyRadPlan/machines/_load.py +48 -0
- pyradplan-0.0.1/pyRadPlan/machines/_photons.py +220 -0
- pyradplan-0.0.1/pyRadPlan/machines/_validate.py +61 -0
- pyradplan-0.0.1/pyRadPlan/matRad/.gitkeep +0 -0
- pyradplan-0.0.1/pyRadPlan/matRad/__init__.py +18 -0
- pyradplan-0.0.1/pyRadPlan/matRad/_engine.py +36 -0
- pyradplan-0.0.1/pyRadPlan/matRad/_matlab.py +26 -0
- pyradplan-0.0.1/pyRadPlan/matRad/_octave.py +51 -0
- pyradplan-0.0.1/pyRadPlan/optimization/__init__.py +12 -0
- pyradplan-0.0.1/pyRadPlan/optimization/_fluenceOptimizer.py +312 -0
- pyradplan-0.0.1/pyRadPlan/optimization/_fluence_optimization.py +57 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/__init__.py +3 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/_optimizationProblem.py +162 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_EUD.py +93 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/__init__.py +19 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_doseUniformity.py +81 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_maxDVH.py +92 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_meanDose.py +80 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_minDVH.py +92 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_objectiveClass.py +98 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_squaredDeviation.py +82 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_squaredOverdosing.py +84 -0
- pyradplan-0.0.1/pyRadPlan/optimization/components/objectives/_squaredUnderdosing.py +84 -0
- pyradplan-0.0.1/pyRadPlan/optimization/projections/__init__.py +5 -0
- pyradplan-0.0.1/pyRadPlan/optimization/projections/_backProjection.py +59 -0
- pyradplan-0.0.1/pyRadPlan/optimization/projections/_constantRBEProjection.py +26 -0
- pyradplan-0.0.1/pyRadPlan/optimization/projections/_doseProjection.py +25 -0
- pyradplan-0.0.1/pyRadPlan/optimization/solvers/__init__.py +18 -0
- pyradplan-0.0.1/pyRadPlan/optimization/solvers/_ipopt.py +89 -0
- pyradplan-0.0.1/pyRadPlan/optimization/solvers/_scipy_solver.py +120 -0
- pyradplan-0.0.1/pyRadPlan/plan/__init__.py +3 -0
- pyradplan-0.0.1/pyRadPlan/plan/_plans.py +360 -0
- pyradplan-0.0.1/pyRadPlan/raytracer/__init__.py +4 -0
- pyradplan-0.0.1/pyRadPlan/raytracer/_base.py +289 -0
- pyradplan-0.0.1/pyRadPlan/raytracer/_perf.py +227 -0
- pyradplan-0.0.1/pyRadPlan/raytracer/_siddon.py +428 -0
- pyradplan-0.0.1/pyRadPlan/scenarios/__init__.py +102 -0
- pyradplan-0.0.1/pyRadPlan/scenarios/_base.py +374 -0
- pyradplan-0.0.1/pyRadPlan/scenarios/_nominal.py +126 -0
- pyradplan-0.0.1/pyRadPlan/stf/__init__.py +29 -0
- pyradplan-0.0.1/pyRadPlan/stf/_base.py +226 -0
- pyradplan-0.0.1/pyRadPlan/stf/_beam.py +195 -0
- pyradplan-0.0.1/pyRadPlan/stf/_beamlet.py +106 -0
- pyradplan-0.0.1/pyRadPlan/stf/_exceptions.py +14 -0
- pyradplan-0.0.1/pyRadPlan/stf/_externalbeam.py +162 -0
- pyradplan-0.0.1/pyRadPlan/stf/_generate_stf.py +23 -0
- pyradplan-0.0.1/pyRadPlan/stf/_ions.py +255 -0
- pyradplan-0.0.1/pyRadPlan/stf/_photons.py +125 -0
- pyradplan-0.0.1/pyRadPlan/stf/_rangeshifter.py +40 -0
- pyradplan-0.0.1/pyRadPlan/stf/_ray.py +201 -0
- pyradplan-0.0.1/pyRadPlan/stf/_steeringinformation.py +181 -0
- pyradplan-0.0.1/pyRadPlan/stf/base_matrad.py +6 -0
- pyradplan-0.0.1/pyRadPlan/stf/hlutLibrary/matRad_default.hlut +10 -0
- pyradplan-0.0.1/pyRadPlan/stf/loadHLUT.py +63 -0
- pyradplan-0.0.1/pyRadPlan/util/__init__.py +0 -0
- pyradplan-0.0.1/pyRadPlan/util/helpers.py +209 -0
- pyradplan-0.0.1/pyRadPlan.egg-info/PKG-INFO +70 -0
- pyradplan-0.0.1/pyRadPlan.egg-info/SOURCES.txt +145 -0
- pyradplan-0.0.1/pyRadPlan.egg-info/dependency_links.txt +1 -0
- pyradplan-0.0.1/pyRadPlan.egg-info/requires.txt +27 -0
- pyradplan-0.0.1/pyRadPlan.egg-info/top_level.txt +6 -0
- pyradplan-0.0.1/pyproject.toml +123 -0
- pyradplan-0.0.1/setup.cfg +4 -0
- pyradplan-0.0.1/test/core/test_coordinates.py +46 -0
- pyradplan-0.0.1/test/core/test_np2sitk.py +178 -0
- pyradplan-0.0.1/test/core/test_resample.py +45 -0
- pyradplan-0.0.1/test/cst/conftest.py +57 -0
- pyradplan-0.0.1/test/cst/test_VOI.py +422 -0
- pyradplan-0.0.1/test/cst/test_cst.py +144 -0
- pyradplan-0.0.1/test/ct/test_ct.py +218 -0
- pyradplan-0.0.1/test/ct/test_hlut.py +10 -0
- pyradplan-0.0.1/test/dose/test_dose_particle.py +234 -0
- pyradplan-0.0.1/test/dose/test_dose_photon.py +22 -0
- pyradplan-0.0.1/test/geometry/test_lps.py +96 -0
- pyradplan-0.0.1/test/stf/test_beamlet.py +53 -0
- pyradplan-0.0.1/test/stf/test_stf.py +205 -0
- pyradplan-0.0.1/test/stf/test_stf_gen.py +295 -0
- pyradplan-0.0.1/test/test_dij.py +238 -0
- pyradplan-0.0.1/test/test_fileHandling.py +37 -0
- pyradplan-0.0.1/test/test_grid.py +148 -0
- pyradplan-0.0.1/test/test_helpers.py +65 -0
- pyradplan-0.0.1/test/test_machine_model.py +155 -0
- pyradplan-0.0.1/test/test_matlabEngine.py +30 -0
- pyradplan-0.0.1/test/test_objectives.py +371 -0
- pyradplan-0.0.1/test/test_octaveEngine.py +30 -0
- pyradplan-0.0.1/test/test_plan.py +158 -0
- pyradplan-0.0.1/test/test_raytracersiddon.py +104 -0
- pyradplan-0.0.1/test/test_scenarios.py +198 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# poetry
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
102
|
+
#poetry.lock
|
|
103
|
+
|
|
104
|
+
# pdm
|
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
106
|
+
#pdm.lock
|
|
107
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
108
|
+
# in version control.
|
|
109
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
110
|
+
.pdm.toml
|
|
111
|
+
|
|
112
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
113
|
+
__pypackages__/
|
|
114
|
+
|
|
115
|
+
# Celery stuff
|
|
116
|
+
celerybeat-schedule
|
|
117
|
+
celerybeat.pid
|
|
118
|
+
|
|
119
|
+
# SageMath parsed files
|
|
120
|
+
*.sage.py
|
|
121
|
+
|
|
122
|
+
# Environments
|
|
123
|
+
.env
|
|
124
|
+
.venv
|
|
125
|
+
env/
|
|
126
|
+
venv/
|
|
127
|
+
ENV/
|
|
128
|
+
env.bak/
|
|
129
|
+
venv.bak/
|
|
130
|
+
|
|
131
|
+
# Spyder project settings
|
|
132
|
+
.spyderproject
|
|
133
|
+
.spyproject
|
|
134
|
+
|
|
135
|
+
# Rope project settings
|
|
136
|
+
.ropeproject
|
|
137
|
+
|
|
138
|
+
# mkdocs documentation
|
|
139
|
+
/site
|
|
140
|
+
|
|
141
|
+
# mypy
|
|
142
|
+
.mypy_cache/
|
|
143
|
+
.dmypy.json
|
|
144
|
+
dmypy.json
|
|
145
|
+
|
|
146
|
+
# Pyre type checker
|
|
147
|
+
.pyre/
|
|
148
|
+
|
|
149
|
+
# pytype static type analyzer
|
|
150
|
+
.pytype/
|
|
151
|
+
|
|
152
|
+
# Cython debug symbols
|
|
153
|
+
cython_debug/
|
|
154
|
+
|
|
155
|
+
# PyCharm
|
|
156
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
157
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
158
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
159
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
160
|
+
#.idea/
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
.vscode/
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
*.pyc
|
|
171
|
+
./matRad
|
|
172
|
+
pyRadPlan/optimization/solvers/ipopt-0.1.9
|
|
173
|
+
pyRadPlan/optimization/solvers/IpoptMUMPS
|
|
174
|
+
.idea
|
|
175
|
+
token.txt
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
#image: python:3.10-alpine3.19
|
|
2
|
+
image: python:3.11.9-slim-bookworm
|
|
3
|
+
|
|
4
|
+
variables: # Change pip's cache directory to be inside the project directory since we can only cache local items.
|
|
5
|
+
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip/"
|
|
6
|
+
|
|
7
|
+
stages:
|
|
8
|
+
- build
|
|
9
|
+
- test
|
|
10
|
+
|
|
11
|
+
# before_script:
|
|
12
|
+
# - apk add --no-cache alpine-sdk g++ hdf5-dev llvm14-dev linux-headers
|
|
13
|
+
# - apt-get update
|
|
14
|
+
|
|
15
|
+
build:
|
|
16
|
+
stage: build
|
|
17
|
+
script:
|
|
18
|
+
- python3 -m venv .venv
|
|
19
|
+
- source .venv/bin/activate
|
|
20
|
+
# - LLVM_CONFIG=/usr/bin/llvm14-config pip install llvmlite
|
|
21
|
+
- pip install -e .
|
|
22
|
+
cache:
|
|
23
|
+
key: "cache-$CI_COMMIT_REF_SLUG"
|
|
24
|
+
paths:
|
|
25
|
+
- .venv/
|
|
26
|
+
- .cache/pip/
|
|
27
|
+
policy: pull-push
|
|
28
|
+
|
|
29
|
+
# TODO: as soon as the COS cache on gitlab works, separate into three jobs running in parallel to the tests
|
|
30
|
+
lint:
|
|
31
|
+
stage: test
|
|
32
|
+
cache:
|
|
33
|
+
key: "cache-$CI_COMMIT_REF_SLUG"
|
|
34
|
+
paths:
|
|
35
|
+
- .venv/
|
|
36
|
+
- .cache/pip/
|
|
37
|
+
policy: pull
|
|
38
|
+
script:
|
|
39
|
+
- source .venv/bin/activate
|
|
40
|
+
- pip install flake8-gl-codeclimate Flake8-pyproject black pylint
|
|
41
|
+
- return_code=0
|
|
42
|
+
- flake8 --format gl-codeclimate --output-file gl-code-quality-report.json --toml-config ./pyproject.toml || return_code=$(($return_code + $?))
|
|
43
|
+
- black --check . 2> >(tee black-report.txt >&2) || return_code=$(($return_code + $?))
|
|
44
|
+
- pylint --output-format=json:pylint.txt,colorized pyRadPlan || return_code=$(($return_code + $?))
|
|
45
|
+
- exit $return_code
|
|
46
|
+
artifacts:
|
|
47
|
+
reports:
|
|
48
|
+
codequality: gl-code-quality-report.json
|
|
49
|
+
paths:
|
|
50
|
+
- black-report.txt
|
|
51
|
+
- pylint.txt
|
|
52
|
+
when: always
|
|
53
|
+
|
|
54
|
+
allow_failure: true
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
tests:
|
|
58
|
+
stage: test
|
|
59
|
+
cache:
|
|
60
|
+
key: "cache-$CI_COMMIT_REF_SLUG"
|
|
61
|
+
paths:
|
|
62
|
+
- .venv/
|
|
63
|
+
- .cache/pip/
|
|
64
|
+
policy: pull
|
|
65
|
+
script:
|
|
66
|
+
- source .venv/bin/activate
|
|
67
|
+
- pip install coverage pytest pytest-cov
|
|
68
|
+
- pytest test --junitxml=.testreports/report.xml --cov=pyRadPlan --cov-report term --cov-report xml:.testreports/coverage.xml --cov-report html:.testreports/html
|
|
69
|
+
artifacts:
|
|
70
|
+
when: always
|
|
71
|
+
reports:
|
|
72
|
+
coverage_report:
|
|
73
|
+
coverage_format: cobertura
|
|
74
|
+
path: .testreports/coverage.xml
|
|
75
|
+
junit: .testreports/report.xml
|
|
76
|
+
paths:
|
|
77
|
+
- .testreports/html
|
|
78
|
+
- .testreports/coverage.xml
|
|
79
|
+
- .testreports/report.xml
|
|
80
|
+
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
3
|
+
rev: v2.3.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: check-yaml
|
|
6
|
+
- id: end-of-file-fixer
|
|
7
|
+
- id: trailing-whitespace
|
|
8
|
+
- repo: https://github.com/psf/black
|
|
9
|
+
rev: 22.10.0
|
|
10
|
+
hooks:
|
|
11
|
+
- id: black
|
|
12
|
+
|
|
13
|
+
- repo: https://github.com/DanielNoord/pydocstringformatter
|
|
14
|
+
rev: v0.7.3
|
|
15
|
+
hooks:
|
|
16
|
+
- id: pydocstringformatter
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Rules for Contribution
|
|
2
|
+
|
|
3
|
+
Everybody is welcome to contribute, still we recommend to get in touch such that we do not double the work.
|
|
4
|
+
|
|
5
|
+
## Branch Name Rules
|
|
6
|
+
In the future, branch name rules will be enforced.
|
|
7
|
+
|
|
8
|
+
There's two predefined branch names for main development
|
|
9
|
+
- **main:** Protected main branch. Only latest release version + hotfixes
|
|
10
|
+
- **develop:** Development branch. Used to prepare patches & minor versions.
|
|
11
|
+
|
|
12
|
+
For individual development work, we will use branch groups. The following groups are allowed
|
|
13
|
+
- **bugfix/*:** Fixing a bug
|
|
14
|
+
- **hotfix/*:** Fixing a breaking change on the main branch
|
|
15
|
+
- **feature/*:** Individual larger novel feature contributions, e.g., feature/myCoolNewDoseCalculation
|
|
16
|
+
- **refactor/*:** An overhaul / refactor of code
|
|
17
|
+
- **interface/*:** Interface to other software
|
|
18
|
+
- **devops/*:** Work on DevOps like the CI pipeline or formatting hooks (e.g., devops/addPython311)
|
|
19
|
+
- **dev/*:** Individual development efforts that are not part of a single group above, or don't have a clear purpose or timeline regarding merging
|
pyradplan-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, DKFZ
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pyradplan-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
|
+
Name: pyRadPlan
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A python interface and reimplementation to matRad
|
|
5
|
+
Author-email: Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Lina Bucher <lina.bucher@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Antonios Kontopoulos <antonios.kontopoulos@dkfz-heidelberg.de>, Niklas Wahl <n.wahl@dkfz-heidelberg.de>
|
|
6
|
+
Maintainer-email: Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Niklas Wahl <n.wahl@dkfz-heidelberg.de>
|
|
7
|
+
Project-URL: Homepage, https://git.dkfz.de
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.9
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: scipy==1.14.0
|
|
15
|
+
Requires-Dist: numpy==2.0.0
|
|
16
|
+
Requires-Dist: pymatreader==1.0.0
|
|
17
|
+
Requires-Dist: h5py==3.11.0
|
|
18
|
+
Requires-Dist: regex==2024.5.15
|
|
19
|
+
Requires-Dist: pydicom==2.4.4
|
|
20
|
+
Requires-Dist: numba==0.60.0
|
|
21
|
+
Requires-Dist: matplotlib==3.9.2
|
|
22
|
+
Requires-Dist: pydantic==2.8.2
|
|
23
|
+
Requires-Dist: numpydantic==1.6.6
|
|
24
|
+
Requires-Dist: SimpleITK==2.4.0
|
|
25
|
+
Requires-Dist: tqdm>=4.0.0
|
|
26
|
+
Provides-Extra: matlab
|
|
27
|
+
Requires-Dist: matlabengine; extra == "matlab"
|
|
28
|
+
Provides-Extra: octave
|
|
29
|
+
Requires-Dist: oct2py; extra == "octave"
|
|
30
|
+
Provides-Extra: gui
|
|
31
|
+
Requires-Dist: PyQt5; extra == "gui"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest; extra == "dev"
|
|
34
|
+
Requires-Dist: coverage; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
36
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
# pyRadPlan
|
|
42
|
+
pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
|
|
43
|
+
|
|
44
|
+
Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
|
|
45
|
+
|
|
46
|
+
## Concept and Goals
|
|
47
|
+
pyRadPlan uses a similar datastructure and workflow concept as in matRad, while trying to ensure that the corresponding datastructures can be easily imported and exported from/to matRad. This facilitates the application of either algortihms from matRad or native pyRadPlan at any staget of the treatment planning workflow.
|
|
48
|
+
|
|
49
|
+
To enforce valid datastructures, we perform validation and serialization with pydantic.
|
|
50
|
+
Datastructures and algorithms rely mostly on SimpleITK, numpy, and scipy for internal data representation and processing.
|
|
51
|
+
|
|
52
|
+
If you are interested in helping with development, get in touch.
|
|
53
|
+
|
|
54
|
+
## Note for Developers
|
|
55
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
56
|
+
If you are a developer or want to contribute, make sure to clone the latest state via git. Then, we strongly suggest to create a virtual python environment with a suitable version and do an editable installation of pyRadPlan in dev mode: `pip install -e .[dev]`
|
|
57
|
+
|
|
58
|
+
> **Note**
|
|
59
|
+
> If you are using venv to create a virtual environment in the project's root folder, we suggest to name it `.venv` as this folder will be automatically excluded by all formatters and linters
|
|
60
|
+
|
|
61
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
62
|
+
- **pytest** is used to run unit tests before publishing the code. Run on the test folder via `pytest test`, or choose any test file following the pytest syntax. We encourage writing at least fundamental unit tests for new code. Will also install `coverage` and the pytest extension to monitor coverage.
|
|
63
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
64
|
+
|
|
65
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
66
|
+
Afterwards run `pre-commit install`. This reads the `.pre-commit_config.yaml` and adds a hook to your git repository, which whenever a commit is made the changed files are reformatted to ensure the PEP standards.
|
|
67
|
+
|
|
68
|
+
### Matlab / Octave Engine
|
|
69
|
+
If you want to interface via matRad, you can use install the matlab engine by appending `[matlab]` to the pip install command. However, as there is some compatibility matrix for what matlabengine version is suitable for your Matlab installation, it might be better to not install the latest version but instead install the correct matlabengine manually before.
|
|
70
|
+
To use Octave via oct2py, analogously append `[octave]`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
# pyRadPlan
|
|
5
|
+
pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
|
|
6
|
+
|
|
7
|
+
Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
|
|
8
|
+
|
|
9
|
+
## Concept and Goals
|
|
10
|
+
pyRadPlan uses a similar datastructure and workflow concept as in matRad, while trying to ensure that the corresponding datastructures can be easily imported and exported from/to matRad. This facilitates the application of either algortihms from matRad or native pyRadPlan at any staget of the treatment planning workflow.
|
|
11
|
+
|
|
12
|
+
To enforce valid datastructures, we perform validation and serialization with pydantic.
|
|
13
|
+
Datastructures and algorithms rely mostly on SimpleITK, numpy, and scipy for internal data representation and processing.
|
|
14
|
+
|
|
15
|
+
If you are interested in helping with development, get in touch.
|
|
16
|
+
|
|
17
|
+
## Note for Developers
|
|
18
|
+
pyRadPlan development uses unit-testing and code formatting via pre-commit hooks to ensure clean code.
|
|
19
|
+
If you are a developer or want to contribute, make sure to clone the latest state via git. Then, we strongly suggest to create a virtual python environment with a suitable version and do an editable installation of pyRadPlan in dev mode: `pip install -e .[dev]`
|
|
20
|
+
|
|
21
|
+
> **Note**
|
|
22
|
+
> If you are using venv to create a virtual environment in the project's root folder, we suggest to name it `.venv` as this folder will be automatically excluded by all formatters and linters
|
|
23
|
+
|
|
24
|
+
This will install an editable pyRadPlan module including `pytest` and `pre-commit` in addition to the standard modules.
|
|
25
|
+
- **pytest** is used to run unit tests before publishing the code. Run on the test folder via `pytest test`, or choose any test file following the pytest syntax. We encourage writing at least fundamental unit tests for new code. Will also install `coverage` and the pytest extension to monitor coverage.
|
|
26
|
+
- **pre-commit** allows for automatic code formatting to ensure following of PEPs (mainly PEP8 and PEP257).
|
|
27
|
+
|
|
28
|
+
After successfully running `pip install -e .[dev]` check in the console that `pre-commit --version` provides a correct response.
|
|
29
|
+
Afterwards run `pre-commit install`. This reads the `.pre-commit_config.yaml` and adds a hook to your git repository, which whenever a commit is made the changed files are reformatted to ensure the PEP standards.
|
|
30
|
+
|
|
31
|
+
### Matlab / Octave Engine
|
|
32
|
+
If you want to interface via matRad, you can use install the matlab engine by appending `[matlab]` to the pip install command. However, as there is some compatibility matrix for what matlabengine version is suitable for your Matlab installation, it might be better to not install the latest version but instead install the correct matlabengine manually before.
|
|
33
|
+
To use Octave via oct2py, analogously append `[octave]`.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from importlib import resources
|
|
2
|
+
import logging
|
|
3
|
+
import numpy as np
|
|
4
|
+
import SimpleITK as sitk
|
|
5
|
+
import pymatreader
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
|
|
8
|
+
from pyRadPlan import (
|
|
9
|
+
IonPlan,
|
|
10
|
+
validate_ct,
|
|
11
|
+
validate_cst,
|
|
12
|
+
generate_stf,
|
|
13
|
+
calc_dose_influence,
|
|
14
|
+
fluence_optimization,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
logging.basicConfig(level=logging.INFO)
|
|
18
|
+
|
|
19
|
+
# Read patient from provided TG119.mat file and validate data
|
|
20
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
21
|
+
tmp = pymatreader.read_mat(path)
|
|
22
|
+
ct = validate_ct(tmp["ct"])
|
|
23
|
+
cst = validate_cst(tmp["cst"], ct=ct)
|
|
24
|
+
|
|
25
|
+
# Create a plan object
|
|
26
|
+
pln = IonPlan(radiation_mode="carbon", machine="Generic")
|
|
27
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
28
|
+
pln.prop_dose_calc = {"calc_bio_dose": True}
|
|
29
|
+
|
|
30
|
+
# Generate Steering Geometry ("stf")
|
|
31
|
+
stf = generate_stf(ct, cst, pln)
|
|
32
|
+
|
|
33
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
34
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
35
|
+
|
|
36
|
+
# Optimize
|
|
37
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
38
|
+
|
|
39
|
+
# Result
|
|
40
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
41
|
+
|
|
42
|
+
# Choose a slice to visualize
|
|
43
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
44
|
+
|
|
45
|
+
# Visualize
|
|
46
|
+
quantities = ["physical_dose", "effect"]
|
|
47
|
+
for quantity in quantities:
|
|
48
|
+
cube_hu = sitk.GetArrayViewFromImage(ct.cube_hu)
|
|
49
|
+
plt.imshow(cube_hu[view_slice, :, :], cmap="gray")
|
|
50
|
+
|
|
51
|
+
plt.tick_params(
|
|
52
|
+
axis="both",
|
|
53
|
+
which="both",
|
|
54
|
+
bottom=False,
|
|
55
|
+
top=False,
|
|
56
|
+
labelbottom=False,
|
|
57
|
+
left=False,
|
|
58
|
+
right=False,
|
|
59
|
+
labelleft=False,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Now let's visualize the VOIs from the StructureSet.
|
|
63
|
+
for v, voi in enumerate(cst.vois):
|
|
64
|
+
mask = sitk.GetArrayViewFromImage(voi.mask)
|
|
65
|
+
color = plt.cm.cool(v / len(cst.vois)) # Select color based on colormap 'cool'
|
|
66
|
+
plt.contour(
|
|
67
|
+
mask[view_slice, :, :],
|
|
68
|
+
levels=[0.5],
|
|
69
|
+
colors=[color],
|
|
70
|
+
linewidths=1,
|
|
71
|
+
)
|
|
72
|
+
dose_array = sitk.GetArrayViewFromImage(result[quantity])
|
|
73
|
+
plt.imshow(
|
|
74
|
+
dose_array[view_slice, :, :],
|
|
75
|
+
cmap="jet",
|
|
76
|
+
interpolation="nearest",
|
|
77
|
+
alpha=0.5 * (dose_array[view_slice, :, :] > 0.02),
|
|
78
|
+
)
|
|
79
|
+
if quantity == "physical_dose":
|
|
80
|
+
plt.colorbar(label="dose [Gy]")
|
|
81
|
+
plt.title(f"Carbon Dose Distribution (Slice z={view_slice})")
|
|
82
|
+
else:
|
|
83
|
+
plt.colorbar(label="effect [1]")
|
|
84
|
+
plt.title(f"Effect [-ln(S)] Distribution (Slice z={view_slice})")
|
|
85
|
+
plt.show()
|
|
86
|
+
plt.savefig(f"carbon_{quantity}.png")
|
|
87
|
+
plt.clf()
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from importlib import resources
|
|
2
|
+
import logging
|
|
3
|
+
import numpy as np
|
|
4
|
+
import SimpleITK as sitk
|
|
5
|
+
import pymatreader
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
|
|
8
|
+
from pyRadPlan import (
|
|
9
|
+
IonPlan,
|
|
10
|
+
validate_ct,
|
|
11
|
+
validate_cst,
|
|
12
|
+
generate_stf,
|
|
13
|
+
calc_dose_influence,
|
|
14
|
+
fluence_optimization,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
logging.basicConfig(level=logging.INFO)
|
|
18
|
+
|
|
19
|
+
# Read patient from provided TG119.mat file and validate data
|
|
20
|
+
path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
|
|
21
|
+
tmp = pymatreader.read_mat(path)
|
|
22
|
+
ct = validate_ct(tmp["ct"])
|
|
23
|
+
cst = validate_cst(tmp["cst"], ct=ct)
|
|
24
|
+
|
|
25
|
+
# Create a plan object
|
|
26
|
+
pln = IonPlan(radiation_mode="helium", machine="Generic")
|
|
27
|
+
pln.prop_stf = {"bixel_width": 4}
|
|
28
|
+
|
|
29
|
+
# Generate Steering Geometry ("stf")
|
|
30
|
+
stf = generate_stf(ct, cst, pln)
|
|
31
|
+
|
|
32
|
+
# Calculate Dose Influence Matrix ("dij")
|
|
33
|
+
dij = calc_dose_influence(ct, cst, stf, pln)
|
|
34
|
+
|
|
35
|
+
# Optimize
|
|
36
|
+
fluence = fluence_optimization(ct, cst, stf, dij, pln)
|
|
37
|
+
|
|
38
|
+
# Result
|
|
39
|
+
result = dij.compute_result_ct_grid(fluence)
|
|
40
|
+
|
|
41
|
+
# Choose a slice to visualize
|
|
42
|
+
view_slice = int(np.round(ct.size[2] / 2))
|
|
43
|
+
|
|
44
|
+
# Visualize
|
|
45
|
+
cube_hu = sitk.GetArrayViewFromImage(ct.cube_hu)
|
|
46
|
+
plt.imshow(cube_hu[view_slice, :, :], cmap="gray")
|
|
47
|
+
|
|
48
|
+
plt.tick_params(
|
|
49
|
+
axis="both",
|
|
50
|
+
which="both",
|
|
51
|
+
bottom=False,
|
|
52
|
+
top=False,
|
|
53
|
+
labelbottom=False,
|
|
54
|
+
left=False,
|
|
55
|
+
right=False,
|
|
56
|
+
labelleft=False,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Now let's visualize the VOIs from the StructureSet.
|
|
60
|
+
for v, voi in enumerate(cst.vois):
|
|
61
|
+
mask = sitk.GetArrayViewFromImage(voi.mask)
|
|
62
|
+
color = plt.cm.cool(v / len(cst.vois)) # Select color based on colormap 'cool'
|
|
63
|
+
plt.contour(
|
|
64
|
+
mask[view_slice, :, :],
|
|
65
|
+
levels=[0.5],
|
|
66
|
+
colors=[color],
|
|
67
|
+
linewidths=1,
|
|
68
|
+
)
|
|
69
|
+
dose_array = sitk.GetArrayViewFromImage(result["physical_dose"])
|
|
70
|
+
plt.imshow(
|
|
71
|
+
dose_array[view_slice, :, :],
|
|
72
|
+
cmap="jet",
|
|
73
|
+
interpolation="nearest",
|
|
74
|
+
alpha=0.5 * (dose_array[view_slice, :, :] > 0.02),
|
|
75
|
+
)
|
|
76
|
+
plt.colorbar(label="dose [Gy]")
|
|
77
|
+
plt.title(f"Helium Dose (Slice z={view_slice})")
|
|
78
|
+
plt.show()
|
|
79
|
+
plt.savefig(f"{pln.radiation_mode}_physical_dose.png")
|
|
80
|
+
plt.clf()
|