cellprofiler-library-nightly 5.0.0.dev332__tar.gz → 5.0.0.dev336__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 (62) hide show
  1. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/PKG-INFO +1 -1
  2. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/_version.py +3 -3
  3. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/image_processing.py +206 -2
  4. cellprofiler_library_nightly-5.0.0.dev336/cellprofiler_library/modules/_enhanceorsuppressfeatures.py +55 -0
  5. cellprofiler_library_nightly-5.0.0.dev336/cellprofiler_library/opts/enhanceorsuppressfeatures.py +21 -0
  6. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library_nightly.egg-info/PKG-INFO +1 -1
  7. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library_nightly.egg-info/SOURCES.txt +2 -0
  8. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/LICENSE +0 -0
  9. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/README.md +0 -0
  10. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/__init__.py +0 -0
  11. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/__init__.py +0 -0
  12. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/file_processing.py +0 -0
  13. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/measurement.py +0 -0
  14. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/object_processing.py +0 -0
  15. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/functions/segmentation.py +0 -0
  16. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/__init__.py +0 -0
  17. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_closing.py +0 -0
  18. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_colortogray.py +0 -0
  19. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_combineobjects.py +0 -0
  20. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_convertimagetoobjects.py +0 -0
  21. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_convertobjectstoimage.py +0 -0
  22. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_correctilluminationapply.py +0 -0
  23. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_crop.py +0 -0
  24. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_dilateimage.py +0 -0
  25. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_enhanceedges.py +0 -0
  26. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_erodeimage.py +0 -0
  27. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_erodeobjects.py +0 -0
  28. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_expandorshrinkobjects.py +0 -0
  29. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_fillobjects.py +0 -0
  30. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_gaussianfilter.py +0 -0
  31. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_measureimageoverlap.py +0 -0
  32. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_measureobjectsizeshape.py +0 -0
  33. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_medialaxis.py +0 -0
  34. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_medianfilter.py +0 -0
  35. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_morphologicalskeleton.py +0 -0
  36. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_opening.py +0 -0
  37. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_overlayobjects.py +0 -0
  38. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_reducenoise.py +0 -0
  39. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_savecroppedobjects.py +0 -0
  40. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_threshold.py +0 -0
  41. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/modules/_watershed.py +0 -0
  42. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/__init__.py +0 -0
  43. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/colortogray.py +0 -0
  44. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/convertimagetoobjects.py +0 -0
  45. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/convertobjectstoimage.py +0 -0
  46. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/correctilluminationapply.py +0 -0
  47. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/crop.py +0 -0
  48. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/dilateimage.py +0 -0
  49. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/erodeimage.py +0 -0
  50. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/erodeobjects.py +0 -0
  51. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/measureimageoverlap.py +0 -0
  52. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/objectsizeshapefeatures.py +0 -0
  53. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/structuring_elements.py +0 -0
  54. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/opts/threshold.py +0 -0
  55. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/py.typed +0 -0
  56. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library/types.py +0 -0
  57. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library_nightly.egg-info/dependency_links.txt +0 -0
  58. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library_nightly.egg-info/requires.txt +0 -0
  59. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/cellprofiler_library_nightly.egg-info/top_level.txt +0 -0
  60. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/environment.yml +0 -0
  61. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/pyproject.toml +0 -0
  62. {cellprofiler_library_nightly-5.0.0.dev332 → cellprofiler_library_nightly-5.0.0.dev336}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellprofiler-library-nightly
3
- Version: 5.0.0.dev332
3
+ Version: 5.0.0.dev336
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>
@@ -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.dev332'
32
- __version_tuple__ = version_tuple = (5, 0, 0, 'dev332')
31
+ __version__ = version = '5.0.0.dev336'
32
+ __version_tuple__ = version_tuple = (5, 0, 0, 'dev336')
33
33
 
34
- __commit_id__ = commit_id = 'g13c77e82d'
34
+ __commit_id__ = commit_id = 'g144173d3c'
@@ -6,12 +6,17 @@ import centrosome.threshold
6
6
  import scipy
7
7
  import matplotlib
8
8
  import math
9
- from typing import Any, Optional, Tuple, Callable, Union, List
10
- from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ObjectSegmentation, Image2D, Image2DMask, StructuringElement
9
+ from numpy.typing import NDArray
10
+ import centrosome.filter
11
+ from typing import Any, Optional, Tuple, Callable, Union, List, TypeVar
12
+ from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask, Image2DColor, Image2DGrayscale, ImageAny, ImageAnyMask, ObjectSegmentation, Image2D, Image2DMask, StructuringElement
11
13
  from cellprofiler_library.opts import threshold as Threshold
14
+ from cellprofiler_library.opts.enhanceorsuppressfeatures import SpeckleAccuracy, NeuriteMethod
12
15
  from cellprofiler_library.opts.crop import RemovalMethod
13
16
  from cellprofiler_library.opts.structuring_elements import StructuringElementShape2D, StructuringElementShape3D
14
17
 
18
+ T = TypeVar("T", bound=ImageAny)
19
+
15
20
  def rgb_to_greyscale(image):
16
21
  if image.shape[-1] == 4:
17
22
  output = skimage.color.rgba2rgb(image)
@@ -924,3 +929,202 @@ def erase_pixels(
924
929
  else:
925
930
  cropped_pixel_data[~crop] = 0
926
931
  return cropped_pixel_data
932
+
933
+
934
+ ###############################################################################
935
+ # EnhanceOrSuppressFeatures
936
+ ###############################################################################
937
+
938
+ def __mask(
939
+ pixel_data: T,
940
+ mask: ImageAnyMask,
941
+ ) -> T:
942
+ data = numpy.zeros_like(pixel_data)
943
+ data[mask] = pixel_data[mask]
944
+ return data
945
+
946
+ def __unmask(
947
+ data: T,
948
+ pixel_data: T,
949
+ mask: ImageAnyMask,
950
+ ) -> T:
951
+ data[~mask] = pixel_data[~mask]
952
+ return data
953
+
954
+ def __structuring_element(
955
+ radius,
956
+ volumetric
957
+ ) -> NDArray[numpy.uint8]:
958
+ if volumetric:
959
+ return skimage.morphology.ball(radius)
960
+
961
+ return skimage.morphology.disk(radius)
962
+
963
+
964
+ def enhance_speckles(
965
+ im_pixel_data: ImageGrayscale,
966
+ im_mask: ImageGrayscaleMask,
967
+ im_volumetric: bool,
968
+ radius: float,
969
+ accuracy: SpeckleAccuracy,
970
+ ) -> ImageGrayscale:
971
+ data = __mask(im_pixel_data, im_mask)
972
+ footprint = __structuring_element(radius, im_volumetric)
973
+
974
+ if accuracy == SpeckleAccuracy.SLOW or radius <= 3:
975
+ result = skimage.morphology.white_tophat(data, footprint=footprint)
976
+ else:
977
+ #
978
+ # white_tophat = img - opening
979
+ # = img - dilate(erode)
980
+ # = img - maximum_filter(minimum_filter)
981
+ #
982
+ minimum = scipy.ndimage.filters.minimum_filter(data, footprint=footprint)
983
+ maximum = scipy.ndimage.filters.maximum_filter(minimum, footprint=footprint)
984
+ result = data - maximum
985
+
986
+ return __unmask(result, im_pixel_data, im_mask)
987
+
988
+
989
+ def enhance_neurites(
990
+ im_pixel_data: ImageGrayscale,
991
+ im_mask: ImageGrayscaleMask,
992
+ im_volumetric: bool,
993
+ im_spacing: Tuple[float, ...],
994
+ smoothing_value: float,
995
+ radius: float,
996
+ method: NeuriteMethod,
997
+ neurite_rescale: bool,
998
+ ) -> ImageGrayscale:
999
+ data = __mask(im_pixel_data, im_mask)
1000
+
1001
+ if method == NeuriteMethod.GRADIENT:
1002
+ # desired effect = img + white_tophat - black_tophat
1003
+ footprint = __structuring_element(radius, im_volumetric)
1004
+ white = skimage.morphology.white_tophat(data, footprint=footprint)
1005
+ black = skimage.morphology.black_tophat(data, footprint=footprint)
1006
+ result = data + white - black
1007
+ result[result > 1] = 1
1008
+ result[result < 0] = 0
1009
+ else:
1010
+ sigma = smoothing_value
1011
+ smoothed = scipy.ndimage.gaussian_filter(data, numpy.divide(sigma, im_spacing))
1012
+
1013
+ if im_volumetric:
1014
+ result = numpy.zeros_like(smoothed)
1015
+ for index, plane in enumerate(smoothed):
1016
+ hessian = centrosome.filter.hessian(plane, return_hessian=False, return_eigenvectors=False)
1017
+ result[index] = (-hessian[:, :, 0] * (hessian[:, :, 0] < 0) * (sigma ** 2))
1018
+ else:
1019
+ hessian = centrosome.filter.hessian(smoothed, return_hessian=False, return_eigenvectors=False)
1020
+ #
1021
+ # The positive values are darker pixels with lighter
1022
+ # neighbors. The original ImageJ code scales the result
1023
+ # by sigma squared - I have a feeling this might be
1024
+ # a first-order correction for e**(-2*sigma), possibly
1025
+ # because the hessian is taken from one pixel away
1026
+ # and the gradient is less as sigma gets larger.
1027
+ #
1028
+ result = -hessian[:, :, 0] * (hessian[:, :, 0] < 0) * (sigma ** 2)
1029
+
1030
+ result = __unmask(result, im_pixel_data, im_mask)
1031
+ if neurite_rescale:
1032
+ result = skimage.exposure.rescale_intensity(result)
1033
+ return result
1034
+
1035
+
1036
+ def enhance_circles(
1037
+ im_pixel_data: ImageGrayscale,
1038
+ im_mask: ImageGrayscaleMask,
1039
+ im_volumetric: bool,
1040
+ radius: float,
1041
+ ) -> ImageGrayscale:
1042
+ data = __mask(im_pixel_data, im_mask)
1043
+ if im_volumetric:
1044
+ result = numpy.zeros_like(data)
1045
+ for index, plane in enumerate(data):
1046
+ result[index] = skimage.transform.hough_circle(plane, radius)[0]
1047
+ else:
1048
+ result = skimage.transform.hough_circle(data, radius)[0]
1049
+ return __unmask(result, im_pixel_data, im_mask)
1050
+
1051
+
1052
+ def enhance_texture(
1053
+ im_pixel_data: ImageGrayscale,
1054
+ im_mask: ImageGrayscaleMask,
1055
+ sigma: float,
1056
+ ) -> ImageGrayscale:
1057
+ mask = im_mask
1058
+ data = __mask(im_pixel_data, mask)
1059
+ gmask = skimage.filters.gaussian(mask.astype(float), sigma, mode="constant")
1060
+ img_mean = (skimage.filters.gaussian(data, sigma, mode="constant") / gmask)
1061
+ img_squared = (skimage.filters.gaussian(data ** 2, sigma, mode="constant")/ gmask)
1062
+ result = img_squared - img_mean ** 2
1063
+ return __unmask(result, im_pixel_data, mask)
1064
+
1065
+
1066
+ def enhance_dark_holes(
1067
+ im_pixel_data: ImageGrayscale,
1068
+ im_mask: ImageGrayscaleMask,
1069
+ im_volumetric: bool,
1070
+ dark_hole_radius_min: int,
1071
+ dark_hole_radius_max: int,
1072
+ min_radius: Optional[int] = None,
1073
+ max_radius: Optional[int] = None,
1074
+ ) -> ImageGrayscale:
1075
+ if min_radius is None:
1076
+ min_radius = max(1, int(dark_hole_radius_min / 2))
1077
+ if max_radius is None:
1078
+ max_radius = int((dark_hole_radius_max + 1) / 2)
1079
+
1080
+ pixel_data = im_pixel_data
1081
+ mask = im_mask
1082
+ se = __structuring_element(1, im_volumetric)
1083
+ inverted_image = pixel_data.max() - pixel_data
1084
+ previous_reconstructed_image = inverted_image
1085
+ eroded_image = inverted_image
1086
+ smoothed_image = numpy.zeros(pixel_data.shape)
1087
+
1088
+ for i in range(max_radius + 1):
1089
+ eroded_image = skimage.morphology.erosion(eroded_image, se)
1090
+ if mask is not None:
1091
+ eroded_image *= mask
1092
+ reconstructed_image = skimage.morphology.reconstruction(eroded_image, inverted_image, "dilation", se)
1093
+ output_image = previous_reconstructed_image - reconstructed_image
1094
+ if i >= min_radius:
1095
+ smoothed_image = numpy.maximum(smoothed_image, output_image)
1096
+ previous_reconstructed_image = reconstructed_image
1097
+ return smoothed_image
1098
+
1099
+
1100
+ def enhance_dic(
1101
+ im_pixel_data: ImageGrayscale,
1102
+ im_volumetric: bool,
1103
+ angle: float,
1104
+ decay: float,
1105
+ smoothing: float,
1106
+ ) -> ImageGrayscale:
1107
+ pixel_data = im_pixel_data
1108
+
1109
+ if im_volumetric:
1110
+ result = numpy.zeros_like(pixel_data).astype(numpy.float64)
1111
+ for index, plane in enumerate(pixel_data):
1112
+ result[index] = centrosome.filter.line_integration(plane, angle, decay, smoothing)
1113
+ return result
1114
+
1115
+ if smoothing == 0:
1116
+ smoothing = float(numpy.finfo(float).eps)
1117
+
1118
+ return centrosome.filter.line_integration(pixel_data, angle, decay, smoothing)
1119
+
1120
+
1121
+ def suppress(
1122
+ im_pixel_data: ImageGrayscale,
1123
+ im_mask: ImageGrayscaleMask,
1124
+ im_volumetric: bool,
1125
+ radius: float,
1126
+ ) -> ImageGrayscale:
1127
+ data = __mask(im_pixel_data, im_mask)
1128
+ footprint = __structuring_element(radius, im_volumetric)
1129
+ result = skimage.morphology.opening(data, footprint)
1130
+ return __unmask(result, im_pixel_data, im_mask)
@@ -0,0 +1,55 @@
1
+ from cellprofiler_library.functions.image_processing import enhance_speckles, enhance_neurites, enhance_circles, enhance_texture, enhance_dark_holes, enhance_dic, suppress
2
+ from pydantic import Field, ConfigDict, validate_call
3
+ from typing import Annotated
4
+ from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask
5
+ from ..opts.enhanceorsuppressfeatures import OperationMethod, EnhanceMethod, SpeckleAccuracy, NeuriteMethod
6
+
7
+ @validate_call(config=ConfigDict(arbitrary_types_allowed=True))
8
+ def enhance_or_suppress_features(
9
+ im_pixel_data: Annotated[ImageGrayscale, Field(description="Image pixel data")],
10
+ im_mask: Annotated[ImageGrayscaleMask, Field(description="Image mask")],
11
+ im_volumetric: Annotated[bool, Field(description="Image is volumetric")] = False,
12
+ im_spacing: Annotated[tuple[float, ...], Field(description="Image spacing")] = (1.0, 1.0, 1.0),
13
+ radius: Annotated[float, Field(description="Feature size")] = 10,
14
+ method: Annotated[OperationMethod, Field(description="Operation method")] = OperationMethod.ENHANCE,
15
+ enhance_method: Annotated[EnhanceMethod, Field(description="Feature type")] = EnhanceMethod.SPECKLES,
16
+ speckle_accuracy: Annotated[SpeckleAccuracy, Field(description="Speed and accuracy")] = SpeckleAccuracy.FAST,
17
+ neurite_choice: Annotated[NeuriteMethod, Field(description="Neurite choice")] = NeuriteMethod.GRADIENT,
18
+ neurite_rescale: Annotated[bool, Field(description="Rescale result image")] = False,
19
+ dark_hole_radius_min: Annotated[int, Field(description="Dark hole radius min")] = 1,
20
+ dark_hole_radius_max: Annotated[int, Field(description="Dark hole radius max")] = 10,
21
+ smoothing_value: Annotated[float, Field(description="Smoothing value")] = 2.0,
22
+ dic_angle: Annotated[float, Field(description="Angle")] = 0.0,
23
+ dic_decay: Annotated[float, Field(description="Decay")] = 0.95,
24
+ ) -> ImageGrayscale:
25
+ if method == OperationMethod.ENHANCE:
26
+ if enhance_method == EnhanceMethod.SPECKLES:
27
+ result = enhance_speckles(im_pixel_data, im_mask, im_volumetric, radius, speckle_accuracy)
28
+
29
+ elif enhance_method == EnhanceMethod.NEURITES:
30
+ result = enhance_neurites(im_pixel_data, im_mask, im_volumetric, im_spacing, smoothing_value, radius, neurite_choice, neurite_rescale)
31
+
32
+ elif enhance_method == EnhanceMethod.DARK_HOLES:
33
+ result = enhance_dark_holes(im_pixel_data, im_mask, im_volumetric, dark_hole_radius_min, dark_hole_radius_max)
34
+
35
+ elif enhance_method == EnhanceMethod.CIRCLES:
36
+ result = enhance_circles(im_pixel_data, im_mask, im_volumetric, radius)
37
+
38
+ elif enhance_method == EnhanceMethod.TEXTURE:
39
+ result = enhance_texture(im_pixel_data, im_mask, smoothing_value)
40
+
41
+ elif enhance_method == EnhanceMethod.DIC:
42
+ result = enhance_dic(im_pixel_data, im_volumetric, dic_angle, dic_decay, smoothing_value)
43
+
44
+ else:
45
+ raise NotImplementedError("Unimplemented enhance method: %s" % enhance_method)
46
+
47
+ elif method == OperationMethod.SUPPRESS:
48
+ result = suppress(im_pixel_data, im_mask, im_volumetric, radius)
49
+
50
+ else:
51
+ raise ValueError("Unknown filtering method: %s" % method)
52
+
53
+ return result
54
+
55
+
@@ -0,0 +1,21 @@
1
+ from enum import Enum
2
+
3
+ class OperationMethod(str, Enum):
4
+ ENHANCE = "Enhance"
5
+ SUPPRESS = "Suppress"
6
+
7
+ class EnhanceMethod(str, Enum):
8
+ SPECKLES = "Speckles"
9
+ NEURITES = "Neurites"
10
+ DARK_HOLES = "Dark holes"
11
+ CIRCLES = "Circles"
12
+ TEXTURE = "Texture"
13
+ DIC = "DIC"
14
+
15
+ class SpeckleAccuracy(str, Enum):
16
+ SLOW = "Slow"
17
+ FAST = "Fast"
18
+
19
+ class NeuriteMethod(str, Enum):
20
+ GRADIENT = "Line structures"
21
+ TUBENESS = "Tubeness"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellprofiler-library-nightly
3
- Version: 5.0.0.dev332
3
+ Version: 5.0.0.dev336
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>
@@ -22,6 +22,7 @@ cellprofiler_library/modules/_correctilluminationapply.py
22
22
  cellprofiler_library/modules/_crop.py
23
23
  cellprofiler_library/modules/_dilateimage.py
24
24
  cellprofiler_library/modules/_enhanceedges.py
25
+ cellprofiler_library/modules/_enhanceorsuppressfeatures.py
25
26
  cellprofiler_library/modules/_erodeimage.py
26
27
  cellprofiler_library/modules/_erodeobjects.py
27
28
  cellprofiler_library/modules/_expandorshrinkobjects.py
@@ -45,6 +46,7 @@ cellprofiler_library/opts/convertobjectstoimage.py
45
46
  cellprofiler_library/opts/correctilluminationapply.py
46
47
  cellprofiler_library/opts/crop.py
47
48
  cellprofiler_library/opts/dilateimage.py
49
+ cellprofiler_library/opts/enhanceorsuppressfeatures.py
48
50
  cellprofiler_library/opts/erodeimage.py
49
51
  cellprofiler_library/opts/erodeobjects.py
50
52
  cellprofiler_library/opts/measureimageoverlap.py