You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reworks the Review plugin so a review runs inside the current napari viewer instead of opening a new one, and has a clean finish state.
Also changes the dock layout and makes the projection plots match napari display better.
Summary
Reworks the Review plugin so a review runs inside the current napari viewer instead of opening a new one, and can be finished cleanly. Also changes the dock layout and makes the projection plots match how napari displays the volume.
Review in the current viewer
Before this PR, "Start reviewing" opened a new napari.Viewer. Any layers or widgets in that viewer were lost.
Now the review runs in the existing viewer:
Start: the chosen image and labels layers are reviewed in place. They are added when reviewing from files, and an empty uint16 labels layer is added when no labels are given. Every other layer is hidden, and the two review layers are locked so they can't be deleted from the UI.
Finish: the start button becomes "Finish review", and the bottom dock has a new "Exit review" button. Finishing removes the review docks and callbacks, then restores the other layers' visibility, the lock state and the layer selection. If the labels changed since the last save, it asks to Save / Discard / Cancel.
Closing the plugin finishes the review first, with the same save prompt.
Session state is kept in a new ReviewSession dataclass, which records what to restore when the review ends.
Layout
Left dock: a single dock holds the slice checker/timer (Datamanager), the save folder field, and the "Choose directory", "Open directory", "Save" and "Exit review" buttons. This replaces the magicgui save widget.
Bottom dock: the three projections (X-Y, Y-Z, X-Z) sit side by side, leaving the right dock for main plugin menus.
Projections follow the layer
The projections previously used hardcoded inferno with contrast 200–2000, and the crop was cast to int16. Now:
the plots use the volume layer's colormap, contrast limits and gamma (gamma through PowerNorm)
they redraw on a display setting change
the crop keeps the data's dtype, or float32 when resized for anisotropy
crop_volume_around_point is now a module-level function and takes an array instead of a layer.
Fixes
self.anisotropy_widgets.enabled was tested without being called, so the zoom factor was always applied.
datamanager read the volume shape from viewer.layers], which is wrong in a viewer that has other layers. The shape is now passed in as image_shape.
Behaviour changes
No second viewer opened, and the current one is no longer force-closed.
During a review, other layers are hidden and the review layers are locked. Both are restored on finish.
When no labels are given, the empty labels layer is uint16. It used to take the image's dtype.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Review startup uses APIs unavailable in supported napari versions, and setup failures can leave layers hidden or locked without a usable session to restore the viewer.
Refactors the Review plugin to run in the current napari viewer, with an explicit finish flow, reorganized controls, and projections that follow the image’s display settings.
Changes:
Adds session tracking, save prompts, and viewer-state restoration when finishing a review.
Combines review controls in a left dock and places projections side by side below the viewer.
Updates projection styling and crop dtype handling, passes the reviewed image shape to the slice checker, and expands tests.
File
Description
napari_cellseg3d/interface.py
Adds button hover styling and an OS folder-opening helper.
napari_cellseg3d/code_plugins/plugin_review.py
Implements in-viewer review sessions, finish handling, dock layout, and layer-aware projection styling.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Review teardown bypasses cleanup and save prompts on native dock closure, omits final-slice timing, and fails to restore original layer visibility, while dirty-label save, discard, cancel, and save-failure behavior lack test coverage.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Label-data replacements can bypass the save prompt, and the Python 3.9 pin conflicts with napari 0.7.1’s requirements, preventing environment creation.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
This environment still pins python=3.9 on line 7, but napari 0.7.1 requires Python 3.10 or newer.…
conda/napari_CellSeg3D_ARM64.yml:13
This environment still pins python=3.9 on line 7, but napari 0.7.1 requires Python 3.10 or newer. Raising only the napari minimum therefore makes the pip stage of environment creation fail to resolve a compatible version. Please update the Python pin alongside this dependency change.
Only listening to paint misses replacement of labels.data, which remains possible through other…
Only listening to paint misses replacement of labels.data, which remains possible through other widgets or the console in the current viewer. After such a change, session.modified stays false and finishing skips the save prompt. Please also track labels.events.data and register that callback for teardown.
This now turns on the existing viewer's scale bar, but _restore_viewer never restores its…
This now turns on the existing viewer's scale bar, but _restore_viewer never restores its previous visibility. Starting and finishing a review therefore leaves the scale bar enabled even if it was hidden beforehand; failed setup also leaves this change behind. Please capture its initial visibility in the session and restore it during teardown.
- Implemented volume_slice_index function to accurately track the current slice in the viewer.
- Updated Datamanager to accept an optional slice_num parameter for better integration with viewer dimensions.
- Enhanced test cases to validate slice behavior with additional viewer axes.
- Closing the Review dock from napari's title bar now ends the review.
The dock is already gone, so the save prompt offers Save/Discard only.
- Review layers that were hidden before the review are hidden again
when it finishes.
- Time spent on the last slice is written to the CSV on finish.
- Add tests for the save prompt (Save/Discard/Cancel, cancelled close,
failed save) and for each fix above.
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
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.
Reworks the Review plugin so a review runs inside the current napari viewer instead of opening a new one, and has a clean finish state.
Also changes the dock layout and makes the projection plots match napari display better.
Summary
Reworks the Review plugin so a review runs inside the current napari viewer instead of opening a new one, and can be finished cleanly. Also changes the dock layout and makes the projection plots match how napari displays the volume.
Review in the current viewer
Before this PR, "Start reviewing" opened a new
napari.Viewer. Any layers or widgets in that viewer were lost.Now the review runs in the existing viewer:
uint16labels layer is added when no labels are given. Every other layer is hidden, and the two review layers are locked so they can't be deleted from the UI.ReviewSessiondataclass, which records what to restore when the review ends.Layout
Datamanager), the save folder field, and the "Choose directory", "Open directory", "Save" and "Exit review" buttons. This replaces the magicgui save widget.Projections follow the layer
The projections previously used hardcoded
infernowith contrast 200–2000, and the crop was cast toint16. Now:PowerNorm)float32when resized for anisotropycrop_volume_around_pointis now a module-level function and takes an array instead of a layer.Fixes
self.anisotropy_widgets.enabledwas tested without being called, so the zoom factor was always applied.datamanagerread the volume shape fromviewer.layers], which is wrong in a viewer that has other layers. The shape is now passed in asimage_shape.Behaviour changes
uint16. It used to take the image's dtype.Stack created with GitHub Stacks CLI • Give Feedback 💬