biomedisa 2024.5.20__py3-none-any.whl → 2024.5.22__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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import subprocess
3
3
 
4
- # from source base directory
4
+ # base directory
5
5
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
6
6
 
7
7
  # pip installation
biomedisa/deeplearning.py CHANGED
@@ -42,6 +42,7 @@ import time
42
42
  import subprocess
43
43
  import glob
44
44
  import tempfile
45
+ import tifffile
45
46
 
46
47
  class Biomedisa(object):
47
48
  pass
@@ -55,6 +56,11 @@ def get_gpu_memory():
55
56
  except:
56
57
  return None
57
58
 
59
+ def number_of_slices(file_path):
60
+ with tifffile.TiffFile(file_path) as tiff:
61
+ z_dim = len(tiff.pages)
62
+ return z_dim
63
+
58
64
  def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=None,
59
65
  path_to_images=None, path_to_labels=None, val_images=None, val_labels=None,
60
66
  path_to_model=None, predict=False, train=False, header_file=None,
@@ -248,8 +254,16 @@ def deep_learning(img_data, label_data=None, val_img_data=None, val_label_data=N
248
254
  # list of images
249
255
  path_to_finals = []
250
256
  if bm.path_to_images is not None and os.path.isdir(bm.path_to_images):
251
- files = glob.glob(bm.path_to_images+'/**/*', recursive=True)
252
- bm.path_to_images = [f for f in files if os.path.isfile(f)]
257
+ # load list of volumetric image files
258
+ files = []
259
+ for data_type in ['.am','.hdr','.mhd','.mha','.nrrd','.nii','.nii.gz','.zip','.mrc']:
260
+ files += [file for file in glob.glob(bm.path_to_images+'/**/*'+data_type, recursive=True) if not os.path.basename(file).startswith('.')]
261
+ for data_type in ['.tif','.tiff']:
262
+ files += [file for file in glob.glob(bm.path_to_images+'/**/*'+data_type, recursive=True) if not os.path.basename(file).startswith('.') and number_of_slices(file)>1]
263
+ if len(files)==0: # assume directory of 2D slices
264
+ bm.path_to_images = [bm.path_to_images]
265
+ else:
266
+ bm.path_to_images = files
253
267
  else:
254
268
  bm.path_to_images = [bm.path_to_images]
255
269
 
@@ -28,7 +28,7 @@
28
28
 
29
29
  import os
30
30
  from biomedisa.features.biomedisa_helper import load_data, save_data
31
- from biomedisa.features.interpolation import smart_interpolation
31
+ from biomedisa.interpolation import smart_interpolation
32
32
  from tifffile import imread, imwrite, TiffFile
33
33
  import numpy as np
34
34
  import argparse
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: biomedisa
3
- Version: 2024.5.20
3
+ Version: 2024.5.22
4
4
  Summary: Segmentation of 3D volumetric image data
5
5
  Author: Philipp Lösel
6
6
  Author-email: philipp.loesel@anu.edu.au
@@ -21,36 +21,48 @@ License-File: LICENSE
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.22
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
+ ## Quickstart
59
+ Install the Biomedisa package from the [Python Package Index](https://pypi.org/project/biomedisa/):
60
+ ```
61
+ python -m pip install -U biomedisa
62
+ ```
63
+ For smart interpolation and deep Learning modules, follow the [installation instructions](https://github.com/biomedisa/biomedisa#installation-command-line-based).
64
+
65
+ ## Smart Interpolation
54
66
  + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/smart_interpolation.md)
55
67
 
56
68
  #### Python example
@@ -77,9 +89,12 @@ save_data('Downloads/final.trigonopterus.smooth.am', smooth_result, header=heade
77
89
  #### Command-line based
78
90
  ```
79
91
  python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif
92
+
93
+ # if pre-segmentation is not exclusively in the XY plane
94
+ python -m biomedisa.interpolation C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif --allaxis
80
95
  ```
81
96
 
82
- # Deep Learning
97
+ ## Deep Learning
83
98
  + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/deep_learning.md)
84
99
 
85
100
  #### Python example (training)
@@ -115,10 +130,10 @@ deep_learning(img_data, label_data, train=True, batch_size=12,
115
130
  #### Command-line based (training)
116
131
  ```
117
132
  # 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
133
+ python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -bs=12
119
134
 
120
135
  # 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
136
+ 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
137
  ```
123
138
  If running into ResourceExhaustedError due to out of memory (OOM), try to use smaller batch size.
124
139
 
@@ -143,7 +158,7 @@ save_data('final.Head5.am', results['regular'], results['header'])
143
158
  python -m biomedisa.deeplearning C:\Users\%USERNAME%\Downloads\testing_axial_crop_pat13.nii.gz C:\Users\%USERNAME%\Downloads\heart.h5 -p
144
159
  ```
145
160
 
146
- # Biomedisa Features
161
+ ## Biomedisa Features
147
162
 
148
163
  #### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
149
164
  ```python
@@ -222,41 +237,16 @@ dice = Dice_score(ground_truth, result)
222
237
  assd = ASSD(ground_truth, result)
223
238
  ```
224
239
 
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
240
+ ## Authors
251
241
 
252
242
  * **Philipp D. Lösel**
253
243
 
254
244
  See also the list of [contributors](https://github.com/biomedisa/biomedisa/blob/master/credits.md) who participated in this project.
255
245
 
256
- # FAQ
246
+ ## FAQ
257
247
  Frequently asked questions can be found at: https://biomedisa.info/faq/.
258
248
 
259
- # Citation
249
+ ## Citation
260
250
 
261
251
  If you use Biomedisa or the data, please cite the following paper:
262
252
 
@@ -270,7 +260,7 @@ If you use Biomedisa's Smart Interpolation, you can also cite the initial descri
270
260
 
271
261
  `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
262
 
273
- # License
263
+ ## License
274
264
 
275
265
  This project is covered under the **EUROPEAN UNION PUBLIC LICENCE v. 1.2 (EUPL)**.
276
266
 
@@ -1,6 +1,6 @@
1
- biomedisa/__init__.py,sha256=RxXuOh-e-W9k7pvmKDyYZz3bbze7AkB7RgRpUCzLbcE,1538
1
+ biomedisa/__init__.py,sha256=hw4mzEjGFXm-vxus2DBfKFW0nKoG0ibL5SH6ShfchrY,1526
2
2
  biomedisa/__main__.py,sha256=a1--8vhtztWEloHVtbM43FZLCfrFo4BELgdsgtWE8ls,536
3
- biomedisa/deeplearning.py,sha256=dVwLkijm0ibtn6zUUV3t2WK6Fzvks4VlgzKNLqzDpAQ,27064
3
+ biomedisa/deeplearning.py,sha256=UG5baX58CrO8YXe9pU6_Bp2OOvbC74LQw4S33HqM2iA,27828
4
4
  biomedisa/interpolation.py,sha256=R8UbBWt7vOuiQCPSeNIpEY0_yfQUg1oBfhAjXi91Hl4,17253
5
5
  biomedisa/mesh.py,sha256=glvpTN0PPByb5j2IbLCdWQtc5O4VT-Pwu3en8EaYyTo,15819
6
6
  biomedisa/features/DataGenerator.py,sha256=bGys6UZ0bnKb_k1Y3Spo6MNPk_goSAmptdZnI39smaw,12770
@@ -21,7 +21,7 @@ biomedisa/features/pid.py,sha256=Jmn1VIp0fBlgBrqZ-yUIQVVb5-NAxNBdibXALVr2PPI,254
21
21
  biomedisa/features/process_image.py,sha256=VtS3fGDvglqJiiJLPK1toe76J58j914NJ8XQKg3CRwo,11091
22
22
  biomedisa/features/pycuda_test.py,sha256=UGAGIz_dgcCJkzjyCqnMlflp-WJPzpCtFQmE9C5DwIo,3275
23
23
  biomedisa/features/remove_outlier.py,sha256=XhbFPkazMmEUZiP0FERdCkrXaLhwO095x4wcn-B3SdU,16756
24
- biomedisa/features/split_volume.py,sha256=l106WXlDSDut-PlP9_O7WmJCp6euoViPjYG7awoA9Y8,8926
24
+ biomedisa/features/split_volume.py,sha256=UgMpHhZPvH90xFo-mJ0Oc0tBXbrf8FQF0kzVySAlO8g,8917
25
25
  biomedisa/features/amira_to_np/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
26
  biomedisa/features/amira_to_np/amira_data_stream.py,sha256=JrZTyKP01CKDFB5d9BlGtSFwBgoAo0AJeAmn3pADH88,32618
27
27
  biomedisa/features/amira_to_np/amira_grammar.py,sha256=z1yajLHmn-GDb-rzZ5iHlKmPZDDbO9fNqP2jXf8z3KE,14324
@@ -37,8 +37,8 @@ biomedisa/features/random_walk/pyopencl_large.py,sha256=q79AxG3p3qFjxfiAZfUK9I5B
37
37
  biomedisa/features/random_walk/pyopencl_small.py,sha256=opNlS-qzOa9qWafBNJdvf6r1aRAFf7_JXf6ISDnkdXE,17068
38
38
  biomedisa/features/random_walk/rw_large.py,sha256=ZnITvk00Y11ZZlGuBRaJO1EwU0wYBdEwdpj9vvXCqF4,19805
39
39
  biomedisa/features/random_walk/rw_small.py,sha256=RPzZe24YrEwYelJukDjvqaoD_SyhgdriEi7uV3kZGXI,14881
40
- biomedisa-2024.5.20.dist-info/LICENSE,sha256=sehayP6UhydNnmstfL4yFR3genMRdpuUh6uZVWJN1H0,14152
41
- biomedisa-2024.5.20.dist-info/METADATA,sha256=uM3KiOS5fzl6WFv8cNRgsCT-l4DnGzgZoBiDqPg_qXM,10677
42
- biomedisa-2024.5.20.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
- biomedisa-2024.5.20.dist-info/top_level.txt,sha256=opsf1Eb4vCguPSxev4HHSeiUKCccT_C_RcUCdAYbHWQ,10
44
- biomedisa-2024.5.20.dist-info/RECORD,,
40
+ biomedisa-2024.5.22.dist-info/LICENSE,sha256=sehayP6UhydNnmstfL4yFR3genMRdpuUh6uZVWJN1H0,14152
41
+ biomedisa-2024.5.22.dist-info/METADATA,sha256=jKMlVJyzFHJ37MREWXc9UbUuDoxVA36hYr-1egUfnhY,10786
42
+ biomedisa-2024.5.22.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
43
+ biomedisa-2024.5.22.dist-info/top_level.txt,sha256=opsf1Eb4vCguPSxev4HHSeiUKCccT_C_RcUCdAYbHWQ,10
44
+ biomedisa-2024.5.22.dist-info/RECORD,,