cellprofiler-library-nightly 5.0.0.dev65__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 (38) hide show
  1. cellprofiler_library_nightly-5.0.0.dev65/LICENSE +41 -0
  2. cellprofiler_library_nightly-5.0.0.dev65/PKG-INFO +87 -0
  3. cellprofiler_library_nightly-5.0.0.dev65/README.md +5 -0
  4. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/__init__.py +0 -0
  5. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/_version.py +16 -0
  6. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/__init__.py +0 -0
  7. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/file_processing.py +154 -0
  8. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/image_processing.py +521 -0
  9. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/measurement.py +455 -0
  10. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/object_processing.py +453 -0
  11. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/functions/segmentation.py +754 -0
  12. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/__init__.py +16 -0
  13. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_closing.py +8 -0
  14. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_combineobjects.py +21 -0
  15. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_enhanceedges.py +91 -0
  16. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_expandorshrinkobjects.py +17 -0
  17. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_fillobjects.py +10 -0
  18. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_measureimageoverlap.py +33 -0
  19. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_medialaxis.py +16 -0
  20. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_medianfilter.py +4 -0
  21. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_morphologicalskeleton.py +8 -0
  22. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_opening.py +7 -0
  23. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_overlayobjects.py +13 -0
  24. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_reducenoise.py +11 -0
  25. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_savecroppedobjects.py +31 -0
  26. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_threshold.py +141 -0
  27. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/modules/_watershed.py +56 -0
  28. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/opts/__init__.py +0 -0
  29. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/opts/measureimageoverlap.py +6 -0
  30. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library/py.typed +0 -0
  31. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library_nightly.egg-info/PKG-INFO +87 -0
  32. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library_nightly.egg-info/SOURCES.txt +36 -0
  33. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library_nightly.egg-info/dependency_links.txt +1 -0
  34. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library_nightly.egg-info/requires.txt +15 -0
  35. cellprofiler_library_nightly-5.0.0.dev65/cellprofiler_library_nightly.egg-info/top_level.txt +1 -0
  36. cellprofiler_library_nightly-5.0.0.dev65/environment.yml +12 -0
  37. cellprofiler_library_nightly-5.0.0.dev65/pyproject.toml +96 -0
  38. cellprofiler_library_nightly-5.0.0.dev65/setup.cfg +4 -0
@@ -0,0 +1,41 @@
1
+ The BSD 3-Clause License
2
+
3
+ Copyright © 2003 - 2021 Broad Institute, Inc. All rights reserved.
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice,
9
+ this list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the Broad Institute, Inc. nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED “AS IS.” BROAD MAKES NO EXPRESS OR IMPLIED
20
+ REPRESENTATIONS OR WARRANTIES OF ANY KIND REGARDING THE SOFTWARE AND
21
+ COPYRIGHT, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE, CONFORMITY WITH ANY DOCUMENTATION,
23
+ NON-INFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT
24
+ DISCOVERABLE. IN NO EVENT SHALL BROAD, THE COPYRIGHT HOLDERS, OR CONTRIBUTORS
25
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE
27
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF, HAVE REASON TO KNOW, OR IN
31
+ FACT SHALL KNOW OF THE POSSIBILITY OF SUCH DAMAGE.
32
+
33
+ If, by operation of law or otherwise, any of the aforementioned warranty
34
+ disclaimers are determined inapplicable, your sole remedy, regardless of the
35
+ form of action, including, but not limited to, negligence and strict
36
+ liability, shall be replacement of the software with an updated version if one
37
+ exists.
38
+
39
+ Development of CellProfiler has been funded in whole or in part with federal
40
+ funds from the National Institutes of Health, the National Science Foundation,
41
+ and the Human Frontier Science Program.
@@ -0,0 +1,87 @@
1
+ Metadata-Version: 2.1
2
+ Name: cellprofiler-library-nightly
3
+ Version: 5.0.0.dev65
4
+ Summary: cellprofiler-lirary implements CellProfiler's image processing and mathematical code, and is usable as a standalone library
5
+ Author: Anne Carpenter, Thouis (Ray) Jones, Lee Kamentsky, Vebjorn Ljosa, David Logan, Mark Bray, Madison Swain-Bowden, Allen Goodman, Claire McQuinn, Alice Lucas, Callum Tromans-Coia
6
+ Author-email: Beth Cimini <bcimini@broadinstitute.org>, David Stirling <dstirling@glencoesoftware.com>, Nodar Gogoberidze <ngogober@broadinstitute.org>
7
+ Maintainer-email: Beth Cimini <bcimini@broadinstitute.org>, Nodar Gogoberidze <ngogober@broadinstitute.org>
8
+ License: The BSD 3-Clause License
9
+
10
+ Copyright © 2003 - 2021 Broad Institute, Inc. All rights reserved.
11
+
12
+ Redistribution and use in source and binary forms, with or without
13
+ modification, are permitted provided that the following conditions are met:
14
+
15
+ 1. Redistributions of source code must retain the above copyright notice,
16
+ this list of conditions and the following disclaimer.
17
+
18
+ 2. Redistributions in binary form must reproduce the above copyright
19
+ notice, this list of conditions and the following disclaimer in the
20
+ documentation and/or other materials provided with the distribution.
21
+
22
+ 3. Neither the name of the Broad Institute, Inc. nor the names of its
23
+ contributors may be used to endorse or promote products derived from
24
+ this software without specific prior written permission.
25
+
26
+ THIS SOFTWARE IS PROVIDED “AS IS.” BROAD MAKES NO EXPRESS OR IMPLIED
27
+ REPRESENTATIONS OR WARRANTIES OF ANY KIND REGARDING THE SOFTWARE AND
28
+ COPYRIGHT, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE, CONFORMITY WITH ANY DOCUMENTATION,
30
+ NON-INFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, WHETHER OR NOT
31
+ DISCOVERABLE. IN NO EVENT SHALL BROAD, THE COPYRIGHT HOLDERS, OR CONTRIBUTORS
32
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO PROCUREMENT OF SUBSTITUTE
34
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF, HAVE REASON TO KNOW, OR IN
38
+ FACT SHALL KNOW OF THE POSSIBILITY OF SUCH DAMAGE.
39
+
40
+ If, by operation of law or otherwise, any of the aforementioned warranty
41
+ disclaimers are determined inapplicable, your sole remedy, regardless of the
42
+ form of action, including, but not limited to, negligence and strict
43
+ liability, shall be replacement of the software with an updated version if one
44
+ exists.
45
+
46
+ Development of CellProfiler has been funded in whole or in part with federal
47
+ funds from the National Institutes of Health, the National Science Foundation,
48
+ and the Human Frontier Science Program.
49
+
50
+ Project-URL: Homepage, https://cellprofiler.org/
51
+ Project-URL: Documentation, https://cellprofiler.org/manuals
52
+ Project-URL: Wiki, https://github.com/CellProfiler/CellProfiler/wiki
53
+ Project-URL: Repository, https://github.com/CellProfiler/CellProfiler
54
+ Project-URL: Issues, https://github.com/CellProfiler/CellProfiler/issues
55
+ Project-URL: Changelog, https://github.com/CellProfiler/CellProfiler/releases
56
+ Keywords: computer vision,image analysis,biology,cell,cellprofiler
57
+ Classifier: Development Status :: 5 - Production/Stable
58
+ Classifier: Intended Audience :: Science/Research
59
+ Classifier: License :: OSI Approved :: BSD License
60
+ Classifier: Operating System :: OS Independent
61
+ Classifier: Programming Language :: Python :: 3.9
62
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
63
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
64
+ Classifier: Topic :: Scientific/Engineering :: Image Processing
65
+ Classifier: Topic :: Scientific/Engineering
66
+ Requires-Python: >=3.9
67
+ Description-Content-Type: text/markdown
68
+ License-File: LICENSE
69
+ Requires-Dist: numpy~=1.24.4
70
+ Requires-Dist: scikit-image~=0.20.0
71
+ Requires-Dist: scipy<1.11,>=1.9.1
72
+ Requires-Dist: mahotas~=1.4.13
73
+ Requires-Dist: centrosome~=1.2.2
74
+ Requires-Dist: matplotlib<4,>=3.1.3
75
+ Requires-Dist: packaging>=20.0
76
+ Provides-Extra: dev
77
+ Requires-Dist: build; extra == "dev"
78
+ Requires-Dist: pyinstaller; extra == "dev"
79
+ Requires-Dist: twine; extra == "dev"
80
+ Provides-Extra: test
81
+ Requires-Dist: pytest~=7.4.1; extra == "test"
82
+
83
+ # library
84
+
85
+ This subpackage contains the code to build the `cellprofiler-library` package. It contains the image processing modules required by the [CellProfiler](cellprofiler.org) software. Both the [core](../core/) subpackage, and the [frontend](../../frontend/) rely on this subpackage. This package can be used in isolation, separate from the `cellprofiler` and `cellprofiler-core` packages to access CellProfiler's image processing functionality as a Python package.
86
+
87
+ It is currently a work under progress, and does not yet contain all or even most of CellProfiler's image processing capabilities.
@@ -0,0 +1,5 @@
1
+ # library
2
+
3
+ This subpackage contains the code to build the `cellprofiler-library` package. It contains the image processing modules required by the [CellProfiler](cellprofiler.org) software. Both the [core](../core/) subpackage, and the [frontend](../../frontend/) rely on this subpackage. This package can be used in isolation, separate from the `cellprofiler` and `cellprofiler-core` packages to access CellProfiler's image processing functionality as a Python package.
4
+
5
+ It is currently a work under progress, and does not yet contain all or even most of CellProfiler's image processing capabilities.
@@ -0,0 +1,16 @@
1
+ # file generated by setuptools_scm
2
+ # don't change, don't track in version control
3
+ TYPE_CHECKING = False
4
+ if TYPE_CHECKING:
5
+ from typing import Tuple, Union
6
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
7
+ else:
8
+ VERSION_TUPLE = object
9
+
10
+ version: str
11
+ __version__: str
12
+ __version_tuple__: VERSION_TUPLE
13
+ version_tuple: VERSION_TUPLE
14
+
15
+ __version__ = version = '5.0.0.dev65'
16
+ __version_tuple__ = version_tuple = (5, 0, 0, 'dev65')
@@ -0,0 +1,154 @@
1
+ import os
2
+
3
+ import numpy
4
+ import skimage
5
+
6
+ def save_object_image_crops(
7
+ input_image,
8
+ input_objects,
9
+ save_dir,
10
+ file_format="tiff8",
11
+ nested_save=False,
12
+ save_names = {"input_filename": None, "input_objects_name": None},
13
+ volumetric=False
14
+ ):
15
+ """
16
+ For a given input_objects array, save crops for each
17
+ object of the provided input_image.
18
+ """
19
+ # Build save paths
20
+ if nested_save:
21
+ if not save_names["input_filename"] and not save_names["input_objects_name"]:
22
+ raise ValueError("Must provide a save_names['input_filename'] or save_names['input_objects_name'] for nested save.")
23
+ save_path = os.path.join(
24
+ save_dir,
25
+ save_names["input_filename"] if save_names["input_filename"] else save_names["input_objects_name"],
26
+ )
27
+ else:
28
+ save_path = save_dir
29
+
30
+ if not os.path.exists(save_path):
31
+ os.makedirs(save_path, exist_ok=True)
32
+
33
+ unique_labels = numpy.unique(input_objects)
34
+
35
+ if unique_labels[0] == 0:
36
+ unique_labels = unique_labels[1:]
37
+
38
+ labels = input_objects
39
+
40
+ if len(input_image.shape) == len(input_objects.shape) + 1 and not volumetric:
41
+ labels = numpy.repeat(
42
+ labels[:, :, numpy.newaxis], input_image.shape[-1], axis=2
43
+ )
44
+
45
+ # Construct filename
46
+ save_filename = f"{save_names['input_filename']+'_' if save_names['input_filename'] else ''}{save_names['input_objects_name']+'_' if save_names['input_objects_name'] else ''}"
47
+
48
+ save_filenames = []
49
+
50
+ for label in unique_labels:
51
+ file_extension = "tiff" if "tiff" in file_format else "png"
52
+
53
+ label_save_filename = os.path.join(save_path, save_filename + f"{label}.{file_extension}")
54
+ save_filenames.append(label_save_filename)
55
+ mask_in = labels == label
56
+ properties = skimage.measure.regionprops(
57
+ mask_in.astype(int), intensity_image=input_image
58
+ )
59
+ mask = properties[0].intensity_image
60
+
61
+ if file_format.casefold() == "png":
62
+ skimage.io.imsave(
63
+ label_save_filename,
64
+ skimage.img_as_ubyte(mask),
65
+ check_contrast=False
66
+ )
67
+ elif file_format.casefold() == "tiff8":
68
+ skimage.io.imsave(
69
+ label_save_filename,
70
+ skimage.img_as_ubyte(mask),
71
+ compress=6,
72
+ check_contrast=False,
73
+ )
74
+ elif file_format.casefold() == "tiff16":
75
+ skimage.io.imsave(
76
+ label_save_filename,
77
+ skimage.img_as_uint(mask),
78
+ compress=6,
79
+ check_contrast=False,
80
+ )
81
+ else:
82
+ raise ValueError(f"{file_format} not in 'png', 'tiff8', or 'tiff16'")
83
+
84
+ return save_filenames
85
+
86
+ def save_object_masks(
87
+ input_objects,
88
+ save_dir,
89
+ file_format="tiff8",
90
+ nested_save=False,
91
+ save_names = {"input_filename": None, "input_objects_name": None},
92
+ ):
93
+ """
94
+ For a given object array, save objects as individual masks
95
+ """
96
+ # Build save paths
97
+ if nested_save:
98
+ if not save_names["input_filename"] and not save_names["input_objects_name"]:
99
+ raise ValueError("Must provide a save_names['input_filename'] or save_names['input_objects_name'] for nested save.")
100
+ save_path = os.path.join(
101
+ save_dir,
102
+ save_names["input_filename"] if save_names["input_filename"] else save_names["input_objects_name"],
103
+ )
104
+ else:
105
+ save_path = save_dir
106
+
107
+ if not os.path.exists(save_path):
108
+ os.makedirs(save_path, exist_ok=True)
109
+
110
+ unique_labels = numpy.unique(input_objects)
111
+
112
+ if unique_labels[0] == 0:
113
+ unique_labels = unique_labels[1:]
114
+
115
+ labels = input_objects
116
+
117
+ # Construct filename
118
+ save_filename = f"{save_names['input_filename']+'_' if save_names['input_filename'] else ''}{save_names['input_objects_name']+'_' if save_names['input_objects_name'] else ''}"
119
+
120
+ filenames = []
121
+
122
+ for label in unique_labels:
123
+ file_extension = "tiff" if "tiff" in file_format else "png"
124
+
125
+ label_save_filename = os.path.join(save_path, save_filename + f"{label}.{file_extension}")
126
+
127
+ filenames.append(label_save_filename)
128
+
129
+ mask = labels == label
130
+
131
+ if file_format.casefold() == "png":
132
+ skimage.io.imsave(
133
+ label_save_filename,
134
+ skimage.img_as_ubyte(mask),
135
+ check_contrast=False
136
+ )
137
+ elif file_format.casefold() == "tiff8":
138
+ skimage.io.imsave(
139
+ label_save_filename,
140
+ skimage.img_as_ubyte(mask),
141
+ compress=6,
142
+ check_contrast=False,
143
+ )
144
+ elif file_format.casefold() == "tiff16":
145
+ skimage.io.imsave(
146
+ label_save_filename,
147
+ skimage.img_as_uint(mask),
148
+ compress=6,
149
+ check_contrast=False,
150
+ )
151
+ else:
152
+ raise ValueError(f"{file_format} not in 'png', 'tiff8', or 'tiff16'")
153
+
154
+ return filenames