cp_measure 0.1.2__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.
cp_measure/bulk.py ADDED
@@ -0,0 +1,38 @@
1
+ """
2
+ Wrapper to fetch measurement functions in bulk. We are keeping the ugly filenames to
3
+ match the original names. This may change in the future.
4
+ """
5
+
6
+ from typing import Callable
7
+
8
+ def get_fast_measurements() -> dict[str, Callable]:
9
+ from cp_measure.fast import (
10
+ measuregranularity,
11
+ measureobjectintensity,
12
+ measureobjectintensitydistribution,
13
+ measureobjectsizeshape,
14
+ measuretexture,
15
+ )
16
+
17
+ return {
18
+ "radial_distribution": measureobjectintensitydistribution.get_radial_distribution,
19
+ "radial_zernikes": measureobjectintensitydistribution.get_radial_zernikes,
20
+ "intensity": measureobjectintensity.get_intensity,
21
+ "sizeshape": measureobjectsizeshape.get_sizeshape,
22
+ "zernike": measureobjectsizeshape.get_zernike,
23
+ "ferret": measureobjectsizeshape.get_ferret,
24
+ "texture": measuretexture.get_texture,
25
+ "granularity": measuregranularity.get_granularity,
26
+
27
+ }
28
+
29
+ def get_correlation_measurements() -> dict[str, Callable]:
30
+ from cp_measure.fast import measurecolocalization
31
+
32
+ return {
33
+ "costes": measurecolocalization.get_correlation_costes,
34
+ "pearson": measurecolocalization.get_correlation_pearson,
35
+ "pearson": measurecolocalization.get_correlation_pearson,
36
+ "manders_fold": measurecolocalization.get_correlation_manders_fold,
37
+ "rwc": measurecolocalization.get_correlation_rwc,
38
+ }
cp_measure/examples.py ADDED
@@ -0,0 +1,51 @@
1
+ """
2
+ Convenience functions for tests and demos.
3
+ """
4
+ import numpy
5
+
6
+ def get_pixels(size: int = 789, seed: int = 42) -> numpy.ndarray:
7
+ rng = numpy.random.default_rng(seed)
8
+ random_pixels = rng.integers(low=0, high=10, size=(size, size))
9
+
10
+ return random_pixels
11
+
12
+
13
+ def get_masks(size: int = 789, mask_width: int = 9) -> tuple[numpy.ndarray]:
14
+ full = numpy.ones((size, size), dtype=numpy.uint16) # A mask that covers the entire image
15
+ empty = numpy.zeros_like(full)
16
+
17
+ # A mask in the center
18
+ center = empty.copy()
19
+ center[mask_width : -mask_width - 1, mask_width : -mask_width - 1] = True
20
+
21
+ # Everything but a mask in the center
22
+ edges = (~center.astype(bool)).astype(numpy.uint16)
23
+
24
+ # Only corners
25
+ corner = empty.copy()
26
+ corner[:mask_width, :mask_width] = True
27
+ corners = [numpy.rot90(corner, k=i, axes=(0, 1)) for i in range(4)]
28
+
29
+ # One pixel mask
30
+ one = empty.copy()
31
+ one[size // 2, size // 2] = True
32
+
33
+ # Two pixels' mask
34
+ two = one + numpy.roll(one, shift=1)
35
+
36
+ # Two masks
37
+ full_two_masks = full.copy()
38
+ full_two_masks[size//2:-1, :] = 2
39
+
40
+ return {
41
+ "full": full,
42
+ "full_2": full_two_masks,
43
+ "center": center,
44
+ "edges": edges,
45
+ **{f"corner_{i}": corners[i] for i in range(4)},
46
+ "one": one,
47
+ "two": two,
48
+ }
49
+
50
+
51
+
@@ -0,0 +1,2 @@
1
+ # Created by pytest automatically.
2
+ *
@@ -0,0 +1,4 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
2
+ # This file is a cache directory tag created by pytest.
3
+ # For information about cache directory tags, see:
4
+ # https://bford.info/cachedir/spec.html
@@ -0,0 +1,8 @@
1
+ # pytest cache directory #
2
+
3
+ This directory contains data from the pytest's cache plugin,
4
+ which provides the `--lf` and `--ff` options, as well as the `cache` fixture.
5
+
6
+ **Do not** commit this to version control.
7
+
8
+ See [the docs](https://docs.pytest.org/en/stable/how-to/cache.html) for more information.
@@ -0,0 +1 @@
1
+ []
@@ -0,0 +1 @@
1
+ []