radstract 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 (80) hide show
  1. radstract-1.0.0/.github/workflows/gh-pages.yml +67 -0
  2. radstract-1.0.0/.github/workflows/lint-and-test.yml +49 -0
  3. radstract-1.0.0/.github/workflows/pypi-release.yml +68 -0
  4. radstract-1.0.0/.gitignore +19 -0
  5. radstract-1.0.0/LICENSE +202 -0
  6. radstract-1.0.0/PKG-INFO +101 -0
  7. radstract-1.0.0/README.md +70 -0
  8. radstract-1.0.0/examples/_test.py +94 -0
  9. radstract-1.0.0/examples/analysis/shapedistro.py +62 -0
  10. radstract-1.0.0/examples/data/colors.py +58 -0
  11. radstract-1.0.0/examples/data/data_conversions.py +47 -0
  12. radstract-1.0.0/examples/data/dicom_creation.py +42 -0
  13. radstract-1.0.0/examples/data/dicom_import.py +36 -0
  14. radstract-1.0.0/examples/data/filters.py +56 -0
  15. radstract-1.0.0/examples/data/models.py +28 -0
  16. radstract-1.0.0/examples/data/nifti_creation.py +34 -0
  17. radstract-1.0.0/examples/data/nifti_import.py +37 -0
  18. radstract-1.0.0/examples/dataset/create_datasets.py +101 -0
  19. radstract-1.0.0/examples/math/smart_intersection.py +38 -0
  20. radstract-1.0.0/examples/visuals/dicom_pdf_example.py +91 -0
  21. radstract-1.0.0/examples/visuals/report_generation.py +151 -0
  22. radstract-1.0.0/pyproject.toml +95 -0
  23. radstract-1.0.0/radstract/__init__.py +28 -0
  24. radstract-1.0.0/radstract/analysis/__init__.py +24 -0
  25. radstract-1.0.0/radstract/analysis/shapedistro/__init__.py +28 -0
  26. radstract-1.0.0/radstract/analysis/shapedistro/models/README.md +3 -0
  27. radstract-1.0.0/radstract/analysis/shapedistro/models/__init__.py +27 -0
  28. radstract-1.0.0/radstract/analysis/shapedistro/models/a3.py +74 -0
  29. radstract-1.0.0/radstract/analysis/shapedistro/models/common.py +75 -0
  30. radstract-1.0.0/radstract/analysis/shapedistro/models/d2.py +57 -0
  31. radstract-1.0.0/radstract/analysis/shapedistro/plots.py +201 -0
  32. radstract-1.0.0/radstract/data/__init__.py +25 -0
  33. radstract-1.0.0/radstract/data/colors.py +232 -0
  34. radstract-1.0.0/radstract/data/dicom/__init__.py +26 -0
  35. radstract-1.0.0/radstract/data/dicom/exports.py +342 -0
  36. radstract-1.0.0/radstract/data/dicom/main.py +86 -0
  37. radstract-1.0.0/radstract/data/dicom/utils.py +79 -0
  38. radstract-1.0.0/radstract/data/dicom/validator.py +234 -0
  39. radstract-1.0.0/radstract/data/images/__init__.py +25 -0
  40. radstract-1.0.0/radstract/data/images/filters.py +115 -0
  41. radstract-1.0.0/radstract/data/images/utils.py +76 -0
  42. radstract-1.0.0/radstract/data/models.py +119 -0
  43. radstract-1.0.0/radstract/data/multimodal.py +109 -0
  44. radstract-1.0.0/radstract/data/nifti/__init__.py +23 -0
  45. radstract-1.0.0/radstract/data/nifti/main.py +198 -0
  46. radstract-1.0.0/radstract/datasets/__init__.py +53 -0
  47. radstract-1.0.0/radstract/datasets/huggingface.py +124 -0
  48. radstract-1.0.0/radstract/datasets/nnunet.py +212 -0
  49. radstract-1.0.0/radstract/datasets/polygon.py +113 -0
  50. radstract-1.0.0/radstract/datasets/polygon_utils.py +100 -0
  51. radstract-1.0.0/radstract/datasets/utils.py +290 -0
  52. radstract-1.0.0/radstract/math/__init__.py +24 -0
  53. radstract-1.0.0/radstract/math/main.py +62 -0
  54. radstract-1.0.0/radstract/testdata.py +122 -0
  55. radstract-1.0.0/radstract/visuals/__init__.py +26 -0
  56. radstract-1.0.0/radstract/visuals/report_generator.py +660 -0
  57. radstract-1.0.0/radstract/visuals/report_utils.py +263 -0
  58. radstract-1.0.0/scripts/whitelist.py +33 -0
  59. radstract-1.0.0/tests/_test_gen_data.py +221 -0
  60. radstract-1.0.0/tests/conftest.py +75 -0
  61. radstract-1.0.0/tests/intergration/test_datasets_intergration.py +208 -0
  62. radstract-1.0.0/tests/intergration/test_dicom_intergration.py +51 -0
  63. radstract-1.0.0/tests/intergration/test_models_intergration.py +28 -0
  64. radstract-1.0.0/tests/intergration/test_multimodal_intergration.py +44 -0
  65. radstract-1.0.0/tests/intergration/test_report_generator_dicom_intergration.py +169 -0
  66. radstract-1.0.0/tests/unit/analysis/test_shapedistro_models.py +75 -0
  67. radstract-1.0.0/tests/unit/analysis/test_shapedistro_plot.py +90 -0
  68. radstract-1.0.0/tests/unit/data/test_color.py +75 -0
  69. radstract-1.0.0/tests/unit/data/test_dicom.py +35 -0
  70. radstract-1.0.0/tests/unit/data/test_dicom_exports.py +131 -0
  71. radstract-1.0.0/tests/unit/data/test_images.py +59 -0
  72. radstract-1.0.0/tests/unit/data/test_multimodal.py +34 -0
  73. radstract-1.0.0/tests/unit/data/test_niftis.py +70 -0
  74. radstract-1.0.0/tests/unit/datasets/test_nnunet_json.py +95 -0
  75. radstract-1.0.0/tests/unit/datasets/test_polygon_utils.py +106 -0
  76. radstract-1.0.0/tests/unit/math/test_math.py +48 -0
  77. radstract-1.0.0/tests/unit/visuals/test_dicom_pdf_generation.py +297 -0
  78. radstract-1.0.0/tests/unit/visuals/test_report_generator.py +572 -0
  79. radstract-1.0.0/tools/license.py +63 -0
  80. radstract-1.0.0/uv.lock +2189 -0
@@ -0,0 +1,67 @@
1
+ # Simple workflow for deploying static content to GitHub Pages
2
+ name: Deploy static content to Pages
3
+
4
+ on:
5
+ # Runs on pushes targeting the default branch
6
+ push:
7
+ branches: ["main"]
8
+
9
+ # Allows you to run this workflow manually from the Actions tab
10
+ workflow_dispatch:
11
+
12
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13
+ permissions:
14
+ contents: read
15
+ pages: write
16
+ id-token: write
17
+
18
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
19
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
20
+ concurrency:
21
+ group: "pages"
22
+ cancel-in-progress: false
23
+
24
+ jobs:
25
+ # Single deploy job since we're just deploying
26
+ deploy:
27
+ environment:
28
+ name: github-pages
29
+ url: ${{ steps.deployment.outputs.page_url }}
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - name: Checkout
33
+ uses: actions/checkout@v4
34
+
35
+ - name: Install uv
36
+ uses: astral-sh/setup-uv@v3
37
+ with:
38
+ version: "latest"
39
+
40
+ - name: Set up Python
41
+ run: uv python install
42
+
43
+ - name: Install dependencies
44
+ run: uv sync --all-groups
45
+
46
+ - name: Build docs with pdoc
47
+ run: uv run pdoc -d numpy -o docs radstract
48
+
49
+ - name: Build package
50
+ run: uv build
51
+
52
+ - name: Include build artifacts in docs
53
+ run: |
54
+ mkdir -p docs/downloads
55
+ cp -r dist/* docs/downloads/
56
+
57
+ - name: Setup Pages
58
+ uses: actions/configure-pages@v5
59
+
60
+ - name: Upload artifact
61
+ uses: actions/upload-pages-artifact@v3
62
+ with:
63
+ path: 'docs'
64
+
65
+ - name: Deploy to GitHub Pages
66
+ id: deployment
67
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,49 @@
1
+ name: Lint & Test
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ lint-and-test:
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - name: Check out code
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v3
19
+ with:
20
+ version: "latest"
21
+
22
+ - name: Set up Python
23
+ run: uv python install
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ uv sync --all-groups
28
+ uv add poethepoet
29
+
30
+ - name: Check code formatting with black
31
+ run: |
32
+ uv run poe format --check
33
+
34
+ - name: Generate test data
35
+ run: |
36
+ uv run poe testgen
37
+
38
+ - name: Run tests
39
+ run: |
40
+ sudo rm -rf tmp/*
41
+ uv run poe test_all
42
+
43
+ - name: Upload coverage to Codecov
44
+ uses: codecov/codecov-action@v5
45
+ with:
46
+ token: ${{ secrets.CODECOV_TOKEN }} # Set this in your repository secrets
47
+ files: coverage.xml
48
+ name: code-coverage-report
49
+ fail_ci_if_error: true
@@ -0,0 +1,68 @@
1
+ name: PyPI Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*'
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Check out code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v3
17
+ with:
18
+ version: "latest"
19
+
20
+ - name: Set up Python
21
+ run: uv python install
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ uv sync --all-groups
26
+ uv add poethepoet
27
+
28
+ - name: Generate test data
29
+ run: |
30
+ uv run poe testgen
31
+
32
+ - name: Run tests
33
+ run: |
34
+ sudo rm -rf tmp/*
35
+ uv run poe test_all
36
+
37
+ release:
38
+ needs: test
39
+ runs-on: ubuntu-latest
40
+ environment:
41
+ name: pypi
42
+ url: https://pypi.org/p/radstract
43
+ permissions:
44
+ id-token: write
45
+ steps:
46
+ - name: Check out code
47
+ uses: actions/checkout@v4
48
+
49
+ - name: Install uv
50
+ uses: astral-sh/setup-uv@v3
51
+ with:
52
+ version: "latest"
53
+
54
+ - name: Set up Python
55
+ run: uv python install
56
+
57
+ - name: Update version from tag
58
+ run: |
59
+ TAG=${GITHUB_REF#refs/tags/v}
60
+ sed -i "s/version = \".*\"/version = \"$TAG\"/" pyproject.toml
61
+
62
+ - name: Build package
63
+ run: uv build
64
+
65
+ - name: Publish to PyPI
66
+ uses: pypa/gh-action-pypi-publish@release/v1
67
+ with:
68
+ print-hash: true
@@ -0,0 +1,19 @@
1
+ # editor settings
2
+ .idea
3
+ .vscode
4
+ _darcs
5
+
6
+ # python
7
+ .coverage
8
+ __pycache__
9
+ .pytest_cache
10
+
11
+ # pdoc
12
+ /docs
13
+
14
+ # examples
15
+ /debug
16
+
17
+ # tests
18
+ /tests/test_data
19
+ .venv
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2024 Adam McArthur
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: radstract
3
+ Version: 1.0.0
4
+ Author-email: Sharpz7 <adam.mcarthur62@gmail.com>
5
+ License: Apache-2.0
6
+ License-File: LICENSE
7
+ Requires-Python: <4.0,>=3.10
8
+ Requires-Dist: black>=25.1.0
9
+ Requires-Dist: importlib-metadata>=7.1.0
10
+ Requires-Dist: licensecheck>=2023.5.2
11
+ Requires-Dist: matplotlib>=3.8.2
12
+ Requires-Dist: nibabel==5.2.1
13
+ Requires-Dist: numpy==1.26.4
14
+ Requires-Dist: opencv-python>=4.9.0.80
15
+ Requires-Dist: pdoc>=14.4.0
16
+ Requires-Dist: pillow>=11.0.0
17
+ Requires-Dist: pydicom>=3.0.1
18
+ Requires-Dist: pylibjpeg-openjpeg>=2.2.1
19
+ Requires-Dist: pylibjpeg>=2.0.1
20
+ Requires-Dist: pytest-cov>=5.0.0
21
+ Requires-Dist: pytest-mock>=3.14.0
22
+ Requires-Dist: pytest-xdist>=3.6.1
23
+ Requires-Dist: pytest>=8.1.1
24
+ Requires-Dist: scikit-image>=0.24.0
25
+ Requires-Dist: simpleitk>=2.4.0
26
+ Requires-Dist: sympy>=1.12
27
+ Requires-Dist: trimesh>=4.0.5
28
+ Requires-Dist: vulture>=2.11
29
+ Requires-Dist: weasyprint>=65.1
30
+ Description-Content-Type: text/markdown
31
+
32
+ [![Lint & Test](https://github.com/radoss-org/radstract/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/radoss-org/radstract/actions/workflows/lint-and-test.yml)
33
+ [![codecov](https://codecov.io/gh/radoss-org/radstract/graph/badge.svg?token=AAC82LNAKU)](https://codecov.io/gh/radoss-org/radstract)
34
+
35
+ ## Radstract
36
+
37
+ Radstract is python library containing shared code for RadOSS projects.
38
+
39
+ It has a range of subpackages for different tasks:
40
+ - Data: For data/image manipulation and conversion functions
41
+ - Analysis: For different methods of analyzing the data, from nifti and dicom files
42
+ - Math: For different mathematical functions and operations
43
+ - Datasets: for converting and working with different datasets (Huggingface etc)
44
+
45
+ Feel free to use this code in your own projects, and if you have any questions or suggestions, please feel free to open an issue.
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install git+https://github.com/radoss-org/radstract.git
51
+ ```
52
+
53
+ See examples here for a quickstart: https://github.com/radoss-org/Radstract/tree/main/examples
54
+
55
+ ## Docs
56
+
57
+ Docs can be viewed at https://radoss-org.github.io/radstract/radstract.html
58
+
59
+ ## Examples
60
+
61
+ See examples here: https://github.com/radoss-org/Radstract/tree/main/examples
62
+
63
+
64
+ ## Developer Guide
65
+
66
+ You can clone the repository and install the dependencies with the following command:
67
+
68
+ ```bash
69
+ git clone https://github.com/radoss-org/radstract.git
70
+ ```
71
+
72
+ You can then install retuve with poetry, and then run the tests:
73
+
74
+ ```bash
75
+ # Needed for the scripts
76
+ pip install poethepoet
77
+
78
+ cd retuve
79
+ poetry install
80
+
81
+ # Generate the test data
82
+ poe testgen
83
+
84
+ # Run all tests, including examples.
85
+ poe test_all
86
+
87
+ # Get info on all other dev scripts
88
+ poe help
89
+ ```
90
+
91
+ ## Acknowledgments
92
+
93
+ Data for the examples and tests is from https://github.com/radoss-org/radoss-creative-commons.
94
+
95
+ Please see this repo for attribution and licensing information.
96
+
97
+ - **Shape Distribution Models** From https://graphics.stanford.edu/courses/cs468-08-fall/pdf/osada.pdf
98
+
99
+ ## License
100
+
101
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,70 @@
1
+ [![Lint & Test](https://github.com/radoss-org/radstract/actions/workflows/lint-and-test.yml/badge.svg)](https://github.com/radoss-org/radstract/actions/workflows/lint-and-test.yml)
2
+ [![codecov](https://codecov.io/gh/radoss-org/radstract/graph/badge.svg?token=AAC82LNAKU)](https://codecov.io/gh/radoss-org/radstract)
3
+
4
+ ## Radstract
5
+
6
+ Radstract is python library containing shared code for RadOSS projects.
7
+
8
+ It has a range of subpackages for different tasks:
9
+ - Data: For data/image manipulation and conversion functions
10
+ - Analysis: For different methods of analyzing the data, from nifti and dicom files
11
+ - Math: For different mathematical functions and operations
12
+ - Datasets: for converting and working with different datasets (Huggingface etc)
13
+
14
+ Feel free to use this code in your own projects, and if you have any questions or suggestions, please feel free to open an issue.
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ pip install git+https://github.com/radoss-org/radstract.git
20
+ ```
21
+
22
+ See examples here for a quickstart: https://github.com/radoss-org/Radstract/tree/main/examples
23
+
24
+ ## Docs
25
+
26
+ Docs can be viewed at https://radoss-org.github.io/radstract/radstract.html
27
+
28
+ ## Examples
29
+
30
+ See examples here: https://github.com/radoss-org/Radstract/tree/main/examples
31
+
32
+
33
+ ## Developer Guide
34
+
35
+ You can clone the repository and install the dependencies with the following command:
36
+
37
+ ```bash
38
+ git clone https://github.com/radoss-org/radstract.git
39
+ ```
40
+
41
+ You can then install retuve with poetry, and then run the tests:
42
+
43
+ ```bash
44
+ # Needed for the scripts
45
+ pip install poethepoet
46
+
47
+ cd retuve
48
+ poetry install
49
+
50
+ # Generate the test data
51
+ poe testgen
52
+
53
+ # Run all tests, including examples.
54
+ poe test_all
55
+
56
+ # Get info on all other dev scripts
57
+ poe help
58
+ ```
59
+
60
+ ## Acknowledgments
61
+
62
+ Data for the examples and tests is from https://github.com/radoss-org/radoss-creative-commons.
63
+
64
+ Please see this repo for attribution and licensing information.
65
+
66
+ - **Shape Distribution Models** From https://graphics.stanford.edu/courses/cs468-08-fall/pdf/osada.pdf
67
+
68
+ ## License
69
+
70
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,94 @@
1
+ # Copyright 2024 Adam McArthur
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import os
16
+ import subprocess
17
+
18
+ import pytest
19
+
20
+ BLACKLIST = []
21
+
22
+
23
+ # Dynamically collect scripts for testing
24
+ def collect_scripts():
25
+ examples_dir = os.path.dirname(__file__)
26
+ module_dir = os.path.abspath(
27
+ os.path.join(examples_dir, "..")
28
+ ) # Assuming your module is one level up from the examples directory
29
+
30
+ scripts = []
31
+ for root, _, files in os.walk(examples_dir):
32
+ for file in files:
33
+ if file.endswith(".py") and file not in BLACKLIST:
34
+ scripts.append((os.path.join(root, file), module_dir))
35
+ return scripts
36
+
37
+
38
+ # Dynamically create test functions for pytest
39
+ scripts = collect_scripts()
40
+ for i, (script_path, module_dir) in enumerate(scripts):
41
+ # test_name should be derived from the script name
42
+ test_name = f'test_{script_path.split("/")[-1].replace(".py", "").replace("_", "")}'
43
+
44
+ # divide i to fit into 4 groups
45
+ group_no = i % 8 + 1
46
+
47
+ def create_test(script_path, module_dir, temp_dir):
48
+ @pytest.mark.xdist_group(name=f"group{group_no}")
49
+ def test():
50
+ try:
51
+ # Capture the initial state of the directory
52
+ initial_files = set(os.listdir(temp_dir))
53
+
54
+ # Set up the environment
55
+ env = os.environ.copy()
56
+ env["PYTHONPATH"] = module_dir
57
+
58
+ # Run the script
59
+ subprocess.run(
60
+ ["python", script_path],
61
+ check=True,
62
+ env=env,
63
+ )
64
+
65
+ # Capture the state of the directory after the script runs
66
+ final_files = set(os.listdir(temp_dir))
67
+
68
+ # Identify new files created during script execution
69
+ new_files = final_files - initial_files
70
+
71
+ # Filter only files with the specified extensions
72
+ target_extensions = {".html", ".mp4", ".jpg", ".png"}
73
+ files_to_remove = [
74
+ file_name
75
+ for file_name in new_files
76
+ if os.path.splitext(file_name)[1].lower()
77
+ in target_extensions
78
+ ]
79
+
80
+ # Delete the filtered files
81
+ for file_name in files_to_remove:
82
+ file_path = os.path.join(temp_dir, file_name)
83
+ if os.path.isfile(file_path):
84
+ os.remove(file_path)
85
+
86
+ except subprocess.CalledProcessError as e:
87
+ pytest.fail(
88
+ f"Script failed: {script_path}\nError message: {e}"
89
+ )
90
+
91
+ return test
92
+
93
+ # Add the test function to the global scope
94
+ globals()[test_name] = create_test(script_path, module_dir, "./")