Skip to content

Refactor Review widget UI - #135

Draft
C-Achard wants to merge 13 commits into
cy/fix-lr-schedulerfrom
cy/review-dock-shape
Draft

C-Achard wants to merge 13 commits into
cy/fix-lr-schedulerfrom
cy/review-dock-shape

Conversation

@C-Achard

Copy link
Copy Markdown
Collaborator

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.

Stack created with GitHub Stacks CLI • Give Feedback 💬

@C-Achard
C-Achard added this pull request to stack #138 November 20, 2026 09:04
@C-Achard C-Achard self-assigned this Nov 20, 2026
@C-Achard
C-Achard requested a balanced review from Copilot November 20, 2026 09:05
@C-Achard C-Achard added the enhancement New feature or request label Nov 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

6 open issues
What changed in this PR

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.
napari_cellseg3d/​code_plugins/​plugin_review_dock.py Accepts the reviewed image shape instead of relying on the first viewer layer.
napari_cellseg3d/​_tests/​test_review.py Expands coverage for session lifecycle, saving, controls, projections, and cropping.

Review effort: Balanced

- 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants