biomedisa 24.5.23__py3-none-any.whl

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 (44) hide show
  1. biomedisa/__init__.py +49 -0
  2. biomedisa/__main__.py +18 -0
  3. biomedisa/deeplearning.py +529 -0
  4. biomedisa/features/DataGenerator.py +299 -0
  5. biomedisa/features/DataGeneratorCrop.py +121 -0
  6. biomedisa/features/PredictDataGenerator.py +87 -0
  7. biomedisa/features/PredictDataGeneratorCrop.py +74 -0
  8. biomedisa/features/__init__.py +0 -0
  9. biomedisa/features/active_contour.py +430 -0
  10. biomedisa/features/amira_to_np/__init__.py +0 -0
  11. biomedisa/features/amira_to_np/amira_data_stream.py +980 -0
  12. biomedisa/features/amira_to_np/amira_grammar.py +369 -0
  13. biomedisa/features/amira_to_np/amira_header.py +290 -0
  14. biomedisa/features/amira_to_np/amira_helper.py +72 -0
  15. biomedisa/features/assd.py +167 -0
  16. biomedisa/features/biomedisa_helper.py +842 -0
  17. biomedisa/features/create_slices.py +277 -0
  18. biomedisa/features/crop_helper.py +581 -0
  19. biomedisa/features/curvop_numba.py +149 -0
  20. biomedisa/features/django_env.py +171 -0
  21. biomedisa/features/keras_helper.py +1195 -0
  22. biomedisa/features/nc_reader.py +179 -0
  23. biomedisa/features/pid.py +52 -0
  24. biomedisa/features/process_image.py +251 -0
  25. biomedisa/features/pycuda_test.py +85 -0
  26. biomedisa/features/random_walk/__init__.py +0 -0
  27. biomedisa/features/random_walk/gpu_kernels.py +184 -0
  28. biomedisa/features/random_walk/pycuda_large.py +826 -0
  29. biomedisa/features/random_walk/pycuda_large_allx.py +806 -0
  30. biomedisa/features/random_walk/pycuda_small.py +414 -0
  31. biomedisa/features/random_walk/pycuda_small_allx.py +493 -0
  32. biomedisa/features/random_walk/pyopencl_large.py +760 -0
  33. biomedisa/features/random_walk/pyopencl_small.py +441 -0
  34. biomedisa/features/random_walk/rw_large.py +389 -0
  35. biomedisa/features/random_walk/rw_small.py +307 -0
  36. biomedisa/features/remove_outlier.py +396 -0
  37. biomedisa/features/split_volume.py +167 -0
  38. biomedisa/interpolation.py +369 -0
  39. biomedisa/mesh.py +403 -0
  40. biomedisa-24.5.23.dist-info/LICENSE +191 -0
  41. biomedisa-24.5.23.dist-info/METADATA +261 -0
  42. biomedisa-24.5.23.dist-info/RECORD +44 -0
  43. biomedisa-24.5.23.dist-info/WHEEL +5 -0
  44. biomedisa-24.5.23.dist-info/top_level.txt +1 -0
@@ -0,0 +1,261 @@
1
+ Metadata-Version: 2.1
2
+ Name: biomedisa
3
+ Version: 24.5.23
4
+ Summary: Segmentation of 3D volumetric image data
5
+ Author: Philipp Lösel
6
+ Author-email: philipp.loesel@anu.edu.au
7
+ Project-URL: Homepage, https://biomedisa.info
8
+ Project-URL: Issues, https://github.com/biomedisa/biomedisa/issues
9
+ Project-URL: GitHub, https://github.com/biomedisa/biomedisa
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+
17
+ [![biomedisa](https://raw.githubusercontent.com/biomedisa/biomedisa/master/biomedisa_app/static/biomedisa_logo.svg)](https://biomedisa.info)
18
+ -----------
19
+ - [Overview](#overview)
20
+ - [Hardware Requirements](#hardware-requirements)
21
+ - [Installation (command-line based)](#installation-command-line-based)
22
+ - [Installation (browser based)](#installation-browser-based)
23
+ - [Download Data](#download-data)
24
+ - [Revisions](#revisions)
25
+ - [Quickstart](#quickstart)
26
+ - [Smart Interpolation](#smart-interpolation)
27
+ - [Deep Learning](#deep-learning)
28
+ - [Mesh Generator](#mesh-generator)
29
+ - [Biomedisa Features](#biomedisa-features)
30
+ - [Authors](#authors)
31
+ - [FAQ](#faq)
32
+ - [Citation](#citation)
33
+ - [License](#license)
34
+
35
+ ## Overview
36
+ Biomedisa (https://biomedisa.info) is a free and easy-to-use open-source application for segmenting large volumetric images, e.g. CT and MRI scans, developed at [The Australian National University CTLab](https://ctlab.anu.edu.au/). Biomedisa's semi-automated segmentation is based on a smart interpolation of sparsely pre-segmented slices, taking into account the complete underlying image data. In addition, Biomedisa enables deep learning for the fully automated segmentation of series of similar samples. It can be used in combination with segmentation tools such as Amira/Avizo, ImageJ/Fiji and 3D Slicer. If you are using Biomedisa or the data for your research please cite: Lösel, P.D. et al. [Introducing Biomedisa as an open-source online platform for biomedical image segmentation.](https://www.nature.com/articles/s41467-020-19303-w) *Nat. Commun.* **11**, 5577 (2020).
37
+
38
+ ## Hardware Requirements
39
+ + One or more NVIDIA GPUs with compute capability 3.0 or higher or an Intel CPU
40
+
41
+ ## Installation (command-line based)
42
+ + [Ubuntu 22.04 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8_gpu_cli.md)
43
+ + [Ubuntu 22.04 + OpenCL + CPU (smart interpolation only and very slow)](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_opencl_cpu_cli.md)
44
+ + [Windows 10 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_cuda_gpu_cli.md)
45
+ + [Windows 10 + OpenCL + GPU (easy to install but lacks features like allaxis, smoothing, uncertainty, optimized GPU memory usage)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_opencl_gpu_cli.md)
46
+ + [Windows 10 + OpenCL + CPU (very slow)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_opencl_cpu_cli.md)
47
+
48
+ ## Installation (browser based)
49
+ + [Ubuntu 22.04](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8.md)
50
+
51
+ ## Download Data
52
+ + Download test data from our [gallery](https://biomedisa.info/gallery/)
53
+
54
+ ## Revisions
55
+ 24.5.22
56
+ + Pip is the preferred installation method
57
+ + Commands, module names and imports have been changed to conform to the Pip standard
58
+ + For versions <=23.9.1 please check [README](https://github.com/biomedisa/biomedisa/blob/master/README/deprecated/README_2023.09.1.md)
59
+
60
+ ## Quickstart
61
+ Install the Biomedisa package from the [Python Package Index](https://pypi.org/project/biomedisa/):
62
+ ```
63
+ python -m pip install -U biomedisa
64
+ ```
65
+ For smart interpolation and deep Learning modules, follow the installation instructions above.
66
+
67
+ ## Smart Interpolation
68
+ + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/smart_interpolation.md)
69
+
70
+ #### Python example
71
+ ```python
72
+ from biomedisa.features.biomedisa_helper import load_data, save_data
73
+ from biomedisa.interpolation import smart_interpolation
74
+
75
+ # load data
76
+ img, _ = load_data('Downloads/trigonopterus.tif')
77
+ labels, header = load_data('Downloads/labels.trigonopterus_smart.am')
78
+
79
+ # run smart interpolation with optional smoothing result
80
+ results = smart_interpolation(img, labels, smooth=100)
81
+
82
+ # get results
83
+ regular_result = results['regular']
84
+ smooth_result = results['smooth']
85
+
86
+ # save results
87
+ save_data('Downloads/final.trigonopterus.am', regular_result, header=header)
88
+ save_data('Downloads/final.trigonopterus.smooth.am', smooth_result, header=header)
89
+ ```
90
+
91
+ #### Command-line based
92
+ ```
93
+ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif
94
+ ```
95
+ If pre-segmentation is not exclusively in the XY plane:
96
+ ```
97
+ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif --allaxis
98
+ ```
99
+
100
+ ## Deep Learning
101
+ + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/deep_learning.md)
102
+
103
+ #### Python example (training)
104
+ ```python
105
+ from biomedisa.features.biomedisa_helper import load_data
106
+ from biomedisa.deeplearning import deep_learning
107
+
108
+ # load image data
109
+ img1, _ = load_data('Head1.am')
110
+ img2, _ = load_data('Head2.am')
111
+ img_data = [img1, img2]
112
+
113
+ # load label data and header information to be stored in the network file (optional)
114
+ label1, _ = load_data('Head1.labels.am')
115
+ label2, header, ext = load_data('Head2.labels.am',
116
+ return_extension=True)
117
+ label_data = [label1, label2]
118
+
119
+ # load validation data (optional)
120
+ img3, _ = load_data('Head3.am')
121
+ img4, _ = load_data('Head4.am')
122
+ label3, _ = load_data('Head3.labels.am')
123
+ label4, _ = load_data('Head4.labels.am')
124
+ val_img_data = [img3, img4]
125
+ val_label_data = [label3, label4]
126
+
127
+ # deep learning
128
+ deep_learning(img_data, label_data, train=True, batch_size=12,
129
+ val_img_data=val_img_data, val_label_data=val_label_data,
130
+ header=header, extension=ext, path_to_model='honeybees.h5')
131
+ ```
132
+
133
+ #### Command-line based (training)
134
+ Start training with a batch size of 12:
135
+ ```
136
+ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -bs=12
137
+ ```
138
+ Monitor training progress using validation data:
139
+ ```
140
+ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -vi=C:\Users\%USERNAME%\Downloads\val_img -vl=C:\Users\%USERNAME%\Downloads\val_labels
141
+ ```
142
+ If running into ResourceExhaustedError due to out of memory (OOM), try to use a smaller batch size.
143
+
144
+ #### Python example (prediction)
145
+ ```python
146
+ from biomedisa.features.biomedisa_helper import load_data, save_data
147
+ from biomedisa.deeplearning import deep_learning
148
+
149
+ # load data
150
+ img, _ = load_data('Head5.am')
151
+
152
+ # deep learning
153
+ results = deep_learning(img, predict=True,
154
+ path_to_model='honeybees.h5', batch_size=6)
155
+
156
+ # save result
157
+ save_data('final.Head5.am', results['regular'], results['header'])
158
+ ```
159
+
160
+ #### Command-line based (prediction)
161
+ ```
162
+ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\testing_axial_crop_pat13.nii.gz C:\Users\%USERNAME%\Downloads\heart.h5 -p
163
+ ```
164
+
165
+ ## Mesh Generator
166
+ + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/save_mesh.md)
167
+
168
+ #### Python example
169
+ Create STL mesh from segmentation (label values are saved as attributes)
170
+ ```python
171
+ from biomedisa.features.biomedisa_helper import load_data, save_data
172
+ from biomedisa.mesh import get_voxel_spacing, save_mesh
173
+
174
+ # load segmentation
175
+ data, header, extension = load_data('final.Head5.am', return_extension=True)
176
+
177
+ # get voxel spacing
178
+ x_res, y_res, z_res = get_voxel_spacing(header, data, extension)
179
+ print(f'Voxel spacing: x_spacing, y_spacing, z_spacing = {x_res}, {y_res}, {z_res}')
180
+
181
+ # save stl file
182
+ save_mesh('final.Head5.stl', data, x_res, y_res, z_res, poly_reduction=0.9, smoothing_iterations=15)
183
+ ```
184
+
185
+ #### Command-line based
186
+ ```
187
+ python -m biomedisa.mesh 'final.Head5.am'
188
+ ```
189
+
190
+ ## Biomedisa Features
191
+
192
+ #### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
193
+ For DICOM, PNG files, or similar formats, file path must reference either a directory or a ZIP file containing the image slices.
194
+ ```python
195
+ from biomedisa.features.biomedisa_helper import load_data, save_data
196
+
197
+ # load data as numpy array
198
+ data, header = load_data('temp.tif')
199
+
200
+ # save data (for TIFF, header=None)
201
+ save_data('temp.tif', data, header)
202
+ ```
203
+
204
+ #### Resize data
205
+ ```python
206
+ from biomedisa.features.biomedisa_helper import img_resize
207
+
208
+ # resize image data
209
+ zsh, ysh, xsh = data.shape
210
+ new_zsh, new_ysh, new_xsh = zsh//2, ysh//2, xsh//2
211
+ data = img_resize(data, new_zsh, new_ysh, new_xsh)
212
+
213
+ # resize label data
214
+ label_data = img_resize(label_data, new_zsh, new_ysh, new_xsh, labels=True)
215
+ ```
216
+
217
+ #### Remove outliers and fill holes
218
+ ```python
219
+ from biomedisa.features.biomedisa_helper import clean, fill
220
+
221
+ # delete outliers smaller than 90% of the segment
222
+ label_data = clean(label_data, 0.9)
223
+
224
+ # fill holes
225
+ label_data = fill(label_data, 0.9)
226
+ ```
227
+
228
+ #### Accuracy assessment
229
+ ```python
230
+ from biomedisa.features.biomedisa_helper import Dice_score, ASSD
231
+ dice = Dice_score(ground_truth, result)
232
+ assd = ASSD(ground_truth, result)
233
+ ```
234
+
235
+ ## Authors
236
+
237
+ * **Philipp D. Lösel**
238
+
239
+ See also the list of [contributors](https://github.com/biomedisa/biomedisa/blob/master/credits.md) who participated in this project.
240
+
241
+ ## FAQ
242
+ Frequently asked questions can be found at: https://biomedisa.info/faq/.
243
+
244
+ ## Citation
245
+
246
+ If you use Biomedisa or the data, please cite the following paper:
247
+
248
+ `Lösel, P.D. et al. Introducing Biomedisa as an open-source online platform for biomedical image segmentation. Nat. Commun. 11, 5577 (2020).` https://doi.org/10.1038/s41467-020-19303-w
249
+
250
+ If you use Biomedisa's Deep Learning, you may also cite:
251
+
252
+ `Lösel, P.D. et al. Natural variability in bee brain size and symmetry revealed by micro-CT imaging and deep learning. PLoS Comput. Biol. 19, e1011529 (2023).` https://doi.org/10.1371/journal.pcbi.1011529
253
+
254
+ If you use Biomedisa's Smart Interpolation, you can also cite the initial description of this method:
255
+
256
+ `Lösel, P. & Heuveline, V. Enhancing a diffusion algorithm for 4D image segmentation using local information. Proc. SPIE 9784, 97842L (2016).` https://doi.org/10.1117/12.2216202
257
+
258
+ ## License
259
+
260
+ This project is covered under the **EUROPEAN UNION PUBLIC LICENCE v. 1.2 (EUPL)**.
261
+
@@ -0,0 +1,44 @@
1
+ biomedisa/__init__.py,sha256=hw4mzEjGFXm-vxus2DBfKFW0nKoG0ibL5SH6ShfchrY,1526
2
+ biomedisa/__main__.py,sha256=a1--8vhtztWEloHVtbM43FZLCfrFo4BELgdsgtWE8ls,536
3
+ biomedisa/deeplearning.py,sha256=UG5baX58CrO8YXe9pU6_Bp2OOvbC74LQw4S33HqM2iA,27828
4
+ biomedisa/interpolation.py,sha256=R8UbBWt7vOuiQCPSeNIpEY0_yfQUg1oBfhAjXi91Hl4,17253
5
+ biomedisa/mesh.py,sha256=glvpTN0PPByb5j2IbLCdWQtc5O4VT-Pwu3en8EaYyTo,15819
6
+ biomedisa/features/DataGenerator.py,sha256=bGys6UZ0bnKb_k1Y3Spo6MNPk_goSAmptdZnI39smaw,12770
7
+ biomedisa/features/DataGeneratorCrop.py,sha256=23R4Z-8tB1CsjYTYfhHGovlJpAny_q9OV9hq8kc2GJg,5454
8
+ biomedisa/features/PredictDataGenerator.py,sha256=JH8SPGQm-Y7_Drec2fw3jBUupvpIkQ1FvkDXP7mUjDY,4074
9
+ biomedisa/features/PredictDataGeneratorCrop.py,sha256=HF5tJbGtlJMHr7lMT9IiIdLG2CTjXstbKoOjlZJ93Is,3431
10
+ biomedisa/features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ biomedisa/features/active_contour.py,sha256=n5_vAD8jvQjU6fQ6A9hxjSmtkLLo_1fl0S5q1H2pmVg,18096
12
+ biomedisa/features/assd.py,sha256=q9NUQXEoA4Pi3d8b5fmys615CWu06Sm0N9-OGwJOFnw,6537
13
+ biomedisa/features/biomedisa_helper.py,sha256=iLbt4RpCU3EK51uiMefkM0321AgBdeLgrT-X4d--YJY,32250
14
+ biomedisa/features/create_slices.py,sha256=tLDJmuJFN8teTiCYvMauExfVzT2ZUF28VcPXpo4sOsE,13001
15
+ biomedisa/features/crop_helper.py,sha256=si72n9Q-C7U0cXYOD9Ux2UqIbZdXbZSOARBYDeqRggI,24533
16
+ biomedisa/features/curvop_numba.py,sha256=AjKQJcUBoURTB8pq1HmugQYpBwBELthhcEu51_r_xPI,7049
17
+ biomedisa/features/django_env.py,sha256=pdiPcBpqu1BWuyvh-palIGVwHFaY-leQ4Gatlbm8hIg,8942
18
+ biomedisa/features/keras_helper.py,sha256=muPwb_W7O63exzWACJ4oLdAc-AQitcxLeNwgHvxyhuE,50488
19
+ biomedisa/features/nc_reader.py,sha256=RoRMwu3ELSNfoV3qZtaT2OWACnXb2EhNFu_DAF1T93o,7406
20
+ biomedisa/features/pid.py,sha256=Jmn1VIp0fBlgBrqZ-yUIQVVb5-NAxNBdibXALVr2PPI,2545
21
+ biomedisa/features/process_image.py,sha256=VtS3fGDvglqJiiJLPK1toe76J58j914NJ8XQKg3CRwo,11091
22
+ biomedisa/features/pycuda_test.py,sha256=UGAGIz_dgcCJkzjyCqnMlflp-WJPzpCtFQmE9C5DwIo,3275
23
+ biomedisa/features/remove_outlier.py,sha256=XhbFPkazMmEUZiP0FERdCkrXaLhwO095x4wcn-B3SdU,16756
24
+ biomedisa/features/split_volume.py,sha256=UgMpHhZPvH90xFo-mJ0Oc0tBXbrf8FQF0kzVySAlO8g,8917
25
+ biomedisa/features/amira_to_np/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ biomedisa/features/amira_to_np/amira_data_stream.py,sha256=JrZTyKP01CKDFB5d9BlGtSFwBgoAo0AJeAmn3pADH88,32618
27
+ biomedisa/features/amira_to_np/amira_grammar.py,sha256=z1yajLHmn-GDb-rzZ5iHlKmPZDDbO9fNqP2jXf8z3KE,14324
28
+ biomedisa/features/amira_to_np/amira_header.py,sha256=eWHECsTx3ls8c0RHjy5xO4s-BehRC-96wONj7n9IzrY,11553
29
+ biomedisa/features/amira_to_np/amira_helper.py,sha256=giuZKkX8eI_2MVAy3wwBvcmmmDxSOo8k9eAzu2QA6uo,2218
30
+ biomedisa/features/random_walk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
+ biomedisa/features/random_walk/gpu_kernels.py,sha256=IQDjq1H6iJCwdS-LCWx2S6F1TMEXjrN2veLcTLCeCoI,7191
32
+ biomedisa/features/random_walk/pycuda_large.py,sha256=Vfvd0uFRB-qLReDFKIyAAhdWDLflKMUEUAm_ZXSkPZs,32917
33
+ biomedisa/features/random_walk/pycuda_large_allx.py,sha256=zjy1Ai8D-foXjaT-6G33vGMANS1i00BBbLCTAMUfP5c,30677
34
+ biomedisa/features/random_walk/pycuda_small.py,sha256=rSwjq2DdtGyNGH1_EfiRQGSgEsCZqvVUrh1UN64AEc8,15786
35
+ biomedisa/features/random_walk/pycuda_small_allx.py,sha256=z4koEQNWqy3EYOhHbMkO8sP6mpl6R7i8mM6OEQQ4kUQ,18225
36
+ biomedisa/features/random_walk/pyopencl_large.py,sha256=q79AxG3p3qFjxfiAZfUK9I5BAYT2prq48yEEmpP1Yjk,31015
37
+ biomedisa/features/random_walk/pyopencl_small.py,sha256=opNlS-qzOa9qWafBNJdvf6r1aRAFf7_JXf6ISDnkdXE,17068
38
+ biomedisa/features/random_walk/rw_large.py,sha256=ZnITvk00Y11ZZlGuBRaJO1EwU0wYBdEwdpj9vvXCqF4,19805
39
+ biomedisa/features/random_walk/rw_small.py,sha256=RPzZe24YrEwYelJukDjvqaoD_SyhgdriEi7uV3kZGXI,14881
40
+ biomedisa-24.5.23.dist-info/LICENSE,sha256=sehayP6UhydNnmstfL4yFR3genMRdpuUh6uZVWJN1H0,14152
41
+ biomedisa-24.5.23.dist-info/METADATA,sha256=XIEKdnTY54QTALYPtNambyN7NP7_e76S2Mo99Ubifv8,10475
42
+ biomedisa-24.5.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
+ biomedisa-24.5.23.dist-info/top_level.txt,sha256=opsf1Eb4vCguPSxev4HHSeiUKCccT_C_RcUCdAYbHWQ,10
44
+ biomedisa-24.5.23.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.43.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ biomedisa