simind-python-connector 1.0.0__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 (122) hide show
  1. simind_python_connector-1.0.0/LICENSE +195 -0
  2. simind_python_connector-1.0.0/MANIFEST.in +13 -0
  3. simind_python_connector-1.0.0/PKG-INFO +274 -0
  4. simind_python_connector-1.0.0/README.md +231 -0
  5. simind_python_connector-1.0.0/docs/api.rst +94 -0
  6. simind_python_connector-1.0.0/docs/backends.rst +56 -0
  7. simind_python_connector-1.0.0/docs/changelog.rst +317 -0
  8. simind_python_connector-1.0.0/docs/conf.py +99 -0
  9. simind_python_connector-1.0.0/docs/connector_modernization_plan.rst +45 -0
  10. simind_python_connector-1.0.0/docs/contributing.rst +48 -0
  11. simind_python_connector-1.0.0/docs/examples/01_basic_simulation.py +93 -0
  12. simind_python_connector-1.0.0/docs/examples/02_runtime_switch_comparison.py +108 -0
  13. simind_python_connector-1.0.0/docs/examples/03_multi_window.py +120 -0
  14. simind_python_connector-1.0.0/docs/examples/04_custom_config.py +228 -0
  15. simind_python_connector-1.0.0/docs/examples/05_scattwin_vs_penetrate_comparison.py +473 -0
  16. simind_python_connector-1.0.0/docs/examples/06_schneider_density_conversion.py +322 -0
  17. simind_python_connector-1.0.0/docs/examples/07A_stir_adaptor_osem.py +211 -0
  18. simind_python_connector-1.0.0/docs/examples/07B_sirf_adaptor_osem.py +193 -0
  19. simind_python_connector-1.0.0/docs/examples/07C_pytomography_adaptor_osem.py +184 -0
  20. simind_python_connector-1.0.0/docs/examples/08A_stir_adaptor_from_dicom.py +64 -0
  21. simind_python_connector-1.0.0/docs/examples/08B_sirf_adaptor_from_dicom.py +64 -0
  22. simind_python_connector-1.0.0/docs/examples/08C_pytomography_adaptor_from_dicom.py +82 -0
  23. simind_python_connector-1.0.0/docs/examples/_python_connector_helpers.py +56 -0
  24. simind_python_connector-1.0.0/docs/examples.rst +107 -0
  25. simind_python_connector-1.0.0/docs/geometry.rst +63 -0
  26. simind_python_connector-1.0.0/docs/index.rst +24 -0
  27. simind_python_connector-1.0.0/docs/installation.rst +104 -0
  28. simind_python_connector-1.0.0/docs/intro.rst +29 -0
  29. simind_python_connector-1.0.0/docs/testing.rst +231 -0
  30. simind_python_connector-1.0.0/docs/usage.rst +148 -0
  31. simind_python_connector-1.0.0/examples/01_basic_simulation.py +93 -0
  32. simind_python_connector-1.0.0/examples/02_runtime_switch_comparison.py +108 -0
  33. simind_python_connector-1.0.0/examples/03_multi_window.py +120 -0
  34. simind_python_connector-1.0.0/examples/04_custom_config.py +228 -0
  35. simind_python_connector-1.0.0/examples/05_scattwin_vs_penetrate_comparison.py +473 -0
  36. simind_python_connector-1.0.0/examples/06_schneider_density_conversion.py +322 -0
  37. simind_python_connector-1.0.0/examples/07A_stir_adaptor_osem.py +211 -0
  38. simind_python_connector-1.0.0/examples/07B_sirf_adaptor_osem.py +193 -0
  39. simind_python_connector-1.0.0/examples/07C_pytomography_adaptor_osem.py +184 -0
  40. simind_python_connector-1.0.0/examples/08A_stir_adaptor_from_dicom.py +64 -0
  41. simind_python_connector-1.0.0/examples/08B_sirf_adaptor_from_dicom.py +64 -0
  42. simind_python_connector-1.0.0/examples/08C_pytomography_adaptor_from_dicom.py +82 -0
  43. simind_python_connector-1.0.0/examples/_python_connector_helpers.py +56 -0
  44. simind_python_connector-1.0.0/pyproject.toml +87 -0
  45. simind_python_connector-1.0.0/requirements-dev.txt +23 -0
  46. simind_python_connector-1.0.0/requirements.txt +10 -0
  47. simind_python_connector-1.0.0/setup.cfg +4 -0
  48. simind_python_connector-1.0.0/simind_python_connector/__init__.py +72 -0
  49. simind_python_connector-1.0.0/simind_python_connector/backends/__init__.py +480 -0
  50. simind_python_connector-1.0.0/simind_python_connector/backends/base.py +387 -0
  51. simind_python_connector-1.0.0/simind_python_connector/backends/sirf_backend.py +309 -0
  52. simind_python_connector-1.0.0/simind_python_connector/backends/stir_backend.py +395 -0
  53. simind_python_connector-1.0.0/simind_python_connector/builders/__init__.py +19 -0
  54. simind_python_connector-1.0.0/simind_python_connector/builders/acquisition_builder.py +526 -0
  55. simind_python_connector-1.0.0/simind_python_connector/builders/image_builder.py +217 -0
  56. simind_python_connector-1.0.0/simind_python_connector/configs/AnyScan.yaml +420 -0
  57. simind_python_connector-1.0.0/simind_python_connector/configs/Discovery670.yaml +412 -0
  58. simind_python_connector-1.0.0/simind_python_connector/configs/Example.yaml +420 -0
  59. simind_python_connector-1.0.0/simind_python_connector/configs/MLD001_SCAN0.yaml +426 -0
  60. simind_python_connector-1.0.0/simind_python_connector/configs/__init__.py +41 -0
  61. simind_python_connector-1.0.0/simind_python_connector/configs/input.smc +51 -0
  62. simind_python_connector-1.0.0/simind_python_connector/connectors/__init__.py +24 -0
  63. simind_python_connector-1.0.0/simind_python_connector/connectors/_spacing.py +69 -0
  64. simind_python_connector-1.0.0/simind_python_connector/connectors/base.py +40 -0
  65. simind_python_connector-1.0.0/simind_python_connector/connectors/python_connector.py +355 -0
  66. simind_python_connector-1.0.0/simind_python_connector/connectors/pytomography_adaptor.py +263 -0
  67. simind_python_connector-1.0.0/simind_python_connector/connectors/sirf_adaptor.py +164 -0
  68. simind_python_connector-1.0.0/simind_python_connector/connectors/stir_adaptor.py +164 -0
  69. simind_python_connector-1.0.0/simind_python_connector/converters/__init__.py +16 -0
  70. simind_python_connector-1.0.0/simind_python_connector/converters/attenuation.py +367 -0
  71. simind_python_connector-1.0.0/simind_python_connector/converters/dicom_to_stir.py +3 -0
  72. simind_python_connector-1.0.0/simind_python_connector/converters/simind_to_stir.py +769 -0
  73. simind_python_connector-1.0.0/simind_python_connector/core/__init__.py +7 -0
  74. simind_python_connector-1.0.0/simind_python_connector/core/config.py +939 -0
  75. simind_python_connector-1.0.0/simind_python_connector/core/executor.py +96 -0
  76. simind_python_connector-1.0.0/simind_python_connector/core/types.py +203 -0
  77. simind_python_connector-1.0.0/simind_python_connector/data/Schneider2000.json +222 -0
  78. simind_python_connector-1.0.0/simind_python_connector/data/__init__.py +25 -0
  79. simind_python_connector-1.0.0/simind_python_connector/data/bone.atn +187 -0
  80. simind_python_connector-1.0.0/simind_python_connector/data/h2o.atn +92 -0
  81. simind_python_connector-1.0.0/simind_python_connector/utils/__init__.py +120 -0
  82. simind_python_connector-1.0.0/simind_python_connector/utils/backend_access.py +121 -0
  83. simind_python_connector-1.0.0/simind_python_connector/utils/import_helpers.py +74 -0
  84. simind_python_connector-1.0.0/simind_python_connector/utils/interfile_numpy.py +195 -0
  85. simind_python_connector-1.0.0/simind_python_connector/utils/interfile_parser.py +175 -0
  86. simind_python_connector-1.0.0/simind_python_connector/utils/io_utils.py +14 -0
  87. simind_python_connector-1.0.0/simind_python_connector/utils/simind_utils.py +70 -0
  88. simind_python_connector-1.0.0/simind_python_connector/utils/sirf_stir_utils.py +194 -0
  89. simind_python_connector-1.0.0/simind_python_connector/utils/stir_utils.py +485 -0
  90. simind_python_connector-1.0.0/simind_python_connector.egg-info/PKG-INFO +274 -0
  91. simind_python_connector-1.0.0/simind_python_connector.egg-info/SOURCES.txt +120 -0
  92. simind_python_connector-1.0.0/simind_python_connector.egg-info/dependency_links.txt +1 -0
  93. simind_python_connector-1.0.0/simind_python_connector.egg-info/requires.txt +19 -0
  94. simind_python_connector-1.0.0/simind_python_connector.egg-info/top_level.txt +1 -0
  95. simind_python_connector-1.0.0/tests/__init__.py +1 -0
  96. simind_python_connector-1.0.0/tests/conftest.py +128 -0
  97. simind_python_connector-1.0.0/tests/test_acquisition_builder_unit.py +152 -0
  98. simind_python_connector-1.0.0/tests/test_arithmetic_operations.py +106 -0
  99. simind_python_connector-1.0.0/tests/test_backends.py +289 -0
  100. simind_python_connector-1.0.0/tests/test_connector_backend_separation.py +42 -0
  101. simind_python_connector-1.0.0/tests/test_connectors_base.py +27 -0
  102. simind_python_connector-1.0.0/tests/test_container_library_isolation.py +40 -0
  103. simind_python_connector-1.0.0/tests/test_example_config_profile.py +40 -0
  104. simind_python_connector-1.0.0/tests/test_examples_backend_separation.py +74 -0
  105. simind_python_connector-1.0.0/tests/test_geometry_isolation_forward_projection.py +352 -0
  106. simind_python_connector-1.0.0/tests/test_image_builder_unit.py +90 -0
  107. simind_python_connector-1.0.0/tests/test_integration.py +38 -0
  108. simind_python_connector-1.0.0/tests/test_interfile_numpy.py +171 -0
  109. simind_python_connector-1.0.0/tests/test_interfile_parser.py +41 -0
  110. simind_python_connector-1.0.0/tests/test_marker_policy.py +72 -0
  111. simind_python_connector-1.0.0/tests/test_native_adaptors.py +389 -0
  112. simind_python_connector-1.0.0/tests/test_osem_geometry_diagnostics.py +363 -0
  113. simind_python_connector-1.0.0/tests/test_package_identity.py +18 -0
  114. simind_python_connector-1.0.0/tests/test_python_connector.py +370 -0
  115. simind_python_connector-1.0.0/tests/test_pytomography_adaptor.py +190 -0
  116. simind_python_connector-1.0.0/tests/test_schneider_density.py +295 -0
  117. simind_python_connector-1.0.0/tests/test_simind_to_stir_converter.py +438 -0
  118. simind_python_connector-1.0.0/tests/test_simulation_config.py +89 -0
  119. simind_python_connector-1.0.0/tests/test_sirf_stir_utils.py +56 -0
  120. simind_python_connector-1.0.0/tests/test_stir_utils_backend_choice_unit.py +78 -0
  121. simind_python_connector-1.0.0/tests/test_utils.py +134 -0
  122. simind_python_connector-1.0.0/tests/test_utils_small.py +53 -0
@@ -0,0 +1,195 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and incorporated
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or
82
+ contributory patent infringement, then any patent licenses granted
83
+ to You under this License for that Work shall terminate as of the
84
+ date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or in addition to the
115
+ NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the
117
+ License.
118
+
119
+ You may add Your own license statement for Your modifications and
120
+ may provide additional grant of rights to use, copy, modify, merge,
121
+ publish, distribute, sublicense, and/or sell copies of the
122
+ Contribution, either alone or together with this Work, provided that
123
+ Your use, reproduction, and distribution of the Work otherwise
124
+ complies with the conditions stated in this License.
125
+
126
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
127
+ any Contribution intentionally submitted for inclusion in the Work
128
+ by You to the Licensor shall be under the terms and conditions of
129
+ this License, without any additional terms or conditions.
130
+ Notwithstanding the above, nothing herein shall supersede or modify
131
+ the terms of any separate license agreement you may have executed
132
+ with Licensor regarding such Contributions.
133
+
134
+ 6. Trademarks. This License does not grant permission to use the trade
135
+ names, trademarks, service marks, or product names of the Licensor,
136
+ except as required for reasonable and customary use in describing the
137
+ origin of the Work and reproducing the content of the NOTICE file.
138
+
139
+ 7. Disclaimer of Warranty. Unless required by applicable law or
140
+ agreed to in writing, Licensor provides the Work (and each
141
+ Contributor provides its Contributions) on an "AS IS" BASIS,
142
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
143
+ implied, including, without limitation, any warranties or conditions
144
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
145
+ PARTICULAR PURPOSE. You are solely responsible for determining the
146
+ appropriateness of using or reproducing the Work and assume any
147
+ risks associated with Your exercise of permissions under this License.
148
+
149
+ 8. Limitation of Liability. In no event and under no legal theory,
150
+ whether in tort (including negligence), contract, or otherwise,
151
+ unless required by applicable law (such as deliberate and grossly
152
+ negligent acts) or agreed to in writing, shall any Contributor be
153
+ liable to You for damages, including any direct, indirect, special,
154
+ incidental, or exemplary damages of any character arising as a
155
+ result of this License or out of the use or inability to use the
156
+ Work (including but not limited to damages for loss of goodwill,
157
+ work stoppage, computer failure or malfunction, or all other
158
+ commercial damages or losses), even if such Contributor has been
159
+ advised of the possibility of such damages.
160
+
161
+ 9. Accepting Warranty or Additional Liability. While redistributing
162
+ the Work or Derivative Works thereof, You may choose to offer,
163
+ and charge a fee for, acceptance of support, warranty, indemnity,
164
+ or other liability obligations and/or rights consistent with this
165
+ License. However, in accepting such obligations, You may act only
166
+ on Your own behalf and on Your sole responsibility, not on behalf
167
+ of any other Contributor, and only if You agree to indemnify,
168
+ defend, and hold each Contributor harmless for any liability
169
+ incurred by, or claims asserted against, such Contributor by reason
170
+ of your accepting any such warranty or additional liability.
171
+
172
+ END OF TERMS AND CONDITIONS
173
+
174
+ APPENDIX: How to apply the Apache License to your work.
175
+
176
+ To apply the Apache License to your work, attach the following
177
+ boilerplate notice, with the fields enclosed by brackets "[]"
178
+ replaced with your own identifying information. (Don't include
179
+ the brackets!) The text should be enclosed in the appropriate
180
+ comment syntax for the file format in use. Also, you may add an
181
+ author and/or copyright holder as appropriate for your jurisdiction.
182
+
183
+ Copyright 2024 Sam Porter, Efstathios Varzakis
184
+
185
+ Licensed under the Apache License, Version 2.0 (the "License");
186
+ you may not use this file except in compliance with the License.
187
+ You may obtain a copy of the License at
188
+
189
+ http://www.apache.org/licenses/LICENSE-2.0
190
+
191
+ Unless required by applicable law or agreed to in writing, software
192
+ distributed under the License is distributed on an "AS IS" BASIS,
193
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
194
+ See the License for the specific language governing permissions and
195
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ include README.md
2
+ include LICENSE
3
+ include requirements.txt
4
+ include requirements-dev.txt
5
+ recursive-include simind_python_connector/data *.atn
6
+ recursive-include simind_python_connector/data *.json
7
+ recursive-include simind_python_connector/configs *.smc *.yaml
8
+ recursive-include docs *.rst *.py
9
+ recursive-include tests *.py
10
+ recursive-include examples *.py
11
+ global-exclude __pycache__
12
+ global-exclude *.py[co]
13
+ global-exclude .DS_Store
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: simind-python-connector
3
+ Version: 1.0.0
4
+ Summary: Python SIMIND Monte Carlo connector with STIR/SIRF/PyTomography adaptors
5
+ Author-email: Sam Porter <sam.porter.18@ucl.ac.uk>, Rebecca Gillen <rebecca.gillen.18@ucl.ac.uk>, "Efstathios (Stahis) Varzakis" <efstathios.varzakis.22@ucl.ac.uk>
6
+ Maintainer-email: Sam Porter <sam.porter.18@ucl.ac.uk>
7
+ License-Expression: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/samdporter/simind-python-connector
9
+ Project-URL: Documentation, https://simind-python-connector.readthedocs.io/
10
+ Project-URL: Repository, https://github.com/samdporter/simind-python-connector
11
+ Project-URL: Issues, https://github.com/samdporter/simind-python-connector/issues
12
+ Project-URL: Changelog, https://github.com/samdporter/simind-python-connector/blob/main/CHANGELOG.md
13
+ Keywords: SPECT,Monte Carlo,medical imaging,SIMIND,SIRF,STIR
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.20.0
26
+ Requires-Dist: pydicom>=2.0.0
27
+ Requires-Dist: pyyaml>=5.4.0
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest>=6.0; extra == "dev"
30
+ Requires-Dist: pytest-cov; extra == "dev"
31
+ Requires-Dist: pytest-mock; extra == "dev"
32
+ Requires-Dist: ruff; extra == "dev"
33
+ Requires-Dist: sphinx; extra == "dev"
34
+ Requires-Dist: sphinx-rtd-theme; extra == "dev"
35
+ Requires-Dist: sphinx-autodoc-typehints; extra == "dev"
36
+ Requires-Dist: myst-parser; extra == "dev"
37
+ Requires-Dist: pre-commit; extra == "dev"
38
+ Requires-Dist: build; extra == "dev"
39
+ Requires-Dist: twine; extra == "dev"
40
+ Provides-Extra: examples
41
+ Requires-Dist: matplotlib>=3.0.0; extra == "examples"
42
+ Dynamic: license-file
43
+
44
+ # simind-python-connector
45
+
46
+ Python SIMIND Monte Carlo Connector.
47
+
48
+ [![Tests](https://github.com/samdporter/simind-python-connector/workflows/Tests/badge.svg)](https://github.com/samdporter/simind-python-connector/actions)
49
+ [![Documentation Status](https://readthedocs.org/projects/simind-python-connector/badge/?version=latest)](https://simind-python-connector.readthedocs.io/en/latest/?badge=latest)
50
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
51
+ [![Python Version](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)
52
+
53
+ A Python toolkit that lets you run SIMIND from Python and use the outputs in
54
+ common reconstruction ecosystems (STIR, SIRF, PyTomography).
55
+
56
+ ## Disclaimer
57
+
58
+ This project is an independent Python connector toolkit and is **not
59
+ affiliated with, endorsed by, or maintained by** the SIMIND project or Lund
60
+ University.
61
+
62
+ SIMIND is **not distributed** with this package. You must separately obtain and
63
+ install a licensed SIMIND installation.
64
+
65
+ ## Quick Links
66
+ - [Full Documentation](https://simind-python-connector.readthedocs.io/)
67
+ - [Installation](https://simind-python-connector.readthedocs.io/en/latest/installation.html)
68
+ - [Backend Support](https://simind-python-connector.readthedocs.io/en/latest/backends.html) - adaptor dependency matrix
69
+
70
+ ## What This Package Does
71
+ 1. Runs SIMIND from Python with a minimal, explicit API.
72
+ 2. Adapts SIMIND data for widely used Python reconstruction packages.
73
+
74
+ ## Key Features
75
+ - **Connector-first API** - `SimindPythonConnector` for direct SIMIND execution from Python
76
+ - **Package Adaptors** - STIR/SIRF/PyTomography adaptors for reconstruction workflows
77
+ - **Native reconstruction workflows** - Use STIR/SIRF/PyTomography reconstruction tools with generated SIMIND data
78
+ - **Dual scoring support** - SCATTWIN and PENETRATE
79
+ - **DICOM builders** - DICOM-driven setup utilities for scanner/input preparation
80
+ - **Advanced Schneider2000 density conversion** - 44-segment HU-to-density mapping
81
+
82
+ ## Installation
83
+
84
+ ### Basic Installation
85
+
86
+ ```bash
87
+ pip install simind-python-connector
88
+ ```
89
+
90
+ Import path remains:
91
+
92
+ ```python
93
+ import simind_python_connector
94
+ ```
95
+
96
+ ### Adaptor Dependencies
97
+
98
+ `SimindPythonConnector` works without SIRF/STIR/PyTomography.
99
+
100
+ Install optional packages only for the adaptor paths you need:
101
+
102
+ - **STIR Python** for `StirSimindAdaptor` workflows (example 07A)
103
+ - **SIRF** for `SirfSimindAdaptor` workflows (example 07B)
104
+ - **PyTomography** for `PyTomographySimindAdaptor` workflows (example 07C)
105
+
106
+ #### Option 1: STIR Python (Recommended for basic usage)
107
+
108
+ Install from conda:
109
+ ```bash
110
+ conda install -c conda-forge stir "numpy<2.0"
111
+ ```
112
+
113
+ **Important**: As of November 2025, the STIR conda package (v6.3.0) requires NumPy < 2.0 due to binary compatibility issues with NumPy 2.x. The package was compiled against NumPy 1.x and will crash with memory errors if NumPy 2.x is installed. This should be resolved in future STIR releases.
114
+
115
+ Or build from source:
116
+ ```bash
117
+ git clone https://github.com/UCL/STIR.git
118
+ cd STIR
119
+ # Follow build instructions in the repository
120
+ ```
121
+
122
+ #### Option 2: SIRF
123
+
124
+ Install from source:
125
+ ```bash
126
+ git clone https://github.com/SyneRBI/SIRF.git
127
+ cd SIRF
128
+ # Follow build instructions in the repository
129
+ ```
130
+
131
+ **Note**: SIRF includes STIR, so a separate STIR install is usually unnecessary.
132
+
133
+ #### Option 3: PyTomography
134
+
135
+ Install PyTomography for the PyTomography adaptor workflow:
136
+
137
+ ```bash
138
+ pip install pytomography
139
+ ```
140
+
141
+ ### SIMIND Requirement
142
+
143
+ SIMIND is **not included** with this package and must be installed separately.
144
+
145
+ Use the official SIMIND resources:
146
+
147
+ - SIMIND site (Medical Radiation Physics, Lund University): https://www.msf.lu.se/en/research/simind-monte-carlo-program
148
+ - SIMIND manual/docs: https://www.msf.lu.se/en/research/simind-monte-carlo-program/manual
149
+
150
+ For local use with this package's scripts, place your SIMIND installation under:
151
+
152
+ ```text
153
+ ./simind
154
+ ```
155
+
156
+ and make sure the executable is available at:
157
+
158
+ ```text
159
+ ./simind/simind
160
+ ```
161
+
162
+ and ensure SIMIND data files are available under:
163
+
164
+ ```text
165
+ ./simind/smc_dir/
166
+ ```
167
+
168
+ The Docker helper scripts use this layout and automatically wire SIMIND paths
169
+ when the binary exists at `./simind/simind`.
170
+
171
+ ## Quick Start
172
+ ```python
173
+ import numpy as np
174
+ from simind_python_connector import SimindPythonConnector
175
+ from simind_python_connector.configs import get
176
+
177
+ source = np.zeros((32, 32, 32), dtype=np.float32) # z, y, x
178
+ source[12:20, 12:20, 12:20] = 1.0
179
+ mu_map = np.zeros_like(source)
180
+ mu_map[source > 0] = 0.15
181
+
182
+ connector = SimindPythonConnector(
183
+ config_source=get("Example.yaml"),
184
+ output_dir="output/basic",
185
+ output_prefix="case01",
186
+ quantization_scale=0.05,
187
+ )
188
+
189
+ connector.configure_voxel_phantom(
190
+ source=source,
191
+ mu_map=mu_map,
192
+ voxel_size_mm=4.0,
193
+ )
194
+ connector.set_energy_windows([126], [154], [0]) # Tc-99m ± 10%
195
+ connector.add_runtime_switch("FI", "tc99m")
196
+ connector.add_runtime_switch("CC", "ma-lehr")
197
+ connector.add_runtime_switch("NN", 1)
198
+ connector.add_runtime_switch("RR", 12345)
199
+
200
+ outputs = connector.run()
201
+ total = outputs["tot_w1"].projection
202
+ print(total.shape)
203
+ ```
204
+
205
+ ### Advanced Density Conversion
206
+
207
+ ```python
208
+ from simind_python_connector.converters.attenuation import hu_to_density_schneider
209
+ import numpy as np
210
+
211
+ # Convert HU image to densities using Schneider2000 model
212
+ hu_image = np.array([[-1000, 0, 500], [800, 1200, 2000]])
213
+ density_map = hu_to_density_schneider(hu_image) # 44-segment clinical model
214
+ ```
215
+
216
+ ### Pure Python Connector (NumPy Outputs)
217
+
218
+ ```python
219
+ from simind_python_connector import RuntimeOperator, SimindPythonConnector
220
+ from simind_python_connector.configs import get
221
+
222
+ connector = SimindPythonConnector(
223
+ config_source=get("AnyScan.yaml"),
224
+ output_dir="output/python_connector",
225
+ output_prefix="case01",
226
+ quantization_scale=1.0,
227
+ )
228
+
229
+ outputs = connector.run(RuntimeOperator(switches={"NN": 1, "RR": 12345}))
230
+ total = outputs["tot_w1"]
231
+ print(total.projection.shape)
232
+ print(total.header_path)
233
+ ```
234
+
235
+ For minimal toy runs with smaller projection/image settings, use
236
+ `get("Example.yaml")`.
237
+
238
+ `quantization_scale` controls source integer quantization before writing SIMIND
239
+ `.smi` files:
240
+
241
+ - `1.0`: uses full internal source integer range (best numeric precision)
242
+ - `< 1.0`: reduces integer scale for faster toy runs but increases rounding error
243
+
244
+ SIMIND treats source maps as integer weights; absolute activity/time scaling is
245
+ controlled separately by simulation settings.
246
+
247
+ ## Docker Environments
248
+
249
+ Dedicated container definitions are provided in [`docker/`](docker/):
250
+
251
+ - `docker/stir/Dockerfile`
252
+ - `docker/sirf/Dockerfile`
253
+ - `docker/pytomography/Dockerfile`
254
+
255
+ Use Docker Compose:
256
+
257
+ ```bash
258
+ docker compose -f docker/compose.yaml build stir
259
+ docker compose -f docker/compose.yaml run --rm stir
260
+ ```
261
+
262
+ Run per-backend validation and separated examples:
263
+
264
+ ```bash
265
+ bash scripts/run_container_validation.sh
266
+ bash scripts/run_container_validation.sh --with-simind
267
+ bash scripts/run_container_examples.sh
268
+ ```
269
+
270
+ ## Contributing
271
+ Please see our [Contributing Guide](CONTRIBUTING.md).
272
+
273
+ ## License
274
+ Apache License 2.0