pyRadPlan 0.2.1__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 (153) hide show
  1. {pyradplan-0.2.1/pyRadPlan.egg-info → pyradplan-0.2.2}/PKG-INFO +11 -1
  2. {pyradplan-0.2.1 → pyradplan-0.2.2}/README.md +10 -0
  3. {pyradplan-0.2.1 → pyradplan-0.2.2}/docs/conf.py +4 -1
  4. pyradplan-0.2.2/pyRadPlan/core/datamodel.py +111 -0
  5. pyradplan-0.2.2/pyRadPlan/dij/__init__.py +6 -0
  6. pyradplan-0.2.2/pyRadPlan/dij/_compose_beam_dijs.py +55 -0
  7. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dij/_dij.py +34 -20
  8. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base.py +17 -8
  9. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base_pencilbeam.py +4 -0
  10. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/_ions.py +76 -10
  11. {pyradplan-0.2.1 → pyradplan-0.2.2/pyRadPlan.egg-info}/PKG-INFO +11 -1
  12. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan.egg-info/SOURCES.txt +1 -0
  13. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyproject.toml +1 -1
  14. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_dij.py +14 -1
  15. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_grid.py +29 -0
  16. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_machine_model.py +19 -0
  17. pyradplan-0.2.1/pyRadPlan/core/datamodel.py +0 -70
  18. pyradplan-0.2.1/pyRadPlan/dij/__init__.py +0 -5
  19. {pyradplan-0.2.1 → pyradplan-0.2.2}/LICENSE +0 -0
  20. {pyradplan-0.2.1 → pyradplan-0.2.2}/examples/carbon_pencilbeam.py +0 -0
  21. {pyradplan-0.2.1 → pyradplan-0.2.2}/examples/helium_pencilbeam.py +0 -0
  22. {pyradplan-0.2.1 → pyradplan-0.2.2}/examples/import_matrad_patient.py +0 -0
  23. {pyradplan-0.2.1 → pyradplan-0.2.2}/examples/photon_pencilbeam.py +0 -0
  24. {pyradplan-0.2.1 → pyradplan-0.2.2}/examples/proton_pencilbeam.py +0 -0
  25. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/__init__.py +0 -0
  26. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/core/__init__.py +0 -0
  27. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/core/_exceptions.py +0 -0
  28. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/core/_grids.py +0 -0
  29. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/core/np2sitk.py +0 -0
  30. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/core/resample.py +0 -0
  31. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/cst/__init__.py +0 -0
  32. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/cst/_cst.py +0 -0
  33. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/cst/_voi.py +0 -0
  34. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/ct/__init__.py +0 -0
  35. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/ct/_ct.py +0 -0
  36. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/ct/_hlut.py +0 -0
  37. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/machines/carbon_Generic.mat +0 -0
  38. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/machines/helium_Generic.mat +0 -0
  39. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/machines/photons_Generic.mat +0 -0
  40. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/machines/protons_Generic.mat +0 -0
  41. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/phantoms/TG119.mat +0 -0
  42. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/stf/matRad_stf.mat +0 -0
  43. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/stf/matRad_stf_onebeam.mat +0 -0
  44. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/data/stf/matrad_stf_onebeam.mat +0 -0
  45. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/__init__.py +0 -0
  46. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/_calc_dose.py +0 -0
  47. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/__init__.py +0 -0
  48. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_base_pencilbeam_particle.py +0 -0
  49. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_factory.py +0 -0
  50. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_hongpb.py +0 -0
  51. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/dose/engines/_svdpb.py +0 -0
  52. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/geometry/__init__.py +0 -0
  53. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/geometry/lps.py +0 -0
  54. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/io/__init__.py +0 -0
  55. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/io/_matlab_file_handler.py +0 -0
  56. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/io/_patient_loader.py +0 -0
  57. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/io/matfile.py +0 -0
  58. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/__init__.py +0 -0
  59. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/_base.py +0 -0
  60. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/_load.py +0 -0
  61. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/_photons.py +0 -0
  62. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/machines/_validate.py +0 -0
  63. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/matRad/__init__.py +0 -0
  64. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/matRad/_engine.py +0 -0
  65. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/matRad/_matlab.py +0 -0
  66. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/matRad/_octave.py +0 -0
  67. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/__init__.py +0 -0
  68. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/_fluence_optimization.py +0 -0
  69. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/__init__.py +0 -0
  70. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_eud.py +0 -0
  71. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_factory.py +0 -0
  72. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_max_dvh.py +0 -0
  73. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_mean.py +0 -0
  74. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_min_dvh.py +0 -0
  75. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_objective.py +0 -0
  76. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_dev.py +0 -0
  77. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_over.py +0 -0
  78. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_squared_under.py +0 -0
  79. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/objectives/_std.py +0 -0
  80. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/__init__.py +0 -0
  81. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_factory.py +0 -0
  82. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_nonlin_fluence.py +0 -0
  83. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_optiprob.py +0 -0
  84. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/problems/_simple_least_squares.py +0 -0
  85. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/__init__.py +0 -0
  86. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_base_solvers.py +0 -0
  87. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_factory.py +0 -0
  88. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_ipopt.py +0 -0
  89. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/optimization/solvers/_scipy_solver.py +0 -0
  90. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/plan/__init__.py +0 -0
  91. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/plan/_plans.py +0 -0
  92. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/quantities/__init__.py +0 -0
  93. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/quantities/_base.py +0 -0
  94. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/quantities/_dose.py +0 -0
  95. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/raytracer/__init__.py +0 -0
  96. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/raytracer/_base.py +0 -0
  97. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/raytracer/_perf.py +0 -0
  98. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/raytracer/_siddon.py +0 -0
  99. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/scenarios/__init__.py +0 -0
  100. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/scenarios/_base.py +0 -0
  101. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/scenarios/_nominal.py +0 -0
  102. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/__init__.py +0 -0
  103. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_beam.py +0 -0
  104. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_beamlet.py +0 -0
  105. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_exceptions.py +0 -0
  106. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_generate_stf.py +0 -0
  107. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_rangeshifter.py +0 -0
  108. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_ray.py +0 -0
  109. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/_steeringinformation.py +0 -0
  110. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/__init__.py +0 -0
  111. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_base.py +0 -0
  112. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_externalbeam.py +0 -0
  113. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_factory.py +0 -0
  114. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_ions.py +0 -0
  115. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/stf/generators/_photons.py +0 -0
  116. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/util/__init__.py +0 -0
  117. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/util/helpers.py +0 -0
  118. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/visualization/__init__.py +0 -0
  119. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan/visualization/_plot_slice.py +0 -0
  120. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan.egg-info/dependency_links.txt +0 -0
  121. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan.egg-info/requires.txt +0 -0
  122. {pyradplan-0.2.1 → pyradplan-0.2.2}/pyRadPlan.egg-info/top_level.txt +0 -0
  123. {pyradplan-0.2.1 → pyradplan-0.2.2}/setup.cfg +0 -0
  124. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/conftest.py +0 -0
  125. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/core/test_coordinates.py +0 -0
  126. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/core/test_np2sitk.py +0 -0
  127. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/core/test_resample.py +0 -0
  128. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/cst/conftest.py +0 -0
  129. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/cst/test_VOI.py +0 -0
  130. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/cst/test_cst.py +0 -0
  131. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/ct/test_ct.py +0 -0
  132. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/ct/test_hlut.py +0 -0
  133. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/dose/test_dose_particle.py +0 -0
  134. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/dose/test_dose_photon.py +0 -0
  135. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/geometry/test_lps.py +0 -0
  136. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_fluence_optiprob.py +0 -0
  137. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_ipopt_solver.py +0 -0
  138. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_objectives.py +0 -0
  139. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_problem_factory.py +0 -0
  140. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_scipy_solver.py +0 -0
  141. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/optimization/test_solver_factory.py +0 -0
  142. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/quantities/test_dose_quantity.py +0 -0
  143. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/stf/test_beamlet.py +0 -0
  144. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/stf/test_stf.py +0 -0
  145. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/stf/test_stf_gen.py +0 -0
  146. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_fileHandling.py +0 -0
  147. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_helpers.py +0 -0
  148. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_matlabEngine.py +0 -0
  149. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_octaveEngine.py +0 -0
  150. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_plan.py +0 -0
  151. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_raytracersiddon.py +0 -0
  152. {pyradplan-0.2.1 → pyradplan-0.2.2}/test/test_scenarios.py +0 -0
  153. {pyradplan-0.2.1 → 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.1
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
@@ -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
 
@@ -16,6 +16,7 @@ from abc import ABC, abstractmethod
16
16
 
17
17
  import SimpleITK as sitk
18
18
  import numpy as np
19
+ from pydantic import ValidationError
19
20
 
20
21
  from pyRadPlan.core import Grid
21
22
  from pyRadPlan.core.np2sitk import linear_indices_to_grid_coordinates
@@ -79,16 +80,14 @@ class DoseEngineBase(ABC):
79
80
  # Public properties
80
81
  def __init__(self, pln: Union[Plan, dict] = None):
81
82
  # Assign default parameters from Matrad_Config or manually
82
- self.dose_grid = None
83
83
  self.mult_scen = "nomScen"
84
84
  self.select_voxels_in_scenarios = None
85
- self.dose_grid = None
86
85
  self.voxel_sub_ix = None # selection of where to calculate / store dose, empty by default
86
+ self.dose_grid = None
87
87
 
88
88
  if pln is not None:
89
89
  self.assign_properties_from_pln(pln, True)
90
90
 
91
- self._dose_grid = None
92
91
  self._ct_grid = None
93
92
 
94
93
  # Protected properties with public get access
@@ -471,10 +470,19 @@ class DoseEngineBase(ABC):
471
470
  dij["ct_grid"] = ct.grid
472
471
 
473
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
+ )
474
479
  self.dose_grid = ct.grid.resample({"x": 5.0, "y": 5.0, "z": 5.0})
475
480
 
476
481
  if not isinstance(self.dose_grid, Grid):
477
- 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"])
478
486
 
479
487
  dij["dose_grid"] = self.dose_grid
480
488
 
@@ -517,8 +525,8 @@ class DoseEngineBase(ABC):
517
525
  # Initialize tmp_vdose_grid_scen
518
526
  tmp_vdose_grid_scen = [None] * ct.num_of_ct_scen
519
527
 
520
- if self._ct_grid == self._dose_grid:
521
- self._dose_grid = self._ct_grid
528
+ if self._ct_grid == self.dose_grid:
529
+ tmp_vdose_grid_scen = tmp_vct_grid_scen
522
530
  resampled_ct = ct
523
531
  else:
524
532
  resampled_ct = resample_ct(
@@ -526,7 +534,8 @@ class DoseEngineBase(ABC):
526
534
  interpolator=sitk.sitkNearestNeighbor,
527
535
  target_grid=self.dose_grid,
528
536
  )
529
- self._dose_grid = Grid.from_sitk_image(resampled_ct.cube_hu)
537
+ self.dose_grid = Grid.from_sitk_image(resampled_ct.cube_hu)
538
+
530
539
  for s in range(ct.num_of_ct_scen):
531
540
  # Receive linear indices and grid locations from the dose grid
532
541
  tmp_cube = np.zeros(ct.cube_dim[::-1], dtype=np.float32)
@@ -555,7 +564,7 @@ class DoseEngineBase(ABC):
555
564
  )
556
565
 
557
566
  self._vox_world_coords_dose_grid = linear_indices_to_grid_coordinates(
558
- self._vdose_grid, self._dose_grid, index_type="numpy"
567
+ self._vdose_grid, self.dose_grid, index_type="numpy"
559
568
  )
560
569
 
561
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):
@@ -1,4 +1,4 @@
1
- from typing import Any, Optional, Annotated, Union
1
+ from typing import Any, Optional, Annotated, Union, Final
2
2
  from typing_extensions import Self
3
3
 
4
4
  # import warnings
@@ -20,6 +20,56 @@ from pyRadPlan.util.helpers import dl2ld
20
20
  from pyRadPlan.machines._base import ExternalBeamMachine
21
21
 
22
22
 
23
+ class IonBeamEmittance(PyRadPlanBaseModel):
24
+ """Emittance data for ion accelerator."""
25
+
26
+ type: Final[str] = "bigaussian"
27
+
28
+ sigma_x: float = Field(alias="sigmaX", ge=0.0)
29
+ sigma_y: float = Field(alias="sigmaY", ge=0.0)
30
+ div_x: float = Field(default=1e-12, alias="divX")
31
+ div_y: float = Field(default=1e-12, alias="divY")
32
+ corr_x: float = Field(default=1e-12, alias="corrX", ge=-1.0, le=1.0)
33
+ corr_y: float = Field(default=1e-12, alias="corrY", ge=-1.0, le=1.0)
34
+
35
+
36
+ class IonEnergySpectrum(PyRadPlanBaseModel):
37
+ pass
38
+
39
+
40
+ class IonEnergySpectrumGaussian(IonEnergySpectrum):
41
+ """
42
+ Energy spectrum data for ion pencil beam kernels.
43
+
44
+ Notes
45
+ -----
46
+ The energy spectrum is defined as a Gaussian distribution with a mean
47
+ energy and a relative spread in percent.
48
+ """
49
+
50
+ type: Final[str] = "gaussian"
51
+
52
+ mean: float = Field(ge=0.0)
53
+ sigma: float = Field(
54
+ ge=0.0, description="Relative spread as percentage sigma of the Gaussian energy spectrum"
55
+ )
56
+
57
+ @property
58
+ def sigma_relative(self) -> float:
59
+ """Relative spread of the energy spectrum."""
60
+ return self.sigma / 100.0
61
+
62
+ @property
63
+ def sigma_absolute(self) -> float:
64
+ """Absolute sigma of the energy spectrum."""
65
+ return self.sigma_relative * self.mean
66
+
67
+ @property
68
+ def fwhm(self) -> float:
69
+ """Full width at half maximum of the energy spectrum."""
70
+ return 2.35482 * self.sigma_absolute
71
+
72
+
23
73
  class IonBeamFocus(PyRadPlanBaseModel):
24
74
  """Focus data for ion pencil beam kernels."""
25
75
 
@@ -27,7 +77,8 @@ class IonBeamFocus(PyRadPlanBaseModel):
27
77
  sigma: NDArray[Shape["1-*"], np.float64]
28
78
  fwhm_iso: Optional[np.float64] = None
29
79
 
30
- # TODO: emittance parameterization
80
+ # emittance parameterization
81
+ emittance: Optional[IonBeamEmittance] = None
31
82
 
32
83
  @field_validator("dist", "sigma", mode="before")
33
84
  @classmethod
@@ -40,6 +91,11 @@ class IonBeamFocus(PyRadPlanBaseModel):
40
91
 
41
92
  return v
42
93
 
94
+ @property
95
+ def has_emittance(self) -> bool:
96
+ """Check if emittance parameters are available."""
97
+ return self.sigma_x is not None and self.sigma_y is not None
98
+
43
99
 
44
100
  class LateralCutOff(PyRadPlanBaseModel):
45
101
  """Lateral cut-off radius and compensation for ion pencil beam kernels."""
@@ -200,7 +256,9 @@ class IonPencilBeamKernel(PyRadPlanBaseModel):
200
256
 
201
257
 
202
258
  class IonAccelerator(ExternalBeamMachine):
203
- """Machine Model for Ion Accelerators
259
+ """
260
+ Machine Model for Ion Accelerators.
261
+
204
262
  Defines minimum meta-data an ion machine must hold
205
263
  Provides multiple data storage formats, currently supported
206
264
  - Pencil-Beam Kernels
@@ -239,6 +297,7 @@ class IonAccelerator(ExternalBeamMachine):
239
297
  # Minimum required data is energies, Bragg-peak positions and beam foci
240
298
  peak_positions: NDArray[Shape["1-*"], np.float64]
241
299
  foci: dict[float, list[IonBeamFocus]]
300
+ spectra: Optional[dict[float, IonEnergySpectrum]] = None
242
301
 
243
302
  # Optionally we can have pencil-beam kernels
244
303
  pb_kernels: Optional[dict[float, IonPencilBeamKernel]] = None
@@ -290,6 +349,14 @@ class IonAccelerator(ExternalBeamMachine):
290
349
 
291
350
  returned_data["foci"] = foci
292
351
 
352
+ # Energy Spectra
353
+ spectra_list = tabulated_energy_data.get("energySpectrum", None)
354
+ if spectra_list is not None:
355
+ returned_data["spectra"] = {
356
+ returned_data["energies"][i]: IonEnergySpectrumGaussian(**spectrum)
357
+ for i, spectrum in enumerate(spectra_list)
358
+ }
359
+
293
360
  # Extract the pencil beam kernels
294
361
  # Pencil beam kernels are not requried so we may skip them
295
362
  # if they can't be validated
@@ -307,8 +374,9 @@ class IonAccelerator(ExternalBeamMachine):
307
374
  # if self.betas not None:
308
375
 
309
376
  @model_validator(mode="after")
310
- def check_machine(self) -> Self:
311
- """Validates the machine model for consistency."""
377
+ def _check_machine(self) -> Self:
378
+ """Validate the machine model for consistency."""
379
+
312
380
  if self.bams_to_iso_dist > self.sad:
313
381
  raise ValueError("BAMS to iso distance must be small than SAD.")
314
382
 
@@ -352,8 +420,7 @@ class IonAccelerator(ExternalBeamMachine):
352
420
 
353
421
  def get_foci_by_index(self, ix_energy: int) -> list[IonBeamFocus]:
354
422
  """
355
- Get the focus data of the pencil beam kernel for a specific energy
356
- index.
423
+ Get the focus data of the kernel for a specific energy index.
357
424
 
358
425
  Parameters
359
426
  ----------
@@ -402,7 +469,7 @@ class IonAccelerator(ExternalBeamMachine):
402
469
  self, energy: Union[float, np.float64], kernel: IonPencilBeamKernel
403
470
  ):
404
471
  """
405
- Updates a pencil-beam kernel for a specific energy.
472
+ Update a pencil-beam kernel for a specific energy.
406
473
 
407
474
  Parameters
408
475
  ----------
@@ -425,8 +492,7 @@ class IonAccelerator(ExternalBeamMachine):
425
492
 
426
493
  def get_focus(self, ix_energy: int) -> dict:
427
494
  """
428
- Get the focus data of the pencil beam kernel for a specific energy
429
- index.
495
+ Get the focus data of the kernel for a specific energy index.
430
496
 
431
497
  Parameters
432
498
  ----------
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyRadPlan
3
- Version: 0.2.1
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)
@@ -34,6 +34,7 @@ pyRadPlan/data/stf/matRad_stf.mat
34
34
  pyRadPlan/data/stf/matRad_stf_onebeam.mat
35
35
  pyRadPlan/data/stf/matrad_stf_onebeam.mat
36
36
  pyRadPlan/dij/__init__.py
37
+ pyRadPlan/dij/_compose_beam_dijs.py
37
38
  pyRadPlan/dij/_dij.py
38
39
  pyRadPlan/dose/__init__.py
39
40
  pyRadPlan/dose/_calc_dose.py
@@ -10,7 +10,7 @@ pyRadPlan = ["data/**/*"]
10
10
 
11
11
  [project]
12
12
  name = "pyRadPlan"
13
- version = "0.2.1"
13
+ version = "0.2.2"
14
14
  # dynamic = ["version"] # Will be used in the future
15
15
  authors = [
16
16
  { name="Niklas Wahl", email = "n.wahl@dkfz-heidelberg.de"},
@@ -3,7 +3,7 @@ import SimpleITK as sitk
3
3
  import numpy as np
4
4
  import scipy.sparse as sp
5
5
  from pyRadPlan.core import Grid
6
- from pyRadPlan.dij import Dij, create_dij, validate_dij
6
+ from pyRadPlan.dij import Dij, create_dij, validate_dij, compose_beam_dijs
7
7
 
8
8
 
9
9
  @pytest.fixture
@@ -239,3 +239,16 @@ def test_result_computation_biodose(sample_dij_dict):
239
239
  with pytest.raises(ValueError):
240
240
  dij.physical_dose = None
241
241
  dij.compute_result_dose_grid(f)
242
+
243
+
244
+ def test_compose_beam_dijs(sample_dij_dict):
245
+ dij = create_dij(**sample_dij_dict)
246
+ composed_dij = compose_beam_dijs([dij, dij])
247
+ assert isinstance(composed_dij, Dij)
248
+ assert composed_dij.num_of_beams == 2 * dij.num_of_beams
249
+ assert composed_dij.total_num_of_bixels == 2 * dij.total_num_of_bixels
250
+ assert composed_dij.beam_num.shape == (2 * dij.total_num_of_bixels,)
251
+ assert composed_dij.ray_num.shape == (2 * dij.total_num_of_bixels,)
252
+ assert composed_dij.bixel_num.shape == (2 * dij.total_num_of_bixels,)
253
+ assert composed_dij.dose_grid == dij.dose_grid
254
+ assert composed_dij.ct_grid == dij.ct_grid
@@ -146,3 +146,32 @@ def test_resample_grid_invalid_resolution(sample_grid):
146
146
 
147
147
  with pytest.raises(ValueError):
148
148
  sample_grid.resample("invalid") # Invalid type
149
+
150
+
151
+ # test the custom implementation of the eq/neq operator on grids
152
+ def test_grids_equal():
153
+ grid = Grid(resolution={"x": 1, "y": 1, "z": 1}, dimensions=(10, 10, 10))
154
+ grid2 = Grid(resolution={"x": 1, "y": 1, "z": 1}, dimensions=(10, 10, 10))
155
+
156
+ assert grid == grid2
157
+
158
+
159
+ def test_grids_not_equal():
160
+ grid = Grid(resolution={"x": 1, "y": 1, "z": 1}, dimensions=(10, 10, 10))
161
+ grid2 = Grid(resolution={"x": 1, "y": 1, "z": 2}, dimensions=(10, 10, 10))
162
+ grid3 = Grid(resolution={"x": 1, "y": 1, "z": 1}, dimensions=(10, 10, 20))
163
+
164
+ assert grid != grid2
165
+ assert grid != grid3
166
+
167
+
168
+ def test_grids_not_equal_types():
169
+ grid = Grid(resolution={"x": 1, "y": 1, "z": 1}, dimensions=(10, 10, 10))
170
+ assert grid != 1
171
+ assert grid != "string"
172
+ assert grid != [1, 2, 3]
173
+
174
+ # revert
175
+ assert 1 != grid
176
+ assert "string" != grid
177
+ assert [1, 2, 3] != grid