biomedisa 2024.5.14__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.
Files changed (48) hide show
  1. biomedisa-2024.5.14/LICENSE +191 -0
  2. biomedisa-2024.5.14/PKG-INFO +306 -0
  3. biomedisa-2024.5.14/README.md +290 -0
  4. biomedisa-2024.5.14/pyproject.toml +23 -0
  5. biomedisa-2024.5.14/setup.cfg +4 -0
  6. biomedisa-2024.5.14/src/biomedisa/__init__.py +53 -0
  7. biomedisa-2024.5.14/src/biomedisa/__main__.py +18 -0
  8. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/DataGenerator.py +299 -0
  9. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/DataGeneratorCrop.py +121 -0
  10. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/PredictDataGenerator.py +87 -0
  11. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/PredictDataGeneratorCrop.py +74 -0
  12. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/__init__.py +0 -0
  13. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/active_contour.py +434 -0
  14. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/amira_to_np/__init__.py +0 -0
  15. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/amira_to_np/amira_data_stream.py +980 -0
  16. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/amira_to_np/amira_grammar.py +369 -0
  17. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/amira_to_np/amira_header.py +290 -0
  18. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/amira_to_np/amira_helper.py +72 -0
  19. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/assd.py +167 -0
  20. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/biomedisa_helper.py +801 -0
  21. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/create_slices.py +286 -0
  22. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/crop_helper.py +586 -0
  23. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/curvop_numba.py +149 -0
  24. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/django_env.py +172 -0
  25. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/keras_helper.py +1219 -0
  26. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/nc_reader.py +179 -0
  27. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/pid.py +52 -0
  28. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/process_image.py +253 -0
  29. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/pycuda_test.py +84 -0
  30. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/__init__.py +0 -0
  31. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/gpu_kernels.py +183 -0
  32. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pycuda_large.py +826 -0
  33. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pycuda_large_allx.py +806 -0
  34. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pycuda_small.py +414 -0
  35. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pycuda_small_allx.py +493 -0
  36. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pyopencl_large.py +760 -0
  37. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/pyopencl_small.py +441 -0
  38. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/rw_large.py +390 -0
  39. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/random_walk/rw_small.py +310 -0
  40. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/remove_outlier.py +399 -0
  41. biomedisa-2024.5.14/src/biomedisa/biomedisa_features/split_volume.py +274 -0
  42. biomedisa-2024.5.14/src/biomedisa/deeplearning.py +519 -0
  43. biomedisa-2024.5.14/src/biomedisa/interpolation.py +371 -0
  44. biomedisa-2024.5.14/src/biomedisa/mesh.py +406 -0
  45. biomedisa-2024.5.14/src/biomedisa.egg-info/PKG-INFO +306 -0
  46. biomedisa-2024.5.14/src/biomedisa.egg-info/SOURCES.txt +46 -0
  47. biomedisa-2024.5.14/src/biomedisa.egg-info/dependency_links.txt +1 -0
  48. biomedisa-2024.5.14/src/biomedisa.egg-info/top_level.txt +1 -0
@@ -0,0 +1,191 @@
1
+ EUROPEAN UNION PUBLIC LICENCE v. 1.2
2
+ EUPL © the European Union 2007, 2016
3
+
4
+ This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined below) which is provided under the
5
+ terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such
6
+ use is covered by a right of the copyright holder of the Work).
7
+ The Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following
8
+ notice immediately following the copyright notice for the Work:
9
+ Licensed under the EUPL
10
+ or has expressed by any other means his willingness to license under the EUPL.
11
+
12
+ 1.Definitions
13
+ In this Licence, the following terms have the following meaning:
14
+ — ‘The Licence’:this Licence.
15
+ — ‘The Original Work’:the work or software distributed or communicated by the Licensor under this Licence, available
16
+ as Source Code and also as Executable Code as the case may be.
17
+ — ‘Derivative Works’:the works or software that could be created by the Licensee, based upon the Original Work or
18
+ modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work
19
+ required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in
20
+ the country mentioned in Article 15.
21
+ — ‘The Work’:the Original Work or its Derivative Works.
22
+ — ‘The Source Code’:the human-readable form of the Work which is the most convenient for people to study and
23
+ modify.
24
+ — ‘The Executable Code’:any code which has generally been compiled and which is meant to be interpreted by
25
+ a computer as a program.
26
+ — ‘The Licensor’:the natural or legal person that distributes or communicates the Work under the Licence.
27
+ — ‘Contributor(s)’:any natural or legal person who modifies the Work under the Licence, or otherwise contributes to
28
+ the creation of a Derivative Work.
29
+ — ‘The Licensee’ or ‘You’:any natural or legal person who makes any usage of the Work under the terms of the
30
+ Licence.
31
+ — ‘Distribution’ or ‘Communication’:any act of selling, giving, lending, renting, distributing, communicating,
32
+ transmitting, or otherwise making available, online or offline, copies of the Work or providing access to its essential
33
+ functionalities at the disposal of any other natural or legal person.
34
+
35
+ 2.Scope of the rights granted by the Licence
36
+ The Licensor hereby grants You a worldwide, royalty-free, non-exclusive, sublicensable licence to do the following, for
37
+ the duration of copyright vested in the Original Work:
38
+ — use the Work in any circumstance and for all usage,
39
+ — reproduce the Work,
40
+ — modify the Work, and make Derivative Works based upon the Work,
41
+ — communicate to the public, including the right to make available or display the Work or copies thereof to the public
42
+ and perform publicly, as the case may be, the Work,
43
+ — distribute the Work or copies thereof,
44
+ — lend and rent the Work or copies thereof,
45
+ — sublicense rights in the Work or copies thereof.
46
+ Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the
47
+ applicable law permits so.
48
+ In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed
49
+ by law in order to make effective the licence of the economic rights here above listed.
50
+ The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to any patents held by the Licensor, to the
51
+ extent necessary to make use of the rights granted on the Work under this Licence.
52
+
53
+ 3.Communication of the Source Code
54
+ The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as
55
+ Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with
56
+ each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to
57
+ the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to
58
+ distribute or communicate the Work.
59
+
60
+ 4.Limitations on copyright
61
+ Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the
62
+ exclusive rights of the rights owners in the Work, of the exhaustion of those rights or of other applicable limitations
63
+ thereto.
64
+
65
+ 5.Obligations of the Licensee
66
+ The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those
67
+ obligations are the following:
68
+
69
+ Attribution right: The Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to
70
+ the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the
71
+ Licence with every copy of the Work he/she distributes or communicates. The Licensee must cause any Derivative Work
72
+ to carry prominent notices stating that the Work has been modified and the date of modification.
73
+
74
+ Copyleft clause: If the Licensee distributes or communicates copies of the Original Works or Derivative Works, this
75
+ Distribution or Communication will be done under the terms of this Licence or of a later version of this Licence unless
76
+ the Original Work is expressly distributed only under this version of the Licence — for example by communicating
77
+ ‘EUPL v. 1.2 only’. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the
78
+ Work or Derivative Work that alter or restrict the terms of the Licence.
79
+
80
+ Compatibility clause: If the Licensee Distributes or Communicates Derivative Works or copies thereof based upon both
81
+ the Work and another work licensed under a Compatible Licence, this Distribution or Communication can be done
82
+ under the terms of this Compatible Licence. For the sake of this clause, ‘Compatible Licence’ refers to the licences listed
83
+ in the appendix attached to this Licence. Should the Licensee's obligations under the Compatible Licence conflict with
84
+ his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
85
+
86
+ Provision of Source Code: When distributing or communicating copies of the Work, the Licensee will provide
87
+ a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available
88
+ for as long as the Licensee continues to distribute or communicate the Work.
89
+ Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names
90
+ of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and
91
+ reproducing the content of the copyright notice.
92
+
93
+ 6.Chain of Authorship
94
+ The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or
95
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
96
+ Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or
97
+ licensed to him/her and that he/she has the power and authority to grant the Licence.
98
+ Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions
99
+ to the Work, under the terms of this Licence.
100
+
101
+ 7.Disclaimer of Warranty
102
+ The Work is a work in progress, which is continuously improved by numerous Contributors. It is not a finished work
103
+ and may therefore contain defects or ‘bugs’ inherent to this type of development.
104
+ For the above reason, the Work is provided under the Licence on an ‘as is’ basis and without warranties of any kind
105
+ concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or
106
+ errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this
107
+ Licence.
108
+ This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
109
+
110
+ 8.Disclaimer of Liability
111
+ Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be
112
+ liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the
113
+ Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss
114
+ of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However,
115
+ the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
116
+
117
+ 9.Additional agreements
118
+ While distributing the Work, You may choose to conclude an additional agreement, defining obligations or services
119
+ consistent with this Licence. However, if accepting obligations, You may act only on your own behalf and on your sole
120
+ responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify,
121
+ defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by
122
+ the fact You have accepted any warranty or additional liability.
123
+
124
+ 10.Acceptance of the Licence
125
+ The provisions of this Licence can be accepted by clicking on an icon ‘I agree’ placed under the bottom of a window
126
+ displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of
127
+ applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms
128
+ and conditions.
129
+ Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You
130
+ by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution
131
+ or Communication by You of the Work or copies thereof.
132
+
133
+ 11.Information to the public
134
+ In case of any Distribution or Communication of the Work by means of electronic communication by You (for example,
135
+ by offering to download the Work from a remote location) the distribution channel or media (for example, a website)
136
+ must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence
137
+ and the way it may be accessible, concluded, stored and reproduced by the Licensee.
138
+
139
+ 12.Termination of the Licence
140
+ The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms
141
+ of the Licence.
142
+ Such a termination will not terminate the licences of any person who has received the Work from the Licensee under
143
+ the Licence, provided such persons remain in full compliance with the Licence.
144
+
145
+ 13.Miscellaneous
146
+ Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the
147
+ Work.
148
+ If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or
149
+ enforceability of the Licence as a whole. Such provision will be construed or reformed so as necessary to make it valid
150
+ and enforceable.
151
+ The European Commission may publish other linguistic versions or new versions of this Licence or updated versions of
152
+ the Appendix, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence.
153
+ New versions of the Licence will be published with a unique version number.
154
+ All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take
155
+ advantage of the linguistic version of their choice.
156
+
157
+ 14.Jurisdiction
158
+ Without prejudice to specific agreement between parties,
159
+ — any litigation resulting from the interpretation of this License, arising between the European Union institutions,
160
+ bodies, offices or agencies, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice
161
+ of the European Union, as laid down in article 272 of the Treaty on the Functioning of the European Union,
162
+ — any litigation arising between other parties and resulting from the interpretation of this License, will be subject to
163
+ the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
164
+
165
+ 15.Applicable Law
166
+ Without prejudice to specific agreement between parties,
167
+ — this Licence shall be governed by the law of the European Union Member State where the Licensor has his seat,
168
+ resides or has his registered office,
169
+ — this licence shall be governed by Belgian law if the Licensor has no seat, residence or registered office inside
170
+ a European Union Member State.
171
+
172
+
173
+ Appendix
174
+
175
+ ‘Compatible Licences’ according to Article 5 EUPL are:
176
+ — GNU General Public License (GPL) v. 2, v. 3
177
+ — GNU Affero General Public License (AGPL) v. 3
178
+ — Open Software License (OSL) v. 2.1, v. 3.0
179
+ — Eclipse Public License (EPL) v. 1.0
180
+ — CeCILL v. 2.0, v. 2.1
181
+ — Mozilla Public Licence (MPL) v. 2
182
+ — GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
183
+ — Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for works other than software
184
+ — European Union Public Licence (EUPL) v. 1.1, v. 1.2
185
+ — Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong Reciprocity (LiLiQ-R+).
186
+
187
+ The European Commission may update this Appendix to later versions of the above licences without producing
188
+ a new version of the EUPL, as long as they provide the rights granted in Article 2 of this Licence and protect the
189
+ covered Source Code from exclusive appropriation.
190
+ All other changes or additions to this Appendix require the production of a new EUPL version.
191
+
@@ -0,0 +1,306 @@
1
+ Metadata-Version: 2.1
2
+ Name: biomedisa
3
+ Version: 2024.5.14
4
+ Summary: Segmentation of 3D volumetric image data
5
+ Author: Philipp Lösel
6
+ Author-email: philipp.loesel@anu.edu.au
7
+ Project-URL: Homepage, https://biomedisa.info
8
+ Project-URL: Issues, https://github.com/biomedisa/biomedisa/issues
9
+ Project-URL: GitHub, https://github.com/biomedisa/biomedisa
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.10
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+
17
+ [![biomedisa](biomedisa_app/static/biomedisa_logo.svg)](https://biomedisa.info)
18
+ -----------
19
+ - [Overview](#overview)
20
+ - [Hardware Requirements](#hardware-requirements)
21
+ - [Installation (command-line based)](#installation-command-line-based)
22
+ - [Installation (browser based)](#installation-browser-based)
23
+ - [Download Data](#download-data)
24
+ - [Smart Interpolation](#smart-interpolation)
25
+ - [Deep Learning](#deep-learning)
26
+ - [Biomedisa Features](#biomedisa-features)
27
+ - [Update Biomedisa](#update-biomedisa)
28
+ - [Releases](#releases)
29
+ - [Authors](#authors)
30
+ - [FAQ](#faq)
31
+ - [Citation](#citation)
32
+ - [License](#license)
33
+
34
+ # Overview
35
+ 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
+
37
+ # Hardware Requirements
38
+ + One or more NVIDIA GPUs with compute capability 3.0 or higher or an Intel CPU.
39
+
40
+ # Installation (command-line based)
41
+ + [Ubuntu 22.04 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8_gpu_cli.md)
42
+ + [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
+ + [Windows 10 + CUDA + GPU (recommended)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_cuda_gpu_cli.md)
44
+ + [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
+ + [Windows 10 + OpenCL + CPU (very slow)](https://github.com/biomedisa/biomedisa/blob/master/README/windows10_opencl_cpu_cli.md)
46
+
47
+ # Installation (browser based)
48
+ + [Ubuntu 22.04](https://github.com/biomedisa/biomedisa/blob/master/README/ubuntu2204_cuda11.8.md)
49
+
50
+ # Download Data
51
+ + Download the data from our [gallery](https://biomedisa.info/gallery/)
52
+
53
+ # Smart Interpolation
54
+ + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/smart_interpolation.md)
55
+
56
+ #### Python example
57
+ ```python
58
+ # change this line to your biomedisa directory
59
+ path_to_biomedisa = '/home/<user>/git/biomedisa'
60
+
61
+ import sys
62
+ sys.path.append(path_to_biomedisa)
63
+ from biomedisa_features.biomedisa_helper import load_data, save_data
64
+ from biomedisa_features.biomedisa_interpolation import smart_interpolation
65
+
66
+ # load data
67
+ img, _ = load_data('Downloads/trigonopterus.tif')
68
+ labels, header = load_data('Downloads/labels.trigonopterus_smart.am')
69
+
70
+ # run smart interpolation with optional smoothing result
71
+ results = smart_interpolation(img, labels, smooth=100)
72
+
73
+ # get results
74
+ regular_result = results['regular']
75
+ smooth_result = results['smooth']
76
+
77
+ # save results
78
+ save_data('Downloads/final.trigonopterus.am', regular_result, header=header)
79
+ save_data('Downloads/final.trigonopterus.smooth.am', smooth_result, header=header)
80
+ ```
81
+
82
+ #### Command-line based
83
+ ```
84
+ # change to the features directory
85
+ cd git/biomedisa/biomedisa_features/
86
+
87
+ # start smart interpolation
88
+ python biomedisa_interpolation.py C:\Users\%USERNAME%\Downloads\tumor.tif C:\Users\%USERNAME%\Downloads\labels.tumor.tif
89
+ ```
90
+
91
+ # Deep Learning
92
+ + [Parameters and Examples](https://github.com/biomedisa/biomedisa/blob/master/README/deep_learning.md)
93
+
94
+ #### Python example (training)
95
+ ```python
96
+ # change this line to your biomedisa directory
97
+ path_to_biomedisa = '/home/<user>/git/biomedisa'
98
+
99
+ # load libraries
100
+ import sys
101
+ sys.path.append(path_to_biomedisa)
102
+ from biomedisa_features.biomedisa_helper import load_data
103
+ from biomedisa_features.biomedisa_deeplearning import deep_learning
104
+
105
+ # load image data
106
+ img1, _ = load_data('Head1.am')
107
+ img2, _ = load_data('Head2.am')
108
+ img_data = [img1, img2]
109
+
110
+ # load label data and header information to be stored in the network file (optional)
111
+ label1, _ = load_data('Head1.labels.am')
112
+ label2, header, ext = load_data('Head2.labels.am',
113
+ return_extension=True)
114
+ label_data = [label1, label2]
115
+
116
+ # load validation data (optional)
117
+ img3, _ = load_data('Head3.am')
118
+ img4, _ = load_data('Head4.am')
119
+ label3, _ = load_data('Head3.labels.am')
120
+ label4, _ = load_data('Head4.labels.am')
121
+ val_img_data = [img3, img4]
122
+ val_label_data = [label3, label4]
123
+
124
+ # deep learning
125
+ deep_learning(img_data, label_data, train=True, batch_size=12,
126
+ val_img_data=val_img_data, val_label_data=val_label_data,
127
+ header=header, extension=ext, path_to_model='honeybees.h5')
128
+ ```
129
+
130
+ #### Command-line based (training)
131
+ ```
132
+ # change to the features directory
133
+ cd git/biomedisa/biomedisa_features/
134
+
135
+ # start training with a batch size of 12
136
+ python biomedisa_deeplearning.py C:\Users\%USERNAME%\Downloads\training_heart C:\Users\%USERNAME%\Downloads\training_heart_labels -t -bs 12
137
+
138
+ # validation (optional)
139
+ python biomedisa_deeplearning.py 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
140
+ ```
141
+ If running into ResourceExhaustedError due to out of memory (OOM), try to use smaller batch size.
142
+
143
+ #### Python example (prediction)
144
+ ```python
145
+ # change this line to your biomedisa directory
146
+ path_to_biomedisa = '/home/<user>/git/biomedisa'
147
+
148
+ # load libraries
149
+ import sys
150
+ sys.path.append(path_to_biomedisa)
151
+ from biomedisa_features.biomedisa_helper import load_data, save_data
152
+ from biomedisa_features.biomedisa_deeplearning import deep_learning
153
+
154
+ # load data
155
+ img, _ = load_data('Head5.am')
156
+
157
+ # deep learning
158
+ results = deep_learning(img, predict=True,
159
+ path_to_model='honeybees.h5', batch_size=6)
160
+
161
+ # save result
162
+ save_data('final.Head5.am', results['regular'], results['header'])
163
+ ```
164
+
165
+ #### Command-line based (prediction)
166
+ ```
167
+ # change to the features directory
168
+ cd git/biomedisa/biomedisa_features/
169
+
170
+ # start prediction with a batch size of 6
171
+ python biomedisa_deeplearning.py C:\Users\%USERNAME%\Downloads\testing_axial_crop_pat13.nii.gz C:\Users\%USERNAME%\Downloads\heart.h5 -p -bs 6
172
+ ```
173
+
174
+ # Biomedisa Features
175
+
176
+ #### Load and save data (such as Amira Mesh, TIFF, NRRD, NIfTI or DICOM)
177
+ ```python
178
+ import sys
179
+ sys.path.append(path_to_biomedisa) # e.g. '/home/<user>/git/biomedisa'
180
+ from biomedisa_features.biomedisa_helper import load_data, save_data
181
+
182
+ # load data as numpy array
183
+ # for DICOM, PNG files, or similar formats, 'path_to_data' must reference
184
+ # either a directory or a ZIP file containing the image slices
185
+ data, header = load_data(path_to_data)
186
+
187
+ # save data (for TIFF, header=None)
188
+ save_data(path_to_data, data, header)
189
+ ```
190
+
191
+ #### Create STL mesh from segmentation (label values are saved as attributes)
192
+ ```python
193
+ import os, sys
194
+ sys.path.append(path_to_biomedisa) # e.g. '/home/<user>/git/biomedisa'
195
+ from biomedisa_features.biomedisa_helper import load_data, save_data
196
+ from biomedisa_features.create_mesh import get_voxel_spacing, save_mesh
197
+
198
+ # load segmentation
199
+ data, header, extension = load_data(path_to_data, return_extension=True)
200
+
201
+ # get voxel spacing
202
+ x_res, y_res, z_res = get_voxel_spacing(header, data, extension)
203
+ print(f'Voxel spacing: x_spacing, y_spacing, z_spacing = {x_res}, {y_res}, {z_res}')
204
+
205
+ # save stl file
206
+ path_to_data = path_to_data.replace(os.path.splitext(path_to_data)[1],'.stl')
207
+ save_mesh(path_to_data, data, x_res, y_res, z_res, poly_reduction=0.9, smoothing_iterations=15)
208
+ ```
209
+
210
+ #### Create mesh directly
211
+ ```
212
+ python git/biomedisa/biomedisa_features/create_mesh.py <path_to_data>
213
+ ```
214
+
215
+ #### Options
216
+ `--poly_reduction` or `-pr`: Reduce number of polygons by this factor (default: 0.9)
217
+
218
+ `--smoothing_iterations` or `-s`: Iteration steps for smoothing (default: 15)
219
+
220
+ `--x_res` or `-xres`: Voxel spacing/resolution x-axis (default: None)
221
+
222
+ `--y_res` or `-yres`: Voxel spacing/resolution y-axis (default: None)
223
+
224
+ `--z_res` or `-zres`: Voxel spacing/resolution z-axis (default: None)
225
+
226
+ #### Resize data
227
+ ```python
228
+ import os, sys
229
+ sys.path.append(path_to_biomedisa) # e.g. '/home/<user>/git/biomedisa'
230
+ from biomedisa_features.biomedisa_helper import img_resize
231
+
232
+ # resize image data
233
+ zsh, ysh, xsh = data.shape
234
+ new_zsh, new_ysh, new_xsh = zsh//2, ysh//2, xsh//2
235
+ data = img_resize(data, new_zsh, new_ysh, new_xsh)
236
+
237
+ # resize label data
238
+ label_data = img_resize(label_data, new_zsh, new_ysh, new_xsh, labels=True)
239
+ ```
240
+
241
+ #### Remove outliers and fill holes
242
+ ```python
243
+ from biomedisa_features.biomedisa_helper import clean, fill
244
+
245
+ # delete outliers smaller than 90% of the segment
246
+ label_data = clean(label_data, 0.9)
247
+
248
+ # fill holes
249
+ label_data = fill(label_data, 0.9)
250
+ ```
251
+
252
+ #### Accuracy assessment
253
+ ```python
254
+ from biomedisa_features.biomedisa_helper import Dice_score, ASSD
255
+ dice = Dice_score(ground_truth, result)
256
+ assd = ASSD(ground_truth, result)
257
+ ```
258
+
259
+ # Update Biomedisa
260
+ If you have used `git clone`, change to the Biomedisa directory and make a pull request.
261
+ ```
262
+ cd git/biomedisa
263
+ git pull
264
+ ```
265
+
266
+ If you have installed the browser based version of Biomedisa (including MySQL database), you also need to update the database.
267
+ ```
268
+ python manage.py migrate
269
+ ```
270
+
271
+ If you have installed an [Apache Server](https://github.com/biomedisa/biomedisa/blob/master/README/APACHE_SERVER.md), you need to restart the server.
272
+ ```
273
+ sudo service apache2 restart
274
+ ```
275
+
276
+ # Releases
277
+
278
+ For the versions available, see the [list of releases](https://github.com/biomedisa/biomedisa/releases).
279
+
280
+ # Authors
281
+
282
+ * **Philipp D. Lösel**
283
+
284
+ See also the list of [contributors](https://github.com/biomedisa/biomedisa/blob/master/credits.md) who participated in this project.
285
+
286
+ # FAQ
287
+ Frequently asked questions can be found at: https://biomedisa.info/faq/.
288
+
289
+ # Citation
290
+
291
+ If you use Biomedisa or the data, please cite the following paper:
292
+
293
+ `Lösel, P.D. et al. Introducing Biomedisa as an open-source online platform for biomedical image segmentation. Nat. Commun. 11, 5577 (2020).` https://doi.org/10.1038/s41467-020-19303-w
294
+
295
+ If you use Biomedisa's Deep Learning, you may also cite:
296
+
297
+ `Lösel, P.D. et al. Natural variability in bee brain size and symmetry revealed by micro-CT imaging and deep learning. PLoS Comput. Biol. 19, e1011529 (2023).` https://doi.org/10.1371/journal.pcbi.1011529
298
+
299
+ If you use Biomedisa's Smart Interpolation, you can also cite the initial description of this method:
300
+
301
+ `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
302
+
303
+ # License
304
+
305
+ This project is covered under the **EUROPEAN UNION PUBLIC LICENCE v. 1.2 (EUPL)**.
306
+