pyRadPlan 0.3.1__tar.gz → 0.3.3__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 (211) hide show
  1. {pyradplan-0.3.1 → pyradplan-0.3.3}/PKG-INFO +3 -2
  2. pyradplan-0.3.3/benchmark/bench_trace_cubes.py +109 -0
  3. pyradplan-0.3.3/examples/pencilbeam_photon_forward.py +187 -0
  4. pyradplan-0.3.3/examples/proton_mimicking.py +108 -0
  5. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/_grids.py +3 -3
  6. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/cst/_cst.py +4 -4
  7. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/cst/_voi.py +10 -2
  8. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dij/_dij.py +5 -0
  9. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_base.py +2 -2
  10. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_base_pencilbeam.py +4 -0
  11. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_fredmc.py +55 -27
  12. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_svdpb.py +84 -30
  13. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/__init__.py +8 -0
  14. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/base/__init__.py +6 -0
  15. pyradplan-0.3.3/pyRadPlan/machines/base/_beam_modifier.py +393 -0
  16. pyradplan-0.3.3/pyRadPlan/machines/photons/_calculate_machine_scale.py +86 -0
  17. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/__init__.py +3 -0
  18. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_objective.py +66 -4
  19. pyradplan-0.3.3/pyRadPlan/optimization/objectives/_squared_mimicking.py +49 -0
  20. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/problems/_optiprob.py +30 -11
  21. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/raytracer/_base.py +22 -5
  22. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/__init__.py +13 -1
  23. pyradplan-0.3.3/pyRadPlan/stf/_beamlet.py +403 -0
  24. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_ray.py +7 -2
  25. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/__init__.py +7 -1
  26. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/_externalbeam.py +73 -0
  27. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/_factory.py +1 -0
  28. pyradplan-0.3.3/pyRadPlan/stf/generators/_photons.py +258 -0
  29. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan.egg-info/PKG-INFO +3 -2
  30. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan.egg-info/SOURCES.txt +7 -0
  31. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan.egg-info/requires.txt +1 -0
  32. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan.egg-info/top_level.txt +1 -0
  33. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyproject.toml +8 -6
  34. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/cst/test_VOI.py +51 -0
  35. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/cst/test_cst.py +26 -0
  36. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_fred.py +1 -2
  37. pyradplan-0.3.3/test/machines/test_beam_modifiers.py +302 -0
  38. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_objectives.py +93 -46
  39. pyradplan-0.3.3/test/stf/test_beamlet.py +274 -0
  40. pyradplan-0.3.1/pyRadPlan/stf/_beamlet.py +0 -112
  41. pyradplan-0.3.1/pyRadPlan/stf/generators/_photons.py +0 -141
  42. pyradplan-0.3.1/test/stf/test_beamlet.py +0 -53
  43. {pyradplan-0.3.1 → pyradplan-0.3.3}/LICENSE +0 -0
  44. {pyradplan-0.3.1 → pyradplan-0.3.3}/README.md +0 -0
  45. {pyradplan-0.3.1 → pyradplan-0.3.3}/docs/conf.py +0 -0
  46. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/intro_minimal_photons.py +0 -0
  47. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/intro_minimal_protons.py +0 -0
  48. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/mc_fred.py +0 -0
  49. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_carbon.py +0 -0
  50. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_helium.py +0 -0
  51. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_photon.py +0 -0
  52. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_proton.py +0 -0
  53. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_proton_let.py +0 -0
  54. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/pencilbeam_vhee.py +0 -0
  55. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/raytracer_rad_depth.py +0 -0
  56. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/utils_matrad.py +0 -0
  57. {pyradplan-0.3.1 → pyradplan-0.3.3}/examples/utils_plotting.py +0 -0
  58. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/__init__.py +0 -0
  59. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/analysis/__init__.py +0 -0
  60. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/analysis/_dvh.py +0 -0
  61. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/__init__.py +0 -0
  62. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/_exceptions.py +0 -0
  63. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/datamodel.py +0 -0
  64. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/np2sitk.py +0 -0
  65. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/resample.py +0 -0
  66. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/xp_utils/__init__.py +0 -0
  67. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/xp_utils/compat.py +0 -0
  68. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/xp_utils/helpers.py +0 -0
  69. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/core/xp_utils/typing.py +0 -0
  70. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/cst/__init__.py +0 -0
  71. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/ct/__init__.py +0 -0
  72. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/ct/_ct.py +0 -0
  73. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/ct/_hlut.py +0 -0
  74. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/VHEE_Focused.mat +0 -0
  75. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/VHEE_Generic.mat +0 -0
  76. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
  77. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
  78. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
  79. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
  80. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/data/phantoms/TG119.mat +0 -0
  81. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dij/__init__.py +0 -0
  82. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dij/_compose_beam_dijs.py +0 -0
  83. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/__init__.py +0 -0
  84. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/_calc_dose.py +0 -0
  85. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/__init__.py +0 -0
  86. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_base_montecarlo.py +0 -0
  87. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +0 -0
  88. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_factory.py +0 -0
  89. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/dose/engines/_hongpb.py +0 -0
  90. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/geometry/__init__.py +0 -0
  91. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/geometry/lps.py +0 -0
  92. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/io/__init__.py +0 -0
  93. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/io/_matlab_file_handler.py +0 -0
  94. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/io/_patient_loader.py +0 -0
  95. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/io/matfile.py +0 -0
  96. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/_load.py +0 -0
  97. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/_validate.py +0 -0
  98. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/base/_base.py +0 -0
  99. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/base/_external_beam.py +0 -0
  100. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/base/_factory.py +0 -0
  101. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/base/_internal_beam.py +0 -0
  102. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/__init__.py +0 -0
  103. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_base.py +0 -0
  104. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_beam_cutoff.py +0 -0
  105. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_beam_emittance.py +0 -0
  106. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_beam_energy.py +0 -0
  107. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_beam_focus.py +0 -0
  108. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_ions.py +0 -0
  109. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/_vhee.py +0 -0
  110. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/kernel/__init__.py +0 -0
  111. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/kernel/_base.py +0 -0
  112. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/kernel/_ions.py +0 -0
  113. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/particles/kernel/_vhee.py +0 -0
  114. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/photons/__init__.py +0 -0
  115. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/photons/_base.py +0 -0
  116. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/photons/_linac.py +0 -0
  117. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/machines/photons/_svd_kernel.py +0 -0
  118. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/matRad/__init__.py +0 -0
  119. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/matRad/_engine.py +0 -0
  120. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/matRad/_matlab.py +0 -0
  121. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/matRad/_octave.py +0 -0
  122. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/__init__.py +0 -0
  123. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
  124. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_eud.py +0 -0
  125. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_factory.py +0 -0
  126. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
  127. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_mean.py +0 -0
  128. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
  129. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
  130. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
  131. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
  132. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/objectives/_std.py +0 -0
  133. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/problems/__init__.py +0 -0
  134. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/problems/_factory.py +0 -0
  135. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/problems/_nonlin_fluence.py +0 -0
  136. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
  137. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/solvers/__init__.py +0 -0
  138. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/solvers/_base_solvers.py +0 -0
  139. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/solvers/_factory.py +0 -0
  140. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/solvers/_ipopt.py +0 -0
  141. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -0
  142. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/plan/__init__.py +0 -0
  143. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/plan/_plans.py +0 -0
  144. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/quantities/__init__.py +0 -0
  145. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/quantities/_base.py +0 -0
  146. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/quantities/_dose.py +0 -0
  147. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/quantities/_let_x_dose.py +0 -0
  148. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/raytracer/__init__.py +0 -0
  149. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/raytracer/_numba_perf.py +0 -0
  150. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/raytracer/_siddon.py +0 -0
  151. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/scenarios/__init__.py +0 -0
  152. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/scenarios/_base.py +0 -0
  153. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/scenarios/_nominal.py +0 -0
  154. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_beam.py +0 -0
  155. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_exceptions.py +0 -0
  156. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_generate_stf.py +0 -0
  157. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_rangeshifter.py +0 -0
  158. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/_steeringinformation.py +0 -0
  159. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/_base.py +0 -0
  160. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/_ions.py +0 -0
  161. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/stf/generators/_vhee.py +0 -0
  162. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/util/__init__.py +0 -0
  163. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/util/helpers.py +0 -0
  164. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/util/keyboard_listener.py +0 -0
  165. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/visualization/__init__.py +0 -0
  166. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/visualization/_plot_multiple_slices.py +0 -0
  167. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan/visualization/_plot_slice.py +0 -0
  168. {pyradplan-0.3.1 → pyradplan-0.3.3}/pyRadPlan.egg-info/dependency_links.txt +0 -0
  169. {pyradplan-0.3.1 → pyradplan-0.3.3}/setup.cfg +0 -0
  170. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/analysis/test_dvh.py +0 -0
  171. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/analysis/test_qi.py +0 -0
  172. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/compute/test_math_interp1d.py +0 -0
  173. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/compute/test_math_quantile.py +0 -0
  174. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/compute/test_namespace_conversion.py +0 -0
  175. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/conftest.py +0 -0
  176. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/core/test_coordinates.py +0 -0
  177. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/core/test_datamodel.py +0 -0
  178. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/core/test_np2sitk.py +0 -0
  179. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/core/test_resample.py +0 -0
  180. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/cst/conftest.py +0 -0
  181. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/ct/test_ct.py +0 -0
  182. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/ct/test_hlut.py +0 -0
  183. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/data/test_validate_test_data.py +0 -0
  184. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/conftest.py +0 -0
  185. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_dose_engine_base.py +0 -0
  186. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_factory.py +0 -0
  187. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_hongpb.py +0 -0
  188. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_pb_geodist.py +0 -0
  189. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/dose/test_svdpb.py +0 -0
  190. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/geometry/test_lps.py +0 -0
  191. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_fluence_optiprob.py +0 -0
  192. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_ipopt_solver.py +0 -0
  193. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_problem_factory.py +0 -0
  194. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_scipy_solver.py +0 -0
  195. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/optimization/test_solver_factory.py +0 -0
  196. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/quantities/test_dose_quantity.py +0 -0
  197. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/quantities/test_let_dose_quantity.py +0 -0
  198. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/stf/test_stf.py +0 -0
  199. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/stf/test_stf_gen.py +0 -0
  200. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_dij.py +0 -0
  201. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_fileHandling.py +0 -0
  202. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_grid.py +0 -0
  203. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_helpers.py +0 -0
  204. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_machine_model.py +0 -0
  205. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_matlabEngine.py +0 -0
  206. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_octaveEngine.py +0 -0
  207. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_plan.py +0 -0
  208. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_raytracersiddon.py +0 -0
  209. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/test_scenarios.py +0 -0
  210. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/visualization/test_plot_multiple_slices.py +0 -0
  211. {pyradplan-0.3.1 → pyradplan-0.3.3}/test/visualization/test_plot_slice.py +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyRadPlan
3
- Version: 0.3.1
3
+ Version: 0.3.3
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>, Samir Schulz <samirshivaji.schulz@dkfz-heidelberg.de>
5
+ Author-email: Niklas Wahl <n.wahl@dkfz-heidelberg.de>, Tobias Becher <t.becher@dkfz-heidelberg.de>, Lina Bucher <lina.bucher@dkfz-heidelberg.de>, Antonios Kontopoulos <antonios.kontopoulos@dkfz-heidelberg.de>, Julius Laub <julius.laub@dkfz-heidelberg.de>, Florian Leininger <florian.leininger@dkfz-heidelberg.de>, Tim Ortkamp <tim.ortkamp@kit.edu>, Victoria Santiago Aguilar <victoria.santiagoaguilar@dkfz-heidelberg.de>, Goran Stanic <goran.stanic@dkfz-heidelberg.de>, Samir Schulz <samirshivaji.schulz@dkfz-heidelberg.de>
6
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
@@ -39,6 +39,7 @@ Provides-Extra: dev
39
39
  Requires-Dist: pytest; extra == "dev"
40
40
  Requires-Dist: coverage; extra == "dev"
41
41
  Requires-Dist: pytest-cov; extra == "dev"
42
+ Requires-Dist: pytest-benchmark; extra == "dev"
42
43
  Requires-Dist: pre-commit; extra == "dev"
43
44
  Requires-Dist: sphinx; extra == "dev"
44
45
  Requires-Dist: numpydoc; extra == "dev"
@@ -0,0 +1,109 @@
1
+ """Benchmarks for RayTracerSiddon.trace_cubes with varying image resolutions."""
2
+
3
+ import numpy as np
4
+ import pytest
5
+ import SimpleITK as sitk
6
+
7
+ from pyRadPlan.raytracer import RayTracerSiddon
8
+ from pyRadPlan.stf._beam import Beam
9
+ from pyRadPlan.stf._ray import Ray
10
+ from pyRadPlan.stf._beamlet import Beamlet
11
+
12
+
13
+ # ---------------------------------------------------------------------------
14
+ # Helpers
15
+ # ---------------------------------------------------------------------------
16
+
17
+
18
+ def _make_cube(size, spacing, origin=None):
19
+ """Create a uniform-density SimpleITK image (density = 1.0 ~ water)."""
20
+ arr = np.ones(size[::-1], dtype=np.float32) # sitk expects (z, y, x)
21
+ image = sitk.GetImageFromArray(arr)
22
+ image.SetSpacing([float(s) for s in spacing])
23
+ if origin is None:
24
+ # Centre the cube around the origin
25
+ origin = [-0.5 * (n - 1) * s for n, s in zip(size, spacing)]
26
+ image.SetOrigin(origin)
27
+ return image
28
+
29
+
30
+ def _make_beam(iso_center, n_rays=1, sad=1000.0, gantry_angle=0.0):
31
+ """Build a minimal Beam object suitable for trace_cubes."""
32
+ # Spread rays in a small grid around the isocenter in BEV (x, y=0, z)
33
+ side = int(np.ceil(np.sqrt(n_rays)))
34
+ offsets = np.linspace(-10, 10, side)
35
+ rays = []
36
+ count = 0
37
+ for x in offsets:
38
+ for z in offsets:
39
+ if count >= n_rays:
40
+ break
41
+ ray_pos_bev = np.array([x, 0.0, z])
42
+ ray_pos = ray_pos_bev.copy() # simplified – gantry 0 means BEV ≈ LPS
43
+ rays.append(
44
+ Ray(
45
+ rayPos_bev=ray_pos_bev,
46
+ ray_pos=ray_pos,
47
+ beamlets=[Beamlet(energy=100.0)],
48
+ )
49
+ )
50
+ count += 1
51
+ if count >= n_rays:
52
+ break
53
+
54
+ return Beam(
55
+ gantry_angle=gantry_angle,
56
+ couch_angle=0.0,
57
+ iso_center=np.array(iso_center, dtype=np.float64),
58
+ rays=rays,
59
+ SAD=sad,
60
+ )
61
+
62
+
63
+ # ---------------------------------------------------------------------------
64
+ # Parametrised image configurations
65
+ # ---------------------------------------------------------------------------
66
+
67
+ # (label, size_xyz, spacing_xyz) – from small/coarse to large/fine
68
+ IMAGE_CONFIGS = [
69
+ ("small_coarse__50x50x50_sp5", (50, 50, 50), (5.0, 5.0, 5.0)),
70
+ ("medium_coarse__100x100x50_sp3", (200, 200, 80), (3.0, 3.0, 3.0)),
71
+ ("medium_fine__100x100x50_sp1", (200, 200, 80), (1.0, 1.0, 2.0)),
72
+ ("large_coarse__200x200x100_sp3", (512, 512, 128), (3.0, 3.0, 3.0)),
73
+ ("large_fine__200x200x100_sp1", (512, 512, 128), (1.0, 1.0, 2.0)),
74
+ ]
75
+
76
+
77
+ # ---------------------------------------------------------------------------
78
+ # Fixtures
79
+ # ---------------------------------------------------------------------------
80
+
81
+
82
+ @pytest.fixture(params=IMAGE_CONFIGS, ids=[c[0] for c in IMAGE_CONFIGS])
83
+ def raytracer_and_beam(request):
84
+ """Yield a (RayTracerSiddon, Beam) pair for each image configuration."""
85
+ label, size, spacing = request.param
86
+ cube = _make_cube(size, spacing)
87
+ iso_center = cube.TransformContinuousIndexToPhysicalPoint([s / 2.0 for s in size])
88
+ rt = RayTracerSiddon(cube)
89
+ rt.lateral_cut_off = 50.0
90
+ beam = _make_beam(iso_center, n_rays=4)
91
+ return rt, beam
92
+
93
+
94
+ # ---------------------------------------------------------------------------
95
+ # Benchmarks
96
+ # ---------------------------------------------------------------------------
97
+
98
+
99
+ def test_trace_cubes(benchmark, raytracer_and_beam):
100
+ """Benchmark trace_cubes for different image resolutions."""
101
+ rt, beam = raytracer_and_beam
102
+ # Use few rounds/iterations – raytracing can be expensive for large images.
103
+ benchmark.pedantic(
104
+ rt.trace_cubes,
105
+ args=(beam,),
106
+ rounds=3,
107
+ iterations=1,
108
+ warmup_rounds=1,
109
+ )
@@ -0,0 +1,187 @@
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_forward.py
12
+
13
+ # %%
14
+ # Import necessary libraries
15
+ import logging
16
+
17
+ import numpy as np
18
+
19
+ import matplotlib.pyplot as plt
20
+
21
+ from pyRadPlan import (
22
+ PhotonPlan,
23
+ generate_stf,
24
+ calc_dose_forward,
25
+ plot_slice,
26
+ load_tg119,
27
+ )
28
+
29
+ from pyRadPlan.machines import create_bld
30
+ from pyRadPlan.stf import FieldShapeAsBLD, FieldShapeComposite
31
+
32
+ from pyRadPlan.machines.photons._calculate_machine_scale import calculate_machine_scale
33
+
34
+ logging.basicConfig(level=logging.INFO)
35
+
36
+
37
+ resolution = 1.0
38
+
39
+ leaf_width = 5
40
+ positions = [ # L-form for testing direction
41
+ [0, 0],
42
+ [-20, 20],
43
+ [-20, 10],
44
+ [-20, 0],
45
+ [-20, 0],
46
+ [-20, 0],
47
+ [-20, 0],
48
+ [-20, 0],
49
+ [-20, 0],
50
+ [0, 0],
51
+ ]
52
+ number_of_elements = len(positions)
53
+ boundaries = np.arange(
54
+ -int(number_of_elements / 2) * leaf_width, int(number_of_elements / 2) * leaf_width, leaf_width
55
+ )
56
+
57
+ mlc_information = {
58
+ "device_type": "MLC",
59
+ "device_orientation": "X",
60
+ "leaf_position_boundaries": boundaries,
61
+ "leaf_positions": positions,
62
+ "leaf_width": leaf_width,
63
+ "leaf_leakage": 0.1,
64
+ }
65
+ mlc_x = create_bld(mlc_information)
66
+ mask_mlc_x = mlc_x.calculate_transmission_mask(resolution)
67
+
68
+ jaw_info = {
69
+ "device_type": "JAW",
70
+ "device_orientation": "X",
71
+ "positions": [-20, 10],
72
+ "field_width": 70,
73
+ "leakage": 0.1,
74
+ }
75
+ jaw_x = create_bld(jaw_info)
76
+ jaw_info["field_width"] = mask_mlc_x.shape[0] * resolution
77
+ jaw_x_matching_field_width = create_bld(jaw_info)
78
+ mask_jaw_x = jaw_x_matching_field_width.calculate_transmission_mask(resolution)
79
+
80
+ mask = mask_mlc_x * mask_jaw_x
81
+
82
+ half_size = jaw_info["field_width"]
83
+ extent = [-half_size, half_size, -half_size, half_size]
84
+
85
+ fig, axes = plt.subplots(1, 3, figsize=(15, 5))
86
+
87
+ axes[0].imshow(mask_jaw_x, cmap="gray", origin="lower", extent=extent)
88
+ axes[0].set_title("Jaw Mask (IEC DICOM)")
89
+ axes[0].set_xlabel("X (mm)")
90
+ axes[0].set_ylabel("Y (mm)")
91
+
92
+ axes[1].imshow(mask_mlc_x, cmap="gray", origin="lower", extent=extent)
93
+ axes[1].set_title("MLC Mask (IEC DICOM)")
94
+ axes[1].set_xlabel("X (mm)")
95
+ axes[1].set_ylabel("Y (mm)")
96
+
97
+ axes[2].imshow(mask, cmap="gray", origin="lower", extent=extent)
98
+ axes[2].set_title("Combined Mask (IEC DICOM)")
99
+ axes[2].set_xlabel("X (mm)")
100
+ axes[2].set_ylabel("Y (mm)")
101
+
102
+ plt.tight_layout()
103
+ plt.show()
104
+
105
+ # %%
106
+ # pyRadPlan internally defines "field shapes" to represent the shape of the beamlets.
107
+ mlc_shape = FieldShapeAsBLD(energy=6.0, bld=mlc_x, resolution=resolution)
108
+ jaw_shape = FieldShapeAsBLD(energy=6.0, bld=jaw_x_matching_field_width, resolution=resolution)
109
+ combined_shape = FieldShapeComposite(energy=6.0, shapes=[mlc_shape, jaw_shape])
110
+
111
+ # Now plot the field shapes to verify their geometry in LPS BEV coordinates
112
+ fig, axes = plt.subplots(1, 3, figsize=(15, 5))
113
+ axes[0].imshow(jaw_shape.mask, cmap="gray", origin="lower", extent=extent)
114
+ axes[0].set_title("Jaw Field Shape (LPS BEV)")
115
+ axes[0].set_xlabel("X (mm)")
116
+ axes[0].set_ylabel("Y (mm)")
117
+
118
+ axes[1].imshow(mlc_shape.mask, cmap="gray", origin="lower", extent=extent)
119
+ axes[1].set_title("MLC Field Shape (LPS BEV)")
120
+ axes[1].set_xlabel("X (mm)")
121
+ axes[1].set_ylabel("Y (mm)")
122
+
123
+ axes[2].imshow(combined_shape.mask, cmap="gray", origin="lower", extent=extent)
124
+ axes[2].set_title("Combined Field Shape (LPS BEV)")
125
+ axes[2].set_xlabel("X (mm)")
126
+ axes[2].set_ylabel("Y (mm)")
127
+
128
+ plt.tight_layout()
129
+ plt.show()
130
+
131
+ # %%
132
+ # Load TG119 (provided within pyRadPlan)
133
+ ct, cst = load_tg119()
134
+
135
+ # %% [markdown]
136
+ # In this section, we create a photon therapy plan using the ParticleHongPencilBeamEngine.
137
+ # %%
138
+ # Create a plan object
139
+ pln = PhotonPlan(machine="Generic")
140
+ num_of_beams = 1
141
+ pln.prop_stf = {
142
+ "gantry_angles": np.linspace(0, 360, num_of_beams, endpoint=False),
143
+ "couch_angles": np.zeros((num_of_beams,)), # np.array([0, 270]),
144
+ "generator": "photonSingleBixel",
145
+ "field_based": True,
146
+ # "field_shape": np.rot90(mask, k=-1), #TODO: Rotation correct? Should automatically be done in ShapeFromBLD?
147
+ "blds": [mlc_x, jaw_x],
148
+ "resolution": 0.5,
149
+ "energy": 6,
150
+ }
151
+
152
+ # Generate Steering Geometry ("stf")
153
+ stf = generate_stf(ct, cst, pln)
154
+
155
+ # Machine Calibration: Calculate the conversion factor between MU and weights
156
+ machine = "Generic"
157
+ ct_dim = [64, 64, 64]
158
+ ct_resolution = [2.0, 2.0, 2.0]
159
+ num_of_ct_scen = 1
160
+
161
+ weights = calculate_machine_scale(machine, ct_dim, ct_resolution, num_of_ct_scen)
162
+
163
+ # Apply weights to the rays in the stf
164
+ for beam in stf.beams:
165
+ for ray in beam.rays:
166
+ for beamlet in ray.beamlets:
167
+ beamlet.weight *= weights
168
+
169
+ # Calculate Dose Influence Matrix ("dij")
170
+ dij = calc_dose_forward(ct, cst, stf, pln)
171
+
172
+
173
+ # %% [markdown]
174
+ # Visualize the results
175
+ # %%
176
+ # Choose a slice to visualize
177
+ view_slice = int(np.round(ct.size[1] / 2))
178
+
179
+ # Visualize
180
+ plot_slice(
181
+ ct=ct,
182
+ cst=cst,
183
+ overlay=dij["physical_dose"],
184
+ view_slice=view_slice,
185
+ plane="coronal",
186
+ overlay_unit="Gy",
187
+ )
@@ -0,0 +1,108 @@
1
+ # %% [markdown]
2
+ """# Example for proton dose mimicking of an existing dose distribution."""
3
+ # %% [markdown]
4
+ # This example demonstrates how to use the perform dose mimicking on an existing dose distribution.
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
+ import SimpleITK as sitk
19
+
20
+ from pyRadPlan import (
21
+ IonPlan,
22
+ generate_stf,
23
+ calc_dose_influence,
24
+ fluence_optimization,
25
+ plot_slice,
26
+ load_tg119,
27
+ xp_utils,
28
+ )
29
+
30
+ from pyRadPlan.optimization.objectives import (
31
+ SquaredDeviation,
32
+ SquaredOverdosing,
33
+ MeanDose,
34
+ SquaredMimicking,
35
+ )
36
+
37
+
38
+ xp_utils.PREFER_GPU = False
39
+ xp_utils.PREFERRED_CPU_ARRAY_BACKEND = "numpy"
40
+ logging.basicConfig(level=logging.INFO)
41
+
42
+ # %%
43
+ # Load TG119 (provided within pyRadPlan)
44
+ ct, cst = load_tg119()
45
+
46
+ # %% [markdown]
47
+ # In this section, we create a proton therapy plan using the ParticleHongPencilBeamEngine.
48
+ # %%
49
+ # Create a plan object
50
+ pln = IonPlan(radiation_mode="protons", machine="Generic")
51
+ pln.prop_opt = {"solver": "scipy"}
52
+ pln.prop_dose_calc = {"dose_grid": ct.grid}
53
+
54
+ # Generate Steering Geometry ("stf")
55
+ stf = generate_stf(ct, cst, pln)
56
+
57
+ # Calculate Dose Influence Matrix ("dij")
58
+ dij = calc_dose_influence(ct, cst, stf, pln)
59
+
60
+ # %%
61
+ # Optimize a standard plan
62
+ # Optimization
63
+ cst.vois[0].objectives = [SquaredOverdosing(priority=10.0, d_max=1.0)] # OAR
64
+ cst.vois[1].objectives = [SquaredDeviation(priority=100.0, d_ref=3.0)] # Target
65
+ cst.vois[2].objectives = [
66
+ MeanDose(priority=1.0, d_ref=0.0),
67
+ SquaredOverdosing(priority=10.0, d_max=2.0),
68
+ ] # BODY
69
+
70
+ # Calculate optimized fluence
71
+ fluence = fluence_optimization(ct, cst, stf, dij, pln)
72
+
73
+ # Compute the result on the CT grid
74
+ result = dij.compute_result_ct_grid(fluence)
75
+
76
+ # %%
77
+ # Now let's mimick a reference dose distribution from the reference plan with noise
78
+ noise_stdev = 0.02
79
+ reference_dose = sitk.SpeckleNoise(result["physical_dose"], noise_stdev)
80
+
81
+ # Let's mimick the noisy dose distribution by using the SquaredMimicking objective.
82
+ cst.vois[1].objectives = [] # Target
83
+ cst.vois[0].objectives = [] # OAR
84
+ cst.vois[2].objectives = [SquaredMimicking(priority=1000.0, d_ref=reference_dose)] # BODY
85
+
86
+ # Calculate optimized fluence
87
+ fluence_mimicked = fluence_optimization(ct, cst, stf, dij, pln)
88
+
89
+ # Compute the result on the CT grid
90
+ result_mimicked = dij.compute_result_ct_grid(fluence_mimicked)
91
+
92
+ # %% [markdown]
93
+ # Visualize the results
94
+ # %%
95
+ # Choose a slice to visualize
96
+ view_slice = int(np.round(ct.size[2] / 2))
97
+
98
+ # Visualize
99
+ plot_slice(
100
+ ct=ct,
101
+ cst=cst,
102
+ overlay=result_mimicked["physical_dose"],
103
+ view_slice=view_slice,
104
+ plane="axial",
105
+ overlay_unit="Gy",
106
+ )
107
+
108
+ # %%
@@ -43,21 +43,21 @@ class Grid(PyRadPlanBaseModel):
43
43
 
44
44
  @computed_field
45
45
  @property
46
- def x(self) -> float:
46
+ def x(self) -> NDArray:
47
47
  """Return the x coordinates in the LPS world system."""
48
48
  x = np.arange(self.dimensions[0]) * self.resolution["x"] + self.origin[0]
49
49
  return x
50
50
 
51
51
  @computed_field
52
52
  @property
53
- def y(self) -> float:
53
+ def y(self) -> NDArray:
54
54
  """Return the y coordinates in the LPS world system."""
55
55
  y = np.arange(self.dimensions[1]) * self.resolution["y"] + self.origin[1]
56
56
  return y
57
57
 
58
58
  @computed_field
59
59
  @property
60
- def z(self) -> float:
60
+ def z(self) -> NDArray:
61
61
  """Return the z coordinates in the LPS world system."""
62
62
  z = np.arange(self.dimensions[2]) * self.resolution["z"] + self.origin[2]
63
63
  return z
@@ -38,15 +38,15 @@ class StructureSet(PyRadPlanBaseModel):
38
38
  arr = vdata_item[3]
39
39
  # return only one scenario (3D) else: Multi-Scenario (4D)
40
40
  return (
41
- [np.asarray(arr.astype(int).tolist())]
41
+ [np.asarray(arr, dtype=int).ravel()]
42
42
  if not isinstance(arr, list)
43
- else [a.astype(int).tolist() for a in arr]
43
+ else [np.asarray(a, dtype=int).ravel() for a in arr]
44
44
  )
45
45
 
46
46
  def create_mask(idx):
47
47
  # Create the ITK mask for a given index list.
48
48
  tmp_mask = np.zeros((ct.size[2], ct.size[0], ct.size[1]), dtype=np.uint8)
49
- tmp_mask.flat[np.asarray(idx) - 1] = 1
49
+ tmp_mask.flat[idx - 1] = 1
50
50
  tmp_mask = np.swapaxes(tmp_mask, 1, 2)
51
51
  mask_image = sitk.GetImageFromArray(tmp_mask)
52
52
  mask_image.CopyInformation(ct.cube_hu)
@@ -349,7 +349,7 @@ class StructureSet(PyRadPlanBaseModel):
349
349
  stats.Execute(labeled)
350
350
 
351
351
  # Step 3: Identify label with largest number of pixels
352
- largest_label = max(stats.GetLabels(), key=lambda label: stats.GetNumberOfPixels(label))
352
+ largest_label = max(stats.GetLabels(), key=stats.GetNumberOfPixels)
353
353
 
354
354
  # Step 4: Create binary mask of largest component
355
355
  body_segmentation = sitk.Equal(labeled, largest_label)
@@ -366,11 +366,19 @@ class VOI(PyRadPlanBaseModel, ABC):
366
366
  raise ValueError("new_ct must be a CT object")
367
367
 
368
368
  if self.mask.GetDimension() == 3:
369
- new_mask = sitk.Resample(self.mask, new_ct.cube_hu)
369
+ new_mask = sitk.Resample(
370
+ self.mask, new_ct.cube_hu, interpolator=sitk.sitkNearestNeighbor
371
+ )
370
372
  elif self.mask.GetDimension() == 4:
371
373
  new_mask = []
372
374
  for i in range(self.mask.GetSize()[-1]):
373
- new_mask.append(sitk.Resample(self.mask[:, :, :, i], new_ct.cube_hu))
375
+ new_mask.append(
376
+ sitk.Resample(
377
+ self.mask[:, :, :, i],
378
+ new_ct.cube_hu,
379
+ interpolator=sitk.sitkNearestNeighbor,
380
+ )
381
+ )
374
382
  new_mask = sitk.JoinSeries(new_mask)
375
383
  else:
376
384
  raise ValueError("Sanity check failed -- mask has invalid dimensions")
@@ -286,6 +286,11 @@ class Dij(PyRadPlanBaseModel):
286
286
 
287
287
  dij_dict = super().to_matrad(context=context)
288
288
 
289
+ # Replace None values with np.array([0]) for savemat compatibility
290
+ for key, value in dij_dict.items():
291
+ if value is None:
292
+ dij_dict[key] = np.array([0])
293
+
289
294
  return dij_dict
290
295
 
291
296
  def get_result_arrays_from_intensity(
@@ -27,7 +27,7 @@ from pyRadPlan.stf import SteeringInformation, validate_stf
27
27
  from pyRadPlan.plan import Plan, validate_pln
28
28
  from pyRadPlan.dij import Dij, validate_dij
29
29
  from pyRadPlan.scenarios import create_scenario_model, ScenarioModel
30
- from pyRadPlan.machines import load_machine_from_mat, validate_machine
30
+ from pyRadPlan.machines import load_machine_from_mat, validate_machine, Machine
31
31
 
32
32
  logger = logging.getLogger(__name__)
33
33
 
@@ -91,7 +91,7 @@ class DoseEngineBase(ABC):
91
91
  self._ct_grid = None
92
92
 
93
93
  # Protected properties with public get access
94
- self._machine = None # base data defined in machine file
94
+ self._machine: Machine = None # base data defined in machine file
95
95
  self._timers = None # timers of dose calc
96
96
  self._num_of_columns_dij = None # number of columns in the dij struct
97
97
  self._vox_world_coords = None # ct voxel coordinates in world
@@ -296,6 +296,7 @@ class PencilBeamEngineAbstract(DoseEngineBase):
296
296
  wed_cube_trace = self.cube_wed
297
297
 
298
298
  self._raytracer = RayTracerSiddon([wed_cube_trace])
299
+ self._raytracer.lateral_cut_off = self.geometric_lateral_cutoff
299
300
 
300
301
  return dij
301
302
 
@@ -389,6 +390,9 @@ class PencilBeamEngineAbstract(DoseEngineBase):
389
390
  start_time = time.time()
390
391
 
391
392
  self._raytracer.debug_core_performance = True
393
+ self._raytracer.lateral_cut_off = beam_info["beam"].get(
394
+ "effective_lateral_cut_off", self._effective_lateral_cutoff
395
+ )
392
396
  rad_depth_cubes = self._raytracer.trace_cubes(beam_info["beam"])
393
397
  self._raytracer.debug_core_performance = False
394
398