cellprofiler-library-nightly 5.0.0.dev627__tar.gz → 5.0.0.dev633__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 (114) hide show
  1. {cellprofiler_library_nightly-5.0.0.dev627/cellprofiler_library_nightly.egg-info → cellprofiler_library_nightly-5.0.0.dev633}/PKG-INFO +1 -1
  2. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/_version.py +3 -3
  3. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/measurement.py +67 -0
  4. cellprofiler_library_nightly-5.0.0.dev633/cellprofiler_library/modules/_measuretexture.py +156 -0
  5. cellprofiler_library_nightly-5.0.0.dev633/cellprofiler_library/opts/measuretexture.py +24 -0
  6. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633/cellprofiler_library_nightly.egg-info}/PKG-INFO +1 -1
  7. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library_nightly.egg-info/SOURCES.txt +2 -0
  8. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/LICENSE +0 -0
  9. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/README.md +0 -0
  10. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/__init__.py +0 -0
  11. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/__init__.py +0 -0
  12. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/file_processing.py +0 -0
  13. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/image_processing.py +0 -0
  14. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/object_processing.py +0 -0
  15. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/functions/segmentation.py +0 -0
  16. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/measurement_model.py +0 -0
  17. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/__init__.py +0 -0
  18. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_closing.py +0 -0
  19. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_colortogray.py +0 -0
  20. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_combineobjects.py +0 -0
  21. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_convertimagetoobjects.py +0 -0
  22. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_convertobjectstoimage.py +0 -0
  23. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_correctilluminationapply.py +0 -0
  24. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_crop.py +0 -0
  25. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_dilateimage.py +0 -0
  26. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_dilateobjects.py +0 -0
  27. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_enhanceedges.py +0 -0
  28. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_enhanceorsuppressfeatures.py +0 -0
  29. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_erodeimage.py +0 -0
  30. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_erodeobjects.py +0 -0
  31. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_expandorshrinkobjects.py +0 -0
  32. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_fillobjects.py +0 -0
  33. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_flipandrotate.py +0 -0
  34. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_gaussianfilter.py +0 -0
  35. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_graytocolor.py +0 -0
  36. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_identifyprimaryobjects.py +0 -0
  37. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_identifysecondaryobjects.py +0 -0
  38. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_identifytertiaryobjects.py +0 -0
  39. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_imagemath.py +0 -0
  40. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measurecolocalization.py +0 -0
  41. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measuregranularity.py +0 -0
  42. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureimageareaoccupied.py +0 -0
  43. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureimageintensity.py +0 -0
  44. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureimageoverlap.py +0 -0
  45. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureimagequality.py +0 -0
  46. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureimageskeleton.py +0 -0
  47. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectintensity.py +0 -0
  48. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectintensitydistribution.py +0 -0
  49. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectneighbors.py +0 -0
  50. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectoverlap.py +0 -0
  51. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectsizeshape.py +0 -0
  52. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_measureobjectskeleton.py +0 -0
  53. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_medialaxis.py +0 -0
  54. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_medianfilter.py +0 -0
  55. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_morph.py +0 -0
  56. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_morphologicalskeleton.py +0 -0
  57. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_opening.py +0 -0
  58. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_overlayobjects.py +0 -0
  59. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_overlayoutlines.py +0 -0
  60. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_reducenoise.py +0 -0
  61. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_removeholes.py +0 -0
  62. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_resize.py +0 -0
  63. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_savecroppedobjects.py +0 -0
  64. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_shrinktoobjectcenters.py +0 -0
  65. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_smooth.py +0 -0
  66. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_threshold.py +0 -0
  67. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/modules/_watershed.py +0 -0
  68. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/__init__.py +0 -0
  69. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/colortogray.py +0 -0
  70. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/convertimagetoobjects.py +0 -0
  71. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/convertobjectstoimage.py +0 -0
  72. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/correctilluminationapply.py +0 -0
  73. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/crop.py +0 -0
  74. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/dilateimage.py +0 -0
  75. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/dilateobjects.py +0 -0
  76. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/enhanceedges.py +0 -0
  77. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/enhanceorsuppressfeatures.py +0 -0
  78. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/erodeimage.py +0 -0
  79. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/erodeobjects.py +0 -0
  80. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/flipandrotate.py +0 -0
  81. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/graytocolor.py +0 -0
  82. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/identifyprimaryobjects.py +0 -0
  83. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/identifysecondaryobjects.py +0 -0
  84. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/identifytertiaryobjects.py +0 -0
  85. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/imagemath.py +0 -0
  86. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measurecolocalization.py +0 -0
  87. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measuregranularity.py +0 -0
  88. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureimageareaoccupied.py +0 -0
  89. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureimageintensity.py +0 -0
  90. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureimageoverlap.py +0 -0
  91. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureimagequality.py +0 -0
  92. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureimageskeleton.py +0 -0
  93. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureobjectintensity.py +0 -0
  94. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureobjectintensitydistribution.py +0 -0
  95. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureobjectneighbors.py +0 -0
  96. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureobjectoverlap.py +0 -0
  97. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/measureobjectskeleton.py +0 -0
  98. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/morph.py +0 -0
  99. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/objectsizeshapefeatures.py +0 -0
  100. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/overlayoutlines.py +0 -0
  101. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/removeholes.py +0 -0
  102. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/resize.py +0 -0
  103. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/shrinktoobjectcenters.py +0 -0
  104. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/smooth.py +0 -0
  105. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/structuring_elements.py +0 -0
  106. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/opts/threshold.py +0 -0
  107. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/py.typed +0 -0
  108. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library/types.py +0 -0
  109. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library_nightly.egg-info/dependency_links.txt +0 -0
  110. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library_nightly.egg-info/requires.txt +0 -0
  111. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/cellprofiler_library_nightly.egg-info/top_level.txt +0 -0
  112. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/environment.yml +0 -0
  113. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/pyproject.toml +0 -0
  114. {cellprofiler_library_nightly-5.0.0.dev627 → cellprofiler_library_nightly-5.0.0.dev633}/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.dev627
3
+ Version: 5.0.0.dev633
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.dev627'
32
- __version_tuple__ = version_tuple = (5, 0, 0, 'dev627')
31
+ __version__ = version = '5.0.0.dev633'
32
+ __version_tuple__ = version_tuple = (5, 0, 0, 'dev633')
33
33
 
34
- __commit_id__ = commit_id = 'gab80ce3b5'
34
+ __commit_id__ = commit_id = 'ge33f943f4'
@@ -4,6 +4,9 @@ import scipy
4
4
  import scipy.ndimage
5
5
  import scipy.sparse
6
6
  import skimage
7
+ import mahotas.features
8
+ import skimage.exposure
9
+ import skimage.measure
7
10
  import centrosome
8
11
  import centrosome.filter
9
12
  import centrosome.propagate
@@ -3899,3 +3902,67 @@ def compute_radial_cv_for_bin(
3899
3902
  radial_cv[empty_object_mask] = 0
3900
3903
 
3901
3904
  return bin_mask, bin_labels, radial_cv, empty_object_mask
3905
+
3906
+
3907
+
3908
+ ###############################################################################
3909
+ # MeasureTexture
3910
+ ###############################################################################
3911
+
3912
+
3913
+ def measure_haralick_features_image(
3914
+ pixel_data: ImageGrayscale,
3915
+ gray_levels: int,
3916
+ scale: int
3917
+ ) -> NDArray[numpy.float64]:
3918
+ pixel_data = skimage.util.img_as_ubyte(pixel_data)
3919
+ if gray_levels != 256:
3920
+ pixel_data = skimage.exposure.rescale_intensity(
3921
+ pixel_data, in_range=(0, 255), out_range=(0, gray_levels - 1)
3922
+ ).astype(numpy.uint8)
3923
+
3924
+ # mahotas.features.haralick bricks itself when provided a dtype larger than uint8 (version 1.4.3)
3925
+ # Returns (n_directions, 13)
3926
+ return mahotas.features.haralick(pixel_data, distance=scale)
3927
+
3928
+
3929
+ def measure_haralick_features_objects(
3930
+ labels: ObjectSegmentation,
3931
+ pixel_data: ImageGrayscale,
3932
+ mask: Optional[ImageGrayscaleMask],
3933
+ gray_levels: int,
3934
+ max_label: int,
3935
+ scale: int,
3936
+ volumetric: bool,
3937
+ ) -> NDArray[numpy.float64]:
3938
+ n_directions = 13 if volumetric else 4
3939
+ if mask is not None:
3940
+ pixel_data[~mask] = 0
3941
+ # mahotas.features.haralick bricks itself when provided a dtype larger than uint8 (version 1.4.3)
3942
+ pixel_data = skimage.util.img_as_ubyte(pixel_data)
3943
+ if gray_levels != 256:
3944
+ pixel_data = skimage.exposure.rescale_intensity(
3945
+ pixel_data, in_range=(0, 255), out_range=(0, gray_levels - 1)
3946
+ ).astype(numpy.uint8)
3947
+ props = skimage.measure.regionprops(labels, pixel_data)
3948
+
3949
+ # Shape: (max_label, n_directions, 13)
3950
+ # We use max_label so that result[i] corresponds to label i+1
3951
+ features = numpy.full((max_label, n_directions, 13), numpy.nan)
3952
+
3953
+ for prop in props:
3954
+ label_data = prop["intensity_image"]
3955
+ try:
3956
+ # mahotas.features.haralick returns (n_directions, 13)
3957
+ # ignore_zeros=True is important for masked objects
3958
+ res = mahotas.features.haralick(
3959
+ label_data, distance=scale, ignore_zeros=True
3960
+ )
3961
+ # If the object is too small or something, mahotas might return something else?
3962
+ # Assuming it returns correct shape if successful.
3963
+ features[prop.label-1, :, :] = res
3964
+ except ValueError:
3965
+ # Keep as NaN
3966
+ pass
3967
+
3968
+ return features
@@ -0,0 +1,156 @@
1
+ import numpy
2
+ from numpy.typing import NDArray
3
+ from typing import List, Union, Optional, Annotated, Tuple
4
+ from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask, ObjectLabel, ObjectSegmentation
5
+ from pydantic import validate_call, Field, ConfigDict, BaseModel
6
+ from cellprofiler_library.functions.measurement import measure_haralick_features_image, measure_haralick_features_objects
7
+ from cellprofiler_library.opts.measuretexture import F_HARALICK, TEXTURE
8
+ from cellprofiler_library.measurement_model import LibraryMeasurements
9
+
10
+
11
+ MeasureTextureStatistics = List[Tuple[
12
+ str, # iamge name
13
+ str, # object name
14
+ str, # feature name
15
+ str, # scale
16
+ str # stat val
17
+ ]]
18
+
19
+ class MeasureTextureDisplayData(BaseModel):
20
+ model_config = ConfigDict(
21
+ arbitrary_types_allowed=True,
22
+ populate_by_name=True
23
+ )
24
+
25
+ statistics: MeasureTextureStatistics
26
+
27
+ @validate_call(config=ConfigDict(arbitrary_types_allowed=True))
28
+ def measure_image_texture(
29
+ pixel_data: Annotated[ImageGrayscale, Field(description="Input image to perform texture measurements on")],
30
+ gray_levels: Annotated[int, Field(description="Enter the number of gray levels (ie, total possible values of intensity) you want to measure texture at")],
31
+ scale: Annotated[int, Field(description="You can specify the scale of texture to be measured, in pixel units; the texture scale is the distance between correlated intensities in the image")],
32
+ image_name: Annotated[str, Field(description="Name to be assigned in measurements")],
33
+ return_visualization_data: Annotated[bool, Field(description="Return data for display")] = False,
34
+ ) -> Union[LibraryMeasurements, Tuple[LibraryMeasurements, MeasureTextureDisplayData]]:
35
+
36
+ haralick_feats = measure_haralick_features_image(pixel_data, gray_levels, scale)
37
+ measurements = LibraryMeasurements()
38
+ statistics: MeasureTextureStatistics = []
39
+
40
+ for direction in range(haralick_feats.shape[0]):
41
+ scale_str = "{:d}_{:02d}".format(scale, direction)
42
+ gray_str = "{:d}".format(gray_levels)
43
+
44
+ for feature_idx, feature_enum in enumerate(F_HARALICK):
45
+ feature_name = feature_enum.value
46
+ full_name = f"{TEXTURE}_{feature_name}_{image_name}_{scale_str}_{gray_str}"
47
+ val = haralick_feats[direction, feature_idx]
48
+ if not numpy.isfinite(val):
49
+ val = 0.0
50
+ measurements.add_image_measurement(full_name, val)
51
+
52
+ if return_visualization_data:
53
+ statistics.append((
54
+ image_name,
55
+ "-",
56
+ f"{feature_name}",
57
+ scale_str,
58
+ "{:.2f}".format(float(val))
59
+ ))
60
+
61
+ if return_visualization_data:
62
+ return measurements, MeasureTextureDisplayData(statistics=statistics)
63
+ else:
64
+ return measurements
65
+
66
+
67
+ @validate_call(config=ConfigDict(arbitrary_types_allowed=True))
68
+ def measure_object_texture(
69
+ object_name: Annotated[str, Field(description="Object name to be assigned in measurements")],
70
+ labels: Annotated[ObjectSegmentation, Field(description="Segmentation labels for object")],
71
+ image_name: Annotated[str, Field(description="Name of the image to assign in measurements")],
72
+ pixel_data: Annotated[ImageGrayscale, Field(description="Image pixel data to measure texture on")],
73
+ mask: Annotated[Optional[ImageGrayscaleMask], Field(description="Image mask if any")],
74
+ gray_levels: Annotated[int, Field(description="Enter the number of gray levels (ie, total possible values of intensity) you want to measure texture at")],
75
+ unique_labels: Annotated[NDArray[ObjectLabel], Field(description="The unique labels in the object segmentation prior to any masking")], # objects.indices
76
+ scale: Annotated[int, Field(description="You can specify the scale of texture to be measured, in pixel units; the texture scale is the distance between correlated intensities in the image")],
77
+ volumetric: Annotated[bool, Field(description="Is the input image or objects 3D?")],
78
+ return_visualization_data: Annotated[bool, Field(description="Return data for display")] = False,
79
+ ) -> Union[LibraryMeasurements, Tuple[LibraryMeasurements, MeasureTextureDisplayData]]:
80
+
81
+ max_label = 0
82
+ if len(unique_labels) > 0:
83
+ max_label = int(numpy.max(unique_labels))
84
+
85
+ haralick_feats = measure_haralick_features_objects(labels, pixel_data, mask, gray_levels, max_label, scale, volumetric)
86
+
87
+ measurements = LibraryMeasurements()
88
+ statistics: MeasureTextureStatistics = []
89
+
90
+ if haralick_feats.size > 0:
91
+ for direction in range(haralick_feats.shape[1]):
92
+ scale_str = "{:d}_{:02d}".format(scale, direction)
93
+ gray_str = "{:d}".format(gray_levels)
94
+
95
+ for feature_idx, feature_enum in enumerate(F_HARALICK):
96
+ feature_name = feature_enum.value
97
+ full_name = f"{TEXTURE}_{feature_name}_{image_name}_{scale_str}_{gray_str}"
98
+
99
+ values = haralick_feats[:, direction, feature_idx]
100
+
101
+ # Calculate stats on valid (finite) values, mirroring original logic
102
+ valid_values = values[numpy.isfinite(values)]
103
+
104
+ # Clean values for storage (replace non-finite with 0), mirroring original frontend logic
105
+ clean_values = values.copy()
106
+ clean_values[~numpy.isfinite(clean_values)] = 0
107
+
108
+ measurements.add_measurement(object_name, full_name, clean_values)
109
+
110
+ stats = [
111
+ ("Mean", "mean", numpy.mean),
112
+ ("Median", "median", numpy.median),
113
+ ("Min", "min", numpy.min),
114
+ ("Max", "max", numpy.max),
115
+ ("StDev", "std dev", numpy.std),
116
+ ]
117
+
118
+ if len(valid_values) > 0:
119
+ for stat_name, display_name, func in stats:
120
+ stat_val = func(valid_values)
121
+ measurements.add_image_measurement(f"{stat_name}_{full_name}", stat_val)
122
+
123
+ if return_visualization_data:
124
+ statistics.append((
125
+ image_name,
126
+ object_name,
127
+ f"{display_name} {feature_name}",
128
+ scale_str,
129
+ f"{float(stat_val):.2f}" if len(clean_values) > 0 else "-",
130
+ ))
131
+ else:
132
+ for stat_name, _, _ in stats:
133
+ measurements.add_image_measurement(f"{stat_name}_{full_name}", 0.0)
134
+ else:
135
+ # Handle empty objects case
136
+ n_directions = 13 if volumetric else 4
137
+
138
+ for direction in range(n_directions):
139
+ scale_str = "{:d}_{:02d}".format(scale, direction)
140
+ gray_str = "{:d}".format(gray_levels)
141
+
142
+ for feature_enum in F_HARALICK:
143
+ feature_name = feature_enum.value
144
+ full_name = f"{TEXTURE}_{feature_name}_{image_name}_{scale_str}_{gray_str}"
145
+
146
+ measurements.add_measurement(object_name, full_name, numpy.zeros((0,)))
147
+
148
+ stats_map_keys = ["Mean", "Median", "Min", "Max", "StDev"]
149
+ for stat_name in stats_map_keys:
150
+ measurements.add_image_measurement(f"{stat_name}_{full_name}", 0.0)
151
+
152
+ if return_visualization_data:
153
+ return measurements, MeasureTextureDisplayData(statistics=statistics)
154
+ else:
155
+ return measurements
156
+
@@ -0,0 +1,24 @@
1
+ from enum import Enum
2
+
3
+ class HaralickFeatures(str, Enum):
4
+ AngularSecondMoment = "AngularSecondMoment",
5
+ Contrast = "Contrast",
6
+ Correlation = "Correlation",
7
+ Variance = "Variance",
8
+ InverseDifferenceMoment = "InverseDifferenceMoment",
9
+ SumAverage = "SumAverage",
10
+ SumVariance = "SumVariance",
11
+ SumEntropy = "SumEntropy",
12
+ Entropy = "Entropy",
13
+ DifferenceVariance = "DifferenceVariance",
14
+ DifferenceEntropy = "DifferenceEntropy",
15
+ InfoMeas1 = "InfoMeas1",
16
+ InfoMeas2 = "InfoMeas2"
17
+
18
+ class MeasurementTarget(str, Enum):
19
+ IMAGES = "Images",
20
+ OBJECTS = "Objects"
21
+ BOTH = "Both"
22
+
23
+ TEXTURE = "Texture"
24
+ F_HARALICK = [i for i in HaralickFeatures]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cellprofiler-library-nightly
3
- Version: 5.0.0.dev627
3
+ Version: 5.0.0.dev633
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>
@@ -49,6 +49,7 @@ cellprofiler_library/modules/_measureobjectneighbors.py
49
49
  cellprofiler_library/modules/_measureobjectoverlap.py
50
50
  cellprofiler_library/modules/_measureobjectsizeshape.py
51
51
  cellprofiler_library/modules/_measureobjectskeleton.py
52
+ cellprofiler_library/modules/_measuretexture.py
52
53
  cellprofiler_library/modules/_medialaxis.py
53
54
  cellprofiler_library/modules/_medianfilter.py
54
55
  cellprofiler_library/modules/_morph.py
@@ -94,6 +95,7 @@ cellprofiler_library/opts/measureobjectintensitydistribution.py
94
95
  cellprofiler_library/opts/measureobjectneighbors.py
95
96
  cellprofiler_library/opts/measureobjectoverlap.py
96
97
  cellprofiler_library/opts/measureobjectskeleton.py
98
+ cellprofiler_library/opts/measuretexture.py
97
99
  cellprofiler_library/opts/morph.py
98
100
  cellprofiler_library/opts/objectsizeshapefeatures.py
99
101
  cellprofiler_library/opts/overlayoutlines.py