Skip to content

Remove redundant copies and recomputation in the CLI analysis path - #38

Merged
annmoel merged 1 commit into
mainfrom
claude/thin2d-thin3d-maskel-16530d
Sep 7, 2026
Merged

Remove redundant copies and recomputation in the CLI analysis path#38
annmoel merged 1 commit into
mainfrom
claude/thin2d-thin3d-maskel-16530d

Conversation

@annmoel

@annmoel annmoel commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator
  • compute_radii now accepts a pre-computed EDT, and the pipeline computes it once per object crop instead of running distance_transform_edt twice (once for junction cleanup's temporary radius matrix, again for the final mask_radius output) whenever both extraction.junction_cleanup and extraction.mask_radius are enabled.
  • Drop the second connected-components labeling pass in _analyze_single_object: it was mathematically equivalent to the _skeleton_has_no_branches check just above it (both detect "every component is a single isolated pixel"), so it ran scipy's labeling twice on the same skeleton for no reason.
  • Fix compute_radii evaluating skeleton > 0 twice in the same expression instead of once.
  • save_skeleton/save_radius pass copy=False to astype() so no full array copy happens when the array is already the target dtype (always true in practice, since lee94_thin and compute_radii already guarantee it).

- compute_radii now accepts a pre-computed EDT, and the pipeline
  computes it once per object crop instead of running
  distance_transform_edt twice (once for junction cleanup's temporary
  radius matrix, again for the final mask_radius output) whenever both
  extraction.junction_cleanup and extraction.mask_radius are enabled.
- Drop the second connected-components labeling pass in
  _analyze_single_object: it was mathematically equivalent to the
  _skeleton_has_no_branches check just above it (both detect "every
  component is a single isolated pixel"), so it ran scipy's labeling
  twice on the same skeleton for no reason.
- Fix compute_radii evaluating `skeleton > 0` twice in the same
  expression instead of once.
- save_skeleton/save_radius pass copy=False to astype() so no full
  array copy happens when the array is already the target dtype
  (always true in practice, since lee94_thin and compute_radii already
  guarantee it).
@annmoel
annmoel merged commit 5d00c4f into main Sep 7, 2026
1 check passed
@annmoel
annmoel deleted the claude/thin2d-thin3d-maskel-16530d branch September 7, 2026 10:56
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