cellprofiler-library-nightly 5.0.0.dev313__py3-none-any.whl → 5.0.0.dev318__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.
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '5.0.0.dev313'
32
- __version_tuple__ = version_tuple = (5, 0, 0, 'dev313')
31
+ __version__ = version = '5.0.0.dev318'
32
+ __version_tuple__ = version_tuple = (5, 0, 0, 'dev318')
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -6,10 +6,9 @@ import centrosome.threshold
6
6
  import scipy
7
7
  import matplotlib
8
8
  from typing import Any, Optional, Tuple, Callable, Union, List
9
- from ..types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ObjectSegmentation
9
+ from ..types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ObjectSegmentation, Image2D
10
10
  from ..opts import threshold as Threshold
11
11
 
12
-
13
12
  def rgb_to_greyscale(image):
14
13
  if image.shape[-1] == 4:
15
14
  output = skimage.color.rgba2rgb(image)
@@ -616,4 +615,22 @@ def image_to_objects(
616
615
  if preserve_label and not cast_to_bool:
617
616
  return data
618
617
 
619
- return skimage.measure.label(data, background=background, connectivity=connectivity)
618
+ return skimage.measure.label(data, background=background, connectivity=connectivity)
619
+
620
+ ###########################################################################
621
+ # CorrectIlluminationApply
622
+ ###########################################################################
623
+
624
+ def apply_divide(image_pixels: Image2D, illum_function_pixel_data: Image2D) -> Image2D:
625
+ return image_pixels / illum_function_pixel_data
626
+
627
+ def apply_subtract(image_pixels: Image2D, illum_function_pixel_data: Image2D) -> Image2D:
628
+ output_image = image_pixels - illum_function_pixel_data
629
+ output_image[output_image < 0] = 0
630
+ return output_image
631
+
632
+ def clip_low(output_pixels: Image2D) -> Image2D:
633
+ return numpy.where(output_pixels < 0, 0, output_pixels)
634
+
635
+ def clip_high(output_pixels: Image2D) -> Image2D:
636
+ return numpy.where(output_pixels > 1, 1, output_pixels)
@@ -0,0 +1,40 @@
1
+ from typing import Annotated, Optional
2
+ from pydantic import Field, validate_call, ConfigDict
3
+ from cellprofiler_library.opts.correctilluminationapply import Method
4
+ from ..types import Image2D
5
+ from ..functions.image_processing import apply_divide, apply_subtract, clip_low, clip_high
6
+
7
+
8
+ @validate_call(config=ConfigDict(arbitrary_types_allowed=True))
9
+ def correct_illumination_apply(
10
+ image_pixels: Annotated[Image2D, Field(description="Pixel data of image to apply the illumination function to")],
11
+ illum_function_pixel_data: Annotated[Image2D, Field(description="Pixel data of illumination function")],
12
+ method_divide_or_subtract: Annotated[Method, Field(description="Method to apply the illumination function")],
13
+ truncate_low: Annotated[Optional[bool], Field(description="Set output image values less than 0 equal to 0?")],
14
+ truncate_high: Annotated[Optional[bool], Field(description="Set output image values greater than 1 equal to 1?")],
15
+ ) -> Annotated[Image2D, Field(description="Pixel data of image with illumination function applied")]:
16
+ """
17
+ Perform illumination according to the parameters of one image setting group
18
+ """
19
+ assert image_pixels.shape[:2] == illum_function_pixel_data.shape[:2], "Input image shape and illumination function shape must be equal"
20
+ #
21
+ # Either divide or subtract the illumination image from the original
22
+ #
23
+ if method_divide_or_subtract == Method.DIVIDE:
24
+ output_pixels = apply_divide(image_pixels, illum_function_pixel_data)
25
+ elif method_divide_or_subtract == Method.SUBTRACT:
26
+ output_pixels = apply_subtract(image_pixels, illum_function_pixel_data)
27
+ else:
28
+ raise ValueError(
29
+ "Unhandled option for divide or subtract: %s"
30
+ % method_divide_or_subtract.value
31
+ )
32
+ #
33
+ # Optionally, clip high and low values
34
+ #
35
+ if truncate_low:
36
+ output_pixels = clip_low(output_pixels)
37
+ if truncate_high:
38
+ output_pixels = clip_high(output_pixels)
39
+
40
+ return output_pixels
@@ -0,0 +1,5 @@
1
+ from enum import Enum
2
+
3
+ class Method(str, Enum):
4
+ DIVIDE = "Divide"
5
+ SUBTRACT = "Subtract"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellprofiler-library-nightly
3
- Version: 5.0.0.dev313
3
+ Version: 5.0.0.dev318
4
4
  Summary: cellprofiler-library implements CellProfiler's image processing and mathematical code, and is usable as a standalone library
5
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
6
  Author-email: Beth Cimini <bcimini@broadinstitute.org>, David Stirling <dstirling@glencoesoftware.com>, Nodar Gogoberidze <ngogober@broadinstitute.org>
@@ -1,10 +1,10 @@
1
1
  cellprofiler_library/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cellprofiler_library/_version.py,sha256=X4VkWpCY3W1OoL-UO0Ujz6sOnuBoWBDUvHRgT9ivJRQ,721
2
+ cellprofiler_library/_version.py,sha256=VKwI68zHVxr7qKLpGyfYE5ws8C3HO1sHftyVZcFWLQk,721
3
3
  cellprofiler_library/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  cellprofiler_library/types.py,sha256=5cCxXOO_TE-uSF4ZB6sDG3eTZ1VWDSXUFifg0N4JYs8,8516
5
5
  cellprofiler_library/functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  cellprofiler_library/functions/file_processing.py,sha256=jumpdgxReyV5xzF4YXZWhkei9CQ9GtWD-VUCuFh-FZM,5168
7
- cellprofiler_library/functions/image_processing.py,sha256=qZLEVpG3IOfgPUH_cJ0k6HVWklHU08JJvxWPnO48qIo,24015
7
+ cellprofiler_library/functions/image_processing.py,sha256=3mGdRhWaVUqCxIh1hjde6Ffnq_wJfJAWxZZU3MNfQkM,24780
8
8
  cellprofiler_library/functions/measurement.py,sha256=8pXcEb1fLgwOEDiTJho1_O-fFGTtIp-Qn1lStjQBjbo,29221
9
9
  cellprofiler_library/functions/object_processing.py,sha256=3cKNq5ewBf_HWz6rdX3XR4WUbd6SklbHZ_H40xt9ODM,19443
10
10
  cellprofiler_library/functions/segmentation.py,sha256=LNE22ByY0X7GepQaHqLdxkzlmIXjD3EglAYJjtT2dGo,25257
@@ -14,6 +14,7 @@ cellprofiler_library/modules/_colortogray.py,sha256=UtiBgh7AXduRBMkHsv2L0u7FayOC
14
14
  cellprofiler_library/modules/_combineobjects.py,sha256=dZz0RXjvVukem3e46wPfQWOQCOfMLHaq0KoFzjKVQqs,830
15
15
  cellprofiler_library/modules/_convertimagetoobjects.py,sha256=_X2YWEHK4hFaP13LEBD-vIwwUUhgJEJLcTkhyMe4JBA,1075
16
16
  cellprofiler_library/modules/_convertobjectstoimage.py,sha256=PMYjH_prBKma4LNgUxmA5GzF7fQ6ko09XszKatTulB4,2274
17
+ cellprofiler_library/modules/_correctilluminationapply.py,sha256=8bZC3AnQv3vpUrNSnLvcc_s0E-P63XbrfwMv7OZNjt4,2084
17
18
  cellprofiler_library/modules/_enhanceedges.py,sha256=PaXZck8fPcxRf-IXCstu-OWmsvM_rDDPMMQ3cZFfVZc,2951
18
19
  cellprofiler_library/modules/_expandorshrinkobjects.py,sha256=A1oeW_O8C5NLJr-xU1R9pSulDau8XUeWaKiilpr-85g,856
19
20
  cellprofiler_library/modules/_fillobjects.py,sha256=1zvlZNJhG8kEzAnVyiSLGPNE338EB5wopD2eK0BVWrc,469
@@ -33,11 +34,12 @@ cellprofiler_library/opts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
33
34
  cellprofiler_library/opts/colortogray.py,sha256=ptAanLQW9iMgQHgC7xvYlbIbshBd5d7uE48t2F0Z5e8,344
34
35
  cellprofiler_library/opts/convertimagetoobjects.py,sha256=9e3VOdpjd4084ATZyFtSQg_VpxbyXrYVFmEFJkrHakg,67
35
36
  cellprofiler_library/opts/convertobjectstoimage.py,sha256=U3jeVtKYFgfxbO7NYndanAyZFoEvbyScOq4T8cpjfX8,188
37
+ cellprofiler_library/opts/correctilluminationapply.py,sha256=IkAqjMjaRdsoY2aXw5_dLI1iRYqCwvcNwCWEpWNZrN4,96
36
38
  cellprofiler_library/opts/measureimageoverlap.py,sha256=uopQCJTX1Uk-NNDAISsdYEOuOtiEBYOyCwu57ZT7X84,134
37
39
  cellprofiler_library/opts/objectsizeshapefeatures.py,sha256=3GIntOH3qXs7F16Tpjmtg7opHYAmmOjEdEwW6q3ht_Y,6306
38
40
  cellprofiler_library/opts/threshold.py,sha256=yg_i5to22Nd9hTakaRxo9UIQZRYWFpavJimjl5JONx4,938
39
- cellprofiler_library_nightly-5.0.0.dev313.dist-info/licenses/LICENSE,sha256=QLWaBS7kAioYx7PmJNXAMJaY8NODcFAag60YlUWuyz0,2276
40
- cellprofiler_library_nightly-5.0.0.dev313.dist-info/METADATA,sha256=--nBROD-RBpNvkLYSVE2ZBgR00courMI1CoD_ShpwhI,5534
41
- cellprofiler_library_nightly-5.0.0.dev313.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
42
- cellprofiler_library_nightly-5.0.0.dev313.dist-info/top_level.txt,sha256=LXq0ApDeDD4gotb6YFTySzdyScvHfS_pqoTg1QsNLBs,21
43
- cellprofiler_library_nightly-5.0.0.dev313.dist-info/RECORD,,
41
+ cellprofiler_library_nightly-5.0.0.dev318.dist-info/licenses/LICENSE,sha256=QLWaBS7kAioYx7PmJNXAMJaY8NODcFAag60YlUWuyz0,2276
42
+ cellprofiler_library_nightly-5.0.0.dev318.dist-info/METADATA,sha256=knZAToPornredt8suy093xlyBp6eTYhKl4A_wEElejs,5534
43
+ cellprofiler_library_nightly-5.0.0.dev318.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
44
+ cellprofiler_library_nightly-5.0.0.dev318.dist-info/top_level.txt,sha256=LXq0ApDeDD4gotb6YFTySzdyScvHfS_pqoTg1QsNLBs,21
45
+ cellprofiler_library_nightly-5.0.0.dev318.dist-info/RECORD,,