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
biomedisa/__init__.py CHANGED
@@ -1,15 +1,11 @@
1
1
  import os
2
- import sys
3
2
  import subprocess
4
3
 
5
- # from source base directory
4
+ # base directory
6
5
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
7
6
 
8
- # pip base directory
9
- if not os.path.exists(os.path.join(BASE_DIR,'biomedisa_features')):
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
biomedisa/deeplearning.py CHANGED
@@ -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 sys, os
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 biomedisa_features.crop_helper as ch
35
- from biomedisa_features.keras_helper import *
36
- from biomedisa_features.biomedisa_helper import _error_, unique_file_path
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 biomedisa_features.django_env import create_pid_object
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 biomedisa_features.django_env import post_processing
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) 2022 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,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 sys, os
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 biomedisa_features.curvop_numba import curvop, evolution
36
- from biomedisa_features.biomedisa_helper import (unique_file_path, load_data, save_data,
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 biomedisa_features.create_slices import create_slices
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+'/biomedisa_features/active_contour.py']
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
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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
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 biomedisa_features.assd import ASSD_one_label
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 biomedisa_features.django_env import create_error_object
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
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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 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
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 biomedisa_features.DataGeneratorCrop import DataGeneratorCrop
39
- from biomedisa_features.PredictDataGeneratorCrop import PredictDataGeneratorCrop
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 sys, os
30
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
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 biomedisa_features.active_contour import init_active_contour
87
- from biomedisa_features.remove_outlier import init_remove_outlier
88
- from biomedisa_features.create_slices import create_slices
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 biomedisa_features.DataGenerator import DataGenerator
44
- from biomedisa_features.PredictDataGenerator import PredictDataGenerator
45
- from biomedisa_features.biomedisa_helper import (
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 biomedisa_features.remove_outlier import clean, fill
48
- from biomedisa_features.active_contour import activeContour
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) 2023 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
  ## ##
@@ -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}'):
@@ -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,15 +27,13 @@
27
27
  ## ##
28
28
  ##########################################################################
29
29
 
30
- import os, sys
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)
34
- import numpy as np
35
- from biomedisa_features.biomedisa_helper import (load_data, save_data, unique_file_path,
30
+ import os
31
+ import biomedisa
32
+ from biomedisa.features.biomedisa_helper import (load_data, save_data, unique_file_path,
36
33
  img_to_uint8, smooth_img_3x3)
37
- from biomedisa_features.create_slices import create_slices
34
+ from biomedisa.features.create_slices import create_slices
38
35
  from shutil import copytree
36
+ import numpy as np
39
37
  import argparse
40
38
  import traceback
41
39
  import subprocess
@@ -61,7 +59,7 @@ def init_process_image(id, process=None):
61
59
 
62
60
  # get host information
63
61
  host = ''
64
- host_base = BASE_DIR
62
+ host_base = biomedisa.BASE_DIR
65
63
  subhost, qsub_pid = None, None
66
64
  if 'REMOTE_QUEUE_HOST' in config:
67
65
  host = config['REMOTE_QUEUE_HOST']
@@ -99,7 +97,7 @@ def init_process_image(id, process=None):
99
97
  if host:
100
98
 
101
99
  # command
102
- cmd = ['python3', host_base+'/biomedisa_features/process_image.py', img.pic.path.replace(BASE_DIR,host_base)]
100
+ cmd = ['python3', host_base+'/biomedisa/features/process_image.py', img.pic.path.replace(biomedisa.BASE_DIR,host_base)]
103
101
  cmd += [f'-iid={img.id}', '-r']
104
102
  if process == 'convert':
105
103
  cmd += ['-c']
@@ -110,7 +108,7 @@ def init_process_image(id, process=None):
110
108
  subprocess.Popen(['ssh', host, 'mkdir', '-p', host_base+'/private_storage/images/'+img.user.username]).wait()
111
109
 
112
110
  # send data to host
113
- success = send_data_to_host(img.pic.path, host+':'+img.pic.path.replace(BASE_DIR,host_base))
111
+ success = send_data_to_host(img.pic.path, host+':'+img.pic.path.replace(biomedisa.BASE_DIR,host_base))
114
112
 
115
113
  # qsub start
116
114
  if 'REMOTE_QUEUE_QSUB' in config and config['REMOTE_QUEUE_QSUB']:
@@ -133,14 +131,14 @@ def init_process_image(id, process=None):
133
131
  subprocess.Popen(cmd).wait()
134
132
 
135
133
  # check if aborted
136
- success = subprocess.Popen(['scp', host+':'+host_base+f'/log/pid_5', BASE_DIR+f'/log/pid_5']).wait()
134
+ success = subprocess.Popen(['scp', host+':'+host_base+f'/log/pid_5', biomedisa.BASE_DIR+f'/log/pid_5']).wait()
137
135
 
138
136
  # get result
139
137
  if success==0:
140
138
  # remove pid file
141
139
  subprocess.Popen(['ssh', host, 'rm', host_base+f'/log/pid_5']).wait()
142
140
 
143
- result_on_host = img.pic.path.replace(BASE_DIR,host_base)
141
+ result_on_host = img.pic.path.replace(biomedisa.BASE_DIR,host_base)
144
142
  result_on_host = result_on_host.replace(os.path.splitext(result_on_host)[1], suffix)
145
143
  success = subprocess.Popen(['scp', host+':'+result_on_host, path_to_result]).wait()
146
144
 
@@ -226,7 +224,7 @@ if __name__ == "__main__":
226
224
 
227
225
  # set pid
228
226
  if bm.remote:
229
- from biomedisa_features.django_env import create_pid_object
227
+ from biomedisa.features.django_env import create_pid_object
230
228
  create_pid_object(os.getpid(), True, 5, bm.img_id)
231
229
 
232
230
  # load data
@@ -1,6 +1,6 @@
1
1
  ##########################################################################
2
2
  ## ##
3
- ## Copyright (c) 2022 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
  ## ##
@@ -82,3 +82,4 @@ if __name__ == "__main__":
82
82
 
83
83
  ctx.pop()
84
84
  del ctx
85
+
@@ -1,6 +1,6 @@
1
1
  ##########################################################################
2
2
  ## ##
3
- ## Copyright (c) 2022 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
  ## ##
@@ -181,3 +181,4 @@ def _build_curvature_gpu():
181
181
  mod = SourceModule(code)
182
182
  kernel = mod.get_function("Funktion")
183
183
  return kernel
184
+
@@ -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
  ## ##
@@ -32,7 +32,7 @@ import numpy as np
32
32
  import pycuda.driver as cuda
33
33
  import pycuda.gpuarray as gpuarray
34
34
  from pycuda.compiler import SourceModule
35
- from biomedisa_features.random_walk.gpu_kernels import (_build_kernel_uncertainty,
35
+ from biomedisa.features.random_walk.gpu_kernels import (_build_kernel_uncertainty,
36
36
  _build_kernel_max, _build_kernel_fill, _build_update_gpu, _build_curvature_gpu)
37
37
 
38
38
  def reduceBlocksize(slices):
@@ -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
  ## ##
@@ -32,7 +32,7 @@ import numpy as np
32
32
  import pycuda.driver as cuda
33
33
  import pycuda.gpuarray as gpuarray
34
34
  from pycuda.compiler import SourceModule
35
- from biomedisa_features.random_walk.gpu_kernels import (_build_kernel_uncertainty,
35
+ from biomedisa.features.random_walk.gpu_kernels import (_build_kernel_uncertainty,
36
36
  _build_kernel_max, _build_kernel_fill, _build_update_gpu, _build_curvature_gpu)
37
37
 
38
38
  def reduceBlocksize(slices):
@@ -1,6 +1,6 @@
1
1
  ##########################################################################
2
2
  ## ##
3
- ## Copyright (c) 2023 Philipp Lösel. All rights reserved. ##
3
+ ## Copyright (c) 20019-2024 Philipp Lösel. All rights reserved. ##
4
4
  ## ##
5
5
  ## This file is part of the open source project biomedisa. ##
6
6
  ## ##
@@ -30,7 +30,7 @@ import numpy as np
30
30
  import pycuda.driver as cuda
31
31
  import pycuda.gpuarray as gpuarray
32
32
  from pycuda.compiler import SourceModule
33
- from biomedisa_features.random_walk.gpu_kernels import _build_kernel_fill
33
+ from biomedisa.features.random_walk.gpu_kernels import _build_kernel_fill
34
34
 
35
35
  def walk(data, slices, indices, indices_child, nbrw, sorw, name, ctx, queue):
36
36
 
@@ -1,6 +1,6 @@
1
1
  ##########################################################################
2
2
  ## ##
3
- ## Copyright (c) 2023 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
  ## ##
@@ -30,7 +30,7 @@ import numpy as np
30
30
  import pycuda.driver as cuda
31
31
  import pycuda.gpuarray as gpuarray
32
32
  from pycuda.compiler import SourceModule
33
- from biomedisa_features.random_walk.gpu_kernels import _build_kernel_fill
33
+ from biomedisa.features.random_walk.gpu_kernels import _build_kernel_fill
34
34
  import numba
35
35
 
36
36
  def walk(data, slices, indices_all, indices_child, nbrw, sorw, name, ctx, queue):