Skip to content

add area modules#8

Open
MikeLippincott wants to merge 2 commits intoWayScience:mainfrom
MikeLippincott:areasizeshape
Open

add area modules#8
MikeLippincott wants to merge 2 commits intoWayScience:mainfrom
MikeLippincott:areasizeshape

Conversation

@MikeLippincott
Copy link
Copy Markdown
Member

@MikeLippincott MikeLippincott commented Apr 21, 2026

Description

Adding and implementing the areasizeshape module

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Member

@jenna-tomkinson jenna-tomkinson left a comment

Choose a reason for hiding this comment

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

This PR is good to go, but I would highly recommend that you go over the naming conventions in this feature measurement and add code comments to provide more clarity. Excited to see ZedProfiler come alive! :D

@@ -1,10 +1,168 @@
"""Area/size/shape featurization module scaffold."""
"""Area, size, and shape features for 3D objects."""
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.

Have you considered renaming to Volume or Surface area to be more specific towards 3D featurization? This is more of a nit-pick as it is pretty understandable with the current naming.

max(props["bbox-1"][0], 0) : min(props["bbox-4"][0], label_object.shape[1]),
max(props["bbox-2"][0], 0) : min(props["bbox-5"][0], label_object.shape[2]),
]
volume_truths = volume > 0
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.

Is this here to avoid any object with a volume = 0?

features_to_record = _empty_feature_result()

desired_properties = [
"area",
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.

Isn't area not a 3D feature? Should this be volume?

"equivalent_diameter",
]
for label in unique_objects:
if label == 0:
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.

Is this label ID or what is 0 in this case?

Comment on lines +132 to +133
subset_lab_object = label_object.copy()
subset_lab_object[subset_lab_object != label] = 0
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.

I am a bit confused by subset_lab_object. I can see it is a copy of label_object, so what makes it a subset in this case? Also, should it be subet_label_object?

)

features_to_record["object_id"].append(label)
features_to_record["Volume"].append(props["area"].item())
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.

This might get a bit confusing to interchange volume and area here. Recommend sticking to one convention if possible.

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.

Overall, this code is very clean! Though, I highly recommend more code comments here. There are instances where area and volume are used interchangeably, which is not always clear, and I find the section on labels unclear about why we are avoiding 0 as a label (especially if it is 0-indexed).

class SupportsImageSetLoader(Protocol):
"""Minimal image-set loader interface required by this module."""

anisotropy_spacing: tuple[float, float, float]
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.

Recommend adding comment here on what anisotropy spacing is. Someone new to 3D might not have knowledge of this already and it is probably safer to be more explicit here.

Suggested change
anisotropy_spacing: tuple[float, float, float]
# Pixel size in x,y,z space?
anisotropy_spacing: tuple[float, float, float]

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.

Also, is this loading in an image-set or is this setting the spacing distances for 3D? The name SupportsImageSetLoader makes it sound like it is taking in the image path and loading it in without any other context.

Comment on lines +20 to +25
class SupportsObjectLoader(Protocol):
"""Minimal object loader interface required by this module."""

label_image: np.ndarray
object_ids: Sequence[int]

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.

What is label_image? As an array that sounds like it will be the FOV since we usually call FOVs images, but for AreaShape that FOV only matters for segmentation. In this case, is label_image actually the label_mask from the segmentation module?

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.

Is this supposed to be in this PR?

Copy link
Copy Markdown
Member

@jenna-tomkinson jenna-tomkinson left a comment

Choose a reason for hiding this comment

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

Apologises I meant to approve before!

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.

3 participants