biomedisa 2024.5.14__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.
- biomedisa/__init__.py +53 -0
- biomedisa/__main__.py +18 -0
- biomedisa/biomedisa_features/DataGenerator.py +299 -0
- biomedisa/biomedisa_features/DataGeneratorCrop.py +121 -0
- biomedisa/biomedisa_features/PredictDataGenerator.py +87 -0
- biomedisa/biomedisa_features/PredictDataGeneratorCrop.py +74 -0
- biomedisa/biomedisa_features/__init__.py +0 -0
- biomedisa/biomedisa_features/active_contour.py +434 -0
- biomedisa/biomedisa_features/amira_to_np/__init__.py +0 -0
- biomedisa/biomedisa_features/amira_to_np/amira_data_stream.py +980 -0
- biomedisa/biomedisa_features/amira_to_np/amira_grammar.py +369 -0
- biomedisa/biomedisa_features/amira_to_np/amira_header.py +290 -0
- biomedisa/biomedisa_features/amira_to_np/amira_helper.py +72 -0
- biomedisa/biomedisa_features/assd.py +167 -0
- biomedisa/biomedisa_features/biomedisa_helper.py +801 -0
- biomedisa/biomedisa_features/create_slices.py +286 -0
- biomedisa/biomedisa_features/crop_helper.py +586 -0
- biomedisa/biomedisa_features/curvop_numba.py +149 -0
- biomedisa/biomedisa_features/django_env.py +172 -0
- biomedisa/biomedisa_features/keras_helper.py +1219 -0
- biomedisa/biomedisa_features/nc_reader.py +179 -0
- biomedisa/biomedisa_features/pid.py +52 -0
- biomedisa/biomedisa_features/process_image.py +253 -0
- biomedisa/biomedisa_features/pycuda_test.py +84 -0
- biomedisa/biomedisa_features/random_walk/__init__.py +0 -0
- biomedisa/biomedisa_features/random_walk/gpu_kernels.py +183 -0
- biomedisa/biomedisa_features/random_walk/pycuda_large.py +826 -0
- biomedisa/biomedisa_features/random_walk/pycuda_large_allx.py +806 -0
- biomedisa/biomedisa_features/random_walk/pycuda_small.py +414 -0
- biomedisa/biomedisa_features/random_walk/pycuda_small_allx.py +493 -0
- biomedisa/biomedisa_features/random_walk/pyopencl_large.py +760 -0
- biomedisa/biomedisa_features/random_walk/pyopencl_small.py +441 -0
- biomedisa/biomedisa_features/random_walk/rw_large.py +390 -0
- biomedisa/biomedisa_features/random_walk/rw_small.py +310 -0
- biomedisa/biomedisa_features/remove_outlier.py +399 -0
- biomedisa/biomedisa_features/split_volume.py +274 -0
- biomedisa/deeplearning.py +519 -0
- biomedisa/interpolation.py +371 -0
- biomedisa/mesh.py +406 -0
- biomedisa-2024.5.14.dist-info/LICENSE +191 -0
- biomedisa-2024.5.14.dist-info/METADATA +306 -0
- biomedisa-2024.5.14.dist-info/RECORD +44 -0
- biomedisa-2024.5.14.dist-info/WHEEL +5 -0
- biomedisa-2024.5.14.dist-info/top_level.txt +1 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
##########################################################################
|
2
|
+
## ##
|
3
|
+
## Copyright (c) 2022 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
|
+
from pycuda.compiler import SourceModule
|
30
|
+
|
31
|
+
def _build_kernel_fill():
|
32
|
+
code = """
|
33
|
+
__global__ void Funktion(float *a, int xsh, int ysh) {
|
34
|
+
|
35
|
+
int zsh = gridDim.z;
|
36
|
+
int flat = xsh * ysh;
|
37
|
+
|
38
|
+
int column = blockIdx.x * blockDim.x + threadIdx.x;
|
39
|
+
int row = blockIdx.y * blockDim.y + threadIdx.y;
|
40
|
+
int plane = blockIdx.z;
|
41
|
+
|
42
|
+
unsigned int vol = zsh * flat;
|
43
|
+
unsigned int index = plane * flat + row * xsh + column;
|
44
|
+
|
45
|
+
if (index < vol && column < xsh && row < ysh) {
|
46
|
+
a[index] = 0;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
"""
|
50
|
+
mod = SourceModule(code)
|
51
|
+
kernel = mod.get_function("Funktion")
|
52
|
+
return kernel
|
53
|
+
|
54
|
+
def _build_kernel_uncertainty():
|
55
|
+
code = """
|
56
|
+
__global__ void Funktion(float *max, float *a, int xsh, int ysh) {
|
57
|
+
|
58
|
+
int zsh = gridDim.z;
|
59
|
+
int flat = xsh * ysh;
|
60
|
+
|
61
|
+
int column = blockIdx.x * blockDim.x + threadIdx.x;
|
62
|
+
int row = blockIdx.y * blockDim.y + threadIdx.y;
|
63
|
+
int plane = blockIdx.z;
|
64
|
+
|
65
|
+
unsigned int vol = zsh * flat;
|
66
|
+
unsigned int index = plane * flat + row * xsh + column;
|
67
|
+
|
68
|
+
if (index < vol && plane>0 && row>0 && column>0 && plane<zsh-1 && row<ysh-1 && column<xsh-1) {
|
69
|
+
float max2 = max[2 * vol + index];
|
70
|
+
if (max2 == 0) {max2 = 1;}
|
71
|
+
float tmp = max[index] / max2;
|
72
|
+
float tmp1 = max[vol + index] / max2;
|
73
|
+
a[index] = 1 - (1 - tmp) * (1 - tmp1);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
"""
|
77
|
+
mod = SourceModule(code)
|
78
|
+
kernel = mod.get_function("Funktion")
|
79
|
+
return kernel
|
80
|
+
|
81
|
+
def _build_kernel_max():
|
82
|
+
code = """
|
83
|
+
__global__ void Funktion(float *max, float *a, int xsh, int ysh) {
|
84
|
+
|
85
|
+
int zsh = gridDim.z;
|
86
|
+
int flat = xsh * ysh;
|
87
|
+
|
88
|
+
int column = blockIdx.x * blockDim.x + threadIdx.x;
|
89
|
+
int row = blockIdx.y * blockDim.y + threadIdx.y;
|
90
|
+
int plane = blockIdx.z;
|
91
|
+
|
92
|
+
unsigned int vol = zsh * flat;
|
93
|
+
unsigned int index = plane * flat + row * xsh + column;
|
94
|
+
|
95
|
+
if (index < vol && plane>0 && row>0 && column>0 && plane<zsh-1 && row<ysh-1 && column<xsh-1) {
|
96
|
+
float tmp = a[index];
|
97
|
+
float max2 = max[2 * vol + index];
|
98
|
+
float max1 = max[vol + index];
|
99
|
+
if (tmp > max2) {
|
100
|
+
max[index] = max1;
|
101
|
+
max[vol + index] = max2;
|
102
|
+
max[2 * vol + index] = tmp;
|
103
|
+
}
|
104
|
+
else if (tmp > max1) {
|
105
|
+
max[index] = max1;
|
106
|
+
max[vol + index] = tmp;
|
107
|
+
}
|
108
|
+
else if (tmp > max[index]) {
|
109
|
+
max[index] = tmp;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
"""
|
114
|
+
mod = SourceModule(code)
|
115
|
+
kernel = mod.get_function("Funktion")
|
116
|
+
return kernel
|
117
|
+
|
118
|
+
def _build_update_gpu():
|
119
|
+
code = """
|
120
|
+
__global__ void Funktion(float *phi, float *curvature, int xsh, int ysh) {
|
121
|
+
|
122
|
+
int zsh = gridDim.z;
|
123
|
+
int flat = xsh * ysh;
|
124
|
+
|
125
|
+
int column = blockIdx.x * blockDim.x + threadIdx.x;
|
126
|
+
int row = blockIdx.y * blockDim.y + threadIdx.y;
|
127
|
+
int plane = blockIdx.z;
|
128
|
+
|
129
|
+
unsigned int vol = zsh * flat;
|
130
|
+
unsigned int index = plane * flat + row * xsh + column;
|
131
|
+
|
132
|
+
if (index < vol && plane>0 && row>0 && column>0 && plane<zsh-1 && row<ysh-1 && column<xsh-1) {
|
133
|
+
phi[index] += 0.01 * curvature[index];
|
134
|
+
}
|
135
|
+
}
|
136
|
+
"""
|
137
|
+
mod = SourceModule(code)
|
138
|
+
kernel = mod.get_function("Funktion")
|
139
|
+
return kernel
|
140
|
+
|
141
|
+
def _build_curvature_gpu():
|
142
|
+
code = """
|
143
|
+
__global__ void Funktion(float *phi, float *curvature, int xsh, int ysh) {
|
144
|
+
|
145
|
+
int zsh = gridDim.z;
|
146
|
+
int flat = xsh * ysh;
|
147
|
+
|
148
|
+
int column = blockIdx.x * blockDim.x + threadIdx.x;
|
149
|
+
int row = blockIdx.y * blockDim.y + threadIdx.y;
|
150
|
+
int plane = blockIdx.z;
|
151
|
+
|
152
|
+
unsigned int vol = zsh * flat;
|
153
|
+
unsigned int index = plane * flat + row * xsh + column;
|
154
|
+
|
155
|
+
if (index < vol && plane>0 && row>0 && column>0 && plane<zsh-1 && row<ysh-1 && column<xsh-1) {
|
156
|
+
|
157
|
+
float eps = 0.0000000001;
|
158
|
+
float dx, dxx, dx2, dy, dyy, dy2, dz, dzz, dz2, dxy, dxz, dyz;
|
159
|
+
|
160
|
+
dx = (phi[index-1] - phi[index+1]) / 2.0;
|
161
|
+
dxx = (phi[index-1] - 2*phi[index] + phi[index+1]);
|
162
|
+
dx2 = dx * dx;
|
163
|
+
|
164
|
+
dy = (phi[index-xsh] - phi[index+xsh]) / 2.0;
|
165
|
+
dyy = (phi[index-xsh] - 2*phi[index] + phi[index+xsh]);
|
166
|
+
dy2 = dy * dy;
|
167
|
+
|
168
|
+
dz = (phi[index-flat] - phi[index+flat]) / 2.0;
|
169
|
+
dzz = (phi[index-flat] - 2*phi[index] + phi[index+flat]);
|
170
|
+
dz2 = dz * dz;
|
171
|
+
|
172
|
+
dxy = (phi[index-xsh-1] + phi[index+xsh+1] - phi[index-xsh+1] - phi[index+xsh-1]) / 4.0;
|
173
|
+
dxz = (phi[index+flat-1] + phi[index-flat+1] - phi[index+flat+1] - phi[index-flat-1]) / 4.0;
|
174
|
+
dyz = (phi[index+flat-xsh] + phi[index-flat+xsh] - phi[index+flat+xsh] - phi[index-flat-xsh]) / 4.0;
|
175
|
+
|
176
|
+
curvature[index] = (dxx*(dy2+dz2)+dyy*(dx2+dz2)+dzz*(dx2+dy2)-2*dx*dy*dxy-2*dx*dz*dxz-2*dy*dz*dyz) / (dx2+dy2+dz2+eps);
|
177
|
+
|
178
|
+
}
|
179
|
+
}
|
180
|
+
"""
|
181
|
+
mod = SourceModule(code)
|
182
|
+
kernel = mod.get_function("Funktion")
|
183
|
+
return kernel
|