Skip to content

Fix bugs#33

Open
gwaybio wants to merge 8 commits into
WayScience:mainfrom
gwaybio:fix-bugs
Open

Fix bugs#33
gwaybio wants to merge 8 commits into
WayScience:mainfrom
gwaybio:fix-bugs

Conversation

@gwaybio

@gwaybio gwaybio commented Jun 22, 2026

Copy link
Copy Markdown
Member

Description

Fixing bugs identified and fixed in WayScience/NF1_3D_organoid_profiling_pipeline#147

What kind of change(s) are included?

  • Documentation (changes docs or other related content)
  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (these changes would cause existing functionality to not work as expected).

Checklist

Please ensure that all boxes are checked before indicating that this pull request is ready for review.

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have searched for existing content to ensure this is not a duplicate.
  • I have performed a self-review of these additions (including spelling, grammar, and related).
  • These changes pass all pre-commit checks.
  • I have added comments to my code to help provide understanding
  • I have added a test which covers the code changes found within this PR
  • I have deleted all non-relevant text in this pull request template.

gwaybio and others added 3 commits June 22, 2026 13:52
Move numpy.empty array allocation outside the per-object loop in
compute_texture. It was being reset on every iteration, discarding all
previous objects' Haralick values and leaving only the last object intact.
All prior objects received uninitialized memory from numpy.empty.

Adds test_texture_values_correct_per_object: independently computes expected
Haralick values per object with mahotas and asserts the pipeline output matches,
catching any regression where the array is reset inside the loop.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…-zero bug

get_outline used find_boundaries with the default mode='thick', which returns
both inner (object-side) and outer (background-side) boundary pixels. Because
the image is zeroed outside the cell before get_outline is called, outer
boundary pixels always have intensity 0, so numpy.min(edge pixels) always
returned 0 regardless of actual edge intensity.

Switching to mode='inner' restricts the edge mask to pixels inside the object
boundary, so all edge pixels have real cell intensities.

Adds test_min_intensity_edge_not_zero_for_bright_cell: a cell with uniform
intensity 100 must have MinIntensityEdge=100, not 0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Port all fixes from the NF1_3D audit to the equivalent ZedProfiler modules:

- colocalization: initialize combined_thresh before try block (Bug 2),
  add numpy.any guard on overlap section, fix Accurate/Fast dispatch inversion
  (Bug 3), remove dead pre-loop pearsonr initialization (Bug 4), and fix
  compute_colocalization hard-coding fast_costes='Accurate' ignoring the
  caller's argument (Bug B)
- granularity: guard per-axis scale factor against division-by-zero when a
  dimension has size 1, in both _upsample_3d and the background upsampling
  block (Bug 7)
- neighbors: replace bbox-crop adjacency detection with 1-voxel morphological
  dilation so face-touching objects are detected correctly (Bug 5)
- intensity: rename bbox variables to avoid collision with max_intensity_*
  names (Bug 9), add index=1 to scipy.ndimage.sum so it sums only the
  target object's voxels (Bug 10)

Add regression tests in each test file covering all fixed bugs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
gwaybio and others added 4 commits June 25, 2026 05:26
Adds "Fast" as a distinct third mode (linear with adaptive skipping)
matching CellProfiler's Accurate/Fast/Faster nomenclature. Previously
"Fast" routed to bisection -- it now routes to linear_costes with
fast_costes="Fast", and "Faster" routes to bisection.

Fixes bisection_costes_threshold_calculation returning thresholds
normalised to [0,1] (mid/scale_max) instead of raw pixel units.
The outer dispatch's `image > thr` comparison requires raw values,
so this was silently bypassing Costes thresholding in "Faster" mode.
CellProfiler's library has the same bug; this is an intentional
divergence, documented in a comment.

Also updates both docstrings to describe all three modes, and adds
value-based tests: convergence across all three modes, low threshold
for correlated images, high threshold for anti-correlated images
(linear only), and a documented test for bisection's degenerate
anti-correlated edge case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Switch README badge from a hardcoded shields.io percentage to a live
  Codecov badge that updates automatically on every push
- Add coverage XML upload to the run_tests matrix job via
  codecov/codecov-action@v5 (no token needed for public repos)
- Remove the coverage_and_badge job and the stale-badge check entirely

One-time setup: activate the repo at codecov.io/gh/WayScience/ZedProfiler.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Running coverage on the full matrix (8 combinations) was redundant.
Coverage is now measured once on ubuntu-24.04 + Python 3.13 in a
separate job, and the matrix run_tests job is back to plain pytest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Both are obsolete now that the README uses a dynamic Codecov badge.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@MikeLippincott MikeLippincott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the code was reviewed in the NF1_3D repo first, so not many comments here

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.

2 participants