Skip to content

Conversation

daniel-wer
Copy link
Member

@daniel-wer daniel-wer commented Feb 5, 2025

The 2D flood fill tool did not work properly when flood filling in a mag other than the finest one if the "third-dimension" coordinate was not divisible by the respective mag. This resulted in early-out flood fills only filling a single or a few voxels.
Also, this commit adjusts the flood fill maximum bounding size limits if the segmentation layer's finest mag is not 1. This allows to use the flood fill tool in coarser mags if the segmentation layer is properly mag-restricted.

URL of deployed dev instance (used for testing):

  • https://___.webknossos.xyz

Steps to test:

  • To test the fix for 2D flood fill for coarse mags
    • Create an annotation with the volume layer restricted to mag 16.
    • Zoom out to mag 16.
    • Activate the flood fill tool in 2D and relabel a segment (on master this only works if the z-position is divisible by the z-component of mag 16, otherwise a single or only a few voxels are labeled)
  • To test the adjusted bbox size limit:
    • Create an annotation with the volume layer restricted to mag 16.
    • Create a bounding box of size 1280³ vx and perform a brush stroke inside.
    • Zoom out to mag 16.
    • Activate the flood fill tool in 3D, activate the bbox restriction, and try to use it to relabel the brushed segment.

Issues:


(Please delete unneeded items, merge only when none are left open)

The 2D flood fill tool did not work properly when flood filling in a mag
other than the finest one if the "third-dimension" coordinate was not
divisible by the respective mag. This resulted in early-out flood fills
only filling a single voxel.
Also, this commit adjusts the flood fill maximum bounding size limits if
the segmentation layer's finest mag is not 1. This allows to use the
flood fill tool in coarser mags if the segmentation layer is properly
mag-restricted.
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Warning

Rate limit exceeded

@daniel-wer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 5f7d9fe and ad610ff.

📒 Files selected for processing (2)
  • frontend/javascripts/components/slider.tsx (1 hunks)
  • frontend/javascripts/types/schemas/dataset_view_configuration_defaults.ts (1 hunks)
📝 Walkthrough

Walkthrough

The pull request updates the flood fill functionality by refining bounding box calculations. In the DataCube class, voxel inclusion now relies on the intersection volume between bounding boxes rather than a simple containment check. Simultaneously, the saga functions have been modified to compute the maximum flood fill bounding box dynamically using the current fill mode and the finest segmentation layer’s magnification. Error messages have also been adjusted to align with the updated logic. There are no changes to exported or public entities.

Changes

Files Summary
frontend/javascripts/oxalis/model/.../data_cube.ts Updated floodFill: now uses intersection volume (via voxelBoundingBoxInMag1) for bounding box checks and updates coveredBBoxMin/coveredBBoxMax based on voxel dimensions rather than global position.
frontend/javascripts/oxalis/model/.../floodfill_saga.tsx Introduced getMaximumBoundingBoxForFloodFill and updated bounding box functions to compute limits based on fill mode and finestSegmentationLayerMag; removed static maximumVoxelSize and refined error messages to reflect new bounding box limits.
CHANGELOG.unreleased.md Updated the changelog to reflect changes in flood fill maximum bounding box size limits and fixes related to the flood fill tool in 2D mode.
biome.json Added new linter rule: "noUnusedImports": "error" to enforce the removal of unused imports.
frontend/javascripts/oxalis/model.ts Removed unused imports: invertTransform and transformPointUnscaled.
frontend/javascripts/oxalis/model/reducers/skeletontracing_reducer.ts Removed unused import: getTreesWithType.
frontend/javascripts/oxalis/model/reducers/ui_reducer.ts Removed unused import: ControlModeEnum.
frontend/javascripts/oxalis/model/sagas/proofread_saga.ts Removed unused import: take.
frontend/javascripts/oxalis/model/sagas/saga_helpers.ts Removed unused import: Predicate.
frontend/javascripts/oxalis/view/action-bar/toolbar_view.tsx Removed unused import: ControlModeEnum.

Possibly related PRs

  • Fix segment registering in coarser mags for non-mag-aligned bounding boxes #8364: The changes in the main PR enhance the bounding box logic for flood fill operations, while the retrieved PR addresses segment registration issues related to non-mag-aligned bounding boxes, indicating a direct connection in their focus on bounding box calculations and handling.
  • Release 24.12.0 #8264: The changes in the main PR, which modify the floodFill method in the DataCube class, are related to the bounding box calculations for flood fill operations in the retrieved PR, as both involve enhancements to the flood fill logic and bounding box handling.
  • Relax bounding box requirements for model training #8222: The changes in the main PR, which enhance the bounding box checks in the flood fill operation, are related to the modifications in the retrieved PR that also focus on bounding box validation and error handling logic for model training. Both PRs involve adjustments to how bounding boxes are processed and validated in their respective contexts.

Suggested reviewers

  • knollengewaechs

Poem

I'm a bunny in the code, hopping through each line,
Refining boxes and bounds so everything aligns.
Voxels join in a careful dance at my command,
Magnification now guides the fill, oh isn’t it grand?
With every tweak, my carrot dreams come true—
A joyful code-hop, just for you! 🥕💻


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (1)

44-55: Add safety checks for the fillMode lookup.
If a fillMode key is missing in Constants.FLOOD_FILL_EXTENTS, maximumBoundingBoxMag1 could be undefined. Consider adding a fallback or assertion.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3b946f8 and ffaa530.

📒 Files selected for processing (2)
  • frontend/javascripts/oxalis/model/bucket_data_handling/data_cube.ts (1 hunks)
  • frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (5)
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (4)

57-93: Bounding box logic well-structured.
This updated approach correctly clamps the bounding box volume. Ensure the maximum bounding box calculation and volume check work as expected for large-scale data.


95-128: Verify plane slices for 2D bounding box.
When applying numberOfSlices, confirm that partial slices or offsets don’t require additional clipping, especially for min/max boundaries.


130-153: Unified bounding box parameter usage looks good.
Passing finestSegmentationLayerMag streamlines bounding box calculations across restricted/unrestricted modes.


212-218: Ensure existence of a valid finest magnification.
If magInfo.getFinestMag() should always return a valid vector, handle corner cases if no magnifications are loaded. Otherwise, this looks fine.

frontend/javascripts/oxalis/model/bucket_data_handling/data_cube.ts (1)

700-719: Check alignment of per-voxel bounding box with global boundaries.
Creating a bounding box in mag1 space is a solid approach for correctly handling coarse-to-fine mapping. The off-by-one for max is consistent with an exclusive boundary, but keep an eye on partial overlaps if any dimension is fractional or if the bounding box extends beyond dataset limits.

Copy link
Member

@philippotto philippotto left a comment

Choose a reason for hiding this comment

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

awesome! testing went well 👍 thanks for looking into this. I only left 💅 feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (3)

44-55: Consider renaming the function to better reflect its return type.

The function returns a Vector3 representing the maximum dimensions, not an actual bounding box. A more accurate name would be getMaximumBoundingBoxDimensionsForFloodFill.

-function getMaximumBoundingBoxForFloodFill(
+function getMaximumBoundingBoxDimensionsForFloodFill(
   fillMode: FillMode,
   finestSegmentationLayerMag: Vector3,
 ): Vector3 {

72-77: Improve variable naming for clarity.

The variable maxBbox represents the maximum dimensions, not an actual bounding box. A more descriptive name would be maxDimensions.

-  const maxBbox = yield* call(
+  const maxDimensions = yield* call(
     getMaximumBoundingBoxForFloodFill,
     fillMode,
     finestSegmentationLayerMag,
   );
-  const maxBboxVolume = Constants.FLOOD_FILL_MULTIPLIER_FOR_BBOX_RESTRICTION * V3.prod(maxBbox);
+  const maxBboxVolume = Constants.FLOOD_FILL_MULTIPLIER_FOR_BBOX_RESTRICTION * V3.prod(maxDimensions);

101-106: Improve variable naming for consistency.

For consistency with the previous suggestions and to better reflect its purpose, rename maxBoundingBox to maxDimensions.

-  const maxBoundingBox = yield* call(
+  const maxDimensions = yield* call(
     getMaximumBoundingBoxForFloodFill,
     fillMode,
     finestSegmentationLayerMag,
   );
-  const halfBoundingBoxSize = V3.scale(maxBoundingBox, 0.5);
+  const halfBoundingBoxSize = V3.scale(maxDimensions, 0.5);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a34c5c3 and c49627f.

📒 Files selected for processing (1)
  • frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: circleci_build
🔇 Additional comments (1)
frontend/javascripts/oxalis/model/sagas/volume/floodfill_saga.tsx (1)

212-218: LGTM! The changes correctly handle coarse magnifications.

The code now properly handles flood fill at different magnifications by:

  1. Getting the finest magnification from magInfo
  2. Using it to scale the bounding box appropriately

@daniel-wer
Copy link
Member Author

I stumbled upon an unused import and wondered why biome doesn't fail. Turns out the rule was not explicitly enabled and seems to be turned off by default 🤷 Was automatically fixable, though :)

@bulldozer-boy bulldozer-boy bot merged commit 08041b5 into master Feb 17, 2025
3 checks passed
@bulldozer-boy bulldozer-boy bot deleted the fix-flood-fill-for-coarse-mags branch February 17, 2025 09:24
@philippotto
Copy link
Member

I stumbled upon an unused import and wondered why biome doesn't fail. Turns out the rule was not explicitly enabled and seems to be turned off by default 🤷 Was automatically fixable, though :)

yes, that rule got lost in a pr which enabled import sorting. i already readded it in my dtype pr. hopefully that one gets merged soon 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flood fill bounding box size maximum should take into account available mags
2 participants