Add RegionPropsNodes.add_node_attrs to recompute regionprops. - #321
Draft
yfukai wants to merge 1 commit into
Draft
Add RegionPropsNodes.add_node_attrs to recompute regionprops.#321yfukai wants to merge 1 commit into
yfukai wants to merge 1 commit into
Conversation
…properties Allows (re-)computing scikit-image region properties for nodes that already exist in a graph, evaluating regionprops on each node's stored `Mask` instead of on a labels image. Useful to compute properties that were not requested when the nodes were created (e.g. intensity features of an additional channel) or to refresh properties after masks were modified, without rebuilding the graph. Missing output attribute keys are registered in the graph with dtypes inferred from the first computed values; existing keys are overwritten. The attribute holding the masks is configurable through the new `mask_key` argument. Property computation and attribute-key registration are factored out into module-level `_region_property_attrs` / `_add_missing_node_attr_keys` helpers shared with `add_nodes`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human summary
This is intended to partly solve #265 by
RegionPropsNode.add_node_attrs.Copilot summary
This pull request extends the
RegionPropsNodesoperator to support (re-)computing region properties for existing nodes in a graph, adds comprehensive validation for extra properties, and introduces robust tests for the new functionality. The most important changes are:New Feature: Recomputing Node Attributes
add_node_attrsmethod toRegionPropsNodes, allowing users to (re-)compute region properties for existing nodes based on their stored masks, optionally using a provided intensity image. This enables adding new properties or updating existing ones without rebuilding the graph._validate_properties,_add_missing_node_attr_keys,_region_property_attrs) to validate requested properties, register new attribute keys, and compute property values for a region. [1] [2] [3]API Improvements
mask_keyparameter to theRegionPropsNodesconstructor, allowing users to specify which node attribute contains the mask objects for property computation.Testing
test_regionprops.pyto verify the correctness of attribute recomputation, validation logic, error handling, and support for custom callable properties and time-point selection.These changes make the region property computation more flexible, robust, and user-friendly, especially for workflows that require updating or extending node attributes after initial graph creation.