Added a Widget for drawing region of interest in napari. feature addition disscussed in #378 #489
Conversation
|
Thanks for starting work on this @harsh-bhanushali-05, this is a feature much requested and anticipated by our users. |
9cce2a8 to
bdb9fc6
Compare
There are a few changes done in addition to the earlier implementation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
|
Tried solving the test cases which were failing in the before commit. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #489 +/- ##
=======================================
Coverage 99.87% 99.87%
=======================================
Files 28 29 +1
Lines 1568 1640 +72
=======================================
+ Hits 1566 1638 +72
Misses 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
niksirbi
left a comment
There was a problem hiding this comment.
@harsh-bhanushali-05 — thanks for your work on this, and for following our contributing guidelines and implementing the feature using the general patterns we've established for widget creation and testing.
This PR lays a solid foundation, and it's great to see you engaging with the project. That said, there are a few key areas where the implementation doesn’t quite align with what we’re aiming for — particularly regarding the new UI interactions:
- You've added a button to create a new ROI layer, but this doesn’t offer much beyond what’s already available through
napari's built-in “New shapes layer” button. Additionally, there’s a bug: if you delete an existing ROI layer and then click your “Create ROI Layer” button, it incorrectly reports that an ROI layer already exists — likely because the reference toself.roi_layerisn’t being cleared properly. - You’ve introduced a right-click interaction to select shapes, which is a clever idea — but
naparialready provides a set of tools and shortcuts for selecting, editing, and deleting shapes. Overriding or duplicating this built-in behaviour can cause confusion and potential conflicts.
The broader point here is that a plugin like ours should extend napari’s functionality, rather than modify or replicate behaviour that’s already well-supported by the base application.
That might not have been clear from the issue description — so that’s on us! What we actually need is:
- A way for users to assign a name to each created ROI, which
naparidoesn’t support out of the box. - Functionality to convert shapes drawn in napari into
movementROI objects (e.g.PolygonOfInterestorLineOfInterest). - A way to save these ROIs — along with their names — to file, so they can be reused or shared across sessions.
These are the key features we’re hoping to support, and your work here could be a great starting point for that.
I’ll go ahead and close this PR for now, but if you’re interested in continuing, please feel free to open a new draft PR that focuses on any of the above tasks. Happy to support and provide guidance as you go.
Thanks again for your contribution!



Before submitting a pull request (PR), please read the contributing guide.
Please fill out as much of this template as you can, but if you have any problems or questions, just leave a comment and we will help out :)
Description
What is this PR
Added a Few ScreenShots to give everyone idea of what i have implemented.


Why is this PR needed?
This is regarding the feature request in issue #378 , Adding a widget in order to draw region of interest.
The widget adds a layer where user can draw using the mouse using various shapes.
What does this PR do?
This PR introduces a dedicated widget for creating and managing Regions of Interest (ROIs) within napari, designed for movement analysis workflows.
References
Please reference any existing issues/PRs that relate to this PR.
How has this PR been tested?
Used the feature on local system trying to break it with all the edges cases.
Wrote test case as well to check the working of the widget.
Please explain how any new code has been tested, and how you have ensured that no existing functionality has changed.
Is this a breaking change?
If this PR breaks any existing functionality, please explain how and why.
No its a feature addition only
Does this PR require an update to the documentation?
It might require as there is entirely new menu on the home screen.
If any features have changed, or have been added. Please explain how the
documentation has been updated.
Checklist: