biomedisa 2024.5.19__py3-none-any.whl → 2024.5.21__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 (45) hide show
  1. biomedisa/__init__.py +3 -7
  2. biomedisa/deeplearning.py +10 -12
  3. biomedisa/{biomedisa_features → features}/DataGenerator.py +1 -1
  4. biomedisa/{biomedisa_features → features}/DataGeneratorCrop.py +1 -1
  5. biomedisa/{biomedisa_features → features}/PredictDataGenerator.py +1 -1
  6. biomedisa/{biomedisa_features → features}/PredictDataGeneratorCrop.py +1 -1
  7. biomedisa/{biomedisa_features → features}/active_contour.py +15 -18
  8. biomedisa/{biomedisa_features → features}/assd.py +1 -1
  9. biomedisa/{biomedisa_features → features}/biomedisa_helper.py +7 -7
  10. biomedisa/{biomedisa_features → features}/create_slices.py +2 -4
  11. biomedisa/{biomedisa_features → features}/crop_helper.py +5 -5
  12. biomedisa/{biomedisa_features → features}/curvop_numba.py +1 -1
  13. biomedisa/{biomedisa_features → features}/django_env.py +9 -10
  14. biomedisa/{biomedisa_features → features}/keras_helper.py +6 -7
  15. biomedisa/{biomedisa_features → features}/nc_reader.py +1 -1
  16. biomedisa/{biomedisa_features → features}/pid.py +2 -2
  17. biomedisa/{biomedisa_features → features}/process_image.py +12 -14
  18. biomedisa/{biomedisa_features → features}/pycuda_test.py +2 -1
  19. biomedisa/{biomedisa_features → features}/random_walk/gpu_kernels.py +2 -1
  20. biomedisa/{biomedisa_features → features}/random_walk/pycuda_large.py +2 -2
  21. biomedisa/{biomedisa_features → features}/random_walk/pycuda_large_allx.py +2 -2
  22. biomedisa/{biomedisa_features → features}/random_walk/pycuda_small.py +2 -2
  23. biomedisa/{biomedisa_features → features}/random_walk/pycuda_small_allx.py +2 -2
  24. biomedisa/{biomedisa_features → features}/random_walk/pyopencl_large.py +1 -1
  25. biomedisa/{biomedisa_features → features}/random_walk/pyopencl_small.py +1 -1
  26. biomedisa/{biomedisa_features → features}/random_walk/rw_large.py +11 -11
  27. biomedisa/{biomedisa_features → features}/random_walk/rw_small.py +12 -12
  28. biomedisa/{biomedisa_features → features}/remove_outlier.py +13 -16
  29. biomedisa/features/split_volume.py +167 -0
  30. biomedisa/interpolation.py +10 -12
  31. biomedisa/mesh.py +9 -12
  32. {biomedisa-2024.5.19.dist-info → biomedisa-2024.5.21.dist-info}/METADATA +34 -51
  33. biomedisa-2024.5.21.dist-info/RECORD +44 -0
  34. biomedisa/biomedisa_features/split_volume.py +0 -274
  35. biomedisa-2024.5.19.dist-info/RECORD +0 -44
  36. /biomedisa/{biomedisa_features → features}/__init__.py +0 -0
  37. /biomedisa/{biomedisa_features → features}/amira_to_np/__init__.py +0 -0
  38. /biomedisa/{biomedisa_features → features}/amira_to_np/amira_data_stream.py +0 -0
  39. /biomedisa/{biomedisa_features → features}/amira_to_np/amira_grammar.py +0 -0
  40. /biomedisa/{biomedisa_features → features}/amira_to_np/amira_header.py +0 -0
  41. /biomedisa/{biomedisa_features → features}/amira_to_np/amira_helper.py +0 -0
  42. /biomedisa/{biomedisa_features → features}/random_walk/__init__.py +0 -0
  43. {biomedisa-2024.5.19.dist-info → biomedisa-2024.5.21.dist-info}/LICENSE +0 -0
  44. {biomedisa-2024.5.19.dist-info → biomedisa-2024.5.21.dist-info}/WHEEL +0 -0
  45. {biomedisa-2024.5.19.dist-info → biomedisa-2024.5.21.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: biomedisa
3
- Version: 2024.5.19
3
+ Version: 2024.5.21
4
4
  Summary: Segmentation of 3D volumetric image data
5
5
  Author: Philipp Lösel
6
6
  Author-email: philipp.loesel@anu.edu.au
@@ -14,48 +14,53 @@ Requires-Python: >=3.8
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
16
 
17
- [![biomedisa](biomedisa_app/static/biomedisa_logo.svg)](https://biomedisa.info)
17
+ [![biomedisa](https://raw.githubusercontent.com/biomedisa/biomedisa/master/biomedisa_app/static/biomedisa_logo.svg)](https://biomedisa.info)
18
18
  -----------
19
19
  - [Overview](#overview)
20
20
  - [Hardware Requirements](#hardware-requirements)
21
21
  - [Installation (command-line based)](#installation-command-line-based)
22
22
  - [Installation (browser based)](#installation-browser-based)
23
23
  - [Download Data](#download-data)
24
+ - [Revisions](#revisions)
24
25
  - [Smart Interpolation](#smart-interpolation)
25
26
  - [Deep Learning](#deep-learning)
26
27
  - [Biomedisa Features](#biomedisa-features)
27
- - [Update Biomedisa](#update-biomedisa)
28
- - [Releases](#releases)
29
28
  - [Authors](#authors)
30
29
  - [FAQ](#faq)
31
30
  - [Citation](#citation)
32
31
  - [License](#license)
33
32
 
34
- # Overview
33
+ ## Overview
35
34
  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).
36
35
 
37
- # Hardware Requirements
36
+ ## Hardware Requirements
38
37
  + One or more NVIDIA GPUs with compute capability 3.0 or higher or an Intel CPU.
39
38
 
40
- # Installation (command-line based)
39
+ ## Installation (command-line based)
41
40
  + [Ubuntu 22.04 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8_gpu_cli.md)
42
41
  + [Ubuntu 22.04 + OpenCL + CPU (smart interpolation only and very slow)](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_opencl_cpu_cli.md)
43
42
  + [Windows 10 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_cuda_gpu_cli.md)
44
43
  + [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)
45
44
  + [Windows 10 + OpenCL + CPU (very slow)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_opencl_cpu_cli.md)
46
45
 
47
- # Installation (browser based)
46
+ ## Installation (browser based)
48
47
  + [Ubuntu 22.04](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8.md)
49
48
 
50
- # Download Data
49
+ ## Download Data
51
50
  + Download the data from our [gallery](https://biomedisa.info/gallery/)
52
51
 
53
- # Smart Interpolation
52
+ ## Revisions
53
+ 2024.05.21
54
+ + Pip is the preferred installation method
55
+ + Commands, module names and imports have been changed to conform to the Pip standard
56
+ + For versions <=2023.09.1 please check [README](https://github.com/biomedisa/biomedisa/blob/master/README/deprecated/README_2023.09.1.md)
57
+
58
+ ## Smart Interpolation
54
59
  + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/smart_interpolation.md)
55
60
 
56
61
  #### Python example
57
62
  ```python
58
- from biomedisa.biomedisa_features.biomedisa_helper import load_data, save_data
63
+ from biomedisa.features.biomedisa_helper import load_data, save_data
59
64
  from biomedisa.interpolation import smart_interpolation
60
65
 
61
66
  # load data
@@ -77,14 +82,17 @@ save_data('Downloads/final.trigonopterus.smooth.am', smooth_result, header=heade
77
82
  #### Command-line based
78
83
  ```
79
84
  python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif
85
+
86
+ # if pre-segmentation is not exclusively in the XY plane
87
+ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif --allaxis
80
88
  ```
81
89
 
82
- # Deep Learning
90
+ ## Deep Learning
83
91
  + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/deep_learning.md)
84
92
 
85
93
  #### Python example (training)
86
94
  ```python
87
- from biomedisa.biomedisa_features.biomedisa_helper import load_data
95
+ from biomedisa.features.biomedisa_helper import load_data
88
96
  from biomedisa.deeplearning import deep_learning
89
97
 
90
98
  # load image data
@@ -115,16 +123,16 @@ deep_learning(img_data, label_data, train=True, batch_size=12,
115
123
  #### Command-line based (training)
116
124
  ```
117
125
  # start training with a batch size of 12
118
- python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -bs 12
126
+ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -bs=12
119
127
 
120
128
  # validation (optional)
121
- 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
129
+ 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
122
130
  ```
123
131
  If running into ResourceExhaustedError due to out of memory (OOM), try to use smaller batch size.
124
132
 
125
133
  #### Python example (prediction)
126
134
  ```python
127
- from biomedisa.biomedisa_features.biomedisa_helper import load_data, save_data
135
+ from biomedisa.features.biomedisa_helper import load_data, save_data
128
136
  from biomedisa.deeplearning import deep_learning
129
137
 
130
138
  # load data
@@ -143,11 +151,11 @@ save_data('final.Head5.am', results['regular'], results['header'])
143
151
  python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\testing_axial_crop_pat13.nii.gz C:\Users\%USERNAME%\Downloads\heart.h5 -p
144
152
  ```
145
153
 
146
- # Biomedisa Features
154
+ ## Biomedisa Features
147
155
 
148
156
  #### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
149
157
  ```python
150
- from biomedisa.biomedisa_features.biomedisa_helper import load_data, save_data
158
+ from biomedisa.features.biomedisa_helper import load_data, save_data
151
159
 
152
160
  # load data as numpy array
153
161
  # for DICOM, PNG files, or similar formats, 'path_to_data' must reference
@@ -160,7 +168,7 @@ save_data(path_to_data, data, header)
160
168
 
161
169
  #### Create STL mesh from segmentation (label values are saved as attributes)
162
170
  ```python
163
- from biomedisa.biomedisa_features.biomedisa_helper import load_data, save_data
171
+ from biomedisa.features.biomedisa_helper import load_data, save_data
164
172
  from biomedisa.mesh import get_voxel_spacing, save_mesh
165
173
 
166
174
  # load segmentation
@@ -193,7 +201,7 @@ python -m biomedisa.mesh <path_to_data>
193
201
 
194
202
  #### Resize data
195
203
  ```python
196
- from biomedisa.biomedisa_features.biomedisa_helper import img_resize
204
+ from biomedisa.features.biomedisa_helper import img_resize
197
205
 
198
206
  # resize image data
199
207
  zsh, ysh, xsh = data.shape
@@ -206,7 +214,7 @@ label_data = img_resize(label_data, new_zsh, new_ysh, new_xsh, labels=True)
206
214
 
207
215
  #### Remove outliers and fill holes
208
216
  ```python
209
- from biomedisa.biomedisa_features.biomedisa_helper import clean, fill
217
+ from biomedisa.features.biomedisa_helper import clean, fill
210
218
 
211
219
  # delete outliers smaller than 90% of the segment
212
220
  label_data = clean(label_data, 0.9)
@@ -217,46 +225,21 @@ label_data = fill(label_data, 0.9)
217
225
 
218
226
  #### Accuracy assessment
219
227
  ```python
220
- from biomedisa.biomedisa_features.biomedisa_helper import Dice_score, ASSD
228
+ from biomedisa.features.biomedisa_helper import Dice_score, ASSD
221
229
  dice = Dice_score(ground_truth, result)
222
230
  assd = ASSD(ground_truth, result)
223
231
  ```
224
232
 
225
- # Update Biomedisa
226
- If you installed Biomedisa via Pip
227
- ```
228
- pip install --upgrade biomedisa
229
- ```
230
- If you used `git clone`, change to the Biomedisa directory and make a pull request
231
- ```
232
- cd git/biomedisa
233
- git pull
234
- ```
235
-
236
- If you installed the browser based version of Biomedisa (including MySQL database), you also need to update the database
237
- ```
238
- python manage.py migrate
239
- ```
240
-
241
- If you installed an [Apache Server](https://github.com/biomedisa/biomedisa/blob/master/README/APACHE_SERVER.md), you need to restart the server
242
- ```
243
- sudo service apache2 restart
244
- ```
245
-
246
- # Releases
247
-
248
- For the versions available, see the [list of releases](https://github.com/biomedisa/biomedisa/releases).
249
-
250
- # Authors
233
+ ## Authors
251
234
 
252
235
  * **Philipp D. Lösel**
253
236
 
254
237
  See also the list of [contributors](https://github.com/biomedisa/biomedisa/blob/master/credits.md) who participated in this project.
255
238
 
256
- # FAQ
239
+ ## FAQ
257
240
  Frequently asked questions can be found at: https://biomedisa.info/faq/.
258
241
 
259
- # Citation
242
+ ## Citation
260
243
 
261
244
  If you use Biomedisa or the data, please cite the following paper:
262
245
 
@@ -270,7 +253,7 @@ If you use Biomedisa's Smart Interpolation, you can also cite the initial descri
270
253
 
271
254
  `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
272
255
 
273
- # License
256
+ ## License
274
257
 
275
258
  This project is covered under the **EUROPEAN UNION PUBLIC LICENCE v. 1.2 (EUPL)**.
276
259
 
@@ -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=dVwLkijm0ibtn6zUUV3t2WK6Fzvks4VlgzKNLqzDpAQ,27064
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=1rM5-fMj71oW99VxEt2U3SZey1EbO9q5CNVJlmN6YxA,50250
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-2024.5.21.dist-info/LICENSE,sha256=sehayP6UhydNnmstfL4yFR3genMRdpuUh6uZVWJN1H0,14152
41
+ biomedisa-2024.5.21.dist-info/METADATA,sha256=GJ9BXl6MH84zMYZrpShMBkSDZx50dYIKWDE97EWj1-w,10465
42
+ biomedisa-2024.5.21.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
+ biomedisa-2024.5.21.dist-info/top_level.txt,sha256=opsf1Eb4vCguPSxev4HHSeiUKCccT_C_RcUCdAYbHWQ,10
44
+ biomedisa-2024.5.21.dist-info/RECORD,,
@@ -1,274 +0,0 @@
1
- ##########################################################################
2
- ## ##
3
- ## Copyright (c) 2024 Philipp Lösel. All rights reserved. ##
4
- ## ##
5
- ## This file is part of the open source project biomedisa. ##
6
- ## ##
7
- ## Licensed under the European Union Public Licence (EUPL) ##
8
- ## v1.2, or - as soon as they will be approved by the ##
9
- ## European Commission - subsequent versions of the EUPL; ##
10
- ## ##
11
- ## You may redistribute it and/or modify it under the terms ##
12
- ## of the EUPL v1.2. You may not use this work except in ##
13
- ## compliance with this Licence. ##
14
- ## ##
15
- ## You can obtain a copy of the Licence at: ##
16
- ## ##
17
- ## https://joinup.ec.europa.eu/page/eupl-text-11-12 ##
18
- ## ##
19
- ## Unless required by applicable law or agreed to in ##
20
- ## writing, software distributed under the Licence is ##
21
- ## distributed on an "AS IS" basis, WITHOUT WARRANTIES ##
22
- ## OR CONDITIONS OF ANY KIND, either express or implied. ##
23
- ## ##
24
- ## See the Licence for the specific language governing ##
25
- ## permissions and limitations under the Licence. ##
26
- ## ##
27
- ##########################################################################
28
-
29
- import sys, os
30
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
31
- sys.path.append(BASE_DIR)
32
- from biomedisa_features.biomedisa_helper import load_data, save_data
33
- import numpy as np
34
- import subprocess
35
- import platform
36
- import glob
37
-
38
- if __name__ == '__main__':
39
-
40
- # path to data
41
- path_to_data = sys.argv[1]
42
- path_to_labels = sys.argv[2]
43
-
44
- # get arguments
45
- nump = 1
46
- smooth = 0
47
- overlap = 100
48
- sub_z, sub_y, sub_x = 1, 1, 1
49
- for i, val in enumerate(sys.argv):
50
- if val in ['--split_z','-sz']:
51
- sub_z = max(int(sys.argv[i+1]), 1)
52
- if val in ['--split_y','-sy']:
53
- sub_y = max(int(sys.argv[i+1]), 1)
54
- if val in ['--split_x','-sx']:
55
- sub_x = max(int(sys.argv[i+1]), 1)
56
- if val in ['--overlap','-ol']:
57
- overlap = max(int(sys.argv[i+1]), 0)
58
- if val in ['-n','-np']:
59
- nump = max(int(sys.argv[i+1]), 1)
60
- if val in ['--smooth','-s']:
61
- smooth = int(sys.argv[i+1])
62
- uq = True if any(x in sys.argv for x in ['--uncertainty','-uq']) else False
63
- allx = 1 if '-allx' in sys.argv else 0
64
-
65
- # base directory
66
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
67
-
68
- # clean tmp folder
69
- filelist = glob.glob(BASE_DIR+'/tmp/*.tif')
70
- for f in filelist:
71
- os.remove(f)
72
-
73
- # data shape
74
- data, _ = load_data(path_to_data, 'split_volume')
75
- shape = np.copy(np.array(data.shape), order='C')
76
- zsh, ysh, xsh = shape
77
- del data
78
-
79
- # split volume
80
- sub_size_z = np.ceil(zsh / sub_z)
81
- sub_size_y = np.ceil(ysh / sub_y)
82
- sub_size_x = np.ceil(xsh / sub_x)
83
-
84
- # iterate over subvolumes
85
- for sub_z_i in range(sub_z):
86
- for sub_y_i in range(sub_y):
87
- for sub_x_i in range(sub_x):
88
- subvolume = sub_z_i*sub_y*sub_x + sub_y_i*sub_x + sub_x_i + 1
89
- print('Subvolume:', subvolume, '/', sub_z*sub_y*sub_x)
90
-
91
- # determine z subvolume
92
- blockmin_z = int(sub_z_i * sub_size_z)
93
- blockmax_z = int((sub_z_i+1) * sub_size_z)
94
- datamin_z = max(blockmin_z - overlap, 0)
95
- datamax_z = min(blockmax_z + overlap, zsh)
96
-
97
- # determine y subvolume
98
- blockmin_y = int(sub_y_i * sub_size_y)
99
- blockmax_y = int((sub_y_i+1) * sub_size_y)
100
- datamin_y = max(blockmin_y - overlap, 0)
101
- datamax_y = min(blockmax_y + overlap, ysh)
102
-
103
- # determine x subvolume
104
- blockmin_x = int(sub_x_i * sub_size_x)
105
- blockmax_x = int((sub_x_i+1) * sub_size_x)
106
- datamin_x = max(blockmin_x - overlap, 0)
107
- datamax_x = min(blockmax_x + overlap, xsh)
108
-
109
- # extract image subvolume
110
- data, _ = load_data(path_to_data, 'split_volume')
111
- save_data(BASE_DIR+f'/tmp/sub_volume_{subvolume}.tif', data[datamin_z:datamax_z,datamin_y:datamax_y,datamin_x:datamax_x], False)
112
- del data
113
-
114
- # extract label subvolume
115
- labelData, header, final_image_type = load_data(path_to_labels, 'split_volume', True)
116
- save_data(BASE_DIR+'/tmp/labels.sub_volume.tif', labelData[datamin_z:datamax_z,datamin_y:datamax_y,datamin_x:datamax_x])
117
- del labelData
118
-
119
- # configure command
120
- cmd = ['mpiexec', '-np', f'{nump}', 'python3', 'biomedisa_interpolation.py', BASE_DIR+f'/tmp/sub_volume_{subvolume}.tif', BASE_DIR+'/tmp/labels.sub_volume.tif', '-s', f'{smooth}']
121
- if uq:
122
- cmd.append('-uq')
123
- if allx:
124
- cmd.append('-allx')
125
- cwd = BASE_DIR + '/demo/'
126
-
127
- # run segmentation
128
- if platform.system() == 'Windows':
129
- cmd[3] = 'python'
130
- cmd.insert(4, '-u')
131
- p = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE)
132
- for line in iter(p.stdout.readline, b''):
133
- line = str(line,'utf-8')
134
- print(line.rstrip())
135
- p.stdout.close()
136
- else:
137
- p = subprocess.Popen(cmd, cwd=cwd)
138
- p.wait()
139
-
140
- # remove tmp files
141
- os.remove(BASE_DIR+f'/tmp/sub_volume_{subvolume}.tif')
142
- os.remove(BASE_DIR+'/tmp/labels.sub_volume.tif')
143
-
144
- # create path_to_final
145
- filename, extension = os.path.splitext(os.path.basename(path_to_data))
146
- if extension == '.gz':
147
- filename = filename[:-4]
148
- filename = 'final.' + filename
149
- path_to_final = path_to_data.replace(os.path.basename(path_to_data), filename + final_image_type)
150
-
151
- # path_to_uq and path_to_smooth
152
- filename, extension = os.path.splitext(path_to_final)
153
- if extension == '.gz':
154
- filename = filename[:-4]
155
- path_to_smooth = filename + '.smooth' + final_image_type
156
- path_to_uq = filename + '.uncertainty.tif'
157
-
158
- # iterate over subvolumes
159
- final = np.zeros((zsh, ysh, xsh), dtype=np.uint8)
160
- for sub_z_i in range(sub_z):
161
- for sub_y_i in range(sub_y):
162
- for sub_x_i in range(sub_x):
163
- subvolume = sub_z_i*sub_y*sub_x + sub_y_i*sub_x + sub_x_i + 1
164
- print('Subvolume:', subvolume, '/', sub_z*sub_y*sub_x)
165
-
166
- # determine z subvolume
167
- blockmin_z = int(sub_z_i * sub_size_z)
168
- blockmax_z = int((sub_z_i+1) * sub_size_z)
169
- datamin_z = max(blockmin_z - overlap, 0)
170
- datamax_z = min(blockmax_z + overlap, zsh)
171
-
172
- # determine y subvolume
173
- blockmin_y = int(sub_y_i * sub_size_y)
174
- blockmax_y = int((sub_y_i+1) * sub_size_y)
175
- datamin_y = max(blockmin_y - overlap, 0)
176
- datamax_y = min(blockmax_y + overlap, ysh)
177
-
178
- # determine x subvolume
179
- blockmin_x = int(sub_x_i * sub_size_x)
180
- blockmax_x = int((sub_x_i+1) * sub_size_x)
181
- datamin_x = max(blockmin_x - overlap, 0)
182
- datamax_x = min(blockmax_x + overlap, xsh)
183
-
184
- # load subvolume
185
- path_to_subvolume = BASE_DIR+f'/tmp/final.sub_volume_{subvolume}.tif'
186
- if os.path.isfile(path_to_subvolume):
187
- tmp, _ = load_data(path_to_subvolume)
188
- final[blockmin_z:blockmax_z,blockmin_y:blockmax_y,blockmin_x:blockmax_x] \
189
- = tmp[blockmin_z-datamin_z:blockmax_z-datamin_z,blockmin_y-datamin_y:blockmax_y-datamin_y,blockmin_x-datamin_x:blockmax_x-datamin_x]
190
- os.remove(path_to_subvolume)
191
-
192
- # save result
193
- save_data(path_to_final, final, header)
194
-
195
- # iterate over subvolumes (smooth)
196
- smooth = 0
197
- final.fill(0)
198
- for sub_z_i in range(sub_z):
199
- for sub_y_i in range(sub_y):
200
- for sub_x_i in range(sub_x):
201
- subvolume = sub_z_i*sub_y*sub_x + sub_y_i*sub_x + sub_x_i + 1
202
- print('Subvolume:', subvolume, '/', sub_z*sub_y*sub_x)
203
-
204
- # determine z subvolume
205
- blockmin_z = int(sub_z_i * sub_size_z)
206
- blockmax_z = int((sub_z_i+1) * sub_size_z)
207
- datamin_z = max(blockmin_z - overlap, 0)
208
- datamax_z = min(blockmax_z + overlap, zsh)
209
-
210
- # determine y subvolume
211
- blockmin_y = int(sub_y_i * sub_size_y)
212
- blockmax_y = int((sub_y_i+1) * sub_size_y)
213
- datamin_y = max(blockmin_y - overlap, 0)
214
- datamax_y = min(blockmax_y + overlap, ysh)
215
-
216
- # determine x subvolume
217
- blockmin_x = int(sub_x_i * sub_size_x)
218
- blockmax_x = int((sub_x_i+1) * sub_size_x)
219
- datamin_x = max(blockmin_x - overlap, 0)
220
- datamax_x = min(blockmax_x + overlap, xsh)
221
-
222
- # load subvolume
223
- path_to_subvolume = BASE_DIR+f'/tmp/final.sub_volume_{subvolume}.smooth.tif'
224
- if os.path.isfile(path_to_subvolume):
225
- tmp, _ = load_data(path_to_subvolume)
226
- final[blockmin_z:blockmax_z,blockmin_y:blockmax_y,blockmin_x:blockmax_x] \
227
- = tmp[blockmin_z-datamin_z:blockmax_z-datamin_z,blockmin_y-datamin_y:blockmax_y-datamin_y,blockmin_x-datamin_x:blockmax_x-datamin_x]
228
- os.remove(path_to_subvolume)
229
- smooth = 1
230
-
231
- # save result
232
- if smooth:
233
- save_data(path_to_smooth, final, header)
234
-
235
- # iterate over subvolumes (uncertainty)
236
- uncertainty = 0
237
- final.fill(0)
238
- for sub_z_i in range(sub_z):
239
- for sub_y_i in range(sub_y):
240
- for sub_x_i in range(sub_x):
241
- subvolume = sub_z_i*sub_y*sub_x + sub_y_i*sub_x + sub_x_i + 1
242
- print('Subvolume:', subvolume, '/', sub_z*sub_y*sub_x)
243
-
244
- # determine z subvolume
245
- blockmin_z = int(sub_z_i * sub_size_z)
246
- blockmax_z = int((sub_z_i+1) * sub_size_z)
247
- datamin_z = max(blockmin_z - overlap, 0)
248
- datamax_z = min(blockmax_z + overlap, zsh)
249
-
250
- # determine y subvolume
251
- blockmin_y = int(sub_y_i * sub_size_y)
252
- blockmax_y = int((sub_y_i+1) * sub_size_y)
253
- datamin_y = max(blockmin_y - overlap, 0)
254
- datamax_y = min(blockmax_y + overlap, ysh)
255
-
256
- # determine x subvolume
257
- blockmin_x = int(sub_x_i * sub_size_x)
258
- blockmax_x = int((sub_x_i+1) * sub_size_x)
259
- datamin_x = max(blockmin_x - overlap, 0)
260
- datamax_x = min(blockmax_x + overlap, xsh)
261
-
262
- # load subvolume
263
- path_to_subvolume = BASE_DIR+f'/tmp/final.sub_volume_{subvolume}.uncertainty.tif'
264
- if os.path.isfile(path_to_subvolume):
265
- tmp, _ = load_data(path_to_subvolume)
266
- final[blockmin_z:blockmax_z,blockmin_y:blockmax_y,blockmin_x:blockmax_x] \
267
- = tmp[blockmin_z-datamin_z:blockmax_z-datamin_z,blockmin_y-datamin_y:blockmax_y-datamin_y,blockmin_x-datamin_x:blockmax_x-datamin_x]
268
- os.remove(path_to_subvolume)
269
- uncertainty = 1
270
-
271
- # save result
272
- if uncertainty:
273
- save_data(path_to_uq, final, header)
274
-
@@ -1,44 +0,0 @@
1
- biomedisa/__init__.py,sha256=BLbuGv-c8I8XMzOOnc07qrcWxq8CUA5NM73S3gkixEI,1690
2
- biomedisa/__main__.py,sha256=a1--8vhtztWEloHVtbM43FZLCfrFo4BELgdsgtWE8ls,536
3
- biomedisa/deeplearning.py,sha256=jh6LivGgWSjIoz_2bm-kfnyq90EMiLZwuh6T8Ldj738,27136
4
- biomedisa/interpolation.py,sha256=mz5Ieiee2RftqisqNzKcCU7IV1n0LGON4zyhvBwE94s,17335
5
- biomedisa/mesh.py,sha256=6f5klVPoA3zmF3jxLCOUkCXelLtlroS6tJquRHaMwsQ,15920
6
- biomedisa/biomedisa_features/DataGenerator.py,sha256=FTktX35_FboSzk4UXG_ZN58xXYJqwjX_7ZJ65bzNuFs,12770
7
- biomedisa/biomedisa_features/DataGeneratorCrop.py,sha256=cL_1rbXSq79vCNAHnIwvow-J1s-4gWStR1pWTbF_VTY,5454
8
- biomedisa/biomedisa_features/PredictDataGenerator.py,sha256=MISkB2tlxCw6rd8pfwwz1clVnvyPwg5dB-8yxR6WsBw,4074
9
- biomedisa/biomedisa_features/PredictDataGeneratorCrop.py,sha256=JBwFcOZMakNMlL5UvP5bNg9FlQl5sbrM9UVSCyFhwBQ,3431
10
- biomedisa/biomedisa_features/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- biomedisa/biomedisa_features/active_contour.py,sha256=PUAfCzHKU-p7xeQoWxmDh0ZFbnInXEsafgeE1k-96d0,18131
12
- biomedisa/biomedisa_features/assd.py,sha256=cXHAhwJqhwOvzgTodlQb21NvYafWTjBJ7_H_icuBNMU,6537
13
- biomedisa/biomedisa_features/biomedisa_helper.py,sha256=OhsjzMUhtGLpeo95zU23_LVSyCKcuMm6rXlzG_QO0hk,32294
14
- biomedisa/biomedisa_features/create_slices.py,sha256=lPYdA2AgwVUJmW94EKrSjKF_lkf7_ROFRSlnLLTQ1EY,13098
15
- biomedisa/biomedisa_features/crop_helper.py,sha256=jcvMysMfCbarDzayTkc6rY5Tv3Mx37k00yyzSc4Nphw,24533
16
- biomedisa/biomedisa_features/curvop_numba.py,sha256=9jc4OvHQ6JDN-DaFhRQMLpBDU85HhqzX_YUVBf3Q3vA,7049
17
- biomedisa/biomedisa_features/django_env.py,sha256=S-ajQpw5A2aBlTYgn_FiyIr02QH05rInzhBDulb9lNg,8989
18
- biomedisa/biomedisa_features/keras_helper.py,sha256=49LTHH_Jn9fyIe5B9uounQNXA86qPjSsvtKAhuEg8qs,50321
19
- biomedisa/biomedisa_features/nc_reader.py,sha256=7uwdmz4pLC__xb8hWjZ7Y9jrkNJOyD01kIA1EOP8GV0,7406
20
- biomedisa/biomedisa_features/pid.py,sha256=HAIq52F-PKwDGRyKE74qsY-bdBTs1s85vcIQTKaMIy8,2528
21
- biomedisa/biomedisa_features/process_image.py,sha256=yxBC3ACV2umscEycXZtY9Hsi1ATws7omnvXROEDfQfA,11159
22
- biomedisa/biomedisa_features/pycuda_test.py,sha256=LLd5JnlDu1hOZUTFs8IbuE2I2sBSRyZaU3sRdNpdy5Y,3274
23
- biomedisa/biomedisa_features/remove_outlier.py,sha256=V-3E7w3SGwmHMBCk1QzVoUJFdMV_NEYkUZG_-R15bqI,16801
24
- biomedisa/biomedisa_features/split_volume.py,sha256=yBdoO3ojEphnfs9P-Ap8NPFrmb-WM8CCZSV9deIEASs,12394
25
- biomedisa/biomedisa_features/amira_to_np/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
- biomedisa/biomedisa_features/amira_to_np/amira_data_stream.py,sha256=JrZTyKP01CKDFB5d9BlGtSFwBgoAo0AJeAmn3pADH88,32618
27
- biomedisa/biomedisa_features/amira_to_np/amira_grammar.py,sha256=z1yajLHmn-GDb-rzZ5iHlKmPZDDbO9fNqP2jXf8z3KE,14324
28
- biomedisa/biomedisa_features/amira_to_np/amira_header.py,sha256=eWHECsTx3ls8c0RHjy5xO4s-BehRC-96wONj7n9IzrY,11553
29
- biomedisa/biomedisa_features/amira_to_np/amira_helper.py,sha256=giuZKkX8eI_2MVAy3wwBvcmmmDxSOo8k9eAzu2QA6uo,2218
30
- biomedisa/biomedisa_features/random_walk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
- biomedisa/biomedisa_features/random_walk/gpu_kernels.py,sha256=r8BsyOU_a5tYMM8d_mS9MPrUCXoTFI7NY8JIQnyfe0U,7190
32
- biomedisa/biomedisa_features/random_walk/pycuda_large.py,sha256=_dfYP2cFSm0aKU6n_YotsdNLZcvO8OjE5hYbgeAQk98,32917
33
- biomedisa/biomedisa_features/random_walk/pycuda_large_allx.py,sha256=Cfb_cq184LgfdiSTImQu7Ax8L_EKQgpXfSVapYGXy0E,30677
34
- biomedisa/biomedisa_features/random_walk/pycuda_small.py,sha256=691oa8JhVwDmS-y7KnNbVUziW14fAtC-lvB3rg2VWA4,15786
35
- biomedisa/biomedisa_features/random_walk/pycuda_small_allx.py,sha256=8bNHDKDxa-02q1ykWo_YWjzYQkM77raX_DivpWkVoQY,18225
36
- biomedisa/biomedisa_features/random_walk/pyopencl_large.py,sha256=cOBhvxrdKCkbr6xaKneBTiUMXPk9lSdjwt95TdHC2EY,31015
37
- biomedisa/biomedisa_features/random_walk/pyopencl_small.py,sha256=2XALYNNv9D8Gb1u2lcjR1O4W9UM0Xxjj0r4nr-NiEkk,17068
38
- biomedisa/biomedisa_features/random_walk/rw_large.py,sha256=FERIsTXmqZprGCTShRR75PesIX5MMVtptk-SqI-4abo,19805
39
- biomedisa/biomedisa_features/random_walk/rw_small.py,sha256=0YFL0Ovb_400Ikbxv5yOXWskl3vAyfQ_0_Gz5EXzvVQ,14881
40
- biomedisa-2024.5.19.dist-info/LICENSE,sha256=sehayP6UhydNnmstfL4yFR3genMRdpuUh6uZVWJN1H0,14152
41
- biomedisa-2024.5.19.dist-info/METADATA,sha256=81H289XkDEGCBCcKyRtjUVoohr8kZIY1PIquZr9RM_Q,10696
42
- biomedisa-2024.5.19.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
- biomedisa-2024.5.19.dist-info/top_level.txt,sha256=opsf1Eb4vCguPSxev4HHSeiUKCccT_C_RcUCdAYbHWQ,10
44
- biomedisa-2024.5.19.dist-info/RECORD,,
File without changes