cellprofiler-library-nightly 5.0.0.dev306__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.dev306'
32
- __version_tuple__ = version_tuple = (5, 0, 0, 'dev306')
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
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)
@@ -594,3 +593,44 @@ def split_rgb(input_image: Image2DColor) -> List[Image2DGrayscale]:
594
593
  def split_multichannel(input_image: Image2DColor) -> List[Image2DGrayscale]:
595
594
  return split_rgb(input_image)
596
595
 
596
+
597
+ ################################################################################
598
+ # ConvertImageToObjects
599
+ ################################################################################
600
+
601
+ def image_to_objects(
602
+ data: ImageAny,
603
+ cast_to_bool: bool,
604
+ preserve_label: bool,
605
+ background: int,
606
+ connectivity: Union[int, None],
607
+ ) -> ObjectSegmentation:
608
+ # Compatibility with skimage
609
+ connectivity = None if connectivity == 0 else connectivity
610
+
611
+ caster = skimage.img_as_bool if cast_to_bool else skimage.img_as_uint
612
+ data = caster(data)
613
+
614
+ # If preservation is desired, just return the original labels
615
+ if preserve_label and not cast_to_bool:
616
+ return data
617
+
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)
@@ -1,7 +1,7 @@
1
1
  from pydantic import Field, validate_call, ConfigDict
2
2
  from typing import Annotated, List, Union, Optional
3
3
 
4
- from cellprofiler_library.opts.colortogray import ImageChannelType
4
+ from ..opts.colortogray import ImageChannelType
5
5
  from ..types import Image2DColor, Image2DGrayscale
6
6
  from ..functions.image_processing import combine_colortogray, split_hsv, split_rgb, split_multichannel
7
7
 
@@ -0,0 +1,14 @@
1
+ from typing import Annotated, Optional, Union
2
+ from pydantic import Field, validate_call, ConfigDict
3
+ from cellprofiler_library.types import ImageGrayscale, ObjectLabelsDense, ImageBinary
4
+ from cellprofiler_library.functions.image_processing import image_to_objects
5
+
6
+ @validate_call(config=ConfigDict(arbitrary_types_allowed=True))
7
+ def convert_image_to_objects(
8
+ data: Annotated[Union[ImageGrayscale, ImageBinary], Field(description="Image to be converted to Objects")],
9
+ cast_to_bool: Annotated[bool, Field(description="Convert a grayscale image to binary before converting it to an object")],
10
+ preserve_label: Annotated[bool, Field(description="Preserve original labels of objects")],
11
+ background: Annotated[int, Field(description="Pixel value of the background")],
12
+ connectivity: Annotated[Optional[int], Field(description="Maximum number of orthogonal hops to consider a pixel/voxel as a neighbor")]
13
+ ) -> ObjectLabelsDense:
14
+ return image_to_objects(data, cast_to_bool, preserve_label, background, connectivity)
@@ -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,3 @@
1
+ '''
2
+ The convertimagetoobjects module does not have any options.
3
+ '''
@@ -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.dev306
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,18 +1,20 @@
1
1
  cellprofiler_library/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- cellprofiler_library/_version.py,sha256=G7VoognR8cVzAPvjy716XjRcsJUGbmEf3x2OzMxn-4o,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=nE7frZyHBSYA5wX5div8VtjYf_IkIOjUKKmRLS-b3Uk,23161
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
11
11
  cellprofiler_library/modules/__init__.py,sha256=Z4Wy42OTD9ujAON4g1oyLJ0oA6K7h3XQiV66JzHGkOw,789
12
12
  cellprofiler_library/modules/_closing.py,sha256=aIqIE0IcT2OcrOmTSWjFzu4iIQKk2yDC9qPHARqRIkc,204
13
- cellprofiler_library/modules/_colortogray.py,sha256=_56iPZR-gmKPhAQTYAVQjwC_F6tS5esa9X5o81-5P_I,1852
13
+ cellprofiler_library/modules/_colortogray.py,sha256=UtiBgh7AXduRBMkHsv2L0u7FayOCfaB58qFGNVIGskM,1833
14
14
  cellprofiler_library/modules/_combineobjects.py,sha256=dZz0RXjvVukem3e46wPfQWOQCOfMLHaq0KoFzjKVQqs,830
15
+ cellprofiler_library/modules/_convertimagetoobjects.py,sha256=_X2YWEHK4hFaP13LEBD-vIwwUUhgJEJLcTkhyMe4JBA,1075
15
16
  cellprofiler_library/modules/_convertobjectstoimage.py,sha256=PMYjH_prBKma4LNgUxmA5GzF7fQ6ko09XszKatTulB4,2274
17
+ cellprofiler_library/modules/_correctilluminationapply.py,sha256=8bZC3AnQv3vpUrNSnLvcc_s0E-P63XbrfwMv7OZNjt4,2084
16
18
  cellprofiler_library/modules/_enhanceedges.py,sha256=PaXZck8fPcxRf-IXCstu-OWmsvM_rDDPMMQ3cZFfVZc,2951
17
19
  cellprofiler_library/modules/_expandorshrinkobjects.py,sha256=A1oeW_O8C5NLJr-xU1R9pSulDau8XUeWaKiilpr-85g,856
18
20
  cellprofiler_library/modules/_fillobjects.py,sha256=1zvlZNJhG8kEzAnVyiSLGPNE338EB5wopD2eK0BVWrc,469
@@ -30,12 +32,14 @@ cellprofiler_library/modules/_threshold.py,sha256=Z2mFd1xBtoctyF5jnkuwuNyBfjSkRt
30
32
  cellprofiler_library/modules/_watershed.py,sha256=T-xmYE8_21wpFCH5HbCTAHu5k5A9-5BL3ToUSpODxPY,1824
31
33
  cellprofiler_library/opts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
34
  cellprofiler_library/opts/colortogray.py,sha256=ptAanLQW9iMgQHgC7xvYlbIbshBd5d7uE48t2F0Z5e8,344
35
+ cellprofiler_library/opts/convertimagetoobjects.py,sha256=9e3VOdpjd4084ATZyFtSQg_VpxbyXrYVFmEFJkrHakg,67
33
36
  cellprofiler_library/opts/convertobjectstoimage.py,sha256=U3jeVtKYFgfxbO7NYndanAyZFoEvbyScOq4T8cpjfX8,188
37
+ cellprofiler_library/opts/correctilluminationapply.py,sha256=IkAqjMjaRdsoY2aXw5_dLI1iRYqCwvcNwCWEpWNZrN4,96
34
38
  cellprofiler_library/opts/measureimageoverlap.py,sha256=uopQCJTX1Uk-NNDAISsdYEOuOtiEBYOyCwu57ZT7X84,134
35
39
  cellprofiler_library/opts/objectsizeshapefeatures.py,sha256=3GIntOH3qXs7F16Tpjmtg7opHYAmmOjEdEwW6q3ht_Y,6306
36
40
  cellprofiler_library/opts/threshold.py,sha256=yg_i5to22Nd9hTakaRxo9UIQZRYWFpavJimjl5JONx4,938
37
- cellprofiler_library_nightly-5.0.0.dev306.dist-info/licenses/LICENSE,sha256=QLWaBS7kAioYx7PmJNXAMJaY8NODcFAag60YlUWuyz0,2276
38
- cellprofiler_library_nightly-5.0.0.dev306.dist-info/METADATA,sha256=zxH7-gWJTKsSPBNW1D1eheNIyVNjcnexF4kPwCwMe5M,5534
39
- cellprofiler_library_nightly-5.0.0.dev306.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- cellprofiler_library_nightly-5.0.0.dev306.dist-info/top_level.txt,sha256=LXq0ApDeDD4gotb6YFTySzdyScvHfS_pqoTg1QsNLBs,21
41
- cellprofiler_library_nightly-5.0.0.dev306.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,,