pyRadPlan 0.2.8__tar.gz → 0.3.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.
Files changed (222) hide show
  1. {pyradplan-0.2.8/pyRadPlan.egg-info → pyradplan-0.3.1}/PKG-INFO +15 -8
  2. {pyradplan-0.2.8 → pyradplan-0.3.1}/README.md +2 -0
  3. pyradplan-0.3.1/examples/intro_minimal_photons.py +39 -0
  4. pyradplan-0.2.8/examples/helium_pencilbeam.py → pyradplan-0.3.1/examples/intro_minimal_protons.py +11 -18
  5. pyradplan-0.3.1/examples/mc_fred.py +123 -0
  6. pyradplan-0.3.1/examples/pencilbeam_carbon.py +71 -0
  7. pyradplan-0.2.8/examples/proton_pencilbeam.py → pyradplan-0.3.1/examples/pencilbeam_helium.py +26 -3
  8. pyradplan-0.2.8/examples/photon_pencilbeam.py → pyradplan-0.3.1/examples/pencilbeam_photon.py +28 -5
  9. pyradplan-0.3.1/examples/pencilbeam_proton.py +82 -0
  10. pyradplan-0.2.8/examples/proton_let_optimization.py → pyradplan-0.3.1/examples/pencilbeam_proton_let.py +34 -6
  11. pyradplan-0.3.1/examples/pencilbeam_vhee.py +92 -0
  12. pyradplan-0.2.8/examples/import_matrad_patient.py → pyradplan-0.3.1/examples/raytracer_rad_depth.py +9 -3
  13. pyradplan-0.3.1/examples/utils_matrad.py +75 -0
  14. pyradplan-0.3.1/examples/utils_plotting.py +169 -0
  15. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/__init__.py +29 -2
  16. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/analysis/__init__.py +1 -1
  17. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/__init__.py +1 -1
  18. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/_grids.py +2 -2
  19. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/datamodel.py +53 -7
  20. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/np2sitk.py +31 -21
  21. pyradplan-0.3.1/pyRadPlan/core/xp_utils/__init__.py +90 -0
  22. pyradplan-0.3.1/pyRadPlan/core/xp_utils/compat.py +190 -0
  23. pyradplan-0.3.1/pyRadPlan/core/xp_utils/helpers.py +385 -0
  24. pyradplan-0.3.1/pyRadPlan/core/xp_utils/typing.py +63 -0
  25. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/cst/__init__.py +2 -0
  26. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/cst/_cst.py +206 -110
  27. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/cst/_voi.py +15 -19
  28. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/ct/__init__.py +2 -0
  29. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/ct/_ct.py +151 -87
  30. pyradplan-0.3.1/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
  31. pyradplan-0.3.1/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
  32. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dij/__init__.py +1 -1
  33. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dij/_dij.py +154 -37
  34. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/__init__.py +1 -1
  35. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/__init__.py +5 -1
  36. pyradplan-0.3.1/pyRadPlan/dose/engines/_base_montecarlo.py +8 -0
  37. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base_pencilbeam.py +136 -88
  38. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +66 -27
  39. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_factory.py +3 -3
  40. pyradplan-0.3.1/pyRadPlan/dose/engines/_fredmc.py +1433 -0
  41. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_hongpb.py +33 -16
  42. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_svdpb.py +0 -6
  43. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/geometry/__init__.py +1 -1
  44. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/io/__init__.py +2 -0
  45. pyradplan-0.3.1/pyRadPlan/machines/__init__.py +37 -0
  46. pyradplan-0.3.1/pyRadPlan/machines/_validate.py +42 -0
  47. pyradplan-0.3.1/pyRadPlan/machines/base/__init__.py +14 -0
  48. pyradplan-0.3.1/pyRadPlan/machines/base/_base.py +59 -0
  49. pyradplan-0.2.8/pyRadPlan/machines/_base.py → pyradplan-0.3.1/pyRadPlan/machines/base/_external_beam.py +9 -53
  50. pyradplan-0.3.1/pyRadPlan/machines/base/_factory.py +55 -0
  51. pyradplan-0.3.1/pyRadPlan/machines/base/_internal_beam.py +7 -0
  52. pyradplan-0.3.1/pyRadPlan/machines/particles/__init__.py +15 -0
  53. pyradplan-0.3.1/pyRadPlan/machines/particles/_base.py +331 -0
  54. pyradplan-0.3.1/pyRadPlan/machines/particles/_beam_cutoff.py +41 -0
  55. pyradplan-0.3.1/pyRadPlan/machines/particles/_beam_emittance.py +19 -0
  56. pyradplan-0.3.1/pyRadPlan/machines/particles/_beam_energy.py +44 -0
  57. pyradplan-0.3.1/pyRadPlan/machines/particles/_beam_focus.py +37 -0
  58. pyradplan-0.3.1/pyRadPlan/machines/particles/_ions.py +85 -0
  59. pyradplan-0.3.1/pyRadPlan/machines/particles/_vhee.py +33 -0
  60. pyradplan-0.3.1/pyRadPlan/machines/particles/kernel/__init__.py +7 -0
  61. pyradplan-0.3.1/pyRadPlan/machines/particles/kernel/_base.py +168 -0
  62. pyradplan-0.3.1/pyRadPlan/machines/particles/kernel/_ions.py +24 -0
  63. pyradplan-0.3.1/pyRadPlan/machines/particles/kernel/_vhee.py +7 -0
  64. pyradplan-0.3.1/pyRadPlan/machines/photons/__init__.py +6 -0
  65. pyradplan-0.3.1/pyRadPlan/machines/photons/_base.py +3 -0
  66. pyradplan-0.2.8/pyRadPlan/machines/_photons.py → pyradplan-0.3.1/pyRadPlan/machines/photons/_linac.py +13 -100
  67. pyradplan-0.3.1/pyRadPlan/machines/photons/_svd_kernel.py +102 -0
  68. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/matRad/__init__.py +2 -0
  69. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/__init__.py +1 -5
  70. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/__init__.py +1 -1
  71. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_eud.py +54 -0
  72. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_factory.py +1 -1
  73. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_max_dvh.py +58 -0
  74. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_mean.py +53 -0
  75. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_min_dvh.py +58 -0
  76. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_objective.py +5 -7
  77. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/objectives/_squared_dev.py +9 -17
  78. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_squared_over.py +39 -0
  79. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_squared_under.py +38 -0
  80. pyradplan-0.3.1/pyRadPlan/optimization/objectives/_std.py +28 -0
  81. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/__init__.py +1 -1
  82. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_factory.py +2 -2
  83. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_nonlin_fluence.py +105 -67
  84. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_optiprob.py +43 -28
  85. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/__init__.py +1 -1
  86. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_base_solvers.py +65 -7
  87. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_factory.py +1 -1
  88. pyradplan-0.3.1/pyRadPlan/optimization/solvers/_ipopt.py +189 -0
  89. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/solvers/_scipy_solver.py +36 -9
  90. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/plan/__init__.py +2 -0
  91. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/plan/_plans.py +8 -2
  92. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/quantities/__init__.py +2 -0
  93. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/quantities/_base.py +77 -31
  94. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/quantities/_dose.py +11 -5
  95. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/quantities/_let_x_dose.py +11 -5
  96. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/raytracer/_base.py +68 -28
  97. pyradplan-0.3.1/pyRadPlan/raytracer/_numba_perf.py +33 -0
  98. pyradplan-0.3.1/pyRadPlan/raytracer/_siddon.py +568 -0
  99. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/scenarios/__init__.py +1 -6
  100. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/__init__.py +1 -1
  101. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_beam.py +30 -0
  102. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_ray.py +46 -13
  103. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/__init__.py +5 -1
  104. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_ions.py +42 -0
  105. pyradplan-0.3.1/pyRadPlan/stf/generators/_vhee.py +186 -0
  106. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/util/__init__.py +2 -0
  107. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/util/helpers.py +12 -11
  108. pyradplan-0.3.1/pyRadPlan/util/keyboard_listener.py +197 -0
  109. pyradplan-0.3.1/pyRadPlan/visualization/__init__.py +9 -0
  110. pyradplan-0.3.1/pyRadPlan/visualization/_plot_multiple_slices.py +138 -0
  111. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/visualization/_plot_slice.py +85 -55
  112. {pyradplan-0.2.8 → pyradplan-0.3.1/pyRadPlan.egg-info}/PKG-INFO +15 -8
  113. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan.egg-info/SOURCES.txt +51 -13
  114. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan.egg-info/requires.txt +10 -4
  115. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyproject.toml +15 -10
  116. pyradplan-0.3.1/test/compute/test_math_interp1d.py +156 -0
  117. pyradplan-0.3.1/test/compute/test_math_quantile.py +76 -0
  118. pyradplan-0.3.1/test/compute/test_namespace_conversion.py +33 -0
  119. pyradplan-0.3.1/test/conftest.py +101 -0
  120. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/core/test_coordinates.py +1 -1
  121. pyradplan-0.3.1/test/core/test_datamodel.py +120 -0
  122. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/cst/test_cst.py +110 -7
  123. pyradplan-0.3.1/test/dose/test_fred.py +336 -0
  124. pyradplan-0.3.1/test/dose/test_pb_geodist.py +105 -0
  125. pyradplan-0.3.1/test/optimization/test_ipopt_solver.py +89 -0
  126. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/optimization/test_objectives.py +50 -27
  127. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/optimization/test_scipy_solver.py +7 -5
  128. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/quantities/test_dose_quantity.py +8 -7
  129. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/quantities/test_let_dose_quantity.py +9 -5
  130. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/stf/test_stf.py +23 -34
  131. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/stf/test_stf_gen.py +10 -25
  132. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_dij.py +67 -48
  133. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_machine_model.py +6 -5
  134. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_raytracersiddon.py +25 -3
  135. pyradplan-0.3.1/test/visualization/test_plot_multiple_slices.py +286 -0
  136. pyradplan-0.2.8/examples/carbon_pencilbeam.py +0 -56
  137. pyradplan-0.2.8/pyRadPlan/data/stf/matRad_stf.mat +0 -0
  138. pyradplan-0.2.8/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
  139. pyradplan-0.2.8/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
  140. pyradplan-0.2.8/pyRadPlan/machines/__init__.py +0 -19
  141. pyradplan-0.2.8/pyRadPlan/machines/_ions.py +0 -593
  142. pyradplan-0.2.8/pyRadPlan/machines/_validate.py +0 -61
  143. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_eud.py +0 -50
  144. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_max_dvh.py +0 -54
  145. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_mean.py +0 -50
  146. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_min_dvh.py +0 -54
  147. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_squared_over.py +0 -45
  148. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_squared_under.py +0 -45
  149. pyradplan-0.2.8/pyRadPlan/optimization/objectives/_std.py +0 -36
  150. pyradplan-0.2.8/pyRadPlan/optimization/solvers/_ipopt.py +0 -112
  151. pyradplan-0.2.8/pyRadPlan/raytracer/_perf.py +0 -229
  152. pyradplan-0.2.8/pyRadPlan/raytracer/_siddon.py +0 -427
  153. pyradplan-0.2.8/pyRadPlan/visualization/__init__.py +0 -5
  154. pyradplan-0.2.8/test/conftest.py +0 -43
  155. pyradplan-0.2.8/test/core/test_datamodel.py +0 -49
  156. pyradplan-0.2.8/test/optimization/test_ipopt_solver.py +0 -39
  157. {pyradplan-0.2.8 → pyradplan-0.3.1}/LICENSE +0 -0
  158. {pyradplan-0.2.8 → pyradplan-0.3.1}/docs/conf.py +0 -0
  159. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/analysis/_dvh.py +0 -0
  160. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/_exceptions.py +0 -0
  161. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/core/resample.py +0 -0
  162. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/ct/_hlut.py +0 -0
  163. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
  164. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
  165. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
  166. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
  167. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/data/phantoms/TG119.mat +0 -0
  168. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
  169. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/_calc_dose.py +0 -0
  170. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/dose/engines/_base.py +0 -0
  171. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/geometry/lps.py +0 -0
  172. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/io/_matlab_file_handler.py +0 -0
  173. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/io/_patient_loader.py +0 -0
  174. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/io/matfile.py +0 -0
  175. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/machines/_load.py +0 -0
  176. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/matRad/_engine.py +0 -0
  177. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/matRad/_matlab.py +0 -0
  178. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/matRad/_octave.py +0 -0
  179. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
  180. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
  181. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/raytracer/__init__.py +0 -0
  182. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/scenarios/_base.py +0 -0
  183. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/scenarios/_nominal.py +0 -0
  184. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_beamlet.py +0 -0
  185. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_exceptions.py +0 -0
  186. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_generate_stf.py +0 -0
  187. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_rangeshifter.py +0 -0
  188. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/_steeringinformation.py +0 -0
  189. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_base.py +0 -0
  190. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
  191. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_factory.py +0 -0
  192. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan/stf/generators/_photons.py +0 -0
  193. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan.egg-info/dependency_links.txt +0 -0
  194. {pyradplan-0.2.8 → pyradplan-0.3.1}/pyRadPlan.egg-info/top_level.txt +0 -0
  195. {pyradplan-0.2.8 → pyradplan-0.3.1}/setup.cfg +0 -0
  196. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/analysis/test_dvh.py +0 -0
  197. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/analysis/test_qi.py +0 -0
  198. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/core/test_np2sitk.py +0 -0
  199. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/core/test_resample.py +0 -0
  200. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/cst/conftest.py +0 -0
  201. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/cst/test_VOI.py +0 -0
  202. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/ct/test_ct.py +0 -0
  203. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/ct/test_hlut.py +0 -0
  204. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/data/test_validate_test_data.py +0 -0
  205. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/dose/conftest.py +0 -0
  206. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/dose/test_dose_engine_base.py +0 -0
  207. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/dose/test_factory.py +0 -0
  208. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/dose/test_hongpb.py +0 -0
  209. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/dose/test_svdpb.py +0 -0
  210. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/geometry/test_lps.py +0 -0
  211. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/optimization/test_fluence_optiprob.py +0 -0
  212. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/optimization/test_problem_factory.py +0 -0
  213. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/optimization/test_solver_factory.py +0 -0
  214. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/stf/test_beamlet.py +0 -0
  215. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_fileHandling.py +0 -0
  216. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_grid.py +0 -0
  217. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_helpers.py +0 -0
  218. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_matlabEngine.py +0 -0
  219. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_octaveEngine.py +0 -0
  220. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_plan.py +0 -0
  221. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/test_scenarios.py +0 -0
  222. {pyradplan-0.2.8 → pyradplan-0.3.1}/test/visualization/test_plot_slice.py +0 -0
@@ -1,26 +1,29 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyRadPlan
3
- Version: 0.2.8
3
+ Version: 0.3.1
4
4
  Summary: A python interface and reimplementation to matRad
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
- 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>
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>, Samir Schulz <samirshivaji.schulz@dkfz-heidelberg.de>
6
+ Maintainer-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>
7
7
  Project-URL: Homepage, https://git.dkfz.de
8
8
  Classifier: Programming Language :: Python :: 3
9
9
  Classifier: License :: OSI Approved :: BSD License
10
10
  Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
11
+ Requires-Python: <3.14,>=3.10
12
12
  Description-Content-Type: text/markdown
13
13
  License-File: LICENSE
14
14
  Requires-Dist: scipy>=1.13.0
15
- Requires-Dist: numpy>=1.26.0
15
+ Requires-Dist: numpy<=2.3,>=2.0
16
+ Requires-Dist: array_api_compat
17
+ Requires-Dist: array_api_strict
18
+ Requires-Dist: array_api_extra
19
+ Requires-Dist: types-array-api
16
20
  Requires-Dist: pymatreader>=1.0.0
17
21
  Requires-Dist: h5py>=3.11.0
18
22
  Requires-Dist: regex>=2024.5.15
19
23
  Requires-Dist: pydicom>=2.4.4
20
- Requires-Dist: numba>=0.60.0
21
24
  Requires-Dist: matplotlib>=3.9.2
22
- Requires-Dist: pydantic<2.11,>=2.10
23
- Requires-Dist: numpydantic>=1.6.0
25
+ Requires-Dist: pydantic<2.13,>=2.10
26
+ Requires-Dist: numpydantic>=1.6.9
24
27
  Requires-Dist: SimpleITK>=2.4.0
25
28
  Requires-Dist: tqdm>=4.0.0
26
29
  Requires-Dist: pint>=0.24.0
@@ -30,6 +33,8 @@ Provides-Extra: octave
30
33
  Requires-Dist: oct2py; extra == "octave"
31
34
  Provides-Extra: gui
32
35
  Requires-Dist: PyQt5; extra == "gui"
36
+ Provides-Extra: numba
37
+ Requires-Dist: numba>=0.61.0; extra == "numba"
33
38
  Provides-Extra: dev
34
39
  Requires-Dist: pytest; extra == "dev"
35
40
  Requires-Dist: coverage; extra == "dev"
@@ -61,6 +66,8 @@ Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de
61
66
  ## Concept and Goals
62
67
  pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
63
68
 
69
+ One of pyRadPlan's main goals is for its algorithms to be [Python Array API](https://data-apis.org/array-api/) conform as much as possible, to allow free choice of compute backends and devices (i.e., [`numpy`](https://numpy.org/), [`cupy`](https://cupy.dev/), [`pytorch`](https://pytorch.org/)). Further, its data structures (more precisely, their metadata) should be easily serializable for exchange with novel LLMs. This facilitate performant treatment planning research while enabling the integration of AI - such as deep neural networks implemented in [`pytorch`](https://pytorch.org/) or interaction with an LLM Agent via [`pydantic-ai`](https://ai.pydantic.dev/) - at every step of the treatment planning workflow.
70
+
64
71
  ### Data Structures
65
72
  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 stage of the treatment planning workflow.
66
73
 
@@ -16,6 +16,8 @@ Development is lead by the [Radiotherapy Optimization group](https://www.dkfz.de
16
16
  ## Concept and Goals
17
17
  pyRadPlan is a multi-modality treatment planning toolkit in python born from the established Matlab-based toolkit [matRad](http://www.matRad.org). As such, pyRadPlan aims to provide a framework as well as tools for combining dose calculation with optimization with focus on ion planning.
18
18
 
19
+ One of pyRadPlan's main goals is for its algorithms to be [Python Array API](https://data-apis.org/array-api/) conform as much as possible, to allow free choice of compute backends and devices (i.e., [`numpy`](https://numpy.org/), [`cupy`](https://cupy.dev/), [`pytorch`](https://pytorch.org/)). Further, its data structures (more precisely, their metadata) should be easily serializable for exchange with novel LLMs. This facilitate performant treatment planning research while enabling the integration of AI - such as deep neural networks implemented in [`pytorch`](https://pytorch.org/) or interaction with an LLM Agent via [`pydantic-ai`](https://ai.pydantic.dev/) - at every step of the treatment planning workflow.
20
+
19
21
  ### Data Structures
20
22
  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 stage of the treatment planning workflow.
21
23
 
@@ -0,0 +1,39 @@
1
+ # %% [markdown]
2
+ """# Example for photon dose calculation using pencilbeam engine."""
3
+
4
+ # %%
5
+ # Necessary imports
6
+ from pyRadPlan import (
7
+ load_tg119,
8
+ PhotonPlan,
9
+ generate_stf,
10
+ calc_dose_influence,
11
+ fluence_optimization,
12
+ plot_slice,
13
+ )
14
+
15
+ # Read patient from provided TG119.mat file and validate data
16
+ ct, cst = load_tg119()
17
+
18
+ # Create a plan object
19
+ pln = PhotonPlan()
20
+
21
+ # Generate Steering Geometry ("stf")
22
+ stf = generate_stf(ct, cst, pln)
23
+
24
+ # Calculate Dose Influence Matrix ("dij")
25
+ dij = calc_dose_influence(ct, cst, stf, pln)
26
+
27
+ # Fluence Optimization (objectives loaded from "cst")
28
+ fluence = fluence_optimization(ct, cst, stf, dij, pln)
29
+
30
+ # Result
31
+ result = dij.compute_result_ct_grid(fluence)
32
+
33
+ # Plot
34
+ plot_slice(
35
+ ct=ct,
36
+ cst=cst,
37
+ overlay=result["physical_dose"],
38
+ overlay_unit="Gy",
39
+ )
@@ -1,24 +1,22 @@
1
- import logging
2
-
3
- import numpy as np
1
+ # %% [markdown]
2
+ """# Example for proton dose calculation using pencilbeam engine."""
4
3
 
4
+ # %%
5
+ # Necessary imports
5
6
  from pyRadPlan import (
6
- IonPlan,
7
- load_tg119,
8
- generate_stf,
9
7
  calc_dose_influence,
10
8
  fluence_optimization,
9
+ generate_stf,
10
+ IonPlan,
11
+ load_tg119,
11
12
  plot_slice,
12
13
  )
13
14
 
14
- logging.basicConfig(level=logging.INFO)
15
-
16
- # Load TG119 (provided within pyRadPlan)
15
+ # Read patient from provided TG119.mat file and validate data
17
16
  ct, cst = load_tg119()
18
17
 
19
18
  # Create a plan object
20
- pln = IonPlan(radiation_mode="helium", machine="Generic")
21
- pln.prop_stf = {"bixel_width": 4}
19
+ pln = IonPlan()
22
20
 
23
21
  # Generate Steering Geometry ("stf")
24
22
  stf = generate_stf(ct, cst, pln)
@@ -26,21 +24,16 @@ stf = generate_stf(ct, cst, pln)
26
24
  # Calculate Dose Influence Matrix ("dij")
27
25
  dij = calc_dose_influence(ct, cst, stf, pln)
28
26
 
29
- # Optimize
27
+ # Fluence Optimization (objectives loaded from "cst")
30
28
  fluence = fluence_optimization(ct, cst, stf, dij, pln)
31
29
 
32
30
  # Result
33
31
  result = dij.compute_result_ct_grid(fluence)
34
32
 
35
- # Choose a slice to visualize
36
- view_slice = int(np.round(ct.size[2] / 2))
37
-
38
- # Visualize
33
+ # Plot
39
34
  plot_slice(
40
35
  ct=ct,
41
36
  cst=cst,
42
37
  overlay=result["physical_dose"],
43
- view_slice=view_slice,
44
- plane="axial",
45
38
  overlay_unit="Gy",
46
39
  )
@@ -0,0 +1,123 @@
1
+ # %% [markdown]
2
+ """# Example for proton dose calculation using the FRED engine."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the pyRadPlan library to perform proton dose calculations using the FRED Monte Carlo engine.
5
+
6
+ # For installation instructions, please refer to https://www.fred-mc.org/
7
+
8
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
9
+ # This will create a .ipynb file in the same directory:
10
+
11
+ # ```bash
12
+ # pip install jupytext
13
+ # jupytext --to notebook path/to/this/file/proton_MC_FRED.py
14
+
15
+ # %%
16
+ # Import necessary libraries
17
+ import logging
18
+ import numpy as np
19
+
20
+ from pyRadPlan import (
21
+ IonPlan,
22
+ generate_stf,
23
+ calc_dose_influence,
24
+ calc_dose_forward,
25
+ load_tg119,
26
+ fluence_optimization,
27
+ plot_slice,
28
+ )
29
+
30
+ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
31
+
32
+ logging.basicConfig(level=logging.INFO)
33
+
34
+ # %%
35
+ # Load TG119 (provided within pyRadPlan)
36
+ ct, cst = load_tg119()
37
+
38
+ # %% [markdown]
39
+ # In this section, we create a proton therapy plan using the FRED engine.
40
+ # First, we define the parameters for the steering information (`prop_stf`).
41
+ # Next, we specify the settings for dose calculation (`prop_dose_calc`),
42
+ # including compatibility with different FRED versions through `dij_format_version`.
43
+ # Finally, we configure the optimization parameters (`prop_opt`), as demonstrated in previous examples.
44
+
45
+ # Use less histories and beams when experimenting. This reduces computation time significantly.
46
+
47
+ # %%
48
+ pln = IonPlan(radiation_mode="protons", machine="Generic")
49
+ pln.prop_stf = {
50
+ "gantry_angles": [0, 180], # define gantry angles for n beams
51
+ "couch_angles": [0, 0],
52
+ "longitudinal_spot_spacing": 2.0,
53
+ "iso_center": np.array([[-5.0, -5.0, -5.0], [-5.0, -5.0, -5.0]]), # two beams
54
+ "bixel_width": 10,
55
+ "add_margin": 1,
56
+ }
57
+ pln.prop_dose_calc = {
58
+ "engine": "FRED", # Use the FRED engine for dose calculation
59
+ "fred_version": "3.76.0", # std: "3.70.0"
60
+ "use_gpu": True, # std: True | one has to set GPU = 1 using 'fred -config' manually!
61
+ "calc_let": False, # std: False
62
+ "scorers": ["Dose"], # std: ["Dose"]
63
+ "room_material": "Air", # vacuum | std: Air
64
+ "print_output": False,
65
+ "num_histories_per_beamlet": 2e3, # use less histories for faster computation (e.g. 2e2) or less beams
66
+ # "dij_format_version": "31", # 20/30 for fred 3.70.0 and 21/31 for fred 3.76.0
67
+ # "save_input": "path/to/save/input",
68
+ # "save_output": "path/to/save/output", # or True (for current dir)/False | std: False (using temp path)
69
+ # "use_output": "path/to/use/output", # skips output file generation if only 'use_output_file' is set and not 'save_output_file'
70
+ }
71
+
72
+ pln.prop_opt = {"solver": "scipy"}
73
+
74
+ # %% [markdown]
75
+ # Generate Steering Geometry ("stf")
76
+ # %%
77
+ stf = generate_stf(ct, cst, pln)
78
+
79
+ # %% [markdown]
80
+ # Run calc_dose_influence (dose influence matrix)
81
+ # %%
82
+ dij = calc_dose_influence(ct, cst, stf, pln)
83
+
84
+ # %% [markdown]
85
+ # Define cst objectives and run fluence optimization
86
+ # %%
87
+ cst.vois[0].objectives = [SquaredOverdosing(priority=100.0, d_max=1.0)] # OAR
88
+ cst.vois[1].objectives = [SquaredDeviation(priority=1000.0, d_ref=3.0)] # Target
89
+ cst.vois[2].objectives = [
90
+ MeanDose(priority=1.0, d_ref=0.0),
91
+ SquaredOverdosing(priority=10.0, d_max=2.0),
92
+ ] # BODY
93
+
94
+ fluence = fluence_optimization(ct, cst, stf, dij, pln)
95
+
96
+ # %% [markdown]
97
+ # Compute dose distribution and other quantities given in pln.prop_opt
98
+ # %%
99
+ result_opt = dij.compute_result_ct_grid(fluence)
100
+
101
+ # %% [markdown]
102
+ # Visualize the results
103
+ # %%
104
+
105
+ # Choose a slice to visualize
106
+ view_slice = int(np.round(ct.size[2] / 2))
107
+
108
+ plot_slice(
109
+ ct=ct,
110
+ cst=cst,
111
+ overlay=result_opt["physical_dose"],
112
+ view_slice=view_slice,
113
+ plane="axial",
114
+ overlay_unit="Gy",
115
+ )
116
+
117
+ # %% [markdown]
118
+ # You can also run calc_dose_forward (direct dose calculation) without optimization.
119
+ # %%
120
+ # Set run_direct_dose_calc to True to perform direct dose calculation
121
+ run_direct_dose_calc = False
122
+ if run_direct_dose_calc:
123
+ result_fwd = calc_dose_forward(ct, cst, stf, pln, np.ones(stf.total_number_of_bixels))
@@ -0,0 +1,71 @@
1
+ # %% [markdown]
2
+ """# Example for carbon dose calculation using pencilbeam engine."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the pyRadPlan library to perform carbon ion dose calculations with biological effect modeling.
5
+
6
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
7
+ # This will create a .ipynb file in the same directory:
8
+
9
+ # ```bash
10
+ # pip install jupytext
11
+ # jupytext --to notebook path/to/this/file/pencilbeam_carbon.py
12
+
13
+ # %%
14
+ # Import necessary libraries
15
+ import logging
16
+
17
+ import numpy as np
18
+
19
+ from pyRadPlan import (
20
+ IonPlan,
21
+ load_tg119,
22
+ generate_stf,
23
+ calc_dose_influence,
24
+ fluence_optimization,
25
+ plot_distributions,
26
+ )
27
+
28
+ logging.basicConfig(level=logging.INFO)
29
+
30
+ # %%
31
+ # Load TG119 (provided within pyRadPlan)
32
+ ct, cst = load_tg119()
33
+
34
+ # %% [markdown]
35
+ # In this section, we create a carbon ion therapy plan with biological effect calculation.
36
+ # %%
37
+ # Create a plan object
38
+ pln = IonPlan(radiation_mode="carbon", machine="Generic")
39
+ pln.prop_stf = {"bixel_width": 4}
40
+ pln.prop_dose_calc = {"calc_bio_dose": True}
41
+ pln.prop_opt = {"solver": "scipy"}
42
+
43
+ # Generate Steering Geometry ("stf")
44
+ stf = generate_stf(ct, cst, pln)
45
+
46
+ # Calculate Dose Influence Matrix ("dij")
47
+ dij = calc_dose_influence(ct, cst, stf, pln)
48
+
49
+ # Optimize
50
+ fluence = fluence_optimization(ct, cst, stf, dij, pln)
51
+
52
+ # Result
53
+ result = dij.compute_result_ct_grid(fluence)
54
+
55
+ # %%
56
+ # Choose slices to visualize
57
+ view_slice = [int(np.round(ct.size[2] / 2))]
58
+
59
+ # Visualize the results
60
+ # Use plot_distributions to visualize the biological effect and physical dose
61
+ # use plot_slice() for single distributions
62
+ plot_distributions(
63
+ ct=ct,
64
+ cst=cst,
65
+ overlays=[result["effect"], result["physical_dose"]],
66
+ view_slice=view_slice,
67
+ plane="axial",
68
+ overlay_unit=["dimensionless", "Gy"],
69
+ overlay_titles=["Biological Effect", "Physical Dose"],
70
+ show_plot=True,
71
+ )
@@ -1,3 +1,17 @@
1
+ # %% [markdown]
2
+ """# Example for helium dose calculation using pencilbeam engine."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the pyRadPlan library to perform helium dose calculations.
5
+
6
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
7
+ # This will create a .ipynb file in the same directory:
8
+
9
+ # ```bash
10
+ # pip install jupytext
11
+ # jupytext --to notebook path/to/this/file/pencilbeam_helium.py
12
+
13
+ # %%
14
+ # Import necessary libraries
1
15
  import logging
2
16
 
3
17
  import numpy as np
@@ -15,11 +29,15 @@ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosin
15
29
 
16
30
  logging.basicConfig(level=logging.INFO)
17
31
 
32
+ # %%
18
33
  # Load TG119 (provided within pyRadPlan)
19
34
  ct, cst = load_tg119()
20
35
 
36
+ # %% [markdown]
37
+ # In this section, we create a helium therapy plan using the ParticleHongPencilBeamEngine.
38
+ # %%
21
39
  # Create a plan object
22
- pln = IonPlan(radiation_mode="protons", machine="Generic")
40
+ pln = IonPlan(radiation_mode="helium", machine="Generic")
23
41
  pln.prop_opt = {"solver": "scipy"}
24
42
 
25
43
  # Generate Steering Geometry ("stf")
@@ -29,17 +47,22 @@ stf = generate_stf(ct, cst, pln)
29
47
  dij = calc_dose_influence(ct, cst, stf, pln)
30
48
 
31
49
  # Optimization
32
- cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
33
50
  cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
51
+ cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
34
52
  cst.vois[2].objectives = [
35
53
  MeanDose(priority=1.0, d_ref=0.0),
36
54
  SquaredOverdosing(priority=10.0, d_max=2.0),
37
55
  ] # BODY
56
+
57
+ # Calculate optimized fluence
38
58
  fluence = fluence_optimization(ct, cst, stf, dij, pln)
39
59
 
40
- # Result
60
+ # Compute the result on the CT grid
41
61
  result = dij.compute_result_ct_grid(fluence)
42
62
 
63
+ # %% [markdown]
64
+ # Visualize the results
65
+ # %%
43
66
  # Choose a slice to visualize
44
67
  view_slice = int(np.round(ct.size[2] / 2))
45
68
 
@@ -1,23 +1,41 @@
1
+ # %% [markdown]
2
+ """# Example for photon dose calculation using pencilbeam engine."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the pyRadPlan library to perform photon dose calculations.
5
+
6
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
7
+ # This will create a .ipynb file in the same directory:
8
+
9
+ # ```bash
10
+ # pip install jupytext
11
+ # jupytext --to notebook path/to/this/file/pencilbeam_photon.py
12
+
13
+ # %%
14
+ # Import necessary libraries
1
15
  import logging
2
16
 
3
17
  import numpy as np
4
18
 
5
19
  from pyRadPlan import (
6
20
  PhotonPlan,
7
- load_tg119,
8
21
  generate_stf,
9
22
  calc_dose_influence,
10
23
  fluence_optimization,
11
24
  plot_slice,
25
+ load_tg119,
12
26
  )
13
27
 
14
28
  from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
15
29
 
16
30
  logging.basicConfig(level=logging.INFO)
17
31
 
32
+ # %%
18
33
  # Load TG119 (provided within pyRadPlan)
19
34
  ct, cst = load_tg119()
20
35
 
36
+ # %% [markdown]
37
+ # In this section, we create a photon therapy plan using the ParticleHongPencilBeamEngine.
38
+ # %%
21
39
  # Create a plan object
22
40
  pln = PhotonPlan(machine="Generic")
23
41
  num_of_beams = 5
@@ -28,22 +46,27 @@ pln.prop_stf = {
28
46
  # Generate Steering Geometry ("stf")
29
47
  stf = generate_stf(ct, cst, pln)
30
48
 
49
+ # Calculate Dose Influence Matrix ("dij")
31
50
  # Calculate Dose Influence Matrix ("dij")
32
51
  dij = calc_dose_influence(ct, cst, stf, pln)
33
52
 
34
- # Optimize
35
- cst.vois[1].objectives = [SquaredDeviation(priority=1000.0, d_ref=3.0)] # Target
36
- cst.vois[0].objectives = [SquaredOverdosing(priority=100.0, d_max=1.0)] # OAR
53
+ # Optimization
54
+ cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
55
+ cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
37
56
  cst.vois[2].objectives = [
38
57
  MeanDose(priority=1.0, d_ref=0.0),
39
58
  SquaredOverdosing(priority=10.0, d_max=2.0),
40
59
  ] # BODY
41
60
 
61
+ # Calculate optimized fluence
42
62
  fluence = fluence_optimization(ct, cst, stf, dij, pln)
43
63
 
44
- # Result
64
+ # Compute the result on the CT grid
45
65
  result = dij.compute_result_ct_grid(fluence)
46
66
 
67
+ # %% [markdown]
68
+ # Visualize the results
69
+ # %%
47
70
  # Choose a slice to visualize
48
71
  view_slice = int(np.round(ct.size[2] / 2))
49
72
 
@@ -0,0 +1,82 @@
1
+ # %% [markdown]
2
+ """# Example for proton dose calculation using pencilbeam engine."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the pyRadPlan library to perform proton dose calculations.
5
+
6
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
7
+ # This will create a .ipynb file in the same directory:
8
+
9
+ # ```bash
10
+ # pip install jupytext
11
+ # jupytext --to notebook path/to/this/file/pencilbeam_proton.py
12
+
13
+ # %%
14
+ # Import necessary libraries
15
+ import logging
16
+
17
+ import numpy as np
18
+
19
+ from pyRadPlan import (
20
+ IonPlan,
21
+ generate_stf,
22
+ calc_dose_influence,
23
+ fluence_optimization,
24
+ plot_slice,
25
+ load_tg119,
26
+ xp_utils,
27
+ )
28
+
29
+ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosing, MeanDose
30
+
31
+
32
+ xp_utils.PREFER_GPU = True
33
+ xp_utils.PREFERRED_CPU_ARRAY_BACKEND = "numpy"
34
+ logging.basicConfig(level=logging.INFO)
35
+
36
+ # %%
37
+ # Load TG119 (provided within pyRadPlan)
38
+ ct, cst = load_tg119()
39
+
40
+ # %% [markdown]
41
+ # In this section, we create a proton therapy plan using the ParticleHongPencilBeamEngine.
42
+ # %%
43
+ # Create a plan object
44
+ pln = IonPlan(radiation_mode="protons", machine="Generic")
45
+ pln.prop_opt = {"solver": "scipy"}
46
+ pln.prop_dose_calc = {"dose_grid": ct.grid}
47
+
48
+ # Generate Steering Geometry ("stf")
49
+ stf = generate_stf(ct, cst, pln)
50
+
51
+ # Calculate Dose Influence Matrix ("dij")
52
+ dij = calc_dose_influence(ct, cst, stf, pln)
53
+
54
+ # Optimization
55
+ cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
56
+ cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
57
+ cst.vois[2].objectives = [
58
+ MeanDose(priority=1.0, d_ref=0.0),
59
+ SquaredOverdosing(priority=10.0, d_max=2.0),
60
+ ] # BODY
61
+
62
+ # Calculate optimized fluence
63
+ fluence = fluence_optimization(ct, cst, stf, dij, pln)
64
+
65
+ # Compute the result on the CT grid
66
+ result = dij.compute_result_ct_grid(fluence)
67
+
68
+ # %% [markdown]
69
+ # Visualize the results
70
+ # %%
71
+ # Choose a slice to visualize
72
+ view_slice = int(np.round(ct.size[2] / 2))
73
+
74
+ # Visualize
75
+ plot_slice(
76
+ ct=ct,
77
+ cst=cst,
78
+ overlay=result["physical_dose"],
79
+ view_slice=view_slice,
80
+ plane="axial",
81
+ overlay_unit="Gy",
82
+ )
@@ -1,3 +1,17 @@
1
+ # %% [markdown]
2
+ """# Example for using LET as quantity during optimization."""
3
+ # %% [markdown]
4
+ # This example demonstrates how pyRadPlan handles additional quantities such as LET.
5
+
6
+ # To display this script in a Jupyter Notebook, you need to install jupytext via pip and run the following command.
7
+ # This will create a .ipynb file in the same directory:
8
+
9
+ # ```bash
10
+ # pip install jupytext
11
+ # jupytext --to notebook path/to/this/file/proton_let.py
12
+
13
+ # %%
14
+ # Import necessary libraries
1
15
  import logging
2
16
 
3
17
  import numpy as np
@@ -15,7 +29,10 @@ from pyRadPlan.optimization.objectives import SquaredDeviation, SquaredOverdosin
15
29
 
16
30
  logging.basicConfig(level=logging.INFO)
17
31
 
18
- # Read patient from provided TG119.mat file and validate data
32
+ # %% [markdown]
33
+ # Just like in the other examples, we load the ct and cst, create the Plan and Steeringinformation
34
+ # %%
35
+ # load TG119
19
36
  ct, cst = load_tg119()
20
37
 
21
38
  # Create a plan object
@@ -28,19 +45,30 @@ stf = generate_stf(ct, cst, pln)
28
45
  # Calculate Dose Influence Matrix ("dij")
29
46
  dij = calc_dose_influence(ct, cst, stf, pln)
30
47
 
31
- # Optimization
32
- cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
48
+ # %% [markdown]
49
+ # When defining the objective functions and its parameters, one can add the respective quantity.
50
+ # Standard quantity is physical dose.
51
+ # %%
52
+ # OAR
33
53
  cst.vois[0].objectives = [
34
54
  SquaredOverdosing(priority=10.0, d_max=1.0),
35
55
  SquaredOverdosing(priority=5.0, d_max=1.0, quantity="let_dose"),
36
- ] # OAR
56
+ ]
57
+ # Target
58
+ cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
59
+ # BODY
37
60
  cst.vois[2].objectives = [
38
61
  MeanDose(priority=1.0, d_ref=0.0),
39
62
  SquaredOverdosing(priority=10.0, d_max=2.0),
40
- ] # BODY
63
+ ]
64
+
65
+ # %% [markdown]
66
+ # We then calculate the optimized fluence and the corresponding result of the plan.
67
+ # Additionally we plot both the physical dose and the LET.
68
+ # %%
41
69
  fluence = fluence_optimization(ct, cst, stf, dij, pln)
42
70
 
43
- # Result
71
+ # Compute the result
44
72
  result = dij.compute_result_ct_grid(fluence)
45
73
 
46
74
  # Choose a slice to visualize