Skip to content

[bugfix] adjust calculatemoments code to properly use labels#228

Merged
bethac07 merged 1 commit intoCellProfiler:masterfrom
wllgrnt:will-fix-calculate-moments
Aug 4, 2025
Merged

[bugfix] adjust calculatemoments code to properly use labels#228
bethac07 merged 1 commit intoCellProfiler:masterfrom
wllgrnt:will-fix-calculate-moments

Conversation

@wllgrnt
Copy link
Copy Markdown
Contributor

@wllgrnt wllgrnt commented Jan 4, 2024

Fixes #207 and #206.

  1. The function get_object_moment was not correct, since it failed to use the labels. What it was instead doing was getting a mask of all pixels in the array with the same numerical value, and then calculating the moments on those (which will definitionally be zero), rather than getting the mask for each label in turn. See the old calculatehistogram.py here for an example of how this function used to be implemented.
  2. The fix in the code was assumed to benp.fix, but it's supposed to be fixup_scipy_ndimage_result as fix (see elsewhere in the codebase).

Also ran black and flake8 on the file.

@allielas
Copy link
Copy Markdown

This fix worked for me in the source build of CellProfiler 4.2.8. Thanks so much!

@bethac07 bethac07 linked an issue Aug 4, 2025 that may be closed by this pull request
@bethac07
Copy link
Copy Markdown
Member

bethac07 commented Aug 4, 2025

Thanks so much, sorry this got buried!

@bethac07 bethac07 merged commit b117374 into CellProfiler:master Aug 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CalculateMoments run error CalculateMoments and EnhancedMeasureTexture Display error

3 participants