Skip to content

[EXPERIMENTAL]: Integrate cp-measure#982

Open
timtreis wants to merge 42 commits intomainfrom
feature/add_cpmeasure
Open

[EXPERIMENTAL]: Integrate cp-measure#982
timtreis wants to merge 42 commits intomainfrom
feature/add_cpmeasure

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Mar 28, 2025

@timtreis timtreis marked this pull request as draft March 28, 2025 16:52
@timtreis timtreis added enhancement ✨ New feature or request image 🔬 squidpy2.0 Everything releated to a Squidpy 2.0 release sdata compat 🌌 release-added labels Mar 28, 2025
@timtreis
Copy link
Copy Markdown
Member Author

timtreis commented May 16, 2025

Note to self:

  • Doesn't correctly parse str names of channels
    INFO Calculating 'cpmeasure' correlation features between channels '0' and '1'.

  • Should show, for permutations, the total number of iterations (in general, the progress bar should contain a (step n out m) readout so one can know how far in the featurisation is. Can easily take more than a day given the amount of cells and cpu_cores. Should also maybe show the total runtime so far for the steps that are done

  • Fails if labels and image don't have the same dimensions, despite transformation to align them

@timtreis timtreis marked this pull request as ready for review September 11, 2025 20:15
@pakiessling
Copy link
Copy Markdown

Tried it out and it worked very well!

One quality of life feature would be the ability to specify channels that should be measured.

Often times there are channels that are not informative / used only for segmentation and those slow down the calculations.

@pakiessling
Copy link
Copy Markdown

Ah I noticed another thing.

For the created morphology table .uns["spatialdata_attrs"] needs to be set, otherwise this runs into problem when querying the Spatialdata afterwards.

timtreis and others added 6 commits January 27, 2026 13:46
- Resolved dependency conflicts (updated to zarr>=3)
- Moved exp module to experimental to align with main
- Integrated CellProfiler features into experimental module
- Added centrosome and cp_measure dependencies
Moved calculate_image_features from experimental._feature to
experimental.im._feature to follow the existing module structure.
Now accessible as squidpy.experimental.im.calculate_image_features
- Test basic feature calculation with shapes
- Test copy vs inplace behavior
- Test error cases for invalid keys
- Uses sdata_hne fixture with skimage:label for fast execution
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 58.67159% with 224 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.87%. Comparing base (76ca03f) to head (0af69aa).

Files with missing lines Patch % Lines
src/squidpy/experimental/im/_feature.py 51.54% 185 Missing and 35 partials ⚠️
src/squidpy/experimental/im/_tiling.py 95.45% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #982      +/-   ##
==========================================
- Coverage   74.05%   72.87%   -1.19%     
==========================================
  Files          39       41       +2     
  Lines        6495     7037     +542     
  Branches     1122     1249     +127     
==========================================
+ Hits         4810     5128     +318     
- Misses       1230     1417     +187     
- Partials      455      492      +37     
Files with missing lines Coverage Δ
src/squidpy/experimental/im/_tiling.py 95.45% <95.45%> (ø)
src/squidpy/experimental/im/_feature.py 51.54% <51.54%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@LucaMarconato
Copy link
Copy Markdown
Member

Looking forward to this PR 👀🥸

timtreis and others added 12 commits January 27, 2026 15:52
Introduces _tiling.py with build_tile_specs() and extract_tile() that
split a label image into overlapping tiles where each cell is assigned
to exactly one tile by centroid. Non-owned cells are zeroed out so
downstream processing never double-counts.

Includes 31 tests: deterministic brick-pattern grid (touching and
non-touching), coverage verification, and visual regression tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@timtreis
Copy link
Copy Markdown
Member Author

timtreis commented Apr 8, 2026

Refactoring in anticipation of afermg/cp_measure#38 being merged so we can upstream behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement ✨ New feature or request image 🔬 release-added sdata compat 🌌 squidpy2.0 Everything releated to a Squidpy 2.0 release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants