Skip to content

docs(frangi_math): correct frangi() polarity docstring — bright vessels on dark#255

Merged
aelefebv merged 1 commit into
dechaofrom
fix-frangi-docstring-bright-on-dark
May 12, 2026
Merged

docs(frangi_math): correct frangi() polarity docstring — bright vessels on dark#255
aelefebv merged 1 commit into
dechaofrom
fix-frangi-docstring-bright-on-dark

Conversation

@aelefebv

Copy link
Copy Markdown
Owner

Summary

Docstring-only fix. The frangi() function in nellie/segmentation/frangi_math.py had the eigenvalue polarity reversed on both halves of its returns block:

  • Claimed positive λ₂/λ₃ → "bright structures" (actually → dark structures)
  • Claimed Frangi "assumes vessels are darker than background" (actually tuned for bright-on-dark — matches nellie's fluorescence-microscopy use case)

Code is correct. Only the docstring text changed; one-line reasoning added so a future reader doesn't have to re-derive the second-derivative convention.

Test plan

  • No code changes — existing tests still pass.
  • Reviewer: spot-check the corrected wording against the code at lines 70–71 (zeros where eigenvalues > 0, keeps where ≤ 0 → bright-on-dark).

🤖 Generated with Claude Code

…ls on dark, λ₂/λ₃ ≤ 0

The ``frangi()`` docstring had the eigenvalue polarity reversed on
both halves:

- Said "Bright structures (positive λ₂, and positive λ₃ in 3D) are
  zeroed" — but bright structures have NEGATIVE λ₂/λ₃ (the image
  curves downward outward from a bright center, so the second
  derivative perpendicular to a bright tubular structure is
  negative). The code zeros where λ₂/λ₃ are POSITIVE, which is the
  dark-on-bright case.
- Said "Frangi assumes vessels are darker than background" — but
  this implementation is tuned for bright vessels on dark
  background, matching nellie's typical use case (fluorescence
  microscopy of bright mitochondria on dark cytoplasm).

Code is correct; only the docstring was misleading. Updated
attribution: dark structures (positive λ₂/λ₃) are zeroed; bright
structures (λ₂ ≤ 0, and λ₃ ≤ 0 in 3D) are kept. Added a one-line
explanation of the second-derivative reasoning so a future reader
doesn't have to re-derive it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@aelefebv
aelefebv merged commit 7bfcc87 into dechao May 12, 2026
6 checks passed
@aelefebv
aelefebv deleted the fix-frangi-docstring-bright-on-dark branch May 12, 2026 21:36
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.

1 participant