biomedisa 2024.5.19__tar.gz → 2024.5.20__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.
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/PKG-INFO +10 -10
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/README.md +9 -9
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/pyproject.toml +1 -1
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa/__init__.py +2 -6
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa/deeplearning.py +10 -12
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/DataGenerator.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/DataGeneratorCrop.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/PredictDataGenerator.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/PredictDataGeneratorCrop.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/active_contour.py +15 -18
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/assd.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/biomedisa_helper.py +7 -7
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/create_slices.py +2 -4
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/crop_helper.py +5 -5
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/curvop_numba.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/django_env.py +9 -10
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/keras_helper.py +6 -7
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/nc_reader.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/pid.py +2 -2
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/process_image.py +12 -14
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/pycuda_test.py +2 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/gpu_kernels.py +2 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pycuda_large.py +2 -2
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pycuda_large_allx.py +2 -2
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pycuda_small.py +2 -2
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pycuda_small_allx.py +2 -2
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pyopencl_large.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/pyopencl_small.py +1 -1
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/rw_large.py +11 -11
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/rw_small.py +12 -12
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/remove_outlier.py +13 -16
- biomedisa-2024.5.20/src/biomedisa/features/split_volume.py +167 -0
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa/interpolation.py +10 -12
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa/mesh.py +9 -12
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa.egg-info/PKG-INFO +10 -10
- biomedisa-2024.5.20/src/biomedisa.egg-info/SOURCES.txt +46 -0
- biomedisa-2024.5.19/src/biomedisa/biomedisa_features/split_volume.py +0 -274
- biomedisa-2024.5.19/src/biomedisa.egg-info/SOURCES.txt +0 -46
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/LICENSE +0 -0
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/setup.cfg +0 -0
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa/__main__.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/__init__.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/amira_to_np/__init__.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/amira_to_np/amira_data_stream.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/amira_to_np/amira_grammar.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/amira_to_np/amira_header.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/amira_to_np/amira_helper.py +0 -0
- {biomedisa-2024.5.19/src/biomedisa/biomedisa_features → biomedisa-2024.5.20/src/biomedisa/features}/random_walk/__init__.py +0 -0
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa.egg-info/dependency_links.txt +0 -0
- {biomedisa-2024.5.19 → biomedisa-2024.5.20}/src/biomedisa.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: biomedisa
|
3
|
-
Version: 2024.5.
|
3
|
+
Version: 2024.5.20
|
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,7 +14,7 @@ Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/markdown
|
15
15
|
License-File: LICENSE
|
16
16
|
|
17
|
-
[](https://biomedisa.info)
|
17
|
+
[](https://biomedisa.info)
|
18
18
|
-----------
|
19
19
|
- [Overview](#overview)
|
20
20
|
- [Hardware Requirements](#hardware-requirements)
|
@@ -55,7 +55,7 @@ Biomedisa (https://biomedisa.info) is a free and easy-to-use open-source applica
|
|
55
55
|
|
56
56
|
#### Python example
|
57
57
|
```python
|
58
|
-
from biomedisa.
|
58
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
59
59
|
from biomedisa.interpolation import smart_interpolation
|
60
60
|
|
61
61
|
# load data
|
@@ -84,7 +84,7 @@ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Use
|
|
84
84
|
|
85
85
|
#### Python example (training)
|
86
86
|
```python
|
87
|
-
from biomedisa.
|
87
|
+
from biomedisa.features.biomedisa_helper import load_data
|
88
88
|
from biomedisa.deeplearning import deep_learning
|
89
89
|
|
90
90
|
# load image data
|
@@ -124,7 +124,7 @@ If running into ResourceExhaustedError due to out of memory (OOM), try to use sm
|
|
124
124
|
|
125
125
|
#### Python example (prediction)
|
126
126
|
```python
|
127
|
-
from biomedisa.
|
127
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
128
128
|
from biomedisa.deeplearning import deep_learning
|
129
129
|
|
130
130
|
# load data
|
@@ -147,7 +147,7 @@ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\testing_axial_cro
|
|
147
147
|
|
148
148
|
#### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
|
149
149
|
```python
|
150
|
-
from biomedisa.
|
150
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
151
151
|
|
152
152
|
# load data as numpy array
|
153
153
|
# for DICOM, PNG files, or similar formats, 'path_to_data' must reference
|
@@ -160,7 +160,7 @@ save_data(path_to_data, data, header)
|
|
160
160
|
|
161
161
|
#### Create STL mesh from segmentation (label values are saved as attributes)
|
162
162
|
```python
|
163
|
-
from biomedisa.
|
163
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
164
164
|
from biomedisa.mesh import get_voxel_spacing, save_mesh
|
165
165
|
|
166
166
|
# load segmentation
|
@@ -193,7 +193,7 @@ python -m biomedisa.mesh <path_to_data>
|
|
193
193
|
|
194
194
|
#### Resize data
|
195
195
|
```python
|
196
|
-
from biomedisa.
|
196
|
+
from biomedisa.features.biomedisa_helper import img_resize
|
197
197
|
|
198
198
|
# resize image data
|
199
199
|
zsh, ysh, xsh = data.shape
|
@@ -206,7 +206,7 @@ label_data = img_resize(label_data, new_zsh, new_ysh, new_xsh, labels=True)
|
|
206
206
|
|
207
207
|
#### Remove outliers and fill holes
|
208
208
|
```python
|
209
|
-
from biomedisa.
|
209
|
+
from biomedisa.features.biomedisa_helper import clean, fill
|
210
210
|
|
211
211
|
# delete outliers smaller than 90% of the segment
|
212
212
|
label_data = clean(label_data, 0.9)
|
@@ -217,7 +217,7 @@ label_data = fill(label_data, 0.9)
|
|
217
217
|
|
218
218
|
#### Accuracy assessment
|
219
219
|
```python
|
220
|
-
from biomedisa.
|
220
|
+
from biomedisa.features.biomedisa_helper import Dice_score, ASSD
|
221
221
|
dice = Dice_score(ground_truth, result)
|
222
222
|
assd = ASSD(ground_truth, result)
|
223
223
|
```
|
@@ -1,4 +1,4 @@
|
|
1
|
-
[](https://biomedisa.info)
|
1
|
+
[](https://biomedisa.info)
|
2
2
|
-----------
|
3
3
|
- [Overview](#overview)
|
4
4
|
- [Hardware Requirements](#hardware-requirements)
|
@@ -39,7 +39,7 @@ Biomedisa (https://biomedisa.info) is a free and easy-to-use open-source applica
|
|
39
39
|
|
40
40
|
#### Python example
|
41
41
|
```python
|
42
|
-
from biomedisa.
|
42
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
43
43
|
from biomedisa.interpolation import smart_interpolation
|
44
44
|
|
45
45
|
# load data
|
@@ -68,7 +68,7 @@ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Use
|
|
68
68
|
|
69
69
|
#### Python example (training)
|
70
70
|
```python
|
71
|
-
from biomedisa.
|
71
|
+
from biomedisa.features.biomedisa_helper import load_data
|
72
72
|
from biomedisa.deeplearning import deep_learning
|
73
73
|
|
74
74
|
# load image data
|
@@ -108,7 +108,7 @@ If running into ResourceExhaustedError due to out of memory (OOM), try to use sm
|
|
108
108
|
|
109
109
|
#### Python example (prediction)
|
110
110
|
```python
|
111
|
-
from biomedisa.
|
111
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
112
112
|
from biomedisa.deeplearning import deep_learning
|
113
113
|
|
114
114
|
# load data
|
@@ -131,7 +131,7 @@ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\testing_axial_cro
|
|
131
131
|
|
132
132
|
#### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
|
133
133
|
```python
|
134
|
-
from biomedisa.
|
134
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
135
135
|
|
136
136
|
# load data as numpy array
|
137
137
|
# for DICOM, PNG files, or similar formats, 'path_to_data' must reference
|
@@ -144,7 +144,7 @@ save_data(path_to_data, data, header)
|
|
144
144
|
|
145
145
|
#### Create STL mesh from segmentation (label values are saved as attributes)
|
146
146
|
```python
|
147
|
-
from biomedisa.
|
147
|
+
from biomedisa.features.biomedisa_helper import load_data, save_data
|
148
148
|
from biomedisa.mesh import get_voxel_spacing, save_mesh
|
149
149
|
|
150
150
|
# load segmentation
|
@@ -177,7 +177,7 @@ python -m biomedisa.mesh <path_to_data>
|
|
177
177
|
|
178
178
|
#### Resize data
|
179
179
|
```python
|
180
|
-
from biomedisa.
|
180
|
+
from biomedisa.features.biomedisa_helper import img_resize
|
181
181
|
|
182
182
|
# resize image data
|
183
183
|
zsh, ysh, xsh = data.shape
|
@@ -190,7 +190,7 @@ label_data = img_resize(label_data, new_zsh, new_ysh, new_xsh, labels=True)
|
|
190
190
|
|
191
191
|
#### Remove outliers and fill holes
|
192
192
|
```python
|
193
|
-
from biomedisa.
|
193
|
+
from biomedisa.features.biomedisa_helper import clean, fill
|
194
194
|
|
195
195
|
# delete outliers smaller than 90% of the segment
|
196
196
|
label_data = clean(label_data, 0.9)
|
@@ -201,7 +201,7 @@ label_data = fill(label_data, 0.9)
|
|
201
201
|
|
202
202
|
#### Accuracy assessment
|
203
203
|
```python
|
204
|
-
from biomedisa.
|
204
|
+
from biomedisa.features.biomedisa_helper import Dice_score, ASSD
|
205
205
|
dice = Dice_score(ground_truth, result)
|
206
206
|
assd = ASSD(ground_truth, result)
|
207
207
|
```
|
@@ -1,15 +1,11 @@
|
|
1
1
|
import os
|
2
|
-
import sys
|
3
2
|
import subprocess
|
4
3
|
|
5
4
|
# from source base directory
|
6
5
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
7
6
|
|
8
|
-
# pip
|
9
|
-
if not os.path.exists(os.path.join(BASE_DIR,'
|
10
|
-
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
11
|
-
# add BASE_DIR to PYTHONPATH for absolute imports
|
12
|
-
sys.path.append(BASE_DIR)
|
7
|
+
# pip installation
|
8
|
+
if not os.path.exists(os.path.join(BASE_DIR,'biomedisa/settings.py')):
|
13
9
|
|
14
10
|
# metadata
|
15
11
|
import importlib_metadata
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/python3
|
2
2
|
##########################################################################
|
3
3
|
## ##
|
4
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
4
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
5
5
|
## ##
|
6
6
|
## This file is part of the open source project biomedisa. ##
|
7
7
|
## ##
|
@@ -27,13 +27,11 @@
|
|
27
27
|
## ##
|
28
28
|
##########################################################################
|
29
29
|
|
30
|
-
import
|
31
|
-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
32
|
-
sys.path.append(BASE_DIR)
|
30
|
+
import os
|
33
31
|
import biomedisa
|
34
|
-
import
|
35
|
-
from
|
36
|
-
from
|
32
|
+
import biomedisa.features.crop_helper as ch
|
33
|
+
from biomedisa.features.keras_helper import *
|
34
|
+
from biomedisa.features.biomedisa_helper import _error_, unique_file_path
|
37
35
|
from tensorflow.python.framework.errors_impl import ResourceExhaustedError
|
38
36
|
import tensorflow as tf
|
39
37
|
import numpy as np
|
@@ -121,7 +119,7 @@ def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=N
|
|
121
119
|
project = os.path.splitext(bm.shortfilename)[0]
|
122
120
|
|
123
121
|
# path to model
|
124
|
-
bm.path_to_model = BASE_DIR + f'/private_storage/images/{bm.username}/{project}.h5'
|
122
|
+
bm.path_to_model = biomedisa.BASE_DIR + f'/private_storage/images/{bm.username}/{project}.h5'
|
125
123
|
if not bm.remote:
|
126
124
|
bm.path_to_model = unique_file_path(bm.path_to_model)
|
127
125
|
|
@@ -129,7 +127,7 @@ def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=N
|
|
129
127
|
project = os.path.splitext(os.path.basename(bm.path_to_model))[0]
|
130
128
|
|
131
129
|
# create pid object
|
132
|
-
from
|
130
|
+
from biomedisa.features.django_env import create_pid_object
|
133
131
|
create_pid_object(os.getpid(), bm.remote, bm.queue, bm.img_id, (bm.path_to_model if bm.train else ''))
|
134
132
|
|
135
133
|
# write in log file
|
@@ -319,7 +317,7 @@ def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=N
|
|
319
317
|
# django environment
|
320
318
|
if bm.django_env:
|
321
319
|
from biomedisa_app.config import config
|
322
|
-
from
|
320
|
+
from biomedisa.features.django_env import post_processing
|
323
321
|
validation=True if bm.validation_split or (bm.val_images is not None and bm.val_images[0] is not None) else False
|
324
322
|
post_processing(bm.path_to_final, time_str, config['SERVER_ALIAS'], bm.remote, bm.queue,
|
325
323
|
img_id=bm.img_id, label_id=bm.label_id, path_to_model=bm.path_to_model,
|
@@ -327,7 +325,7 @@ def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=N
|
|
327
325
|
train=bm.train, predict=bm.predict, validation=validation)
|
328
326
|
|
329
327
|
# write in log file
|
330
|
-
path_to_time = BASE_DIR + '/log/time.txt'
|
328
|
+
path_to_time = biomedisa.BASE_DIR + '/log/time.txt'
|
331
329
|
with open(path_to_time, 'a') as timefile:
|
332
330
|
if predict:
|
333
331
|
message = 'Successfully segmented ' + bm.shortfilename
|
@@ -490,7 +488,7 @@ if __name__ == '__main__':
|
|
490
488
|
reference_image_path = bm.path_to_images
|
491
489
|
bm.username = os.path.basename(os.path.dirname(reference_image_path))
|
492
490
|
bm.shortfilename = os.path.basename(reference_image_path)
|
493
|
-
bm.path_to_logfile = BASE_DIR + '/log/logfile.txt'
|
491
|
+
bm.path_to_logfile = biomedisa.BASE_DIR + '/log/logfile.txt'
|
494
492
|
else:
|
495
493
|
bm.django_env = False
|
496
494
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c)
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/python3
|
2
2
|
##########################################################################
|
3
3
|
## ##
|
4
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
4
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
5
5
|
## ##
|
6
6
|
## This file is part of the open source project biomedisa. ##
|
7
7
|
## ##
|
@@ -27,13 +27,10 @@
|
|
27
27
|
## ##
|
28
28
|
##########################################################################
|
29
29
|
|
30
|
-
import
|
31
|
-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
32
|
-
if not BASE_DIR in sys.path:
|
33
|
-
sys.path.append(BASE_DIR)
|
30
|
+
import os
|
34
31
|
import biomedisa
|
35
|
-
from
|
36
|
-
from
|
32
|
+
from biomedisa.features.curvop_numba import curvop, evolution
|
33
|
+
from biomedisa.features.biomedisa_helper import (unique_file_path, load_data, save_data,
|
37
34
|
pre_processing, img_to_uint8, silent_remove)
|
38
35
|
import numpy as np
|
39
36
|
import numba
|
@@ -143,7 +140,7 @@ def activeContour(data, labelData, alpha=1.0, smooth=1, steps=3,
|
|
143
140
|
if bm.django_env:
|
144
141
|
bm.username = os.path.basename(os.path.dirname(bm.path_to_data))
|
145
142
|
bm.shortfilename = os.path.basename(bm.path_to_data)
|
146
|
-
bm.path_to_logfile = BASE_DIR + '/log/logfile.txt'
|
143
|
+
bm.path_to_logfile = biomedisa.BASE_DIR + '/log/logfile.txt'
|
147
144
|
|
148
145
|
# pre-processing
|
149
146
|
bm = pre_processing(bm)
|
@@ -234,13 +231,13 @@ def refinement(bm):
|
|
234
231
|
|
235
232
|
def post_processing(path_to_acwe, image_id=None, friend_id=None, simple=False, remote=False):
|
236
233
|
if remote:
|
237
|
-
with open(BASE_DIR + '/log/config_4', 'w') as configfile:
|
234
|
+
with open(biomedisa.BASE_DIR + '/log/config_4', 'w') as configfile:
|
238
235
|
print(path_to_acwe, 'phantom', file=configfile)
|
239
236
|
else:
|
240
237
|
import django
|
241
238
|
django.setup()
|
242
239
|
from biomedisa_app.models import Upload
|
243
|
-
from
|
240
|
+
from biomedisa.features.create_slices import create_slices
|
244
241
|
from redis import Redis
|
245
242
|
from rq import Queue
|
246
243
|
|
@@ -300,7 +297,7 @@ def init_active_contour(image_id, friend_id, label_id, simple=False):
|
|
300
297
|
|
301
298
|
# get host information
|
302
299
|
host = ''
|
303
|
-
host_base = BASE_DIR
|
300
|
+
host_base = biomedisa.BASE_DIR
|
304
301
|
subhost, qsub_pid = None, None
|
305
302
|
if 'REMOTE_QUEUE_HOST' in config:
|
306
303
|
host = config['REMOTE_QUEUE_HOST']
|
@@ -313,8 +310,8 @@ def init_active_contour(image_id, friend_id, label_id, simple=False):
|
|
313
310
|
if host:
|
314
311
|
|
315
312
|
# command
|
316
|
-
cmd = ['python3', host_base+'/
|
317
|
-
cmd += [image.pic.path.replace(BASE_DIR,host_base), friend.pic.path.replace(BASE_DIR,host_base)]
|
313
|
+
cmd = ['python3', host_base+'/biomedisa/features/active_contour.py']
|
314
|
+
cmd += [image.pic.path.replace(biomedisa.BASE_DIR,host_base), friend.pic.path.replace(biomedisa.BASE_DIR,host_base)]
|
318
315
|
cmd += [f'-iid={image.id}', f'-fid={friend.id}', '-r']
|
319
316
|
|
320
317
|
# command (append only on demand)
|
@@ -338,8 +335,8 @@ def init_active_contour(image_id, friend_id, label_id, simple=False):
|
|
338
335
|
|
339
336
|
# send data to host
|
340
337
|
success=0
|
341
|
-
success+=send_data_to_host(image.pic.path, host+':'+image.pic.path.replace(BASE_DIR,host_base))
|
342
|
-
success+=send_data_to_host(friend.pic.path, host+':'+friend.pic.path.replace(BASE_DIR,host_base))
|
338
|
+
success+=send_data_to_host(image.pic.path, host+':'+image.pic.path.replace(biomedisa.BASE_DIR,host_base))
|
339
|
+
success+=send_data_to_host(friend.pic.path, host+':'+friend.pic.path.replace(biomedisa.BASE_DIR,host_base))
|
343
340
|
|
344
341
|
if success==0:
|
345
342
|
|
@@ -355,14 +352,14 @@ def init_active_contour(image_id, friend_id, label_id, simple=False):
|
|
355
352
|
subprocess.Popen(cmd).wait()
|
356
353
|
|
357
354
|
# config
|
358
|
-
success = subprocess.Popen(['scp', host+':'+host_base+'/log/config_4', BASE_DIR+'/log/config_4']).wait()
|
355
|
+
success = subprocess.Popen(['scp', host+':'+host_base+'/log/config_4', biomedisa.BASE_DIR+'/log/config_4']).wait()
|
359
356
|
|
360
357
|
if success==0:
|
361
|
-
with open(BASE_DIR + '/log/config_4', 'r') as configfile:
|
358
|
+
with open(biomedisa.BASE_DIR + '/log/config_4', 'r') as configfile:
|
362
359
|
acwe_on_host, _ = configfile.read().split()
|
363
360
|
|
364
361
|
# local file names
|
365
|
-
path_to_acwe = unique_file_path(acwe_on_host.replace(host_base,BASE_DIR))
|
362
|
+
path_to_acwe = unique_file_path(acwe_on_host.replace(host_base,biomedisa.BASE_DIR))
|
366
363
|
|
367
364
|
# get results
|
368
365
|
subprocess.Popen(['scp', host+':'+acwe_on_host, path_to_acwe]).wait()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -27,9 +27,9 @@
|
|
27
27
|
##########################################################################
|
28
28
|
|
29
29
|
import os
|
30
|
-
|
31
|
-
from
|
32
|
-
from
|
30
|
+
import biomedisa
|
31
|
+
from biomedisa.features.amira_to_np.amira_helper import amira_to_np, np_to_amira
|
32
|
+
from biomedisa.features.nc_reader import nc_to_np, np_to_nc
|
33
33
|
from tifffile import imread, imwrite
|
34
34
|
from medpy.io import load, save
|
35
35
|
import SimpleITK as sitk
|
@@ -53,7 +53,7 @@ def silent_remove(filename):
|
|
53
53
|
pass
|
54
54
|
|
55
55
|
# create a unique filename
|
56
|
-
def unique_file_path(path, dir_path=BASE_DIR+'/private_storage/'):
|
56
|
+
def unique_file_path(path, dir_path=biomedisa.BASE_DIR+'/private_storage/'):
|
57
57
|
|
58
58
|
# get extension
|
59
59
|
username = os.path.basename(os.path.dirname(path))
|
@@ -116,7 +116,7 @@ def Dice_score(ground_truth, result, average_dice=False):
|
|
116
116
|
|
117
117
|
def ASSD(ground_truth, result):
|
118
118
|
try:
|
119
|
-
from
|
119
|
+
from biomedisa.features.assd import ASSD_one_label
|
120
120
|
number_of_elements = 0
|
121
121
|
distances = 0
|
122
122
|
hausdorff = 0
|
@@ -389,7 +389,7 @@ def load_data(path_to_data, process='None', return_extension=False):
|
|
389
389
|
|
390
390
|
def _error_(bm, message):
|
391
391
|
if bm.django_env:
|
392
|
-
from
|
392
|
+
from biomedisa.features.django_env import create_error_object
|
393
393
|
create_error_object(message, bm.remote, bm.queue, bm.img_id)
|
394
394
|
with open(bm.path_to_logfile, 'a') as logfile:
|
395
395
|
print('%s %s %s %s' %(time.ctime(), bm.username, bm.shortfilename, message), file=logfile)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/python3
|
2
2
|
##########################################################################
|
3
3
|
## ##
|
4
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
4
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
5
5
|
## ##
|
6
6
|
## This file is part of the open source project biomedisa. ##
|
7
7
|
## ##
|
@@ -28,9 +28,7 @@
|
|
28
28
|
##########################################################################
|
29
29
|
|
30
30
|
import sys, os
|
31
|
-
|
32
|
-
sys.path.append(BASE_DIR)
|
33
|
-
from biomedisa_features.biomedisa_helper import load_data, color_to_gray, img_to_uint8, img_resize, id_generator
|
31
|
+
from biomedisa.features.biomedisa_helper import load_data, color_to_gray, img_to_uint8, img_resize, id_generator
|
34
32
|
from PIL import Image
|
35
33
|
import numpy as np
|
36
34
|
from glob import glob
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -27,16 +27,16 @@
|
|
27
27
|
##########################################################################
|
28
28
|
|
29
29
|
import os
|
30
|
-
from
|
31
|
-
from
|
30
|
+
from biomedisa.features.keras_helper import read_img_list
|
31
|
+
from biomedisa.features.biomedisa_helper import img_resize, load_data, save_data, set_labels_to_zero
|
32
32
|
from tensorflow.python.framework.errors_impl import ResourceExhaustedError
|
33
33
|
from tensorflow.keras.applications import DenseNet121, densenet
|
34
34
|
from tensorflow.keras.optimizers import Adam
|
35
35
|
from tensorflow.keras.models import Model, load_model
|
36
36
|
from tensorflow.keras.layers import Input, GlobalAveragePooling2D, Dropout, Dense
|
37
37
|
from tensorflow.keras.callbacks import Callback, ModelCheckpoint
|
38
|
-
from
|
39
|
-
from
|
38
|
+
from biomedisa.features.DataGeneratorCrop import DataGeneratorCrop
|
39
|
+
from biomedisa.features.PredictDataGeneratorCrop import PredictDataGeneratorCrop
|
40
40
|
import tensorflow as tf
|
41
41
|
import numpy as np
|
42
42
|
from glob import glob
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -26,15 +26,14 @@
|
|
26
26
|
## ##
|
27
27
|
##########################################################################
|
28
28
|
|
29
|
-
import
|
30
|
-
|
31
|
-
import subprocess
|
29
|
+
import os
|
30
|
+
import biomedisa
|
32
31
|
|
33
32
|
def create_error_object(message, remote=False, queue=None, img_id=None):
|
34
33
|
|
35
34
|
# remote server
|
36
35
|
if remote:
|
37
|
-
with open(BASE_DIR + f'/log/error_{queue}', 'w') as errorfile:
|
36
|
+
with open(biomedisa.BASE_DIR + f'/log/error_{queue}', 'w') as errorfile:
|
38
37
|
print(message, file=errorfile)
|
39
38
|
|
40
39
|
# local server
|
@@ -57,7 +56,7 @@ def create_pid_object(pid, remote=False, queue=None, img_id=None, path_to_model=
|
|
57
56
|
|
58
57
|
# remote server
|
59
58
|
if remote:
|
60
|
-
with open(BASE_DIR + f'/log/pid_{queue}', 'w') as pidfile:
|
59
|
+
with open(biomedisa.BASE_DIR + f'/log/pid_{queue}', 'w') as pidfile:
|
61
60
|
print(pid, file=pidfile)
|
62
61
|
|
63
62
|
# local server
|
@@ -74,7 +73,7 @@ def post_processing(path_to_final, time_str, server_name, remote, queue, dice=1.
|
|
74
73
|
|
75
74
|
# remote server
|
76
75
|
if remote:
|
77
|
-
with open(BASE_DIR + f'/log/config_{queue}', 'w') as configfile:
|
76
|
+
with open(biomedisa.BASE_DIR + f'/log/config_{queue}', 'w') as configfile:
|
78
77
|
print(path_to_final, path_to_uq, path_to_smooth, uncertainty, smooth, str(time_str).replace(' ','-'), server_name, path_to_model, path_to_cropped_image, dice, file=configfile)
|
79
78
|
|
80
79
|
# local server
|
@@ -83,9 +82,9 @@ def post_processing(path_to_final, time_str, server_name, remote, queue, dice=1.
|
|
83
82
|
django.setup()
|
84
83
|
from biomedisa_app.models import Upload
|
85
84
|
from biomedisa_app.views import send_notification
|
86
|
-
from
|
87
|
-
from
|
88
|
-
from
|
85
|
+
from biomedisa.features.active_contour import init_active_contour
|
86
|
+
from biomedisa.features.remove_outlier import init_remove_outlier
|
87
|
+
from biomedisa.features.create_slices import create_slices
|
89
88
|
from redis import Redis
|
90
89
|
from rq import Queue
|
91
90
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -27,7 +27,6 @@
|
|
27
27
|
##########################################################################
|
28
28
|
|
29
29
|
import os
|
30
|
-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
31
30
|
try:
|
32
31
|
from tensorflow.keras.optimizers.legacy import SGD
|
33
32
|
except:
|
@@ -40,12 +39,12 @@ from tensorflow.keras.layers import (
|
|
40
39
|
from tensorflow.keras import backend as K
|
41
40
|
from tensorflow.keras.utils import to_categorical
|
42
41
|
from tensorflow.keras.callbacks import Callback, ModelCheckpoint, EarlyStopping
|
43
|
-
from
|
44
|
-
from
|
45
|
-
from
|
42
|
+
from biomedisa.features.DataGenerator import DataGenerator
|
43
|
+
from biomedisa.features.PredictDataGenerator import PredictDataGenerator
|
44
|
+
from biomedisa.features.biomedisa_helper import (
|
46
45
|
img_resize, load_data, save_data, set_labels_to_zero, id_generator, unique_file_path)
|
47
|
-
from
|
48
|
-
from
|
46
|
+
from biomedisa.features.remove_outlier import clean, fill
|
47
|
+
from biomedisa.features.active_contour import activeContour
|
49
48
|
import matplotlib.pyplot as plt
|
50
49
|
import SimpleITK as sitk
|
51
50
|
import tensorflow as tf
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c) 2024 Philipp Lösel. All rights reserved.
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -1,6 +1,6 @@
|
|
1
1
|
##########################################################################
|
2
2
|
## ##
|
3
|
-
## Copyright (c)
|
3
|
+
## Copyright (c) 2019-2024 Philipp Lösel. All rights reserved. ##
|
4
4
|
## ##
|
5
5
|
## This file is part of the open source project biomedisa. ##
|
6
6
|
## ##
|
@@ -34,7 +34,7 @@ if __name__ == "__main__":
|
|
34
34
|
queue = sys.argv[1]
|
35
35
|
|
36
36
|
# path to biomedisa
|
37
|
-
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
37
|
+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
38
38
|
|
39
39
|
# wait for pid
|
40
40
|
while not os.path.exists(BASE_DIR + f'/log/pid_{queue}'):
|