pyRadPlan 0.2.0__tar.gz → 0.2.2__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.
Files changed (154) hide show
  1. {pyradplan-0.2.0/pyRadPlan.egg-info → pyradplan-0.2.2}/PKG-INFO +11 -1
  2. {pyradplan-0.2.0 → pyradplan-0.2.2}/README.md +10 -0
  3. {pyradplan-0.2.0 → pyradplan-0.2.2}/docs/conf.py +4 -1
  4. {pyradplan-0.2.0 → pyradplan-0.2.2}/examples/carbon_pencilbeam.py +3 -9
  5. {pyradplan-0.2.0 → pyradplan-0.2.2}/examples/helium_pencilbeam.py +3 -8
  6. {pyradplan-0.2.0 → pyradplan-0.2.2}/examples/import_matrad_patient.py +4 -3
  7. {pyradplan-0.2.0 → pyradplan-0.2.2}/examples/photon_pencilbeam.py +3 -9
  8. {pyradplan-0.2.0 → pyradplan-0.2.2}/examples/proton_pencilbeam.py +3 -9
  9. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/__init__.py +2 -1
  10. pyradplan-0.2.2/pyRadPlan/core/datamodel.py +111 -0
  11. pyradplan-0.2.2/pyRadPlan/dij/__init__.py +6 -0
  12. pyradplan-0.2.2/pyRadPlan/dij/_compose_beam_dijs.py +55 -0
  13. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dij/_dij.py +34 -20
  14. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/__init__.py +1 -1
  15. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base.py +22 -11
  16. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base_pencilbeam.py +9 -1
  17. pyradplan-0.2.2/pyRadPlan/io/__init__.py +4 -0
  18. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/io/_patient_loader.py +22 -0
  19. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/_ions.py +76 -10
  20. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/_load.py +4 -3
  21. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/raytracer/__init__.py +2 -0
  22. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/raytracer/_base.py +17 -32
  23. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/raytracer/_perf.py +4 -2
  24. {pyradplan-0.2.0 → pyradplan-0.2.2/pyRadPlan.egg-info}/PKG-INFO +11 -1
  25. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan.egg-info/SOURCES.txt +1 -0
  26. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyproject.toml +1 -1
  27. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/conftest.py +4 -3
  28. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/core/test_coordinates.py +4 -3
  29. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/cst/conftest.py +4 -3
  30. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/stf/test_stf.py +4 -3
  31. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/stf/test_stf_gen.py +4 -3
  32. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_dij.py +14 -1
  33. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_fileHandling.py +16 -5
  34. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_grid.py +29 -0
  35. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_machine_model.py +19 -0
  36. pyradplan-0.2.0/pyRadPlan/core/datamodel.py +0 -70
  37. pyradplan-0.2.0/pyRadPlan/dij/__init__.py +0 -5
  38. pyradplan-0.2.0/pyRadPlan/io/__init__.py +0 -4
  39. {pyradplan-0.2.0 → pyradplan-0.2.2}/LICENSE +0 -0
  40. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/core/__init__.py +0 -0
  41. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/core/_exceptions.py +0 -0
  42. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/core/_grids.py +0 -0
  43. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/core/np2sitk.py +0 -0
  44. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/core/resample.py +0 -0
  45. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/cst/__init__.py +0 -0
  46. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/cst/_cst.py +0 -0
  47. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/cst/_voi.py +0 -0
  48. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/ct/__init__.py +0 -0
  49. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/ct/_ct.py +0 -0
  50. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/ct/_hlut.py +0 -0
  51. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
  52. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
  53. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
  54. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
  55. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/phantoms/TG119.mat +0 -0
  56. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/stf/matRad_stf.mat +0 -0
  57. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
  58. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
  59. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/__init__.py +0 -0
  60. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/_calc_dose.py +0 -0
  61. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +0 -0
  62. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_factory.py +0 -0
  63. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_hongpb.py +0 -0
  64. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_svdpb.py +0 -0
  65. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/geometry/__init__.py +0 -0
  66. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/geometry/lps.py +0 -0
  67. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/io/_matlab_file_handler.py +0 -0
  68. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/io/matfile.py +0 -0
  69. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/__init__.py +0 -0
  70. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/_base.py +0 -0
  71. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/_photons.py +0 -0
  72. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/machines/_validate.py +0 -0
  73. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/matRad/__init__.py +0 -0
  74. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/matRad/_engine.py +0 -0
  75. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/matRad/_matlab.py +0 -0
  76. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/matRad/_octave.py +0 -0
  77. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/__init__.py +0 -0
  78. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
  79. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/__init__.py +0 -0
  80. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_eud.py +0 -0
  81. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_factory.py +0 -0
  82. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
  83. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_mean.py +0 -0
  84. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
  85. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_objective.py +0 -0
  86. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
  87. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
  88. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
  89. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_std.py +0 -0
  90. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/__init__.py +0 -0
  91. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_factory.py +0 -0
  92. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_nonlin_fluence.py +0 -0
  93. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_optiprob.py +0 -0
  94. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
  95. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/__init__.py +0 -0
  96. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_base_solvers.py +0 -0
  97. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_factory.py +0 -0
  98. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_ipopt.py +0 -0
  99. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -0
  100. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/plan/__init__.py +0 -0
  101. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/plan/_plans.py +0 -0
  102. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/quantities/__init__.py +0 -0
  103. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/quantities/_base.py +0 -0
  104. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/quantities/_dose.py +0 -0
  105. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/raytracer/_siddon.py +0 -0
  106. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/scenarios/__init__.py +0 -0
  107. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/scenarios/_base.py +0 -0
  108. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/scenarios/_nominal.py +0 -0
  109. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/__init__.py +0 -0
  110. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_beam.py +0 -0
  111. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_beamlet.py +0 -0
  112. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_exceptions.py +0 -0
  113. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_generate_stf.py +0 -0
  114. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_rangeshifter.py +0 -0
  115. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_ray.py +0 -0
  116. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/_steeringinformation.py +0 -0
  117. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/__init__.py +0 -0
  118. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_base.py +0 -0
  119. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
  120. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_factory.py +0 -0
  121. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_ions.py +0 -0
  122. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_photons.py +0 -0
  123. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/util/__init__.py +0 -0
  124. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/util/helpers.py +0 -0
  125. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/visualization/__init__.py +0 -0
  126. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan/visualization/_plot_slice.py +0 -0
  127. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan.egg-info/dependency_links.txt +0 -0
  128. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan.egg-info/requires.txt +0 -0
  129. {pyradplan-0.2.0 → pyradplan-0.2.2}/pyRadPlan.egg-info/top_level.txt +0 -0
  130. {pyradplan-0.2.0 → pyradplan-0.2.2}/setup.cfg +0 -0
  131. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/core/test_np2sitk.py +0 -0
  132. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/core/test_resample.py +0 -0
  133. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/cst/test_VOI.py +0 -0
  134. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/cst/test_cst.py +0 -0
  135. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/ct/test_ct.py +0 -0
  136. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/ct/test_hlut.py +0 -0
  137. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/dose/test_dose_particle.py +0 -0
  138. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/dose/test_dose_photon.py +0 -0
  139. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/geometry/test_lps.py +0 -0
  140. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_fluence_optiprob.py +0 -0
  141. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_ipopt_solver.py +0 -0
  142. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_objectives.py +0 -0
  143. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_problem_factory.py +0 -0
  144. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_scipy_solver.py +0 -0
  145. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/optimization/test_solver_factory.py +0 -0
  146. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/quantities/test_dose_quantity.py +0 -0
  147. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/stf/test_beamlet.py +0 -0
  148. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_helpers.py +0 -0
  149. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_matlabEngine.py +0 -0
  150. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_octaveEngine.py +0 -0
  151. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_plan.py +0 -0
  152. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_raytracersiddon.py +0 -0
  153. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/test_scenarios.py +0 -0
  154. {pyradplan-0.2.0 → pyradplan-0.2.2}/test/visualization/test_plot_slice.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyRadPlan
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: A python interface and reimplementation to matRad
5
5
  Author-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, 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>
6
6
  Maintainer-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Tobias Becher <t.becher@dkfz-heidelberg.de>
@@ -43,6 +43,16 @@ Requires-Dist: autodoc_pydantic; extra == "dev"
43
43
  Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
44
44
 
45
45
  # pyRadPlan
46
+ [![Tests](https://github.com/e0404/pyRadPlan/actions/workflows/tests.yml/badge.svg)](https://github.com/e0404/pyRadPlan/actions/workflows/tests.yml)
47
+ [![codecov](https://codecov.io/gh/e0404/pyRadPlan/graph/badge.svg?token=S1KCYDU17G)](https://codecov.io/gh/e0404/pyRadPlan)
48
+ [![pypi version](https://img.shields.io/pypi/v/pyRadPlan)](https://pypi.org/project/pyRadPlan/)
49
+ ![pyversion](https://img.shields.io/pypi/pyversions/pyRadPlan)
50
+ ![contributors](https://img.shields.io/github/contributors-anon/e0404/pyRadPlan)
51
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
52
+ ![License](https://img.shields.io/github/license/e0404/pyRadPlan)
53
+
54
+
55
+
46
56
  pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
47
57
 
48
58
  Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
@@ -1,4 +1,14 @@
1
1
  # pyRadPlan
2
+ [![Tests](https://github.com/e0404/pyRadPlan/actions/workflows/tests.yml/badge.svg)](https://github.com/e0404/pyRadPlan/actions/workflows/tests.yml)
3
+ [![codecov](https://codecov.io/gh/e0404/pyRadPlan/graph/badge.svg?token=S1KCYDU17G)](https://codecov.io/gh/e0404/pyRadPlan)
4
+ [![pypi version](https://img.shields.io/pypi/v/pyRadPlan)](https://pypi.org/project/pyRadPlan/)
5
+ ![pyversion](https://img.shields.io/pypi/pyversions/pyRadPlan)
6
+ ![contributors](https://img.shields.io/github/contributors-anon/e0404/pyRadPlan)
7
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
8
+ ![License](https://img.shields.io/github/license/e0404/pyRadPlan)
9
+
10
+
11
+
2
12
  pyRadPlan is an open-source radiotherapy treatment planning toolkit designed for interoperability with [matRad](http://www.matRad.org).
3
13
 
4
14
  Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de/radopt) at the [German Cancer Research Center (DKFZ)](https://www.dkfz.de)
@@ -7,6 +7,7 @@
7
7
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
8
  import os
9
9
  import sys
10
+ from pyRadPlan import __version__
10
11
 
11
12
  print(os.path.abspath("../pyRadPlan"))
12
13
  sys.path.insert(0, os.path.abspath("../pyRadPlan")) # Adjust to your source folder
@@ -14,7 +15,9 @@ sys.path.insert(0, os.path.abspath("../pyRadPlan")) # Adjust to your source fol
14
15
  project = "pyRadPlan"
15
16
  copyright = "2024, e0404"
16
17
  author = "e0404"
17
- release = "0.0.1"
18
+
19
+ version = __version__
20
+ release = __version__
18
21
 
19
22
  # -- General configuration ---------------------------------------------------
20
23
  # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
@@ -1,15 +1,10 @@
1
1
  import logging
2
2
 
3
- try:
4
- from importlib import resources # Standard from Python 3.9+
5
- except ImportError:
6
- import importlib_resources as resources # Backport for older versions
7
-
8
3
  import numpy as np
9
4
 
10
5
  from pyRadPlan import (
11
6
  IonPlan,
12
- load_patient,
7
+ load_tg119,
13
8
  generate_stf,
14
9
  calc_dose_influence,
15
10
  fluence_optimization,
@@ -18,9 +13,8 @@ from pyRadPlan import (
18
13
 
19
14
  logging.basicConfig(level=logging.INFO)
20
15
 
21
- # Read patient from provided TG119.mat file and validate data
22
- path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
23
- ct, cst = load_patient(path)
16
+ # Load TG119 (provided within pyRadPlan)
17
+ ct, cst = load_tg119()
24
18
 
25
19
  # Create a plan object
26
20
  pln = IonPlan(radiation_mode="carbon", machine="Generic")
@@ -1,14 +1,10 @@
1
1
  import logging
2
2
 
3
- try:
4
- from importlib import resources # Standard from Python 3.9+
5
- except ImportError:
6
- import importlib_resources as resources # Backport for older versions
7
3
  import numpy as np
8
4
 
9
5
  from pyRadPlan import (
10
6
  IonPlan,
11
- load_patient,
7
+ load_tg119,
12
8
  generate_stf,
13
9
  calc_dose_influence,
14
10
  fluence_optimization,
@@ -17,9 +13,8 @@ from pyRadPlan import (
17
13
 
18
14
  logging.basicConfig(level=logging.INFO)
19
15
 
20
- # Read patient from provided TG119.mat file and validate data
21
- path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
22
- ct, cst = load_patient(path)
16
+ # Load TG119 (provided within pyRadPlan)
17
+ ct, cst = load_tg119()
23
18
 
24
19
  # Create a plan object
25
20
  pln = IonPlan(radiation_mode="helium", machine="Generic")
@@ -8,11 +8,12 @@ calling the RayTracer.
8
8
 
9
9
  # Standard Library Imports
10
10
  import logging
11
+ import sys
11
12
 
12
- try:
13
- from importlib import resources # Standard from Python 3.9+
14
- except ImportError:
13
+ if sys.version_info < (3, 10):
15
14
  import importlib_resources as resources # Backport for older versions
15
+ else:
16
+ from importlib import resources # Standard from Python 3.9+
16
17
 
17
18
  # Third Party Imports from pyRadPlan requirements
18
19
 
@@ -1,15 +1,10 @@
1
1
  import logging
2
2
 
3
- try:
4
- from importlib import resources # Standard from Python 3.9+
5
- except ImportError:
6
- import importlib_resources as resources # Backport for older versions
7
-
8
3
  import numpy as np
9
4
 
10
5
  from pyRadPlan import (
11
6
  PhotonPlan,
12
- load_patient,
7
+ load_tg119,
13
8
  generate_stf,
14
9
  calc_dose_influence,
15
10
  fluence_optimization,
@@ -20,9 +15,8 @@ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosin
20
15
 
21
16
  logging.basicConfig(level=logging.INFO)
22
17
 
23
- # Read patient from provided TG119.mat file and validate data
24
- path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
25
- ct, cst = load_patient(path)
18
+ # Load TG119 (provided within pyRadPlan)
19
+ ct, cst = load_tg119()
26
20
 
27
21
  # Create a plan object
28
22
  pln = PhotonPlan(machine="Generic")
@@ -1,10 +1,5 @@
1
1
  import logging
2
2
 
3
- try:
4
- from importlib import resources # Standard from Python 3.9+
5
- except ImportError:
6
- import importlib_resources as resources # Backport for older versions
7
-
8
3
  import numpy as np
9
4
 
10
5
  from pyRadPlan import (
@@ -13,16 +8,15 @@ from pyRadPlan import (
13
8
  calc_dose_influence,
14
9
  fluence_optimization,
15
10
  plot_slice,
16
- load_patient,
11
+ load_tg119,
17
12
  )
18
13
 
19
14
  from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
20
15
 
21
16
  logging.basicConfig(level=logging.INFO)
22
17
 
23
- # Read patient from provided TG119.mat file and validate data
24
- path = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
25
- ct, cst = load_patient(path)
18
+ # Load TG119 (provided within pyRadPlan)
19
+ ct, cst = load_tg119()
26
20
 
27
21
  # Create a plan object
28
22
  pln = IonPlan(radiation_mode="protons", machine="Generic")
@@ -11,7 +11,7 @@ from .stf import SteeringInformation, validate_stf
11
11
  from .dose._calc_dose import calc_dose_influence, calc_dose_forward
12
12
  from .optimization._fluence_optimization import fluence_optimization
13
13
  from .visualization import plot_slice
14
- from .io import load_patient
14
+ from .io import load_patient, load_tg119
15
15
 
16
16
  try:
17
17
  __version__ = version(__name__)
@@ -40,4 +40,5 @@ __all__ = [
40
40
  "validate_stf",
41
41
  "plot_slice",
42
42
  "load_patient",
43
+ "load_tg119",
43
44
  ]
@@ -0,0 +1,111 @@
1
+ """Basic Model for all pyRadPlan Datastructures."""
2
+
3
+ from typing import Any, Union
4
+ import numpy as np
5
+ from pydantic import (
6
+ AliasGenerator,
7
+ BaseModel,
8
+ ConfigDict,
9
+ )
10
+ from pydantic.alias_generators import to_camel
11
+ from copy import deepcopy
12
+
13
+
14
+ class PyRadPlanBaseModel(BaseModel):
15
+ """
16
+ Base class for all pyRadPlan data structures.
17
+
18
+ Especially useful for structures that should be matRad compatible.
19
+ Extends Pydantic's BaseModel to use pydantic validation and serialization.
20
+
21
+ Attributes
22
+ ----------
23
+ model_config : ConfigDict
24
+ Configuration for the model, including alias generation, population by
25
+ name, arbitrary types allowed, assignment validation, and attribute
26
+ creation from dictionary.
27
+ """
28
+
29
+ model_config = ConfigDict(
30
+ alias_generator=AliasGenerator(alias=to_camel),
31
+ populate_by_name=True, # Allows both snake_case and camelCase attributes
32
+ arbitrary_types_allowed=True, # Allows arbitrary types in the model (will be casted)
33
+ validate_assignment=True, # Validate assignment of values to fields
34
+ # (not only during construction)
35
+ from_attributes=True, # Allows to create a model from a dictionary
36
+ )
37
+
38
+ def __eq__(self, other: Any) -> bool:
39
+ """
40
+ Specialized __eq__ method to compare two pyRadPlanBaseModel instances.
41
+
42
+ It first tries to compare the instances using the super().__eq__ method.
43
+ If this fails, it compares the dictionaries. This is due to some issues
44
+ comparing numpy arrays within the models.
45
+ """
46
+ try:
47
+ return super().__eq__(other)
48
+ except ValueError:
49
+ if self.__dict__.keys() != other.__dict__.keys():
50
+ return False
51
+ stack = [(self.__dict__, other.__dict__)]
52
+ while stack:
53
+ dict_a, dict_b = stack.pop()
54
+ if dict_a.keys() != dict_b.keys():
55
+ return False
56
+ for key in dict_a:
57
+ if isinstance(dict_a[key], dict) and isinstance(dict_b[key], dict):
58
+ stack.append((dict_a[key], dict_b[key]))
59
+ elif isinstance(dict_a[key], np.ndarray) and isinstance(
60
+ dict_b[key], np.ndarray
61
+ ):
62
+ if not np.array_equal(dict_a[key], dict_b[key]):
63
+ return False
64
+ elif dict_a[key] != dict_b[key]:
65
+ return False
66
+ return True
67
+
68
+ def __ne__(self, other: Any) -> bool:
69
+ """
70
+ Specialized __ne__ method to compare two PyRadPlanBaseModel instances.
71
+
72
+ This method returns the negation of the __eq__ method.
73
+ """
74
+ if isinstance(other, self.__class__):
75
+ return not self.__eq__(other)
76
+ else:
77
+ return True
78
+
79
+ def to_matrad(self, context: Union[str, dict] = "mat-file") -> Any:
80
+ """
81
+ Perform matRad compatible serialization.
82
+
83
+ Parameters
84
+ ----------
85
+ context : str, optional
86
+ The context in which the datastructure should be serialized,
87
+ by default 'mat-file'.
88
+
89
+ Returns
90
+ -------
91
+ Any
92
+ A datastructre compatible with matRad in the given context
93
+
94
+ Notes
95
+ -----
96
+ Currently, the only supported context is 'mat-file'. In the future,
97
+ this could be extended to support other contexts, such as direct
98
+ calling via the matlab engine or oct2py.
99
+ """
100
+ self_copy = deepcopy(self)
101
+ if isinstance(context, dict):
102
+ if "matRad" not in context:
103
+ context.update({"matRad": "mat-file"})
104
+ else:
105
+ context = {"matRad": context}
106
+
107
+ if context["matRad"] != "mat-file":
108
+ raise ValueError(f"Context {context} not supported")
109
+
110
+ # Standard is a model_dump using above alias and context information
111
+ return self_copy.model_dump(by_alias=True, context=context)
@@ -0,0 +1,6 @@
1
+ """Module for Dij Datamodel and related functions."""
2
+
3
+ from pyRadPlan.dij._dij import Dij, create_dij, validate_dij
4
+ from pyRadPlan.dij._compose_beam_dijs import compose_beam_dijs
5
+
6
+ __all__ = ["Dij", "create_dij", "validate_dij", "compose_beam_dijs"]
@@ -0,0 +1,55 @@
1
+ import numpy as np
2
+
3
+ from scipy.sparse import hstack
4
+ from ._dij import Dij
5
+
6
+
7
+ def compose_beam_dijs(dijs: list[Dij]) -> Dij:
8
+ """Compose multiple Dij objects into a single Dij object.
9
+
10
+ Parameters
11
+ ----------
12
+ dijs : list[Dij]
13
+ List of Dij objects to be composed.
14
+
15
+ Returns
16
+ -------
17
+ Dij
18
+ Composed Dij object.
19
+ """
20
+
21
+ qs = dijs[0].quantities
22
+
23
+ num_of_beams = 0
24
+ beam_num = np.array([], dtype=int)
25
+ ray_num = np.array([], dtype=int)
26
+ bixel_num = np.array([], dtype=int)
27
+
28
+ for i, dij in enumerate(dijs):
29
+ beam_num = np.append(beam_num, dij.beam_num + num_of_beams)
30
+ ray_num = np.append(ray_num, dij.ray_num)
31
+ bixel_num = np.append(bixel_num, dij.bixel_num)
32
+ num_of_beams = num_of_beams + dij.num_of_beams
33
+
34
+ matrices = {}
35
+ for q in qs:
36
+ tmp_matrices = [getattr(dij, q) for dij in dijs]
37
+
38
+ new_matrix = np.empty_like(tmp_matrices[0], dtype=object)
39
+
40
+ for i, scen_matrix in enumerate(tmp_matrices[0].flat):
41
+ if scen_matrix is not None:
42
+ new_matrix.flat[i] = hstack([tmp_matrix.flat[i] for tmp_matrix in tmp_matrices])
43
+
44
+ matrices.update({q: new_matrix})
45
+
46
+ return Dij(
47
+ ct_grid=dijs[0].ct_grid,
48
+ dose_grid=dijs[0].dose_grid,
49
+ matrices=matrices,
50
+ num_of_beams=num_of_beams,
51
+ beam_num=beam_num,
52
+ ray_num=ray_num,
53
+ bixel_num=bixel_num,
54
+ **matrices
55
+ )
@@ -62,6 +62,13 @@ class Dij(PyRadPlanBaseModel):
62
62
  def num_of_voxels(self) -> int:
63
63
  """Number of voxels in the dose influence matrix."""
64
64
  return self.physical_dose.flat[0].shape[0]
65
+
66
+ @computed_field
67
+ @property
68
+ def quantities(self) -> list[str]:
69
+ """Name of available uantities matrices."""
70
+ potential_quantities = ["physical_dose", "let_dose", "alpha_dose", "sqrt_beta_dose"]
71
+ return [q for q in potential_quantities if getattr(self, q) is not None]
65
72
 
66
73
  @field_validator("physical_dose", "let_dose", "alpha_dose", "sqrt_beta_dose", mode="before")
67
74
  @classmethod
@@ -119,6 +126,25 @@ class Dij(PyRadPlanBaseModel):
119
126
  grid = Grid.model_validate(grid)
120
127
  return grid
121
128
 
129
+ @field_validator("beam_num", mode="before")
130
+ @classmethod
131
+ def validate_unique_indices_in_beam_num(
132
+ cls, v: np.ndarray, info: ValidationInfo
133
+ ) -> np.ndarray:
134
+ """
135
+ Validate the number of unique indices in beam_num.
136
+
137
+ Raises
138
+ ------
139
+ ValueError: Number of unique indices does not match number of beams.
140
+ """
141
+ num_of_beams = info.data["num_of_beams"]
142
+ if len(np.unique(v)) != num_of_beams:
143
+ raise ValueError(
144
+ "Number of unique indices in beam_num does not match number of beams."
145
+ )
146
+ return v
147
+
122
148
  @field_validator("beam_num", "ray_num", "bixel_num", mode="after")
123
149
  @classmethod
124
150
  def validate_numbering_arrays(cls, v: np.ndarray, info: ValidationInfo) -> np.ndarray:
@@ -146,25 +172,8 @@ class Dij(PyRadPlanBaseModel):
146
172
  "Numbering arrays shape inconsistent with number of bixels"
147
173
  )
148
174
 
149
- return v
150
-
151
- @field_validator("beam_num")
152
- @classmethod
153
- def validate_unique_indices_in_beam_num(
154
- cls, v: np.ndarray, info: ValidationInfo
155
- ) -> np.ndarray:
156
- """
157
- Validate the number of unique indices in beam_num.
158
-
159
- Raises
160
- ------
161
- ValueError: Number of unique indices does not match number of beams.
162
- """
163
- num_of_beams = info.data["num_of_beams"]
164
- if len(np.unique(v)) != num_of_beams:
165
- raise ValueError(
166
- "Number of unique indices in beam_num does not match number of beams."
167
- )
175
+ if info.context and "from_matRad" in info.context and info.context["from_matRad"]:
176
+ v -= 1
168
177
  return v
169
178
 
170
179
  # Serialization
@@ -346,7 +355,12 @@ def create_dij(data: Union[dict[str, Any], Dij, None] = None, **kwargs) -> Dij:
346
355
  if isinstance(data, Dij):
347
356
  return data
348
357
 
349
- return Dij.model_validate(data)
358
+ if "beamNum" in data and np.min(data["beamNum"]) != 0:
359
+ # add context when from matRad
360
+ context = {"from_matRad": True}
361
+ else:
362
+ context = {"from_matRad": False}
363
+ return Dij.model_validate(data, context=context)
350
364
 
351
365
  return Dij(**kwargs)
352
366
 
@@ -10,7 +10,7 @@ register_engine(ParticleHongPencilBeamEngine)
10
10
  __all__ = [
11
11
  "DoseEngineBase",
12
12
  "PhotonPencilBeamSVDEngine",
13
- " ParticleHongPencilBeamEngine",
13
+ "ParticleHongPencilBeamEngine",
14
14
  "get_engine",
15
15
  "get_available_engines",
16
16
  "register_engine",
@@ -2,10 +2,12 @@
2
2
 
3
3
  import logging
4
4
 
5
- try:
6
- from importlib import resources # Standard from Python 3.9+
7
- except ImportError:
5
+ import sys
6
+
7
+ if sys.version_info < (3, 10):
8
8
  import importlib_resources as resources # Backport for older versions
9
+ else:
10
+ from importlib import resources # Standard from Python 3.9+
9
11
 
10
12
  import warnings
11
13
  import time
@@ -14,6 +16,7 @@ from abc import ABC, abstractmethod
14
16
 
15
17
  import SimpleITK as sitk
16
18
  import numpy as np
19
+ from pydantic import ValidationError
17
20
 
18
21
  from pyRadPlan.core import Grid
19
22
  from pyRadPlan.core.np2sitk import linear_indices_to_grid_coordinates
@@ -77,16 +80,14 @@ class DoseEngineBase(ABC):
77
80
  # Public properties
78
81
  def __init__(self, pln: Union[Plan, dict] = None):
79
82
  # Assign default parameters from Matrad_Config or manually
80
- self.dose_grid = None
81
83
  self.mult_scen = "nomScen"
82
84
  self.select_voxels_in_scenarios = None
83
- self.dose_grid = None
84
85
  self.voxel_sub_ix = None # selection of where to calculate / store dose, empty by default
86
+ self.dose_grid = None
85
87
 
86
88
  if pln is not None:
87
89
  self.assign_properties_from_pln(pln, True)
88
90
 
89
- self._dose_grid = None
90
91
  self._ct_grid = None
91
92
 
92
93
  # Protected properties with public get access
@@ -469,10 +470,19 @@ class DoseEngineBase(ABC):
469
470
  dij["ct_grid"] = ct.grid
470
471
 
471
472
  if self.dose_grid is None:
473
+ logger.info(
474
+ "Dose grid not set. Using default resolution: x=%f, y=%f, z=%f",
475
+ ct.grid.resolution["x"],
476
+ ct.grid.resolution["y"],
477
+ ct.grid.resolution["z"],
478
+ )
472
479
  self.dose_grid = ct.grid.resample({"x": 5.0, "y": 5.0, "z": 5.0})
473
480
 
474
481
  if not isinstance(self.dose_grid, Grid):
475
- self.dose_grid = Grid.model_validate(self.dose_grid)
482
+ try:
483
+ self.dose_grid = Grid.model_validate(self.dose_grid)
484
+ except ValidationError:
485
+ self.dose_grid = ct.grid.resample(self.dose_grid["resolution"])
476
486
 
477
487
  dij["dose_grid"] = self.dose_grid
478
488
 
@@ -515,8 +525,8 @@ class DoseEngineBase(ABC):
515
525
  # Initialize tmp_vdose_grid_scen
516
526
  tmp_vdose_grid_scen = [None] * ct.num_of_ct_scen
517
527
 
518
- if self._ct_grid == self._dose_grid:
519
- self._dose_grid = self._ct_grid
528
+ if self._ct_grid == self.dose_grid:
529
+ tmp_vdose_grid_scen = tmp_vct_grid_scen
520
530
  resampled_ct = ct
521
531
  else:
522
532
  resampled_ct = resample_ct(
@@ -524,7 +534,8 @@ class DoseEngineBase(ABC):
524
534
  interpolator=sitk.sitkNearestNeighbor,
525
535
  target_grid=self.dose_grid,
526
536
  )
527
- self._dose_grid = Grid.from_sitk_image(resampled_ct.cube_hu)
537
+ self.dose_grid = Grid.from_sitk_image(resampled_ct.cube_hu)
538
+
528
539
  for s in range(ct.num_of_ct_scen):
529
540
  # Receive linear indices and grid locations from the dose grid
530
541
  tmp_cube = np.zeros(ct.cube_dim[::-1], dtype=np.float32)
@@ -553,7 +564,7 @@ class DoseEngineBase(ABC):
553
564
  )
554
565
 
555
566
  self._vox_world_coords_dose_grid = linear_indices_to_grid_coordinates(
556
- self._vdose_grid, self._dose_grid, index_type="numpy"
567
+ self._vdose_grid, self.dose_grid, index_type="numpy"
557
568
  )
558
569
 
559
570
  # Create helper masks
@@ -180,6 +180,10 @@ class PencilBeamEngineAbstract(DoseEngineBase):
180
180
  # Initialize Ray Geometry
181
181
  curr_ray = self._init_ray(curr_beam, j)
182
182
 
183
+ # check if ray hit anything. If so, skip the computation
184
+ if all(not arr.size for arr in curr_ray["rad_depths"]):
185
+ continue
186
+
183
187
  # TODO: incorporate scenarios correctly
184
188
  for ct_scen in range(self.mult_scen.num_of_ct_scen):
185
189
  for range_scen in range(self.mult_scen.tot_num_range_scen):
@@ -300,6 +304,8 @@ class PencilBeamEngineAbstract(DoseEngineBase):
300
304
 
301
305
  self._computed_quantities.append(q_name)
302
306
 
307
+ self._effective_lateral_cutoff = self.geometric_lateral_cutoff
308
+
303
309
  return dij
304
310
 
305
311
  def _init_beam(
@@ -592,7 +598,9 @@ class PencilBeamEngineAbstract(DoseEngineBase):
592
598
  return scen_ray
593
599
 
594
600
  def _get_ray_geometry_from_beam(self, ray: dict[str], beam_info: dict[str]):
595
- ray["effective_lateral_cut_off"] = beam_info["effective_lateral_cut_off"]
601
+ ray["effective_lateral_cut_off"] = beam_info.get(
602
+ "effective_lateral_cut_off", self._effective_lateral_cutoff
603
+ )
596
604
  lateral_ray_cutoff = self._get_lateral_distance_from_dose_cutoff_on_ray(ray)
597
605
 
598
606
  # Ray tracing for beam i and ray j
@@ -0,0 +1,4 @@
1
+ from ._matlab_file_handler import MatlabFileHandler
2
+ from ._patient_loader import load_patient, load_tg119, validate_matrad_patient
3
+
4
+ __all__ = ["MatlabFileHandler", "load_patient", "load_tg119", "validate_matrad_patient"]
@@ -2,6 +2,12 @@ from typing import Optional
2
2
  import os
3
3
  import warnings
4
4
  import logging
5
+ import sys
6
+
7
+ if sys.version_info < (3, 10):
8
+ import importlib_resources as resources # Backport for older versions
9
+ else:
10
+ from importlib import resources # Standard from Python 3.9+
5
11
 
6
12
  from pyRadPlan.ct import validate_ct, CT
7
13
  from pyRadPlan.cst import validate_cst, StructureSet
@@ -13,6 +19,22 @@ from . import matfile
13
19
  logger = logging.getLogger(__name__)
14
20
 
15
21
 
22
+ def load_tg119() -> tuple[CT, StructureSet]:
23
+ """
24
+ Load the included TG119 phantom.
25
+
26
+ This is a helper function to load the TG119 phantom included in the
27
+ package data using importlib.resources.
28
+
29
+ Returns
30
+ -------
31
+ tuple[CT, StructureSet]
32
+ The CT and StructureSet objects.
33
+ """
34
+ phantom_data_str = resources.files("pyRadPlan.data.phantoms").joinpath("TG119.mat")
35
+ return load_patient(phantom_data_str)
36
+
37
+
16
38
  def load_patient(
17
39
  filename: os.PathLike,
18
40
  extra_plan_data: Optional[dict] = None,