Repository navigation
feat(roimanager): add a tool for creating rectangular rois - #142
Open
ehennestad wants to merge 2 commits into
Open
ehennestad wants to merge 2 commits into
ehennestad wants to merge 2 commits into
Conversation
Roimanager can create circular, polygonal and freehand rois, but not rectangular ones, and nansen.stack.crop takes a rectangle that there was no interactive way to pick. This adds the pieces for that, following how circleSelect works: - roimanager.pointerTool.rectangleSelect shows a rectangle at the pointer and creates a roi where it is clicked. The g and h keys change its size, with shift for the y-direction only. - roimanager.roiMap/createRectangularRoi creates the roi as a polygon with whole-pixel corners. A rectangle that does not fit where it was clicked is moved inside the image and keeps its size. - imviewer.plugin.RegionSelector holds the rois in a roi map and gives the placed rectangles back. - nansen.stack.selectRectangularRegions opens a stack in imviewer and returns the rectangles the user places, finishing on enter. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
Test Results381 tests 381 ✅ 44s ⏱️ Results for commit 9ed4a2d. |
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.
Roimanager can create circular, polygonal and freehand rois, but not rectangular ones, and
nansen.stack.croptakes a rectangle that there has been no interactive way to pick. This adds a rectangle tool built the same way as the circle tool, plus the small pieces needed to use it from outside roimanager.roimanager.pointerTool.rectangleSelectmirrorscircleSelect: it draws a rectangle at the pointer, creates a roi centered on the point that is clicked, and changes size with the g and h keys, with shift for the y-direction only.roimanager.roiMap/createRectangularRoicreates the roi as a polygon with whole-pixel corners. A rectangle that does not fit where it was clicked is moved inside the image and keeps the size the user picked, rather than being cut down to whatever fits, which would otherwise leave rois too small to be useful. A rectangle larger than the image is cut down to the image.imviewer.plugin.RegionSelectoris a small plugin that owns a roi group and a roi map, registers the two pointer tools, and gives the placed rectangles back as an N-by-4 array. It exists becausePointerManageris scoped to imviewer and its plugins, so a plain function cannot reach it.nansen.stack.selectRectangularRegionsis the entry point: it opens an ImageStack in imviewer, lets the user place rectangles, and returns them when enter is pressed, or reports that the selection was aborted on escape or if the window is closed. The default rectangle is one sixth of the image, and an earlier selection can be passed in to adjust it.Tests are in
nansen.unittest.roimanager.RectangularRoiTestand cover where a rectangle lands for a given point, the two edge cases and the oversize case, and the size the pointer tool creates rois with. They run headless on an invisible figure, with a struct standing in for the image viewer, since the roi map only needs the image size from it. The interactive part, placing rois by clicking, is not covered and needs a mouse.🤖 Generated with Claude Code