Skip to main content

cp-measure implements CellProfiler Measurements. You can integrate them to your workflow or use them from CellProfiler 5 once they are integrated there.

Project description

#+TITLE: Cell Profiler measurements

Do you need to use [[https://github.com/CellProfiler][CellProfiler]] features, but you want to do it in a programmatic way? Look no more, this package was developed by and for the click-a-phobic scientists.

* Quick overview
** Installation
#+begin_src bash
pip install cp-measure
#+end_src
*** Poetry
If you want a development environment.
#+begin_src bash
git clone git@github.com:afermg/cp_measure.git
cd cp_measure
poetry install
#+end_src

** Usage
Users usually want to calculate all the features. There are four type of measurements, based on their inputs:
- Type 1: 1 image + 1 set of masks (e.g., intensity)
- Type 2: 2 images + 1 set of masks (e.g., colocalization)
- Type 3: 2 sets of masks (e.g., number of neighbors)
- Type 4: 1 image + 2 sets of masks (e.g., skeleton)

This shows the simplest way to use the first set (1 image, 1 mask set), which currently follows the style of scikit-image (1 image, 1 matrix with non-overlapping labels).
#+begin_src python
import numpy as np

from cp_measure.bulk import get_core_measurements

measurements = get_core_measurements()
print(measurements.keys())
# dict_keys(['radial_distribution', 'radial_zernikes', 'intensity', 'sizeshape', 'zernike', 'ferret', 'texture', 'granularity'])

size = 200
rng = np.random.default_rng(42)
pixels = rng.integers(low=0, high=10, size=(size, size))

masks = np.zeros_like(pixels)
masks[5:-6, 5:-6] = 1

results = {}
for name, v in measurements.items():
results = {**results, **v(masks, pixels)}

"""
{'RadialDistribution_FracAtD_1of4': array([0.0477544]),
'RadialDistribution_MeanFrac_1of4': array([0.98888986]),
'RadialDistribution_RadialCV_1of4': array([0.04705031]),
...
'Granularity_16': array([100.])}
"""
#+end_src

**** Multimask (Type 3) methods:
#+begin_src

#+end_src

*** Call specific measurements
If you need a specific measurement/feature you can just import it. Note that measurements come in sets, so you have to fetch the one that you specifically require from the resultant dictionary. Any available measurement can be found using code as follows:
#+begin_src python
import numpy as np

from cp_measure.minimal.measureobjectsizeshape import get_sizeshape

mask = np.zeros((50, 50))
mask[5:-6, 5:-6] = 1
get_sizeshape(mask, None) # pixels, the second argument, is not necessary for this measurement
#+end_src

The other available functions are as follows:
- measureobjectintensitydistribution.get_radial_zernikes,
- measureobjectintensity.get_intensity,
- measureobjectsizeshape.get_zernike,
- measureobjectsizeshape.get_ferret,
- measuregranularity.get_granularity,
- measuretexture.get_texture,

And for Type 2 functions:
- measurecolocalization.get_correlation_pearson
- measurecolocalization.get_correlation_manders_fold
- measurecolocalization.get_correlation_rwc
- measurecolocalization.get_correlation_costes
- measurecolocalization.get_correlation_overlap

For Type 3 functions:
- measureobjectoverlap.measureobjectoverlap
- measureobjectneghbors.measureobjectneighboors

* Pending measurements
You can follow progress [[https://docs.google.com/spreadsheets/d/1_7jQ8EjPwOr2MUnO5Tw56iu4Y0udAzCJEny-LQMgRGE/edit?usp=sharing][here]].

*** Done
- Type 1, 2 and 3 measurements in sklearn style (multiple masks per image)
*** Pending
- Add a wrapper for type 3 measurements
- Type 4 measurements


*** Additional notes
The Image-wide functions will not be implemented directly, they were originally implemented independently to the Object (mask) functions. We will adjust the existing functions assume that an image-wide measurement is the same as measuring an object with the same size as the intensity image.


* Additional notes
- This is not optimised for efficiency (yet). We aim to reproduce the 'vanilla' results of CellProfiler with minimal code changes. Optimisations will be implemented once we come up with a standard interface for functionally-focused CellProfiler components.
- The functions exposed perform minimal checks. They will fail if provided with empty masks. Not all functions will fail if provided with masks only.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cp_measure-0.1.7.tar.gz (88.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cp_measure-0.1.7-py3-none-any.whl (52.9 kB view details)

Uploaded Python 3

File details

Details for the file cp_measure-0.1.7.tar.gz.

File metadata

  • Download URL: cp_measure-0.1.7.tar.gz
  • Upload date:
  • Size: 88.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.8.12

File hashes

Hashes for cp_measure-0.1.7.tar.gz
Algorithm Hash digest
SHA256 be6433805c880b1329a4f7c68bcd3f4173b065c2bb551a1679890039f98d563c
MD5 387de9d0184f1026b2145232ea763ed6
BLAKE2b-256 9d03b85cf0a5c777a0641d5aa00606423db9a414551bb34a66efd99cbdecf3a3

See more details on using hashes here.

File details

Details for the file cp_measure-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: cp_measure-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 52.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.9 Linux/6.8.12

File hashes

Hashes for cp_measure-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 aad1c7f9fafa490567d7e87758a27db85cf54202214ffc44dfc4fa4e6498b0f1
MD5 ef5e7fd83c02c4d44533411eb23c8d88
BLAKE2b-256 f4454210f5f41c12ade69fd820691d7767e3db15c5114d63db555da57c76064f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page