cellprofiler-library-nightly 5.0.0.dev509__tar.gz → 5.0.0.dev512__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.
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/PKG-INFO +1 -1
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/_version.py +3 -3
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/measurement.py +4 -6
- cellprofiler_library_nightly-5.0.0.dev512/cellprofiler_library/modules/_measuregranularity.py +80 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library_nightly.egg-info/PKG-INFO +1 -1
- cellprofiler_library_nightly-5.0.0.dev509/cellprofiler_library/modules/_measuregranularity.py +0 -42
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/LICENSE +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/README.md +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/file_processing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/image_processing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/object_processing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/functions/segmentation.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/measurement_model.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_closing.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_colortogray.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_combineobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_convertimagetoobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_convertobjectstoimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_correctilluminationapply.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_crop.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_dilateimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_dilateobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_enhanceedges.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_enhanceorsuppressfeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_erodeimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_erodeobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_expandorshrinkobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_fillobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_flipandrotate.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_gaussianfilter.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_graytocolor.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_identifyprimaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_identifysecondaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_identifytertiaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_imagemath.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_measurecolocalization.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_measureimageoverlap.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_measureobjectsizeshape.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_medialaxis.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_medianfilter.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_morph.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_morphologicalskeleton.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_opening.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_overlayobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_overlayoutlines.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_reducenoise.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_removeholes.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_resize.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_savecroppedobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_shrinktoobjectcenters.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_smooth.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_threshold.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/modules/_watershed.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/__init__.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/colortogray.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/convertimagetoobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/convertobjectstoimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/correctilluminationapply.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/crop.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/dilateimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/dilateobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/enhanceedges.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/enhanceorsuppressfeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/erodeimage.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/erodeobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/flipandrotate.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/graytocolor.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/identifyprimaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/identifysecondaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/identifytertiaryobjects.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/imagemath.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/measurecolocalization.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/measuregranularity.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/measureimageoverlap.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/morph.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/objectsizeshapefeatures.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/overlayoutlines.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/removeholes.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/resize.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/shrinktoobjectcenters.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/smooth.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/structuring_elements.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/opts/threshold.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/py.typed +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library/types.py +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library_nightly.egg-info/SOURCES.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library_nightly.egg-info/dependency_links.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library_nightly.egg-info/requires.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/cellprofiler_library_nightly.egg-info/top_level.txt +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/environment.yml +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/pyproject.toml +0 -0
- {cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/setup.cfg +0 -0
{cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cellprofiler-library-nightly
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev512
|
|
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.
|
|
32
|
-
__version_tuple__ = version_tuple = (5, 0, 0, '
|
|
31
|
+
__version__ = version = '5.0.0.dev512'
|
|
32
|
+
__version_tuple__ = version_tuple = (5, 0, 0, 'dev512')
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'g36bc7931b'
|
|
@@ -11,7 +11,7 @@ import centrosome.fastemd
|
|
|
11
11
|
|
|
12
12
|
from centrosome.cpmorphology import fixup_scipy_ndimage_result as fix
|
|
13
13
|
from sklearn.cluster import KMeans
|
|
14
|
-
from typing import Tuple, Optional, Dict, Callable, List
|
|
14
|
+
from typing import Tuple, Optional, Dict, Callable, List, Union
|
|
15
15
|
from scipy.linalg import lstsq
|
|
16
16
|
from numpy.typing import NDArray
|
|
17
17
|
|
|
@@ -1419,8 +1419,7 @@ def get_granularity_measurements(
|
|
|
1419
1419
|
granular_spectrum_length: int,
|
|
1420
1420
|
dimensions: int,
|
|
1421
1421
|
object_records: List[ObjectRecord]
|
|
1422
|
-
):
|
|
1423
|
-
# TODO: PR #5034 update the return types of this funciton
|
|
1422
|
+
) -> Tuple[List[List[List[Union[str, NDArray[numpy.float64]]]]], List[float]]:
|
|
1424
1423
|
# Transcribed from the Matlab module: granspectr function
|
|
1425
1424
|
#
|
|
1426
1425
|
# CALCULATES GRANULAR SPECTRUM, ALSO KNOWN AS SIZE DISTRIBUTION,
|
|
@@ -1445,14 +1444,12 @@ def get_granularity_measurements(
|
|
|
1445
1444
|
measurements_arr = []
|
|
1446
1445
|
image_measurements_arr = []
|
|
1447
1446
|
|
|
1448
|
-
statistics = []
|
|
1449
1447
|
for i in range(1, ng + 1):
|
|
1450
1448
|
prevmean = currentmean
|
|
1451
1449
|
ero = masked_erode(ero, mask, footprint)
|
|
1452
1450
|
rec = skimage.morphology.reconstruction(ero, pixels, footprint=footprint)
|
|
1453
1451
|
currentmean = np.mean(rec[mask])
|
|
1454
1452
|
gs = (prevmean - currentmean) * 100 / startmean
|
|
1455
|
-
statistics += ["%.2f" % gs]
|
|
1456
1453
|
image_measurements_arr += [gs]
|
|
1457
1454
|
# measurements.add_image_measurement(feature, gs)
|
|
1458
1455
|
#
|
|
@@ -1484,5 +1481,6 @@ def get_granularity_measurements(
|
|
|
1484
1481
|
gss = np.zeros((0,))
|
|
1485
1482
|
obj_measurements += [[object_record.name, gss]]
|
|
1486
1483
|
measurements_arr += [obj_measurements]
|
|
1487
|
-
return measurements_arr, image_measurements_arr
|
|
1484
|
+
return measurements_arr, image_measurements_arr
|
|
1488
1485
|
|
|
1486
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
from pydantic import validate_call, ConfigDict, Field
|
|
2
|
+
from typing import Annotated, List, Dict, Any, Tuple
|
|
3
|
+
from enum import Enum
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
from cellprofiler_library.measurement_model import LibraryMeasurements
|
|
7
|
+
from cellprofiler_library.functions.measurement import get_granularity_measurements, ObjectRecord
|
|
8
|
+
from cellprofiler_library.functions.image_processing import apply_grayscale_tophat_filter, downsample_image_and_mask
|
|
9
|
+
from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask
|
|
10
|
+
|
|
11
|
+
class GranularityMeasurementFormat(str, Enum):
|
|
12
|
+
GRANULARITY = "Granularity_%d_%s"
|
|
13
|
+
|
|
14
|
+
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
|
|
15
|
+
def measure_granularity(
|
|
16
|
+
image_name: Annotated[str, Field(description="Name of the image")],
|
|
17
|
+
im_pixel_data: Annotated[ImageGrayscale, Field(description="Pixel values of the image")],
|
|
18
|
+
im_mask: Annotated[ImageGrayscaleMask, Field(description="Boolean mask of where the measurements should be made")],
|
|
19
|
+
subsample_size: Annotated[float, Field(description="Subsampling factor for granularity measurements")],
|
|
20
|
+
image_sample_size: Annotated[float, Field(description="Subsampling factor for background reduction")],
|
|
21
|
+
element_size: Annotated[int, Field(description="Radius of structuring element")],
|
|
22
|
+
object_records: Annotated[List[ObjectRecord], Field(description="Object records")],
|
|
23
|
+
granular_spectrum_length: Annotated[int, Field(description="Range of the granular spectrum")],
|
|
24
|
+
dimensions: Annotated[int, Field(description="Dimensionality of the image")] = 2,
|
|
25
|
+
) -> Tuple[LibraryMeasurements, List[str]]:
|
|
26
|
+
#
|
|
27
|
+
# Downsample the image and mask
|
|
28
|
+
#
|
|
29
|
+
pixels, mask, new_shape = downsample_image_and_mask(im_pixel_data, im_mask, dimensions, subsample_size)
|
|
30
|
+
|
|
31
|
+
#
|
|
32
|
+
# Remove background pixels using a greyscale tophat filter
|
|
33
|
+
#
|
|
34
|
+
pixels = apply_grayscale_tophat_filter(pixels, mask, dimensions, image_sample_size, element_size, new_shape)
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Compute measurements
|
|
38
|
+
#
|
|
39
|
+
measurements_arr, image_measurements_arr = get_granularity_measurements(
|
|
40
|
+
im_pixel_data,
|
|
41
|
+
pixels,
|
|
42
|
+
mask,
|
|
43
|
+
new_shape,
|
|
44
|
+
granular_spectrum_length,
|
|
45
|
+
dimensions,
|
|
46
|
+
object_records
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
measurements = LibraryMeasurements()
|
|
50
|
+
stats_strings = []
|
|
51
|
+
|
|
52
|
+
# Process Image Measurements
|
|
53
|
+
for i, gs_value in enumerate(image_measurements_arr):
|
|
54
|
+
spectrum_index = i + 1
|
|
55
|
+
feature_name = GranularityMeasurementFormat.GRANULARITY % (spectrum_index, image_name)
|
|
56
|
+
measurements.add_image_measurement(feature_name, gs_value)
|
|
57
|
+
stats_strings.append("%.2f" % gs_value)
|
|
58
|
+
|
|
59
|
+
# Process Object Measurements
|
|
60
|
+
# measurements_arr is list of lists. Outer list index i corresponds to spectrum_index i+1.
|
|
61
|
+
for i, obj_measurements_list in enumerate(measurements_arr):
|
|
62
|
+
spectrum_index = i + 1
|
|
63
|
+
feature_name = GranularityMeasurementFormat.GRANULARITY % (spectrum_index, image_name)
|
|
64
|
+
|
|
65
|
+
for obj_name, obj_gss in obj_measurements_list:
|
|
66
|
+
measurements.add_measurement(obj_name, feature_name, obj_gss)
|
|
67
|
+
|
|
68
|
+
# Calculate stats for this object measurement and add to Image measurements
|
|
69
|
+
stat_name_base = f"{feature_name}_{obj_name}"
|
|
70
|
+
|
|
71
|
+
measurements.add_image_measurement(f"Mean_{stat_name_base}", np.mean(obj_gss) if len(obj_gss) > 0 else 0.0)
|
|
72
|
+
measurements.add_image_measurement(f"Median_{stat_name_base}", np.median(obj_gss) if len(obj_gss) > 0 else 0.0)
|
|
73
|
+
measurements.add_image_measurement(f"Max_{stat_name_base}", np.max(obj_gss) if len(obj_gss) > 0 else 0.0)
|
|
74
|
+
measurements.add_image_measurement(f"Min_{stat_name_base}", np.min(obj_gss) if len(obj_gss) > 0 else 0.0)
|
|
75
|
+
measurements.add_image_measurement(f"StDev_{stat_name_base}", np.std(obj_gss) if len(obj_gss) > 0 else 0.0)
|
|
76
|
+
|
|
77
|
+
# Summary for UI display
|
|
78
|
+
summary = [image_name] + stats_strings
|
|
79
|
+
|
|
80
|
+
return measurements, summary
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cellprofiler-library-nightly
|
|
3
|
-
Version: 5.0.0.
|
|
3
|
+
Version: 5.0.0.dev512
|
|
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>
|
cellprofiler_library_nightly-5.0.0.dev509/cellprofiler_library/modules/_measuregranularity.py
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
from pydantic import validate_call, ConfigDict, Field
|
|
2
|
-
from typing import Annotated, List
|
|
3
|
-
from cellprofiler_library.functions.measurement import get_granularity_measurements, ObjectRecord
|
|
4
|
-
from cellprofiler_library.functions.image_processing import apply_grayscale_tophat_filter, downsample_image_and_mask
|
|
5
|
-
from cellprofiler_library.types import ImageGrayscale, ImageGrayscaleMask
|
|
6
|
-
|
|
7
|
-
@validate_call(config=ConfigDict(arbitrary_types_allowed=True))
|
|
8
|
-
def measure_granularity(
|
|
9
|
-
im_pixel_data: Annotated[ImageGrayscale, Field(description="Pixel values of the image")],
|
|
10
|
-
im_mask: Annotated[ImageGrayscaleMask, Field(description="Boolean mask of where the measurements should be made")],
|
|
11
|
-
subsample_size: Annotated[float, Field(description="Subsampling factor for granularity measurements")],
|
|
12
|
-
image_sample_size: Annotated[float, Field(description="Subsampling factor for background reduction")],
|
|
13
|
-
element_size: Annotated[int, Field(description="Radius of structuring element")],
|
|
14
|
-
object_records: Annotated[List[ObjectRecord], Field(description="Object records")],
|
|
15
|
-
granular_spectrum_length: Annotated[int, Field(description="Range of the granular spectrum")],
|
|
16
|
-
dimensions: Annotated[int, Field(description="Dimensionality of the image")] = 2,
|
|
17
|
-
):
|
|
18
|
-
# TODO: PR #5034 update the return types of this funciton
|
|
19
|
-
#
|
|
20
|
-
# Downsample the image and mask
|
|
21
|
-
#
|
|
22
|
-
pixels, mask, new_shape = downsample_image_and_mask(im_pixel_data, im_mask, dimensions, subsample_size)
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
# Remove background pixels using a greyscale tophat filter
|
|
26
|
-
#
|
|
27
|
-
pixels = apply_grayscale_tophat_filter(pixels, mask, dimensions, image_sample_size, element_size, new_shape)
|
|
28
|
-
|
|
29
|
-
#
|
|
30
|
-
# Compute measurements
|
|
31
|
-
#
|
|
32
|
-
_measurements_arr, _image_measurements_arr, _statistics = get_granularity_measurements(
|
|
33
|
-
im_pixel_data,
|
|
34
|
-
pixels,
|
|
35
|
-
mask,
|
|
36
|
-
new_shape,
|
|
37
|
-
granular_spectrum_length,
|
|
38
|
-
dimensions,
|
|
39
|
-
object_records
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
return _measurements_arr, _image_measurements_arr, _statistics
|
{cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/LICENSE
RENAMED
|
File without changes
|
{cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/README.md
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{cellprofiler_library_nightly-5.0.0.dev509 → cellprofiler_library_nightly-5.0.0.dev512}/setup.cfg
RENAMED
|
File without changes
|